これは、この問題を解決するために私が見つけた最良の方法は、.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
次に、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