[Slackbuilds-users] Symlinks and AUTOMATIC removals
Jeremy Hansen
jebrhansen+SBo at gmail.com
Fri Dec 27 04:27:07 UTC 2024
On Wed, Dec 25, 2024, 9:06 AM Shahab Vahedi via SlackBuilds-users <
slackbuilds-users at slackbuilds.org> wrote:
> 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.
>
Do you have an example package where this occurred?
I can't think of a reason why the doinst.sh should have $LIBDIRSUFFIX in it
(but maybe there's edge cases I can't think of). Symlinks generally
(always?) should be created within the package directory structure by
commands in the SlackBuild, which will replace $LIBDIRSUFFIX with the
correct location in that directory structure.
Then, when makepkg is ran, it will remove symlinks and add them
automatically to the doinst.sh.
If there is really a reason to manually add symlinks to the doinst.sh, a
sed command should be used to ensure the correct directory is listed in the
final doinst.sh before the makepkg is ran.
Jeremy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.slackbuilds.org/pipermail/slackbuilds-users/attachments/20241226/f4f5172a/attachment.htm>
More information about the SlackBuilds-users
mailing list