Moving most of the inline docs in autorun.sh to scripts/README.md. This makes the documentation more discoverable and approachable (no need to read source code). This commit also removes redundancies from the inline docs, clears up some phrasing, and uses more standard formatting and phrasing such as: - using `` instead of "" - calling itself `autorun.sh` - calling pre and post "execution phases"
Custom scripts
You can add custom scripts to this directory and declare them to be run at build time in the scripts: section of recipe.yml. Custom scripts can be run at either the pre: execution phase right after the custom repositories are added, or at the post: phase after all of the automatic build steps.
Your scripts will be given exactly one argument when they are executed, which specifies its precise execution phase (pre or post). The primary purpose of this argument is to streamline the reuse of scripts for multiple stages. This behaviour is mirrored both in manually declared scripts and scripts ran by autorun.sh.
autorun.sh
autorun.sh is a script that automatically runs all scripts in the folders scripts/pre/ and scripts/post/ at the correct execution phases. It is enabled by default, but you can disable it by removing it from recipe.yml. Manually listed scripts can be combined with autorun.sh.
There are a few rules, which aim to simplify your script management:
autorun.shwill only execute scripts at the FIRST level within the directory, which means that anything stored in e.g.scripts/pre/deeperfolder/will NOT execute. This is intentional, so that you can store libraries and helper scripts within subdirectories.- You script directories and the scripts within them can be symlinks, to allow
easy reuse of scripts. For example, if you want the same scripts to execute
during both the
preandpoststages, you could simply symlink individual scripts or the entirepreandpostdirectories to each other. However, remember to only use RELATIVE symlinks, to ensure that the links work properly. For example,ln -s ../pre/foo.sh scripts/post/foo.sh. - All scripts execute in a numerically and alphabetically sorted order, which
allows you to easily control the execution order of your scripts. If it's
important that they execute in a specific order, then you should give them
appropriate names. For example,
05-foo.swould always execute before another script named99-bar.sh. It's recommended to use zero-padded, numerical prefixes when you want to specify the execution order. - The manually listed scripts in
recipe.ymlshould be stored directly withinscripts/, or in a custom subdirectory that doesn't match any of the execution phases. For example, you could set thepre:section ofrecipe.ymlto execute bothautorun.shandfizzwidget/something.sh, and then place a bunch of auto-executed scripts underscripts/pre/for the autorunner. This makes it very simple to reuse common scripts between multiple differentrecipe.ymlfiles, while also having some scripts be specific to differentrecipe.ymls. - You can safely specify
autorun.shas a script inrecipe.yml, even if the special directories don't exist or don't contain any scripts. It will gracefully skip the processing if there's nothing to do.