Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions packaging/ceralive-modem-support/debian/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# postrm for ceralive-modem-support.
#
# On PURGE, retire the runtime state this package's helper creates but does not own as
# packaged files: the ACTIVE fcc-unlock symlinks it wrote into ModemManager's multiarch
# directory. Those are symlinks into /usr/share/ModemManager/fcc-unlock.d, so removing
# packaged files: the ACTIVE fcc-unlock symlinks it wrote into ModemManager's admin
# directory. Those are symlinks into /usr/share/ModemManager/fcc-unlock.available.d, so removing
# them removes nothing of ModemManager's own — but leaving them behind would let a purged
# package keep a radio's FCC-unlock script active, which is exactly the state todo 33
# forbids by default.
Expand All @@ -12,23 +12,22 @@
# is left strictly alone: it is not ours.
set -e

AVAILABLE_DIR=/usr/share/ModemManager/fcc-unlock.d
AVAILABLE_DIR=/usr/share/ModemManager/fcc-unlock.available.d
ACTIVE_DIR=/etc/ModemManager/fcc-unlock.d

purge_active_fcc_symlinks() {
for dir in /usr/lib/*/ModemManager/fcc-unlock.d; do
[ -d "$dir" ] || continue
for link in "$dir"/*; do
[ -L "$link" ] || continue
target="$(readlink -f "$link" 2>/dev/null || true)"
case "$target" in
"$AVAILABLE_DIR"/*)
rm -f "$link"
echo "ceralive-modem-support: purge removed active FCC-unlock symlink $link"
;;
esac
done
rmdir "$dir" 2>/dev/null || true
[ -d "$ACTIVE_DIR" ] || return 0
for link in "$ACTIVE_DIR"/*; do
[ -L "$link" ] || continue
target="$(readlink -f "$link" 2>/dev/null || true)"
case "$target" in
"$AVAILABLE_DIR"/*)
rm -f "$link"
echo "ceralive-modem-support: purge removed active FCC-unlock symlink $link"
;;
esac
done
rmdir "$ACTIVE_DIR" 2>/dev/null || true
}

case "$1" in
Expand Down
6 changes: 3 additions & 3 deletions packaging/ci/test-companion-chroot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ if apt-get install -y -qq --allow-downgrades "$OLD" >/tmp/down.log 2>&1; then ok
[ "$(dpkg-query -W -f='${Version}' ceralive-modem-support)" = "0.9.0" ] && ok "downgraded to 0.9.0" || bad "downgrade did not take"

echo "== 9. purge leaves zero leftovers =="
mkdir -p "$ACTIVE"; ln -sfn /usr/share/ModemManager/fcc-unlock.d/2c7c "$ACTIVE/2c7c"
printf 'not ours\n' > /usr/share/ModemManager/fcc-unlock.d/keepme
mkdir -p "$ACTIVE"; ln -sfn /usr/share/ModemManager/fcc-unlock.available.d/2c7c "$ACTIVE/2c7c"
printf 'not ours\n' > "$ACTIVE/keepme"
if dpkg -P ceralive-modem-support >/tmp/purge.log 2>&1; then ok "dpkg -P exit 0"; else bad "purge failed"; cat /tmp/purge.log; fi
if dpkg -L ceralive-modem-support >/dev/null 2>&1; then bad "dpkg -L still resolves after purge"; else ok "dpkg -L errors after purge"; fi
left=0
Expand All @@ -249,7 +249,7 @@ for d in /usr/lib/ceralive-modem-support /usr/share/ceralive-modem-support; do
[ -e "$d" ] && { bad "leftover directory after purge: $d"; left=1; }
done
[ -L "$ACTIVE/2c7c" ] && { bad "purge left an active FCC symlink behind"; left=1; }
[ -f /usr/share/ModemManager/fcc-unlock.d/keepme ] || { bad "purge deleted a file that was not ours"; left=1; }
[ -f "$ACTIVE/keepme" ] || { bad "purge deleted a file that was not ours"; left=1; }
[ "$left" -eq 0 ] && ok "zero leftovers over every declared path; foreign files untouched"

echo
Expand Down