问题
I'm trying to build a package which has some files under /etc
that are not configuration. They are included in the conffiles
automatically even if I create an empty package.conffiles
in the debian
directory.
How can I stop dh_installdeb
from doing that?
回答1:
Originally, this answer suggested providing your own debian/conffiles
files only listing actual configuration files to be installed. Apparently that only serves to add more configuration files but won't override the whole conffiles
file.
However, I can't quite see why you'd even want that. If the files are not configuration files, the user won't edit them, so none of the automatic conffile handling will get in your way on upgrades. Also, if they're not actually config files, I'd highly recommend to simply install them to a place other than /etc, avoiding your issue as well.
回答2:
I’m not sure I understand rafl’s answer, but dh_installdeb
as of debhelper=9.20120115ubuntu3
adds everything below /etc
to conffiles nearly unconditionally: debian/conffiles
adds conffiles but does not override them.
It’s possible to override manually in debian/rules
. For example, in order to prevent any files from being registered as conffiles:
override_dh_installdeb:
dh_installdeb
find ${CURDIR}/debian/*/DEBIAN -name conffiles -delete
(of course, indentation must be hard tab)
回答3:
It's possible to define a upgrade rule at preinst script in debian/<package-name>.preinst
using dpkg-maintscript-helper.
#!/bin/sh
# preinst script for <package-name>
set -e
case "$1" in
install|upgrade)
if dpkg-maintscript-helper supports rm_conffile 2>/dev/null; then
dpkg-maintscript-helper rm_conffile /etc/foo/conf.d/bar <Previous package version> -- "$@"
fi
;;
abort-upgrade)
;;
*)
echo "preinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0
More info: The right way to remove an obsolete conffile in a Debian package
回答4:
Here is what I came up with as an extension of Vasiliy's answer. It effectively does what dh_installdeb does but without automatically adding /etc
files. This way you regain full control again over what files are considered conffiles and what are not.
override_dh_installdeb:
dh_installdeb
@echo "Recreating conffiles without auto-adding /etc files"
@for dir in ${CURDIR}/debian/*/DEBIAN; do \
PKG=$$(basename $$(dirname $$dir)); \
FILES=""; \
if [ -f ${CURDIR}/debian/conffiles ]; then \
FILES="${CURDIR}/debian/conffiles"; \
fi; \
if [ -f ${CURDIR}/debian/$${PKG}.conffiles ]; then \
FILES="$$FILES ${CURDIR}/debian/$${PKG}.conffiles"; \
fi; \
if [ -n "$$FILES" ]; then \
cat $$FILES | sort -u > $$dir/conffiles; \
elif [ -f $$dir/conffiles ]; then \
rm $$dir/conffiles; \
fi; \
done
(Of course, use REAL tabs if pasting into your rules file).
This answer uses BASH (or /bin/sh which is either symlinked to BASH or is a variant of it). There may be a way to achieve this by using only makefile internal commands, but I'm not that good with those.
This should work even when building multiple binary packages from the same source and it respects the plain debian/conffiles
as well as the package-specific debian/${pkg}.conffiles
.
来源:https://stackoverflow.com/questions/3398511/prevent-creation-of-conffiles