Bug#997866: usrmerge: cannot handle generated files that have already been re-generated in the new location
Hi Marco, Am 28.10.21 um 13:14 schrieb Marco d'Itri: On Oct 26, Lukas Märdian wrote: In Ubuntu, the attached patch was applied to achieve the following: I will be happy to merge something which can achieve this, but I need a few clarifications first. Thank you very much for your review and comments! Please find attached an updated version of my patch. + if (-e "/usr$n" && $n ~~ @generated_files) { Is it really needed to check this before the following file != directory checks? This looks like a bug, because rm would fail if $n were a directory. You're right. It would be better to clear any generated files only after it was checked to not be a directory. + rm('-f', "$n"); Does -f actually have a purpose here? Not really. Let's get rid of that. + 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") Cheers, Lukas diff --git a/convert-usrmerge b/convert-usrmerge index e36b95f..0724811 100755 --- a/convert-usrmerge +++ b/convert-usrmerge @@ -166,6 +166,19 @@ sub convert_file { if -d $n and -e "/usr$n"; fatal("/usr$n is a directory and $n is not") if -d "/usr$n"; + + # 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($n); + return; + } + fatal("Both $n and /usr$n exist") if -e "/usr$n";
Bug#997866: usrmerge: cannot handle generated files that have already been re-generated in the new location
On Oct 26, Lukas Märdian wrote: > In Ubuntu, the attached patch was applied to achieve the following: I will be happy to merge something which can achieve this, but I need a few clarifications first. > + if (-e "/usr$n" && $n ~~ @generated_files) { Is it really needed to check this before the following file != directory checks? This looks like a bug, because rm would fail if $n were a directory. > + rm('-f', "$n"); Does -f actually have a purpose here? > + 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") -- ciao, Marco signature.asc Description: PGP signature
Bug#997866: usrmerge: cannot handle generated files that have already been re-generated in the new location
Package: usrmerge Version: 25 Severity: normal Tags: patch User: ubuntu-de...@lists.ubuntu.com Usertags: origin-ubuntu jammy ubuntu-patch X-Debbugs-Cc: sl...@ubuntu.com 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.0 +0200 +++ usrmerge-25ubuntu2/convert-usrmerge 2021-10-26 11:11:12.0 +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")