[Slackbuilds-users] broken symlink or owner
B. Watson
urchlay at slackware.uk
Sun Jun 7 03:01:25 UTC 2026
On Sat, 6 Jun 2026, fourtysixandtwo wrote:
> "cp -aL" would also fix the problem...dereference the link.
Just using cp (with no flags) generally would do the same.
<root at xiphos:~># mkdir a
<root at xiphos:~># cd a
<root at xiphos:~/a># touch a
<root at xiphos:~/a># ln -s a b
<root at xiphos:~/a># ls -l
total 0
-rw-r--r-- 1 root root 0 Jun 6 22:53 a
lrwxrwxrwx 1 root root 1 Jun 6 22:53 b -> a
<root at xiphos:~/a># cp b c
<root at xiphos:~/a># ls -l c
-rw-r--r-- 1 root root 0 Jun 6 22:54 c
"c" ends up a regular file, not a symlink.
<root at xiphos:~/a># cp -a b d
<root at xiphos:~/a># ls -l d
lrwxrwxrwx 1 root root 1 Jun 6 22:53 d -> a
...with "cp -a", the destination ends up being a symlink.
The intent of using "cp -a" is to preserve the timestamp, I suppose. But
"cat $CWD/file > $PKG/path/file" doesn't preserve the timestamp either.
Six of one, half a dozen of the other.
So the rule should be: do not use "cp -a" to copy files from $CWD into
$PKG. Not only does it risk creating broken symlinks, but your script
doesn't know for a fact that root is the owner of the files in $CWD,
and shouldn't make that assumption.
More information about the SlackBuilds-users
mailing list