[Slackbuilds-users] icon theme symlink optimization

B Watson yalhcru at gmail.com
Wed Apr 8 05:09:41 UTC 2020

Ever notice most of the *-icon-theme builds take *forever* to build?
Even though they're just copying data, with no compiling happening?
The culprit is makepkg's symlink detection and doinst.sh generation.

To anyone who maintains a build that contains thousands of
symlinks... please consider doing this to your build.

The changes come at the end of the script, just before makepkg is
called. Example:

cd $PKG

find . -type l \
  -printf '( cd %h ; rm -rf %f )\n( cd %h ; ln -sf %l %f )\n' -delete | \
  sed 's,cd \./,cd ,' >> $PKG/install/doinst.sh

/sbin/makepkg -l y -c n

This produces an install/doinst.sh that's identical[1] to the one makepkg
would have generated, but it happens a *lot* faster. If you're using
an SSD for /tmp, you can expect the build to run in seconds rather than
minutes. Even on a hard drive, expect at least a 2x to 10x speedup.

[1] Unless there are spaces in the filenames.

To decide whether or not this is worth doing to your build, first
build it the usual way. Then:

grep -c 'ln -sf' /tmp/SBo/package-<whatever>/install/doinst.sh

...which will show you how many symlinks exist in your package. If the
number's above 1000 or so (some are closer to 20,000 or 40,000), it's
worth trying this speedup technique.

When you do this to your build, you should keep a copy of the old
install/doinst.sh from before the modification. Paste the above code (the
giant find|sed stanza) into your build, run it (it should be noticeably
faster), then diff the old doinst.sh and the newly-generated one. They
should be identical. If not, either figure out why & fix it, or revert
the change and leave the build alone.

In my git branch, I've done this to these builds:


If you're the maintainer of one of these, you may want to double-check
that the generated doinst.sh hasn't changed (I checked them myself,
but why take my word for it?)

Before anyone asks: yes, I'm planning to send Pat a patch for him
to consider adding to makepkg. However I've got to deal with the
spaces-in-filenames issue first.

More information about the SlackBuilds-users mailing list