From 37143b0e23582f8754808b77aee4b594bb877ba1 Mon Sep 17 00:00:00 2001 From: "Emmett Wasik (Viv)" <101368650+iamcult@users.noreply.github.com> Date: Mon, 24 Apr 2023 14:40:51 -0400 Subject: [PATCH] feat: add per-recipe shell script support (#38) --- Containerfile | 5 +++++ build.sh | 9 +++++++++ recipe.yml | 5 +++++ scripts/example.sh | 3 +++ 4 files changed, 22 insertions(+) create mode 100644 scripts/example.sh diff --git a/Containerfile b/Containerfile index f600dcc..03c5b6f 100644 --- a/Containerfile +++ b/Containerfile @@ -8,6 +8,11 @@ ARG RECIPE COPY etc /etc # COPY usr /usr +# copy scripts +RUN mkdir /tmp/scripts +COPY scripts /tmp/scripts +RUN find /tmp/scripts -type f -exec chmod +x {} \; + COPY ${RECIPE} /tmp/ublue-recipe.yml # yq used in build.sh and the setup-flatpaks recipe to read the recipe.yml diff --git a/build.sh b/build.sh index 231260c..df60f8c 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,13 @@ #!/bin/bash +# run scripts +echo "-- Running scripts defined in recipe.yml --" +buildscripts=$(yq '.scripts[]' < /tmp/ublue-recipe.yml) +for script in $(echo -e "$buildscripts"); do \ + echo "Running: ${script}" && \ + /tmp/scripts/$script; \ +done +echo "---" + # remove the default firefox (from fedora) in favor of the flatpak rpm-ostree override remove firefox firefox-langpacks diff --git a/recipe.yml b/recipe.yml index 2a8e8e3..93725cb 100644 --- a/recipe.yml +++ b/recipe.yml @@ -15,6 +15,11 @@ fedora-version: 37 # This description will be visible in the container metadata description: A starting point for further customization of uBlue images. Make your own! https://ublue.it/making-your-own/ +# These scripts will be executed during the container build +# Place scripts in scripts/ and put the corresponding filename here +scripts: +# - example.sh + # These rpms will be installed from the fedora repository # using rpm-ostree and will be preinstalled in the final image rpms: diff --git a/scripts/example.sh b/scripts/example.sh new file mode 100644 index 0000000..3c7d709 --- /dev/null +++ b/scripts/example.sh @@ -0,0 +1,3 @@ +#!/bin/bash +echo 'This is an example shell script' +echo 'Scripts here will run during build if specified in recipe.yml'