From 5cacb2fcd86aa499aba4188ef6357e7e008373bc Mon Sep 17 00:00:00 2001 From: Arcitec <38923130+Arcitec@users.noreply.github.com> Date: Wed, 10 May 2023 08:35:12 +0200 Subject: [PATCH] feat: ultimate laziness achieved with a powerful new script runner It's so easy that even Homer Simpson could use it to automate the nuclear plant. Enjoy! --- README.md | 2 + recipe.yml | 9 +++++ scripts/autorun.sh | 99 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 scripts/autorun.sh diff --git a/README.md b/README.md index af10a70abb..2ad16765af 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ Instead, you can create shell scripts in the `scripts/` directory (look at the ` Your scripts will be given exactly one argument when they are executed, which specifies its precise execution phase and corresponds to the name of the `scripts:` category that it was assigned to. The primary purpose of this argument is to streamline the reuse of scripts for multiple stages. +If you're looking for a fully automated script runner, you should read the code of the included `scripts/autorun.sh` to see how it works, and then simply specify that as your script in `recipe.yml`. You can also add manually listed scripts in addition to the auto-runner, which can be very useful when managing multiple recipes. + ### Custom package repositories If you want to add custom package repositories to your image, you can include them in the `recipe.yml` as a list of URLs under the `rpm.repos:` section. They **must** be proper `.repo` files (such as `https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-38/atim-starship-fedora-38.repo`). In the build process, the `.repo` file will be downloaded and placed inside `/etc/yum.repos.d/` where rpm-ostree can access it. diff --git a/recipe.yml b/recipe.yml index b64a703805..77ae555a4a 100644 --- a/recipe.yml +++ b/recipe.yml @@ -21,14 +21,23 @@ description: A starting point for further customization of uBlue images. Make yo # Place scripts in the "scripts/" dir and put the corresponding filenames here. # Any files that aren't listed here won't be executed automatically, which # means that you can place "helper" or "library" scripts in the folder too. +# Remember to use "autorun.sh" if you want an automatic runner. scripts: # "Pre" scripts run very early in the build, immediately after your custom # repos have been imported (so that you can access those repos if necessary). pre: + # Automatically runs script files within "scripts/pre/". + - autorun.sh + # Manually listed scripts. Can be combined with the autorunner, which can + # be useful if you're managing multiple recipes and some need extra scripts. + # See the contents of "scripts/autorun.sh" for more usage instructions. # - example_pre.sh # "Post" scripts run at the end of the build process. post: + # Automatically runs script files within "scripts/post/". + - autorun.sh + # Manually listed scripts. # - example_post.sh # Custom RPM configuration. diff --git a/scripts/autorun.sh b/scripts/autorun.sh new file mode 100644 index 0000000000..499ed35b59 --- /dev/null +++ b/scripts/autorun.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash + +# Tell this script to exit if there are any errors. +set -oue pipefail + +# +# AUTORUN: +# +# This script simplifies your "recipe.yml" management whenever you simply want +# to "run everything automatically" based on whatever script files exist on disk. +# +# Set any or all of your "recipe.yml" script categories to "autorun.sh", and +# enjoy the magic! The autorunner will then automatically look up all ".sh" +# script files within the corresponding "scripts/