Per the Debian 政策手册 http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html,我的 postinst 脚本在升级和配置时被调用,如“postinst 配置旧版“, 在哪里旧版是以前安装的版本(可能为空)。我想确定新版本,即当前正在配置(升级到)的版本。
环境变量$DPKG_MAINTSCRIPT_PACKAGE
包含包名称;似乎没有等效的_VERSION
场地。/var/lib/dpkg/status
在 postinst 运行后更新,所以我似乎也无法从那里解析它。
有任何想法吗?
这是我发现解决此问题的最佳方法是在您的.postinst
(或其他控制文件):
case "$1" in
configure)
new_version="__NEW_VERSION__"
# Do something interesting interesting with $new_version...
;;
abort-upgrade|abort-remove|abort-deconfigure)
# Do nothing
;;
*)
echo "Unrecognized postinst argument '$1'"
;;
esac
Then in debian/rules
,在构建时将占位符变量替换为正确的版本号:
# Must not depend on anything. This is to be called by
# binary-arch/binary-indep in another 'make' thread.
binary-common:
dh_testdir
dh_testroot
dh_lintian
< ... snip ... >
# Replace __NEW_VERSION__ with the actual new version in any control files
for pkg in $$(dh_listpackages -i); do \
sed -i -e 's/__NEW_VERSION__/$(shell $(SHELL) debian/gen_deb_version)/' debian/$$pkg/DEBIAN/*; \
done
# Note dh_builddeb *must* come after the above code
dh_builddeb
所结果的.postinst
片段,发现于debian/<package-name>/DEBIAN/postinst
,看起来像:
case "$1" in
configure)
new_version="1.2.3"
# Do something interesting interesting with $new_version...
;;
abort-upgrade|abort-remove|abort-deconfigure)
# Do nothing
;;
*)
echo "Unrecognized postinst argument '$1'"
;;
esac
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)