#1108217 fcopy aborts on dead symlinks

#1108217#5
Date:
2025-06-23 14:00:15 UTC
From:
To:
Since e0d7b49 (first appeared in bookworm) fcopy tests for broken symlinks. However this change breaks relative symlinks because of class semantics (/foo/bar/DEFAULT -> ../etc means /foo/bar should be a symlink relative to bar, not to DEFAULT in the target tree). Also during installation, absolute symlinks pointing to files absent in the installer will be ignored by fcopy.

e0d7b49 was a fix for #985303. I'm not sure what the correct behaviour would be for that, since we don't use substitutions.

#1108217#10
Date:
2025-06-24 12:23:00 UTC
From:
To:
Does fcopy works for you without this change for broken/relative symlinks?
Does fcopy handles relative symlinks diffrently than absolute
symlinks?

Do you have any suggestion how fcopy should behave for symlinks?

#1108217#15
Date:
2025-06-25 15:29:40 UTC
From:
To:
Hello Thomas,
Yes. We just revert the change since bookworm.
symlinks?
No, AFAIK. Just that absolute symlinks which might work in a running system won't during installation.
For dead symlinks as source without -H: just die like in do_substitutions (having a dead symlink in the context of the configspace should be an configuration error), or continue with a warning (no strong preference there).

For healthy symlinks without -H and with -S: do substitutions as normal.

I attached an untested patch which might do that; Will test the next days.

Kind regards,
Victor

#1108217#20
Date:
2025-06-27 13:25:05 UTC
From:
To:
Attached a patch without the duplicated '-l $sourcefile'

And some tests:

$ mkdir --parents config/normal_file config/absolute_in-tree_symlink config/absolute_out-of-tree_symlink config/etc/relative_in-tree_symlink config/etc/relative_out-of-tree_symlink
$ echo '{%PATH%}' > config/normal_file/DEFAULT
$ ln -s /normal_file config/absolute_in-tree_symlink/DEFAULT
$ ln -s /tmp/fai/fai.log config/absolute_out-of-tree_symlink/DEFAULT
$ ln -s ../normal_file config/etc/relative_in-tree_symlink/DEFAULT
$ ln -s ../etc/debian_version config/etc/relative_out-of-tree_symlink/DEFAULT

Without patch:
$ fcopy.orig -s config -t target -c DEFAULT -rHS /
fcopy: config/absolute_in-tree_symlink/DEFAULT is a broken symlink
# Even though normal_file will be copied later, at this point the symlink is broken (and later it would still be, because -t is not /)

fcopy: config/etc/relative_in-tree_symlink/DEFAULT is a broken symlink
# In the target tree ../normal_file will be fine, but config/etc/relative_in-tree_symlink/../normal_file doesn't resolve

fcopy: config/absolute_out-of-tree_symlink/DEFAULT is a broken symlink
# This would only work during installation

fcopy: copied config/normal_file/DEFAULT to target/normal_file
# Ok

fcopy: config/etc/relative_out-of-tree_symlink/DEFAULT is a broken symlink
# Similar reason to relative_in-tree_symlink

$ cat target/normal_file
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
# substitution worked

With patch:
$ fcopy -s config -t target -c DEFAULT -rHS /
fcopy: symlinked config/absolute_out-of-tree_symlink/DEFAULT -> /tmp/fai/fai.log to target/absolute_out-of-tree_symlink
fcopy: copied config/normal_file/DEFAULT to target/normal_file
fcopy: symlinked config/etc/relative_out-of-tree_symlink/DEFAULT -> ../etc/debian_version to target/etc/relative_out-of-tree_symlink
fcopy: symlinked config/etc/relative_in-tree_symlink/DEFAULT -> ../normal_file to target/etc/relative_in-tree_symlink
fcopy: symlinked config/absolute_in-tree_symlink/DEFAULT -> /normal_file to target/absolute_in-tree_symlink

$ cat target/normal_file
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

With patch and without -H still as expected:
$ mkdir --parents config/some_file target
$ echo '{%PATH%}' > config/some_file/OTHER_CLASS
$ ln -s OTHER_CLASS config/some_file/DEFAULT
$ fcopy -s config -t target -c DEFAULT -r /
fcopy: copied config/some_file/DEFAULT to target/some_file
$ cat target/some_file
{%PATH%}

With -S too:
$ cat target/some_file
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games