On Mon, Jan 13, 2025 at 08:48:54PM +0100, Helmut Grohne wrote: > I'm attaching a patch that fixes both and also attaching my test cases > (that are all passing now). I added more comments such that the mess > becomes easier to understand by my future self and others.
As with bfh-container, I'd like to replace my patch. As progress-linux-container is missing from bookworm, I was actually unable to produce a failure with the earlier patch as the broken path was upgrading a single aliased diversion to a duplicated diversion and that is unsupported in principle. Still, using the same mechanism as bfh-container should be more reliable in such less supported situations. Here goes the updates patch and test. Helmut
diff --minimal -Nru progress-linux-metapackages-20221002/debian/changelog progress-linux-metapackages-20221002/debian/changelog --- progress-linux-metapackages-20221002/debian/changelog 2024-12-12 18:04:29.000000000 +0100 +++ progress-linux-metapackages-20221002/debian/changelog 2025-01-13 16:34:35.000000000 +0100 @@ -1,3 +1,10 @@ +progress-linux-metapackages (20221002-20.1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Fix --rename flags on duplicated diversions (DEP17 M18, Closes: #-1) + + -- Helmut Grohne <hel...@subdivi.de> Mon, 13 Jan 2025 16:34:35 +0100 + progress-linux-metapackages (20221002-20) sid; urgency=medium * Uploading to sid. diff --minimal -Nru progress-linux-metapackages-20221002/debian/progress-linux-container.preinst progress-linux-metapackages-20221002/debian/progress-linux-container.preinst --- progress-linux-metapackages-20221002/debian/progress-linux-container.preinst 2024-12-12 18:01:20.000000000 +0100 +++ progress-linux-metapackages-20221002/debian/progress-linux-container.preinst 2025-01-13 16:34:35.000000000 +0100 @@ -8,46 +8,59 @@ for FILE in halt poweroff reboot shutdown coldreboot do - TRUENAME_USR="$(dpkg-divert --truename "/usr/sbin/${FILE}")" - TRUENAME_ALIAS="$(dpkg-divert --truename "/sbin/${FILE}")" - RENAME_FLAG="--no-rename" - - if [ "${TRUENAME_USR}" = "/usr/sbin/${FILE}" ] + # DEP17 M18 duplicated diversion. Once trixie is + # released, remove the aliased diversions in postinst + # and only have the canonical one with --rename here. + TRUENAME="$(dpkg-divert --truename "/sbin/${FILE}")" + if [ "$(dpkg-divert --truename "/usr/sbin/${FILE}")" != "/usr/sbin/${FILE}" ] then - if [ "${TRUENAME_ALIAS}" = "/sbin/${FILE}" ] - then - RENAME_FLAG="--rename" - fi - - dpkg-divert --package progress-linux-container --quiet --add "${RENAME_FLAG}" --divert "/usr/lib/container/divert/${FILE}.orig" "/usr/sbin/${FILE}" - fi - - # DEP17 M18 duplicated diversion, can be removed after trixie. - if [ "${TRUENAME_ALIAS}" = "/sbin/${FILE}" ] + : # Canonically diverted already. Nothing to rename. + elif [ "${TRUENAME}" = "/lib/container/divert/${FILE}.orig.usr-is-merged" ] then - dpkg-divert --package progress-linux-container --quiet --add "${RENAME_FLAG}" --divert "/lib/container/divert/${FILE}.orig.usr-is-merged" "/sbin/${FILE}" - elif [ "${TRUENAME_ALIAS}" != "/lib/container/divert/${FILE}.orig.usr-is-merged" ] + : # Aliased diversion as expected. Nothing to rename. + elif [ "${TRUENAME}" != "/sbin/${FILE}" ] then - dpkg-divert --package progress-linux-container --quiet --remove --no-rename "/sbin/${FILE}" - dpkg-divert --package progress-linux-container --quiet --add --no-rename --divert "/lib/container/divert/${FILE}.orig.usr-is-merged" "/sbin/${FILE}" - - if [ -e "${TRUENAME_ALIAS}" ] || [ -h "${TRUENAME_ALIAS}" ] + # Aliased diversion with earlier target. Fix target. + dpkg-divert --remove --no-rename "/sbin/${FILE}" + if [ -e "${DPKG_ROOT}${TRUENAME}" ] || [ -h "${DPKG_ROOT}${TRUENAME}" ] then - mv "${TRUENAME_ALIAS}" "/lib/container/divert/${FILE}.orig.usr-is-merged" + mv "${DPKG_ROOT}${TRUENAME}" "${DPKG_ROOT}/lib/container/divert/${FILE}.orig.usr-is-merged" fi + elif dpkg -S "/sbin/${FILE}" >/dev/null 2>&1 + then + # Not diverted yet. Installed as aliased. + mv "${DPKG_ROOT}/sbin/${FILE}" "${DPKG_ROOT}/lib/container/divert/${FILE}.orig.usr-is-merged" + elif [ -e "${DPKG_ROOT}/usr/sbin/${FILE}" ] || [ -h "${DPKG_ROOT}/usr/sbin/${FILE}" ] + then + # Not diverted yet. Installed as canonical. + mv "${DPKG_ROOT}/usr/sbin/${FILE}" "${DPKG_ROOT}/usr/lib/container/divert/${FILE}.orig" fi + # All necessary moving has been done. Hence --no-rename. + dpkg-divert --package progress-linux-container --quiet --add --no-rename --divert "/lib/container/divert/${FILE}.orig.usr-is-merged" "/sbin/${FILE}" + dpkg-divert --package progress-linux-container --quiet --add --no-rename --divert "/usr/lib/container/divert/${FILE}.orig" "/usr/sbin/${FILE}" done for FILE in pm-hibernate pm-suspend pm-suspend-hybrid do - TRUENAME_USR="$(dpkg-divert --truename "/usr/sbin/${FILE}")" + TRUENAME="$(dpkg-divert --truename "/usr/sbin/${FILE}")" - if [ "${TRUENAME_USR}" = "/lib/container/divert/${FILE}.orig" ] + if [ "${TRUENAME}" = "/usr/sbin/${FILE}" ] + then + # Not diverted yet. + dpkg-divert --package progress-linux-container --quiet --add --rename --divert "/usr/lib/container/divert/${FILE}.orig" "/usr/sbin/${FILE}" + elif [ "${TRUENAME}" != "/usr/lib/container/divert/${FILE}.orig" ] then + # Upgrading from pre-trixie. Update the diversion target from aliased to canonical. dpkg-divert --package progress-linux-container --quiet --remove --no-rename "/usr/sbin/${FILE}" dpkg-divert --package progress-linux-container --quiet --add --no-rename --divert "/usr/lib/container/divert/${FILE}.orig" "/usr/sbin/${FILE}" - else - dpkg-divert --package progress-linux-container --quiet --add --rename --divert "/usr/lib/container/divert/${FILE}.orig" "/usr/sbin/${FILE}" + if [ "${TRUENAME}" != "/lib/container/divert/${FILE}.orig" ] + then + # Diversion target differs in more than aliasing. + if [ -e "${DPKG_ROOT}${TRUENAME}" ] || [ -h "${DPKG_ROOT}${TRUENAME}" ] + then + mv "${DPKG_ROOT}${TRUENAME}" "${DPKG_ROOT}/usr/lib/container/divert/${FILE}.orig" + fi + fi fi done ;;
test-pl.sh
Description: Bourne shell script