[Slackbuilds-users] Slackbuild script code structure

B. Watson urchlay at slackware.uk
Fri Jan 16 05:53:12 UTC 2026



On Fri, 16 Jan 2026, Riza Dindir wrote:

> I want to use functions in slackbuilds to structure the build script. The changes to the script will not change the way slackbuild is working. And the script will
> pass validation done with sbolint.

Can you show us an example of what you mean?

I use functions for things like... running make and make install with
the same arguments, if there are lots of them needed. Or wrapping
the 'install' command if it's going to be called multiple times.
Or calling the "chroot -R root:root ." and "find|xargs|chmod" stuff
multiple times, if there are multiple source tarballs.

Example of what I'm talking about would be asap.SlackBuild,
zathura.SlackBuild, or ovcc.SlackBuild.

I also like to assign long repeated directory names to a variable:

PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cp -a README.md $PKGDOC
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild

Basically, to me anyway, these make the scripts simpler, not more
complex. I think the Agile folks call it the DRY principle (don't
repeat yourself).


More information about the SlackBuilds-users mailing list