Skip to content

Commit 84171e8

Browse files
authored
fix(packaging): purge FCC links from admin tier (#16)
1 parent 5a4714a commit 84171e8

2 files changed

Lines changed: 18 additions & 19 deletions

File tree

packaging/ceralive-modem-support/debian/postrm

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# postrm for ceralive-modem-support.
33
#
44
# On PURGE, retire the runtime state this package's helper creates but does not own as
5-
# packaged files: the ACTIVE fcc-unlock symlinks it wrote into ModemManager's multiarch
6-
# directory. Those are symlinks into /usr/share/ModemManager/fcc-unlock.d, so removing
5+
# packaged files: the ACTIVE fcc-unlock symlinks it wrote into ModemManager's admin
6+
# directory. Those are symlinks into /usr/share/ModemManager/fcc-unlock.available.d, so removing
77
# them removes nothing of ModemManager's own — but leaving them behind would let a purged
88
# package keep a radio's FCC-unlock script active, which is exactly the state todo 33
99
# forbids by default.
@@ -12,23 +12,22 @@
1212
# is left strictly alone: it is not ours.
1313
set -e
1414

15-
AVAILABLE_DIR=/usr/share/ModemManager/fcc-unlock.d
15+
AVAILABLE_DIR=/usr/share/ModemManager/fcc-unlock.available.d
16+
ACTIVE_DIR=/etc/ModemManager/fcc-unlock.d
1617

1718
purge_active_fcc_symlinks() {
18-
for dir in /usr/lib/*/ModemManager/fcc-unlock.d; do
19-
[ -d "$dir" ] || continue
20-
for link in "$dir"/*; do
21-
[ -L "$link" ] || continue
22-
target="$(readlink -f "$link" 2>/dev/null || true)"
23-
case "$target" in
24-
"$AVAILABLE_DIR"/*)
25-
rm -f "$link"
26-
echo "ceralive-modem-support: purge removed active FCC-unlock symlink $link"
27-
;;
28-
esac
29-
done
30-
rmdir "$dir" 2>/dev/null || true
19+
[ -d "$ACTIVE_DIR" ] || return 0
20+
for link in "$ACTIVE_DIR"/*; do
21+
[ -L "$link" ] || continue
22+
target="$(readlink -f "$link" 2>/dev/null || true)"
23+
case "$target" in
24+
"$AVAILABLE_DIR"/*)
25+
rm -f "$link"
26+
echo "ceralive-modem-support: purge removed active FCC-unlock symlink $link"
27+
;;
28+
esac
3129
done
30+
rmdir "$ACTIVE_DIR" 2>/dev/null || true
3231
}
3332

3433
case "$1" in

packaging/ci/test-companion-chroot.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ if apt-get install -y -qq --allow-downgrades "$OLD" >/tmp/down.log 2>&1; then ok
237237
[ "$(dpkg-query -W -f='${Version}' ceralive-modem-support)" = "0.9.0" ] && ok "downgraded to 0.9.0" || bad "downgrade did not take"
238238
239239
echo "== 9. purge leaves zero leftovers =="
240-
mkdir -p "$ACTIVE"; ln -sfn /usr/share/ModemManager/fcc-unlock.d/2c7c "$ACTIVE/2c7c"
241-
printf 'not ours\n' > /usr/share/ModemManager/fcc-unlock.d/keepme
240+
mkdir -p "$ACTIVE"; ln -sfn /usr/share/ModemManager/fcc-unlock.available.d/2c7c "$ACTIVE/2c7c"
241+
printf 'not ours\n' > "$ACTIVE/keepme"
242242
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
243243
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
244244
left=0
@@ -249,7 +249,7 @@ for d in /usr/lib/ceralive-modem-support /usr/share/ceralive-modem-support; do
249249
[ -e "$d" ] && { bad "leftover directory after purge: $d"; left=1; }
250250
done
251251
[ -L "$ACTIVE/2c7c" ] && { bad "purge left an active FCC symlink behind"; left=1; }
252-
[ -f /usr/share/ModemManager/fcc-unlock.d/keepme ] || { bad "purge deleted a file that was not ours"; left=1; }
252+
[ -f "$ACTIVE/keepme" ] || { bad "purge deleted a file that was not ours"; left=1; }
253253
[ "$left" -eq 0 ] && ok "zero leftovers over every declared path; foreign files untouched"
254254
255255
echo

0 commit comments

Comments
 (0)