diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:58:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:58:51 +0000 |
commit | e52abbeea0a0fd87f2df577263fdfcb89da6c1b0 (patch) | |
tree | 27a6f3ded04c521f55558166ee9322076339ca2b /debian/dpkg.postinst | |
parent | Adding upstream version 1.21.22. (diff) | |
download | dpkg-e52abbeea0a0fd87f2df577263fdfcb89da6c1b0.tar.xz dpkg-e52abbeea0a0fd87f2df577263fdfcb89da6c1b0.zip |
Adding debian version 1.21.22.debian/1.21.22debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | debian/dpkg.postinst | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/debian/dpkg.postinst b/debian/dpkg.postinst new file mode 100644 index 0000000..ac2ad07 --- /dev/null +++ b/debian/dpkg.postinst @@ -0,0 +1,113 @@ +#!/bin/sh +# See deb-postinst(5). + +set -e + +PROGNAME=dpkg + +. /usr/share/dpkg/sh/dpkg-error.sh + +setup_colors + +get_vendor() +{ + local origin="$DPKG_ROOT/etc/dpkg/origins/default" + local vendor + + if [ -e "$origin" ]; then + vendor=$(sed -ne 's/^Vendor: *\([^ ]\+\) */\1/p' "$origin" | tr A-Z a-z) + fi + + echo "${vendor:-default}" +} + +check_merged_usr_via_aliased_dirs() +{ + local vendor + + vendor=$(get_vendor) + + case "$vendor" in + debian) + # In Debian some people have gotten so offended by the following _warning_ + # that they have resorted to bullying and abuse. Life's too short, sorry. + return + ;; + ubuntu) + # Ubuntu does not seem interested in it. + return + ;; + esac + + for d in /bin /sbin /lib /lib32 /libo32 /libx32 /lib64; do + linkname="$(readlink $DPKG_ROOT$d || true)" + if [ "$linkname" = "usr$d" ] || [ "$linkname" = "/usr$d" ]; then + warning "This system uses merged-usr-via-aliased-dirs, going behind dpkg's" + warning "back, breaking its core assumptions. This can cause silent file" + warning "overwrites and disappearances, and its general tools misbehavior." + warning "See <https://wiki.debian.org/Teams/Dpkg/FAQ#broken-usrmerge>." + break + fi + done +} + +# Version 1.21.0 had bogus handling of DPKG_ADMINDIR in update-alternatives, +# and misplaced them, fix them up. +fixup_misplaced_alternatives() +( + admindir=${DPKG_ADMINDIR:-/var/lib/dpkg} + + cd "$admindir" + + for file in *; do + if ! [ -f "$file" ]; then + # Ignore anything that is not a file. + continue + fi + + # Check whether this is a known file we do not want to act on. + case "$file" in + arch|\ + available|available-old|\ + cmethopt|methlock|\ + diversions|diversions-old|\ + lock|lock-frontend|\ + statoverride|statoverride-old|\ + status|status-old) + # Ignore known files just to make sure. + continue + ;; + *) + esac + + # Check whether the file looks like an alternative state file. + mode="$(head -1 "$file")" + case "$mode" in + auto|manual) + # Looks like a state file, we will handle this one. + echo "Moving misplaced alternative state file $admindir/$file..." + mv "$file" "alternatives/$file" + ;; + *) + warning "unknown dpkg database file $admindir/$file is not a misplaced alternative state... leaving as is" + continue + ;; + esac + done +) + +case "$1" in +configure) + fixup_misplaced_alternatives + + check_merged_usr_via_aliased_dirs + ;; +abort-upgrade|abort-deconfigure|abort-remove) + ;; +*) + error "called with unknown argument '$1'" + ;; +esac + +#DEBHELPER# +exit 0 |