Hi guillem, On Tue, Mar 21, 2017 at 12:04 AM, Bastien ROUCARIES <[email protected]> wrote: > On Mon, Mar 20, 2017 at 11:01 PM, Bastien ROUCARIES > <[email protected]> wrote: >> Add also this patch >> >> On Mon, Mar 20, 2017 at 5:02 PM, Bastien ROUCARIES >> <[email protected]> wrote: >>> On Mon, Mar 20, 2017 at 4:32 PM, Bastien ROUCARIES >>> <[email protected]> wrote: >>>> control: tags -1 + patch >>>> >>>> Hi, >>>> >>>> Found joinded patch to honor DPKG_ROOT. Tested using test suite >>> >>> Improve portability by not using find -printf >
Could you get a glimpse at this serie
From 024298e9ddf236718c4b75155bbaf1e809fdc8e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <[email protected]> Date: Mon, 20 Mar 2017 23:00:36 +0100 Subject: [PATCH 7/7] Use simpler variant for find Safer and simpler --- scripts/dpkg-maintscript-helper.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/dpkg-maintscript-helper.sh b/scripts/dpkg-maintscript-helper.sh index e8f4c662c..931b0f762 100755 --- a/scripts/dpkg-maintscript-helper.sh +++ b/scripts/dpkg-maintscript-helper.sh @@ -418,14 +418,13 @@ prepare_dir_to_symlink() error "directory '$PATHNAME' contains files not owned by" \ "package $PACKAGE, cannot switch to symlink" else - (cd "$DPKG_ROOT$PATHNAME"; find ./ -print0 | xargs -0 -n1 \ + (cd "$DPKG_ROOT"; find "./$PATHNAME" -print0) | xargs -0 -n1 \ sh -c ' - file=$2; - pathname=$1; - echo -n $file |sed s,[.]/,$pathname/,g ;printf "\0"' \ - findhelper $PATHNAME | \ + file="$1"; + printf "%s\0" "${file#./}"' \ + findhelper | \ xargs -0 -n1 \ - dpkg-maintscript-helper package_owns_file_or_error $PACKAGE) || \ + dpkg-maintscript-helper package_owns_file_or_error $PACKAGE || \ error "directory '$PATHNAME' contains files not owned by" \ "package $PACKAGE, cannot switch to symlink" fi -- 2.11.0
From a251b8f7aadd33203d26db3a61f9431bf9c4ac22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <[email protected]> Date: Mon, 20 Mar 2017 17:01:42 +0100 Subject: [PATCH 6/7] Improve portability by not using find -printf --- scripts/dpkg-maintscript-helper.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/dpkg-maintscript-helper.sh b/scripts/dpkg-maintscript-helper.sh index 5becba33a..e8f4c662c 100755 --- a/scripts/dpkg-maintscript-helper.sh +++ b/scripts/dpkg-maintscript-helper.sh @@ -412,20 +412,20 @@ prepare_dir_to_symlink() # If there are locally created files or files owned by another package # we should not perform the switch. - if [ -n "$DPKG_ROOT" ]; then + if [ -z "$DPKG_ROOT" ]; then find "$PATHNAME" -print0 | xargs -0 -n1 \ dpkg-maintscript-helper package_owns_file_or_error $PACKAGE || \ error "directory '$PATHNAME' contains files not owned by" \ "package $PACKAGE, cannot switch to symlink" else - find "$DPKG_ROOT$PATHNAME" -printf "%P\0" | xargs -0 -n1 \ + (cd "$DPKG_ROOT$PATHNAME"; find ./ -print0 | xargs -0 -n1 \ sh -c ' - file=$2 - pathname=$1 - echo -n "$pathname/$file"; printf "\0"' \ - addpathname $PATHNAME | \ + file=$2; + pathname=$1; + echo -n $file |sed s,[.]/,$pathname/,g ;printf "\0"' \ + findhelper $PATHNAME | \ xargs -0 -n1 \ - dpkg-maintscript-helper package_owns_file_or_error $PACKAGE || \ + dpkg-maintscript-helper package_owns_file_or_error $PACKAGE) || \ error "directory '$PATHNAME' contains files not owned by" \ "package $PACKAGE, cannot switch to symlink" fi -- 2.11.0
From 2d870b20534bac2847b55b544351c112a85595e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <[email protected]> Date: Mon, 20 Mar 2017 16:27:09 +0100 Subject: [PATCH 5/7] Honor DPKG_ROOT in dir to symlink --- scripts/dpkg-maintscript-helper.sh | 83 +++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 32 deletions(-) diff --git a/scripts/dpkg-maintscript-helper.sh b/scripts/dpkg-maintscript-helper.sh index 0b867d805..5becba33a 100755 --- a/scripts/dpkg-maintscript-helper.sh +++ b/scripts/dpkg-maintscript-helper.sh @@ -354,10 +354,10 @@ dir_to_symlink() { "PACKAGE=$PACKAGE LASTVERSION=$LASTVERSION ACTION=$1 PARAM=$2" case "$DPKG_MAINTSCRIPT_NAME" in - preinst) + preinst) if [ "$1" = "install" -o "$1" = "upgrade" ] && [ -n "$2" ] && - [ ! -h "$PATHNAME" ] && [ -d "$PATHNAME" ] && + [ ! -h "$DPKG_ROOT$PATHNAME" ] && [ -d "$DPKG_ROOT$PATHNAME" ] && dpkg --compare-versions -- "$2" le-nl "$LASTVERSION"; then prepare_dir_to_symlink "$PACKAGE" "$PATHNAME" fi @@ -368,24 +368,24 @@ dir_to_symlink() { # have been unpacked, then upgraded with an unpack and thus # never been configured before. if [ "$1" = "configure" ] && - [ -d "${PATHNAME}.dpkg-backup" ] && - [ ! -h "$PATHNAME" ] && [ -d "$PATHNAME" ] && - [ -f "$PATHNAME/.dpkg-staging-dir" ]; then + [ -d "$DPKG_ROOT${PATHNAME}.dpkg-backup" ] && + [ ! -h "$DPKG_ROOT$PATHNAME" ] && [ -d "$DPKG_ROOT$PATHNAME" ] && + [ -f "$DPKG_ROOT$PATHNAME/.dpkg-staging-dir" ]; then finish_dir_to_symlink "$PATHNAME" "$SYMLINK_TARGET" fi ;; postrm) - if [ "$1" = "purge" ] && [ -d "${PATHNAME}.dpkg-backup" ]; then - rm -rf "${PATHNAME}.dpkg-backup" + if [ "$1" = "purge" ] && [ -d "$DPKG_ROOT${PATHNAME}.dpkg-backup" ]; then + rm -rf "$DPKG_ROOT${PATHNAME}.dpkg-backup" fi if [ "$1" = "abort-install" -o "$1" = "abort-upgrade" ] && [ -n "$2" ] && - [ -d "${PATHNAME}.dpkg-backup" ] && - [ \( ! -h "$PATHNAME" -a -d "$PATHNAME" -a \ - -f "$PATHNAME/.dpkg-staging-dir" \) -o \ - \( -h "$PATHNAME" -a symlink_match "$PATHNAME" "$SYMLINK_TARGET" \)] && + [ -d "$DPKG_ROOT${PATHNAME}.dpkg-backup" ] && + [ \( ! -h "$DPKG_ROOT$PATHNAME" -a -d "$DPKG_ROOT$PATHNAME" -a \ + -f "$DPKG_ROOT$PATHNAME/.dpkg-staging-dir" \) -o \ + \( -h "$DPKG_ROOT$PATHNAME" -a symlink_match "$PATHNAME" "$SYMLINK_TARGET" \)] && dpkg --compare-versions -- "$2" le-nl "$LASTVERSION"; then - abort_dir_to_symlink "$PATHNAME" + abort_dir_to_symlink "$DPKG_ROOT$PATHNAME" fi ;; *) @@ -412,10 +412,23 @@ prepare_dir_to_symlink() # If there are locally created files or files owned by another package # we should not perform the switch. - find "$PATHNAME" -print0 | xargs -0 -n1 \ - dpkg-maintscript-helper package_owns_file_or_error $PACKAGE || \ - error "directory '$PATHNAME' contains files not owned by" \ - "package $PACKAGE, cannot switch to symlink" + if [ -n "$DPKG_ROOT" ]; then + find "$PATHNAME" -print0 | xargs -0 -n1 \ + dpkg-maintscript-helper package_owns_file_or_error $PACKAGE || \ + error "directory '$PATHNAME' contains files not owned by" \ + "package $PACKAGE, cannot switch to symlink" + else + find "$DPKG_ROOT$PATHNAME" -printf "%P\0" | xargs -0 -n1 \ + sh -c ' + file=$2 + pathname=$1 + echo -n "$pathname/$file"; printf "\0"' \ + addpathname $PATHNAME | \ + xargs -0 -n1 \ + dpkg-maintscript-helper package_owns_file_or_error $PACKAGE || \ + error "directory '$PATHNAME' contains files not owned by" \ + "package $PACKAGE, cannot switch to symlink" + fi # At this point, we know that the directory either contains no files, # or only non-conffiles owned by the package. @@ -431,11 +444,11 @@ prepare_dir_to_symlink() # So we need to create a staging directory, to avoid removing files # from other packages, and to trap any new files in the directory # to move them to their correct place later on. - mv -f "$PATHNAME" "${PATHNAME}.dpkg-backup" - mkdir "$PATHNAME" + mv -f "$DPKG_ROOT$PATHNAME" "$DPKG_ROOT${PATHNAME}.dpkg-backup" + mkdir "$DPKG_ROOT$PATHNAME" # Mark it as a staging directory, so that we can track things. - touch "$PATHNAME/.dpkg-staging-dir" + touch "$DPKG_ROOT$PATHNAME/.dpkg-staging-dir" } finish_dir_to_symlink() @@ -452,19 +465,25 @@ finish_dir_to_symlink() else ABS_SYMLINK_TARGET="$SYMLINK_TARGET" fi - rm "$PATHNAME/.dpkg-staging-dir" - find "$PATHNAME" -mindepth 1 -print0 | \ - xargs -0 -i% mv -f "%" "$ABS_SYMLINK_TARGET/" + rm "$DPKG_ROOT$PATHNAME/.dpkg-staging-dir" + find "$DPKG_ROOT$PATHNAME" -mindepth 1 -print0 | \ + xargs -0 -i% mv -f "%" "$DPKG_ROOT$ABS_SYMLINK_TARGET/" # Remove the staging directory. - rmdir "$PATHNAME" + rmdir "$DPKG_ROOT$PATHNAME" # Do the actual switch. - ln -s "$SYMLINK_TARGET" "$PATHNAME" - + case $SYMLINK_TARGET in + /*) + ln -s "$DPKG_ROOT$SYMLINK_TARGET" "$DPKG_ROOT$PATHNAME" + ;; + *) + ln -s "$SYMLINK_TARGET" "$DPKG_ROOT$PATHNAME" + ;; + esac # We are left behind the old files owned by this package in the backup # directory, just remove it. - rm -rf "${PATHNAME}.dpkg-backup" + rm -rf "$DPKG_ROOT${PATHNAME}.dpkg-backup" } abort_dir_to_symlink() @@ -472,16 +491,16 @@ abort_dir_to_symlink() local PATHNAME="$1" echo "Restoring backup of $PATHNAME ..." - if [ -h "$PATHNAME" ]; then - rm -f "$PATHNAME" + if [ -h "$DPKG_ROOT$PATHNAME" ]; then + rm -f "$DPKG_ROOT$PATHNAME" else # The staging directory must be empty, as no other package # should have been unpacked in between. - rm -f "$PATHNAME/.dpkg-staging-dir" - rmdir "$PATHNAME" + rm -f "$DPKG_ROOT$PATHNAME/.dpkg-staging-dir" + rmdir "$DPKG_ROOT$PATHNAME" fi - mv "${PATHNAME}.dpkg-backup" "$PATHNAME" + mv "$DPKG_ROOT${PATHNAME}.dpkg-backup" "$DPKG_ROOT$PATHNAME" } # Common functions @@ -512,7 +531,7 @@ ensure_package_owns_file() { package_owns_file_or_error() { local PACKAGE="$1" - local FILE="$2" + local FILE="${2%/}" if ! ensure_package_owns_file $PACKAGE $FILE ; then error "File '$FILE' not owned by package " \ "'$PACKAGE'" -- 2.11.0
From 14814cd71ca2fac0857c51615dfcb0f6fd13655b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <[email protected]> Date: Wed, 15 Mar 2017 12:10:07 +0100 Subject: [PATCH 4/7] Factorize owns_file --- scripts/dpkg-maintscript-helper.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/scripts/dpkg-maintscript-helper.sh b/scripts/dpkg-maintscript-helper.sh index b4b3ac1b3..0b867d805 100755 --- a/scripts/dpkg-maintscript-helper.sh +++ b/scripts/dpkg-maintscript-helper.sh @@ -412,14 +412,8 @@ prepare_dir_to_symlink() # If there are locally created files or files owned by another package # we should not perform the switch. - find "$PATHNAME" -print0 | xargs -0 -n1 sh -c ' - package="$1" - file="$2" - if ! dpkg-query -L "$package" | grep -F -q -x "$file"; then - exit 1 - fi - exit 0 - ' check-files-ownership "$PACKAGE" || \ + find "$PATHNAME" -print0 | xargs -0 -n1 \ + dpkg-maintscript-helper package_owns_file_or_error $PACKAGE || \ error "directory '$PATHNAME' contains files not owned by" \ "package $PACKAGE, cannot switch to symlink" @@ -515,6 +509,18 @@ ensure_package_owns_file() { return 0 } + +package_owns_file_or_error() { + local PACKAGE="$1" + local FILE="$2" + if ! ensure_package_owns_file $PACKAGE $FILE ; then + error "File '$FILE' not owned by package " \ + "'$PACKAGE'" + return 1 + fi + return 0 +} + symlink_match() { local SYMLINK="$1" @@ -614,6 +620,9 @@ symlink_to_dir) dir_to_symlink) dir_to_symlink "$@" ;; +package_owns_file_or_error) + package_owns_file_or_error "$@" + ;; --help|help|-?) usage ;; -- 2.11.0
From f680a1705a529d65f374667b44251fcf12b9abbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <[email protected]> Date: Tue, 14 Mar 2017 21:57:38 +0100 Subject: [PATCH 3/7] Symplify a condition by using a function --- scripts/dpkg-maintscript-helper.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/dpkg-maintscript-helper.sh b/scripts/dpkg-maintscript-helper.sh index 4cf7f04eb..b4b3ac1b3 100755 --- a/scripts/dpkg-maintscript-helper.sh +++ b/scripts/dpkg-maintscript-helper.sh @@ -383,9 +383,7 @@ dir_to_symlink() { [ -d "${PATHNAME}.dpkg-backup" ] && [ \( ! -h "$PATHNAME" -a -d "$PATHNAME" -a \ -f "$PATHNAME/.dpkg-staging-dir" \) -o \ - \( -h "$PATHNAME" -a \ - \( "$(readlink "$PATHNAME")" = "$SYMLINK_TARGET" -o \ - "$(readlink -f "$PATHNAME")" = "$SYMLINK_TARGET" \) \) ] && + \( -h "$PATHNAME" -a symlink_match "$PATHNAME" "$SYMLINK_TARGET" \)] && dpkg --compare-versions -- "$2" le-nl "$LASTVERSION"; then abort_dir_to_symlink "$PATHNAME" fi -- 2.11.0
From e1331be07812900c9bee7525547b046120ab2329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <[email protected]> Date: Tue, 14 Mar 2017 15:05:53 +0100 Subject: [PATCH 2/7] Use DPKG_ROOT for symlink to dir --- scripts/dpkg-maintscript-helper.sh | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/scripts/dpkg-maintscript-helper.sh b/scripts/dpkg-maintscript-helper.sh index e0e66f921..4cf7f04eb 100755 --- a/scripts/dpkg-maintscript-helper.sh +++ b/scripts/dpkg-maintscript-helper.sh @@ -280,10 +280,10 @@ symlink_to_dir() { case "$DPKG_MAINTSCRIPT_NAME" in preinst) if [ "$1" = "install" -o "$1" = "upgrade" ] && - [ -n "$2" ] && [ -h "$SYMLINK" ] && + [ -n "$2" ] && [ -h "${DPKG_ROOT}$SYMLINK" ] && symlink_match "$SYMLINK" "$SYMLINK_TARGET" && dpkg --compare-versions -- "$2" le-nl "$LASTVERSION"; then - mv -f "$SYMLINK" "${SYMLINK}.dpkg-backup" + mv -f "${DPKG_ROOT}$SYMLINK" "${DPKG_ROOT}${SYMLINK}.dpkg-backup" fi ;; postinst) @@ -291,23 +291,23 @@ symlink_to_dir() { # know what was the last configured version, and we might # have been unpacked, then upgraded with an unpack and thus # never been configured before. - if [ "$1" = "configure" ] && [ -h "${SYMLINK}.dpkg-backup" ] && + if [ "$1" = "configure" ] && [ -h "${DPKG_ROOT}${SYMLINK}.dpkg-backup" ] && symlink_match "${SYMLINK}.dpkg-backup" "$SYMLINK_TARGET" then - rm -f "${SYMLINK}.dpkg-backup" + rm -f "${DPKG_ROOT}${SYMLINK}.dpkg-backup" fi ;; postrm) - if [ "$1" = "purge" ] && [ -h "${SYMLINK}.dpkg-backup" ]; then - rm -f "${SYMLINK}.dpkg-backup" + if [ "$1" = "purge" ] && [ -h "${DPKG_ROOT}${SYMLINK}.dpkg-backup" ]; then + rm -f "${DPKG_ROOT}${SYMLINK}.dpkg-backup" fi if [ "$1" = "abort-install" -o "$1" = "abort-upgrade" ] && [ -n "$2" ] && - [ ! -e "$SYMLINK" ] && [ -h "${SYMLINK}.dpkg-backup" ] && + [ ! -e "${DPKG_ROOT}$SYMLINK" ] && [ -h "${DPKG_ROOT}${SYMLINK}.dpkg-backup" ] && symlink_match "${SYMLINK}.dpkg-backup" "$SYMLINK_TARGET" && dpkg --compare-versions -- "$2" le-nl "$LASTVERSION"; then echo "Restoring backup of $SYMLINK ..." - mv "${SYMLINK}.dpkg-backup" "$SYMLINK" + mv "${DPKG_ROOT}${SYMLINK}.dpkg-backup" "${DPKG_ROOT}$SYMLINK" fi ;; *) @@ -519,11 +519,15 @@ ensure_package_owns_file() { symlink_match() { - local SYMLINK="$1" - local SYMLINK_TARGET="$2" - - [ "$(readlink "$SYMLINK")" = "$SYMLINK_TARGET" ] || \ - [ "$(readlink -f "$SYMLINK")" = "$SYMLINK_TARGET" ] + local SYMLINK="$1" + local SYMLINK_TARGET="$2" + local DPKG_ROOT_CANON="" + if [ -n $DPKG_ROOT ]; then + DPKG_ROOT_CANON="$(readlink -f "$DPKG_ROOT")" + fi + + [ "$(readlink "$SYMLINK")" = "$SYMLINK_TARGET" ] || \ + [ "$(readlink -f "${DPKG_ROOT_CANON}$SYMLINK")" = "${DPKG_ROOT_CANON}$SYMLINK_TARGET" ] } debug() { -- 2.11.0
From 47311959ef71a67768ecfef357883e27027867b0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies <[email protected]> Date: Sat, 23 Jul 2016 10:07:53 +0200 Subject: [PATCH 1/7] dpkg-maintscript-helper: support DPKG_ROOT for config file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- scripts/dpkg-maintscript-helper.sh | 62 +++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/scripts/dpkg-maintscript-helper.sh b/scripts/dpkg-maintscript-helper.sh index 2366dcbdb..e0e66f921 100755 --- a/scripts/dpkg-maintscript-helper.sh +++ b/scripts/dpkg-maintscript-helper.sh @@ -69,8 +69,8 @@ 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" ] && @@ -88,31 +88,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 } @@ -122,13 +122,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 backupped" - mv "$CONFFILE.dpkg-backup" "$CONFFILE" + if [ -e "${DPKG_ROOT}$CONFFILE.dpkg-backup" ]; then + echo "Reinstalling ${DPKG_ROOT}$CONFFILE that was backupped" + mv "${DPKG_ROOT}$CONFFILE.dpkg-backup" "${DPKG_ROOT}$CONFFILE" fi } @@ -196,16 +196,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 } @@ -214,16 +214,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() { @@ -232,9 +232,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 } -- 2.11.0

