Package: usrmerge
Version: 25
Severity: normal
Tags: patch
User: [email protected]
Usertags: origin-ubuntu jammy ubuntu-patch
X-Debbugs-Cc: [email protected]
Dear Maintainer,
in certain cases where an application was upgraded to already generate
its files in the new usr-merged location (e.g. /usr/lib/...) instead of
the previous/old location in /lib/... the convert-usrmerge script can
run into error like this:
FATAL ERROR:
Both /lib/udev/hwdb.bin and /usr/lib/udev/hwdb.bin exist.
We can detect such scenarios by using an allow-list of known generated
files and clearing the legacy locations in such cases.
In Ubuntu, the attached patch was applied to achieve the following:
* Clear generated files if they have already been re-generated (LP: #1930573)
Thanks for considering the patch.
Cheers,
Lukas
-- System Information:
Debian Release: 11.0
APT prefers impish-updates
APT policy: (500, 'impish-updates'), (500, 'impish-security'), (500, 'impish')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.13.0-20-generic (SMP w/4 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_WARN, TAINT_OOT_MODULE
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8),
LANGUAGE=de_DE:en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru usrmerge-25ubuntu1/convert-usrmerge
usrmerge-25ubuntu2/convert-usrmerge
--- usrmerge-25ubuntu1/convert-usrmerge 2021-04-27 04:42:00.000000000 +0200
+++ usrmerge-25ubuntu2/convert-usrmerge 2021-10-26 11:11:12.000000000 +0200
@@ -162,6 +162,18 @@
fatal("Both $n and /usr$n exist");
}
+ # generated files
+ # if it was already re-generated in the new place, clear the legacy
location
+ # Origin of generated files:
+ # /lib/udev/hwdb.bin -> 'systemd-hwdb --usr update'
+ my @generated_files = qw(
+ /lib/udev/hwdb.bin
+ );
+ if (-e "/usr$n" && $n ~~ @generated_files) {
+ rm('-f', "$n");
+ return;
+ }
+
fatal("$n is a directory and /usr$n is not")
if -d $n and -e "/usr$n";
fatal("/usr$n is a directory and $n is not")