This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=ab625356a41fd10f9e6d16becef021bdd81ea441 commit ab625356a41fd10f9e6d16becef021bdd81ea441 Author: David Kalnischkies <[email protected]> AuthorDate: Sat Jul 23 10:07:53 2016 +0200 dpkg-maintscript-helper: Support DPKG_ROOT for conffiles As dpkg-maintscript-helper "works around known dpkg limitations in maintainer scripts" it should behave as if it were a maintainerscript and prepend DPKG_ROOT to all paths it uses. This is preferred over having the conffile parameter(s) be prepended with DPKG_ROOT by the maintainerscripts calling the helper as the helper would then need to strip DPKG_ROOT from the path to verify if the conffile belongs to the package – it also means that it magically works for all callers instantly instead of requiring e.g. dh_installdeb to be patched and packages to be rebuilt against a patched version. Signed-off-by: Guillem Jover <[email protected]> --- debian/changelog | 3 ++ scripts/dpkg-maintscript-helper.sh | 63 +++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/debian/changelog b/debian/changelog index e6df5a20d..b37b3ccc6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -40,6 +40,9 @@ dpkg (1.20.1) UNRELEASED; urgency=medium * dpkg-realpath: Add support for DPKG_ROOT. Thanks to Helmut Grohne <[email protected]>. * dpkg-realpath: Add support for --root and --instdir options. + * dpkg-maintscript-helper: Add support for DPKG_ROOT: + - Add DPKG_ROOT support for conffiles. + Thanks to David Kalnischkies <[email protected]>. * Portability: - libdpkg: When using uselocale(), include <xlocale.h> for locale_t if the header is available. Needed on BSDs. diff --git a/scripts/dpkg-maintscript-helper.sh b/scripts/dpkg-maintscript-helper.sh index e74ac66a6..6c93f19fa 100755 --- a/scripts/dpkg-maintscript-helper.sh +++ b/scripts/dpkg-maintscript-helper.sh @@ -71,8 +71,9 @@ rm_conffile() { ;; postrm) if [ "$1" = "purge" ]; then - rm -f "$CONFFILE.dpkg-bak" "$CONFFILE.dpkg-remove" \ - "$CONFFILE.dpkg-backup" + rm -f "$DPKG_ROOT$CONFFILE.dpkg-bak" \ + "$DPKG_ROOT$CONFFILE.dpkg-remove" \ + "$DPKG_ROOT$CONFFILE.dpkg-backup" fi if [ "$1" = "abort-install" -o "$1" = "abort-upgrade" ] && [ -n "$2" ] && @@ -90,31 +91,31 @@ prepare_rm_conffile() { local CONFFILE="$1" local PACKAGE="$2" - [ -e "$CONFFILE" ] || return 0 + [ -e "$DPKG_ROOT$CONFFILE" ] || return 0 ensure_package_owns_file "$PACKAGE" "$CONFFILE" || return 0 local md5sum old_md5sum - md5sum="$(md5sum "$CONFFILE" | sed -e 's/ .*//')" + md5sum="$(md5sum "$DPKG_ROOT$CONFFILE" | sed -e 's/ .*//')" old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$PACKAGE" | \ sed -n -e "\\'^ $CONFFILE ' { s/ obsolete$//; s/.* //; p }")" if [ "$md5sum" != "$old_md5sum" ]; then - mv -f "$CONFFILE" "$CONFFILE.dpkg-backup" + mv -f "$DPKG_ROOT$CONFFILE" "$DPKG_ROOT$CONFFILE.dpkg-backup" else - mv -f "$CONFFILE" "$CONFFILE.dpkg-remove" + mv -f "$DPKG_ROOT$CONFFILE" "$DPKG_ROOT$CONFFILE.dpkg-remove" fi } finish_rm_conffile() { local CONFFILE="$1" - if [ -e "$CONFFILE.dpkg-backup" ]; then - echo "Obsolete conffile $CONFFILE has been modified by you." - echo "Saving as $CONFFILE.dpkg-bak ..." - mv -f "$CONFFILE.dpkg-backup" "$CONFFILE.dpkg-bak" + if [ -e "$DPKG_ROOT$CONFFILE.dpkg-backup" ]; then + echo "Obsolete conffile $DPKG_ROOT$CONFFILE has been modified by you." + echo "Saving as $DPKG_ROOT$CONFFILE.dpkg-bak ..." + mv -f "$DPKG_ROOT$CONFFILE.dpkg-backup" "$DPKG_ROOT$CONFFILE.dpkg-bak" fi - if [ -e "$CONFFILE.dpkg-remove" ]; then - echo "Removing obsolete conffile $CONFFILE ..." - rm -f "$CONFFILE.dpkg-remove" + if [ -e "$DPKG_ROOT$CONFFILE.dpkg-remove" ]; then + echo "Removing obsolete conffile $DPKG_ROOT$CONFFILE ..." + rm -f "$DPKG_ROOT$CONFFILE.dpkg-remove" fi } @@ -124,13 +125,13 @@ abort_rm_conffile() { ensure_package_owns_file "$PACKAGE" "$CONFFILE" || return 0 - if [ -e "$CONFFILE.dpkg-remove" ]; then - echo "Reinstalling $CONFFILE that was moved away" - mv "$CONFFILE.dpkg-remove" "$CONFFILE" + if [ -e "$DPKG_ROOT$CONFFILE.dpkg-remove" ]; then + echo "Reinstalling $DPKG_ROOT$CONFFILE that was moved away" + mv "$DPKG_ROOT$CONFFILE.dpkg-remove" "$DPKG_ROOT$CONFFILE" fi - if [ -e "$CONFFILE.dpkg-backup" ]; then - echo "Reinstalling $CONFFILE that was backed-up" - mv "$CONFFILE.dpkg-backup" "$CONFFILE" + if [ -e "$DPKG_ROOT$CONFFILE.dpkg-backup" ]; then + echo "Reinstalling $DPKG_ROOT$CONFFILE that was backed-up" + mv "$DPKG_ROOT$CONFFILE.dpkg-backup" "$DPKG_ROOT$CONFFILE" fi } @@ -200,16 +201,16 @@ prepare_mv_conffile() { local CONFFILE="$1" local PACKAGE="$2" - [ -e "$CONFFILE" ] || return 0 + [ -e "$DPKG_ROOT$CONFFILE" ] || return 0 ensure_package_owns_file "$PACKAGE" "$CONFFILE" || return 0 local md5sum old_md5sum - md5sum="$(md5sum "$CONFFILE" | sed -e 's/ .*//')" + md5sum="$(md5sum "$DPKG_ROOT$CONFFILE" | sed -e 's/ .*//')" old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$PACKAGE" | \ sed -n -e "\\'^ $CONFFILE ' { s/ obsolete$//; s/.* //; p }")" if [ "$md5sum" = "$old_md5sum" ]; then - mv -f "$CONFFILE" "$CONFFILE.dpkg-remove" + mv -f "$DPKG_ROOT$CONFFILE" "$DPKG_ROOT$CONFFILE.dpkg-remove" fi } @@ -218,16 +219,16 @@ finish_mv_conffile() { local NEWCONFFILE="$2" local PACKAGE="$3" - rm -f "$OLDCONFFILE.dpkg-remove" + rm -f "$DPKG_ROOT$OLDCONFFILE.dpkg-remove" - [ -e "$OLDCONFFILE" ] || return 0 + [ -e "$DPKG_ROOT$OLDCONFFILE" ] || return 0 ensure_package_owns_file "$PACKAGE" "$OLDCONFFILE" || return 0 - echo "Preserving user changes to $NEWCONFFILE (renamed from $OLDCONFFILE)..." - if [ -e "$NEWCONFFILE" ]; then - mv -f "$NEWCONFFILE" "$NEWCONFFILE.dpkg-new" + echo "Preserving user changes to $DPKG_ROOT$NEWCONFFILE (renamed from $DPKG_ROOT$OLDCONFFILE)..." + if [ -e "$DPKG_ROOT$NEWCONFFILE" ]; then + mv -f "$DPKG_ROOT$NEWCONFFILE" "$DPKG_ROOT$NEWCONFFILE.dpkg-new" fi - mv -f "$OLDCONFFILE" "$NEWCONFFILE" + mv -f "$DPKG_ROOT$OLDCONFFILE" "$DPKG_ROOT$NEWCONFFILE" } abort_mv_conffile() { @@ -236,9 +237,9 @@ abort_mv_conffile() { ensure_package_owns_file "$PACKAGE" "$CONFFILE" || return 0 - if [ -e "$CONFFILE.dpkg-remove" ]; then - echo "Reinstalling $CONFFILE that was moved away" - mv "$CONFFILE.dpkg-remove" "$CONFFILE" + if [ -e "$DPKG_ROOT$CONFFILE.dpkg-remove" ]; then + echo "Reinstalling $DPKG_ROOT$CONFFILE that was moved away" + mv "$DPKG_ROOT$CONFFILE.dpkg-remove" "$DPKG_ROOT$CONFFILE" fi } -- Dpkg.Org's dpkg

