在debian维护者脚本中获取常用函数

时间:2014-04-01 15:56:43

标签: shell debian dpkg post-install

我有许多常用功能,我想在debian维护者脚本(preinst / postinst / prerm / postrm)中使用它,将其命名为common.sh。

如果我添加" common.sh"到DEBIAN目录,dpkg抱怨:

dpkg-deb: warning: conffile '' is not a plain file
dpkg-deb: warning: ignoring 1 warning about the control file(s)

但是,包正确构建。

安装时,很难找到我的common.sh所在的正确目录。在preinst中,它似乎在寻找/var/lib/dpkg/tmp.ci,而在postinst中它似乎在寻找/var/lib/dpkg/info

我可以将common.sh放在tmp目录中并稍后删除它,但我觉得安装到操作系统的文件应该保留,直到dpkg可以删除它们。

无论如何,我想知道真正的'debian'这样做的方式是?

1 个答案:

答案 0 :(得分:2)

preinst是从某个实现定义的目录运行的,因为包还没有解压缩到文件系统中的正确位置。

我非常确定标准软件包不允许将额外的文件强制进入DEBIAN部分。您可以将common.sh安装到文件系统中,通常位于/ usr / share / yourpackagename /下,并从postinst和prerm脚本中使用它。

它不适用于preinst和postrm,因为包内容不可用。