Package: wireless-regdb
Version: 2021.08.28-1
Severity: important
Tags: d-i
X-Debbugs-Cc: debian-boot@lists.debian.org

Dear Maintainer,

I've noticed after installing wireless-regdb on a fresh install the
package-provided file is not actually used (older version from
wireless-regdb-udeb is used), and update-alternative to select the
upstream version of the regdb also fails


(debian-boot@l.d.o: sorry for the explicit cc, I'm not really sure what
the d-i tag implies)


The problem is that the installer copies /lib/firmware/regulatory.db and
/lib/firmware/regulatory.db.p7s from the installer, and wireless-regdb
postinstall script does not overwrite these if they exist.

This can be reproduced in a minimal container:
root@00e7025e1eeb:/# mkdir /lib/firmware
root@00e7025e1eeb:/# touch /lib/firmware/regulatory.db
root@00e7025e1eeb:/# apt install -y wireless-regdb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
  crda
The following NEW packages will be installed:
  wireless-regdb
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 13.9 kB of archives.
After this operation, 42.0 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 wireless-regdb all 
2020.04.29-2 [13.9 kB]
Fetched 13.9 kB in 0s (222 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package wireless-regdb.
(Reading database ... 6662 files and directories currently installed.)
Preparing to unpack .../wireless-regdb_2020.04.29-2_all.deb ...
Unpacking wireless-regdb (2020.04.29-2) ...
Setting up wireless-regdb (2020.04.29-2) ...
update-alternatives: using /lib/firmware/regulatory.db-debian to provide 
/lib/firmware/regulatory.db (regulatory.db) in auto mode
update-alternatives: warning: not replacing /lib/firmware/regulatory.db with a 
link
update-alternatives: warning: forcing reinstallation of alternative 
/lib/firmware/regulatory.db-debian because link group regulatory.db is broken
update-alternatives: warning: not replacing /lib/firmware/regulatory.db with a 
link
root@00e7025e1eeb:/# ls -l /lib/firmware/regulatory.db*
-rw-r--r-- 1 root root    0 Jun 10 00:21 /lib/firmware/regulatory.db
-rw-r--r-- 1 root root 3764 Jun 30  2020 /lib/firmware/regulatory.db-debian
-rw-r--r-- 1 root root 3764 Jun 30  2020 /lib/firmware/regulatory.db-upstream
lrwxrwxrwx 1 root root   35 Jun 10 00:21 /lib/firmware/regulatory.db.p7s -> 
/etc/alternatives/regulatory.db.p7s
-rw-r--r-- 1 root root 1249 Jun 30  2020 /lib/firmware/regulatory.db.p7s-debian
-rw-r--r-- 1 root root 1182 Jun 30  2020 
/lib/firmware/regulatory.db.p7s-upstream
root@00e7025e1eeb:/# update-alternatives --config regulatory.db
There are 2 choices for the alternative regulatory.db (providing 
/lib/firmware/regulatory.db).

  Selection    Path                                  Priority   Status
------------------------------------------------------------
  0            /lib/firmware/regulatory.db-debian     100       auto mode
* 1            /lib/firmware/regulatory.db-debian     100       manual mode
  2            /lib/firmware/regulatory.db-upstream   50        manual mode

Press <enter> to keep the current choice[*], or type selection number:
update-alternatives: warning: forcing reinstallation of alternative 
/lib/firmware/regulatory.db-debian because link group regulatory.db is broken
update-alternatives: warning: not replacing /lib/firmware/regulatory.db with a 
link
root@00e7025e1eeb:/# ls -l /lib/firmware/regulatory.db
-rw-r--r-- 1 root root    0 Jun 10 00:21 /lib/firmware/regulatory.db


Running with --force removes the original file with a warning and works:
root@00e7025e1eeb:/# update-alternatives --force --config regulatory.db
There are 2 choices for the alternative regulatory.db (providing 
/lib/firmware/regulatory.db).

  Selection    Path                                  Priority   Status
------------------------------------------------------------
  0            /lib/firmware/regulatory.db-debian     100       auto mode
* 1            /lib/firmware/regulatory.db-debian     100       manual mode
  2            /lib/firmware/regulatory.db-upstream   50        manual mode

Press <enter> to keep the current choice[*], or type selection number:
update-alternatives: warning: forcing reinstallation of alternative 
/lib/firmware/regulatory.db-debian because link group regulatory.db is broken
root@00e7025e1eeb:/# ls -l /lib/firmware/regulatory.db
lrwxrwxrwx 1 root root 31 Jun 10 00:23 /lib/firmware/regulatory.db -> 
/etc/alternatives/regulatory.db




The original cause for this is that deian-installer copies the files
because of the combinaison of these two:
https://salsa.debian.org/installer-team/debian-installer/-/blob/master/build/pkg-lists/base#L34
 - wireless-regdb-udeb contains the firmwares as regular files
https://salsa.debian.org/installer-team/hw-detect/-/blob/master/hw-detect.post-base-installer.d/50install-firmware#L14
 - it copies /lib/firmware content in base post-install step

the udeb regdb is also slightly obsolete, I'm not sure why it was needed
in the first place but it might be possible to use the normal package
instead?

That won't fix existing systems though.
If wireless-regdb had been owning the files in dpkg it would be fair
game to just overwrite the files (dpkg overwrites any untracked file
when installing a package that provides the path).

Would it make sense to include regulatory.db -> regulatory.db-debian
(+same for p7s) links in the package itself, so package installation
overwrites these and the post update-alternative step fixes it?
It seems to fix "broken" links without force in this case.
(or push real links to /etc/alternatives/regulatory.db would work too)


Thanks,
-- 
Dominique Martinet

Reply via email to