下午好,
我能够使用以下方法将我的项目构建成一个deb包:
fakeroot dpkg-deb --build mypackage接下来,我可以使用
dpkg -i mypackage.deb当我这样做时,所有的东西都被正确地安装和复制,但是我想在包安装之后运行一些bash命令。
我知道这需要使用mypackage/DEBIAN目录中的postinst文件来完成。
我已经在网上看到了一些这个脚本的例子,但是对于如何编写一个脚本以及如何将它包含在构建中没有明确的解释。
下面是我想要制作的一个示例脚本。
谢谢你的帮助,
下面是后置文件。
#!/bin/sh
set -e
case "$1" in
configure)
# EXECUTE MY BASH COMMAND
echo /usr/local/lib > /etc/ld.so.conf && ldconfig
;;
abort-upgrade|abort-remove|abort-deconfigure)
exit 0
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
update-alternatives --install /usr/bin/fakeroot fakeroot /usr/bin/fakeroot-ng 5 \
--slave /usr/share/man/man1/fakeroot.1.gz \
fakeroot.1.gz /usr/share/man/man1/fakeroot-ng.1.gz
exit 0发布于 2014-09-17 17:23:31
首先,这里可能是最相关的文档:Debian策略手册:包维护人员描述和安装过程。
第二,在编写或处理维护脚本时,最重要的事情是必须记住:它们必须是幂等的。假设脚本将连续运行许多次,并确保这样的脚本不会中断。
直接回答你的问题,
DEBIAN构建时,将其放入dpkg-deb目录是正确的。如果您使用Debhelper进行更安全或更方便的构建设置,则可以将postinst放在debian/$packagename.postinst中。dpkg -i、apt-get install还是其他方式)必须涉及成功运行它的前脚本和后期脚本。可以在不运行任何维护脚本的情况下“解压”deb,但这不被认为是“安装”。- _configure_: A package is being installed or upgraded. If the package wasn't installed before, `$2` will be empty. Otherwise `$2` will contain the old version number of the package; the version from which you are upgrading.
- _abort-upgrade_: An upgrade operation was aborted. As an example, I have version V1 of mypkg installed, and I try to upgrade it to V2. But the preinst or postinst of V1 fail to run successfully, or there is a file conflict. dpkg stops trying to install V2, and re-runs the postinst from V1 (with the "`abort-upgrade`" action) in case any state needs to be restored.
- _abort-remove_: A remove operation was aborted. For example, if I ran "dpkg -P mypkg", but mypkg's prerm script failed to run, or something else happened that made dpkg think it could not safly uninstall mypkg. So it runs mypkg's postinst again (with the "`abort-remove`" action) in case any state needs to be restored.
- _abort-deconfigure_: As you might guess, a deconfigure operation was aborted. "deconfiguring" is sort of a half-removal action used when a package being installed conflicts with others already installed. To make the explanation short, if the `abort-deconfigure` action is being run, the postinst is expected to restore any state that might have been undone by the `prerm` script with the `deconfigure` action.要获得更多的细节,请参见https://people.debian.org/~srivasta/MaintainerScripts.html的伟大图表和解释。
/usr/bin/fakeroot-ng“是fakeroot命令的另一种选择。根据这个选项的优先级和其他注册替代的优先级,以及用户的偏好,现在可以在某人运行"fakeroot“时调用fakeroot。发布于 2015-01-07 15:57:25
只要想想这句话:
echo /usr/local/lib > /etc/ld.so.conf && ldconfig根据Debian政策,你不应该修改ld.so.conf
一个简单的选择是这样做:
后脚本中的 :
/usr/local/lib > /etc/ld.so.conf.d/EXAMPLE.conf && ldconfig和postrm脚本中的
rm /etc/ld.so.conf.d/EXAMPLE.conf && ldconfighttps://stackoverflow.com/questions/25879793
复制相似问题