[Slackbuilds-users] Good practice to manage autodetected optional deps

Jeremy Hansen jebrhansen+SBo at gmail.com
Wed Feb 14 01:08:03 UTC 2024


On Tue, Feb 13, 2024, 4:34 PM Tonus <tonus1 at free.fr> wrote:

> Hi all
>
> I have a slackbuild that builds man pages if Pandoc is installed
> (autodetected).
>
> If it isn't, the man pages compression in the SBo template makes the
> script fail
> What's the good practice ? Add `|| true` at the end of the lines ?
>
> Tryed on clean system without Pandoc and on my system that has Pandoc,
> it builds fine.
>
> --
> Regards,
>
> Tonus
>

There are a couple of options:

1. You could do an if/then check to see if the man pages exist and then run
the command if found.
2. You could require the user to pass an option to enable man page support
(with the note pandoc is required) and then use that to enable/disable the
building of the man pages (I assume they have an on/off override of the
autodetect). You could continue to use that flag to determine if the man
pages should be compressed.
3. You could detect whether pandoc is installed and make the above decision
for the user based on that.

Personally, #1 seems the easiest. Just detect if there are man pages with
an if/then statement and if they are, run the compression command:

if [ -d $PKG/usr/man ]; then
  # run compression command
fi

(You may need to tweak that if statement depending on how the program
handles dirs.)

Jeremy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.slackbuilds.org/pipermail/slackbuilds-users/attachments/20240213/9c895548/attachment.htm>


More information about the SlackBuilds-users mailing list