[Slackbuilds-users] Symlinks and AUTOMATIC removals
Shahab Vahedi
list+sbo at vahedi.org
Wed Dec 25 17:06:09 UTC 2024
Today, I have observed a peculiar behaviour from "removepkg". I'd like
to share it with and see if anybody knows better about this.
------------------------------------------------------------------------
Links must be created by "doinst.sh" scripts. If "removepkg" finds (?)
the following pattern in "doinst.sh" script of a package:
( cd some/path ; rm -rf some.file )
( cd some/path ; ln -sf /the/source/file some.file )
those becomes the first files that are _automatically_ removed:
# removepkg brother-brscan4
Removing files:
--> Deleting symlink /some/path/some.file
...
This is wanted, because these automatic removals can make the
"/some/path" directory empty which the rest of removal procedure will
remove.
You have to be careful about this mechanism as it is dumb. For
instance, if there are variables like /usr/lib$LIBDIRSUFFIX/..., they
won't be expanded and you end-up with:
Removing files:
--> //usr/lib${LIBDIRSUFFIX}/sane/libsane-brother4.so (symlink) no
longer exists. Skipping.
...
In that case, you're better with a tweak on the construct by replacing
';' with '&&':
( cd some/path && rm -rf some.file )
( cd some/path && ln -sf /the/source/file some.file )
And then removing the symlinks manually by "douninst.sh". However, if
you rely on automatic removal of empty directories, it won't happen
anymore, because "douninst.sh" is called after that. So your
"douninst.sh" might have to take care of it as well.
------------------------------------------------------------------------
Shahab
More information about the SlackBuilds-users
mailing list