<div dir="auto"><div><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, Dec 25, 2024, 9:06 AM Shahab Vahedi via SlackBuilds-users <<a href="mailto:slackbuilds-users@slackbuilds.org">slackbuilds-users@slackbuilds.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Today, I have observed a peculiar behaviour from "removepkg". I'd like<br>
to share it with and see if anybody knows better about this.<br>
<br>
------------------------------------------------------------------------<br>
<br>
Links must be created by "doinst.sh" scripts. If "removepkg" finds (?)<br>
the following pattern in "doinst.sh" script of a package:<br>
<br>
( cd some/path ; rm -rf some.file )<br>
( cd some/path ; ln -sf /the/source/file some.file )<br>
<br>
those becomes the first files that are _automatically_ removed:<br>
<br>
# removepkg brother-brscan4<br>
Removing files:<br>
--> Deleting symlink /some/path/some.file<br>
...<br>
<br>
This is wanted, because these automatic removals can make the<br>
"/some/path" directory empty which the rest of removal procedure will<br>
remove.<br>
<br>
You have to be careful about this mechanism as it is dumb. For<br>
instance, if there are variables like /usr/lib$LIBDIRSUFFIX/..., they<br>
won't be expanded and you end-up with:<br>
<br>
Removing files:<br>
--> //usr/lib${LIBDIRSUFFIX}/sane/libsane-brother4.so (symlink) no<br>
longer exists. Skipping.<br>
...<br>
<br>
In that case, you're better with a tweak on the construct by replacing<br>
';' with '&&':<br>
<br>
( cd some/path && rm -rf some.file )<br>
( cd some/path && ln -sf /the/source/file some.file )<br>
<br>
And then removing the symlinks manually by "douninst.sh". However, if<br>
you rely on automatic removal of empty directories, it won't happen<br>
anymore, because "douninst.sh" is called after that. So your<br>
"douninst.sh" might have to take care of it as well.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Do you have an example package where this occurred? </div><div dir="auto"><br></div><div dir="auto">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. </div><div dir="auto"><br></div><div dir="auto">Then, when makepkg is ran, it will remove symlinks and add them automatically to the doinst.sh.</div><div dir="auto"><br></div><div dir="auto">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. </div><div dir="auto"><br></div><div dir="auto">Jeremy</div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>