Hi Marco,
Am 28.10.21 um 13:14 schrieb Marco d'Itri:
On Oct 26, Lukas Märdian <sl...@ubuntu.com> 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";