From 99504097023fe853915b653a10195fb2383b83c7 Mon Sep 17 00:00:00 2001 From: ER Date: Wed, 9 Aug 2023 19:59:04 +0300 Subject: [PATCH 01/79] chore: outline rewrite without code changes * this does not work yet * comments & documentation will be added once the rewrite is complete --- scripts/build.sh => build.sh | 0 config/common-packages.yml | 9 +++ config/recipe.yml | 21 ++++++ {scripts => config/scripts}/README.md | 0 {scripts => config/scripts}/autorun.sh | 0 {scripts => config/scripts}/example.sh | 0 {scripts => config/scripts}/post/.gitkeep | 0 {scripts => config/scripts}/pre/.gitkeep | 0 modules/rpm-ostree/rpm-ostree.sh | 4 + modules/script/script.sh | 4 + modules/yafti/yafti.sh | 4 + recipe.yml | 91 ----------------------- 12 files changed, 42 insertions(+), 91 deletions(-) rename scripts/build.sh => build.sh (100%) create mode 100644 config/common-packages.yml create mode 100644 config/recipe.yml rename {scripts => config/scripts}/README.md (100%) rename {scripts => config/scripts}/autorun.sh (100%) rename {scripts => config/scripts}/example.sh (100%) rename {scripts => config/scripts}/post/.gitkeep (100%) rename {scripts => config/scripts}/pre/.gitkeep (100%) create mode 100644 modules/rpm-ostree/rpm-ostree.sh create mode 100644 modules/script/script.sh create mode 100644 modules/yafti/yafti.sh delete mode 100644 recipe.yml diff --git a/scripts/build.sh b/build.sh similarity index 100% rename from scripts/build.sh rename to build.sh diff --git a/config/common-packages.yml b/config/common-packages.yml new file mode 100644 index 0000000000..926d1b71c4 --- /dev/null +++ b/config/common-packages.yml @@ -0,0 +1,9 @@ +type: rpm-ostree + repos: + # - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%FEDORA_VERSION%/atim-starship-fedora-%FEDORA_VERSION%.repo + install: + - python3-pip + - libadwaita + remove: + - firefox + - firefox-langpacks diff --git a/config/recipe.yml b/config/recipe.yml new file mode 100644 index 0000000000..62aa62ab76 --- /dev/null +++ b/config/recipe.yml @@ -0,0 +1,21 @@ +name: startingpoint +description: A starting point for further customization of uBlue images. Make your own! https://ublue.it/making-your-own/ +base-image: ghcr.io/ublue-os/silverblue-main +fedora-version: 38 + +modules: + - type: script + run: # commands directly run inside scripts directory + - ./autorun.sh pre + + - from-file: common-packages.yml # paths relative to "config" directory + + - type: script + run: + - ./autorun.sh post + + - type: yafti # no need for an enable-disable key, inclusion implicitly enables + # config: yafti.yml # if not specified, would use a default config + custom-flatpaks: + - Celluloid: io.github.celluloid_player.Celluloid + - Krita: org.kde.krita \ No newline at end of file diff --git a/scripts/README.md b/config/scripts/README.md similarity index 100% rename from scripts/README.md rename to config/scripts/README.md diff --git a/scripts/autorun.sh b/config/scripts/autorun.sh similarity index 100% rename from scripts/autorun.sh rename to config/scripts/autorun.sh diff --git a/scripts/example.sh b/config/scripts/example.sh similarity index 100% rename from scripts/example.sh rename to config/scripts/example.sh diff --git a/scripts/post/.gitkeep b/config/scripts/post/.gitkeep similarity index 100% rename from scripts/post/.gitkeep rename to config/scripts/post/.gitkeep diff --git a/scripts/pre/.gitkeep b/config/scripts/pre/.gitkeep similarity index 100% rename from scripts/pre/.gitkeep rename to config/scripts/pre/.gitkeep diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh new file mode 100644 index 0000000000..a777d0feb9 --- /dev/null +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail diff --git a/modules/script/script.sh b/modules/script/script.sh new file mode 100644 index 0000000000..0fac16cd67 --- /dev/null +++ b/modules/script/script.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail \ No newline at end of file diff --git a/modules/yafti/yafti.sh b/modules/yafti/yafti.sh new file mode 100644 index 0000000000..0fac16cd67 --- /dev/null +++ b/modules/yafti/yafti.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail \ No newline at end of file diff --git a/recipe.yml b/recipe.yml deleted file mode 100644 index debc00c71b..0000000000 --- a/recipe.yml +++ /dev/null @@ -1,91 +0,0 @@ -# This file can only be edited inside the uBlue image's git repository. - -# The image will be at "ghcr.io/yourusername/name". -name: startingpoint - -# The native container image to build on top of. -# Warning: Non-uBlue images might not work properly, due to missing components. -base-image: ghcr.io/ublue-os/silverblue-main - -# What Fedora version to use. Use an explicit version or `latest`. -# If you use `latest`, you will be automatically updated to the next major -# Fedora version, assuming the image you're using as your base container -# builds with the tag (all uBlue images do this). -fedora-version: 38 - -# 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 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. -# You can 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. - # - 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. -# These changes will be integrated into your custom image at the "system level". -rpm: - # A list of urls of ".repo" files that should be added to your system. - # This is the proper way to add custom COPR repos to your image. - # Tip: Use `%FEDORA_VERSION%` instead of static Fedora version numbers, - # so that your repos automatically use your image's actual Fedora version, - # which greatly simplifies future maintenance of your custom recipe. - repos: - # Example (which also demonstrates version number expansion): - # - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%FEDORA_VERSION%/atim-starship-fedora-%FEDORA_VERSION%.repo - - # These RPMs will be installed from your enabled repositories (Fedora's own - # repos, extra "repos" you've added, etc). The installation is automatically - # performed via rpm-ostree during the image build, and will be pre-installed - # at the "system level" in the final image. - install: - # Needed for yafti (the first boot installer). Remove if you're not using yafti. - - python3-pip - # GNOME's GTK4 theme, Libadwaita. Already included in Silverblue, but not - # other spins. You can remove if you aren't using yafti, but many native - # apps and binaries require it, so it's a good idea to always include it - # if you ever download or compile any custom software on your machine. - - libadwaita - # Add your own below: - # Example: - # - tilix - - # These RPMs will be removed from the system image. This step happens during - # image build, BEFORE installing custom RPMs (from the "rpm.install" category). - remove: - # Remove the native firefox (from Fedora) in favor of the Flatpak. - - firefox - - firefox-langpacks - -# Configuration for the "first boot" experience, which is available after login. -firstboot: - # Whether to embed "yafti" into the OS image and configure it to autostart, - # which is the preferred uBlue "first boot" GUI. Set this to "false" if you've - # decided to use a different solution instead. - yafti: true - - # These Flatpaks will be suggested for install after user login, via the yafti - # "first boot" GUI. Everything below will be merged into the "yafti.yml" config - # on build, in a category named "Custom". If you prefer, you can instead remove - # everything below and directly edit "yafti.yml" to have more control. - # Alternatively, if you've disabled "yafti", you can still install these via - # the "just setup-flatpaks" command from our "custom.just" template file. - # This is just an example selection: - flatpaks: - - io.github.celluloid_player.Celluloid - - org.kde.krita From 4325e65c10e7c7d02f3a3832776a31e35e0d45ac Mon Sep 17 00:00:00 2001 From: ER Date: Wed, 9 Aug 2023 20:27:42 +0300 Subject: [PATCH 02/79] chore: refactor code to support new structure * this doesn't do much yet and a lot of code was deleted, functionality will be gradually added back --- Containerfile | 16 +++--- build.sh | 133 ++++++-------------------------------------------- 2 files changed, 23 insertions(+), 126 deletions(-) diff --git a/Containerfile b/Containerfile index dcbc6612b0..195fb6fe5a 100644 --- a/Containerfile +++ b/Containerfile @@ -13,7 +13,7 @@ FROM ${BASE_IMAGE_URL}:${FEDORA_MAJOR_VERSION} # The default recipe set to the recipe's default filename # so that `podman build` should just work for many people. -ARG RECIPE=./recipe.yml +ARG RECIPE=recipe.yml # The default image registry to write to policy.json and cosign.yaml ARG IMAGE_REGISTRY=ghcr.io/ublue-os @@ -30,8 +30,8 @@ COPY usr /usr # Copy public key COPY cosign.pub /usr/share/ublue-os/cosign.pub -# Copy the recipe that we're building. -COPY ${RECIPE} /usr/share/ublue-os/recipe.yml +# Copy the config folder +COPY config /usr/share/ublue-os/startingpoint # Copy nix install script and Universal Blue wallpapers RPM from Bling image COPY --from=ghcr.io/ublue-os/bling:latest /rpms/ublue-os-wallpapers-0.1-1.fc38.noarch.rpm /tmp/ublue-os-wallpapers-0.1-1.fc38.noarch.rpm @@ -39,19 +39,19 @@ COPY --from=ghcr.io/ublue-os/bling:latest /rpms/ublue-os-wallpapers-0.1-1.fc38.n # Integrate bling justfiles onto image COPY --from=ghcr.io/ublue-os/bling:latest /files/usr/share/ublue-os/just /usr/share/ublue-os/just -# Add nix installer if you want to use it +# Copy dnkmmr's nix installer COPY --from=ghcr.io/ublue-os/bling:latest /files/usr/bin/ublue-nix* /usr/bin # "yq" used in build.sh and the "setup-flatpaks" just-action to read recipe.yml. # Copied from the official container image since it's not available as an RPM. COPY --from=docker.io/mikefarah/yq /usr/bin/yq /usr/bin/yq -# Copy the build script and all custom scripts. -COPY scripts /tmp/scripts +COPY build.sh /tmp/build.sh # Run the build script, then clean up temp files and finalize container build. +# TODO move this rpm-ostree cmd somewhere else RUN rpm-ostree install /tmp/ublue-os-wallpapers-0.1-1.fc38.noarch.rpm && \ - chmod +x /tmp/scripts/build.sh && \ - /tmp/scripts/build.sh && \ + chmod +x /tmp/build.sh && \ + /tmp/build.sh && \ rm -rf /tmp/* /var/* && \ ostree container commit diff --git a/build.sh b/build.sh index c5d43fffbf..bc487b0b64 100644 --- a/build.sh +++ b/build.sh @@ -3,136 +3,33 @@ # Tell build process to exit if there are any errors. set -oue pipefail -# Helper functions. -RECIPE_FILE="/usr/share/ublue-os/recipe.yml" +# Absolute path to recipe file +RECIPE_FILE="/usr/share/ublue-os/startingpoint/${RECIPE}" + get_yaml_array() { - mapfile -t "${1}" < <(yq -- "${2}" "${RECIPE_FILE}") + local array=() + mapfile -t array < <(yq -- "\$1" "$RECIPE_FILE") + printf '%s\n' "${array[@]}" } get_yaml_string() { yq -- "${1}" "${RECIPE_FILE}" } # Automatically determine which Fedora version we're building. -FEDORA_VERSION="$(cat /usr/lib/os-release | grep -Po '(?<=VERSION_ID=)\d+')" +FEDORA_VERSION="$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)" # Read configuration variables. BASE_IMAGE="$(get_yaml_string '.base-image')" -YAFTI_ENABLED="$(get_yaml_string '.firstboot.yafti')" +IMAGE_NAME="$(get_yaml_string '.name')" # Welcome. -echo "Building custom Fedora ${FEDORA_VERSION} from image: \"${BASE_IMAGE}\"." - -# Add custom repos. -get_yaml_array repos '.rpm.repos[]' -if [[ ${#repos[@]} -gt 0 ]]; then - echo "-- Adding repos defined in recipe.yml --" - for repo in "${repos[@]}"; do - repo="${repo//%FEDORA_VERSION%/${FEDORA_VERSION}}" - wget "${repo}" -P "/etc/yum.repos.d/" - done - echo "---" -fi - -# Ensure that all script files are executable. -find /tmp/scripts -type f -exec chmod +x {} \; - -# Run "pre" scripts. -run_scripts() { - script_mode="$1" - get_yaml_array buildscripts ".scripts.${script_mode}[]" - if [[ ${#buildscripts[@]} -gt 0 ]]; then - echo "-- Running [${script_mode}] scripts defined in recipe.yml --" - for script in "${buildscripts[@]}"; do - echo "Running [${script_mode}]: ${script}" - "/tmp/scripts/${script}" "${script_mode}" - done - echo "---" - fi -} -run_scripts "pre" - -# Install RPMs. -get_yaml_array install_rpms '.rpm.install[]' -if [[ ${#install_rpms[@]} -gt 0 ]]; then - echo "-- Installing RPMs defined in recipe.yml --" - echo "Installing: ${install_rpms[@]}" - rpm-ostree install "${install_rpms[@]}" - echo "---" -fi - -# Remove RPMs. -get_yaml_array remove_rpms '.rpm.remove[]' -if [[ ${#remove_rpms[@]} -gt 0 ]]; then - echo "-- Removing RPMs defined in recipe.yml --" - echo "Removing: ${remove_rpms[@]}" - rpm-ostree override remove "${remove_rpms[@]}" - echo "---" -fi - -# Toggle yafti, which provides the "first boot" experience, https://github.com/ublue-os/yafti. -FIRSTBOOT_DATA="/usr/share/ublue-os/firstboot" -FIRSTBOOT_LINK="/usr/etc/profile.d/ublue-firstboot.sh" -if [[ "${YAFTI_ENABLED}" == "true" ]]; then - echo "-- firstboot: Installing and enabling \"yafti\" --" - pip install --prefix=/usr yafti - # Create symlink to our profile script, which creates the per-user "autorun yafti" links. - mkdir -p "$(dirname "${FIRSTBOOT_LINK}")" - ln -s "${FIRSTBOOT_DATA}/launcher/login-profile.sh" "${FIRSTBOOT_LINK}" -else - echo "-- firstboot: Removing all \"firstboot\" components --" - # Removes the script symlink that creates the per-user autostart symlinks. - # We must forcibly remove this here, in case it was added by an upstream image. - rm -f "${FIRSTBOOT_LINK}" - # Remove all of the launcher-scripts and yafti config, to de-clutter image and - # ensure it can't run by accident due to lingering symlinks or upstream image. - rm -rf "${FIRSTBOOT_DATA}" -fi - -# Add a new yafti "package group" called Custom, for the packages defined in recipe.yml. -# Only adds the package group if yafti is enabled and Flatpaks are defined in the recipe. -if [[ "${YAFTI_ENABLED}" == "true" ]]; then - YAFTI_FILE="${FIRSTBOOT_DATA}/yafti.yml" - get_yaml_array flatpaks '.firstboot.flatpaks[]' - if [[ ${#flatpaks[@]} -gt 0 ]]; then - echo "-- yafti: Adding Flatpaks defined in recipe.yml --" - yq -i '.screens.applications.values.groups.Custom.description = "Flatpaks suggested by the image maintainer."' "${YAFTI_FILE}" - yq -i '.screens.applications.values.groups.Custom.default = true' "${YAFTI_FILE}" - for pkg in "${flatpaks[@]}"; do - echo "Adding to yafti: ${pkg}" - yq -i ".screens.applications.values.groups.Custom.packages += [{\"${pkg}\": \"${pkg}\"}]" "${YAFTI_FILE}" - done - echo "---" - fi -fi - -# Setup container signing -echo "Setup container signing in policy.json and cosign.yaml" -echo "Registry to write: $IMAGE_REGISTRY" - -# Copy Name -NAME=$(get_yaml_string '.name') -cp /usr/share/ublue-os/cosign.pub /usr/etc/pki/containers/"$NAME".pub - -# Work around the fact that jq doesn't have an "inplace" option -FILE=/usr/etc/containers/policy.json -TMP=/tmp/policy.json +echo "Building $IMAGE_NAME from Fedora $FEDORA_VERSION ($BASE_IMAGE)." -jq '.transports.docker |= - {"'"$IMAGE_REGISTRY"'": [ - { - "type": "sigstoreSigned", - "keyPath": "/usr/etc/pki/containers/'"$NAME"'.pub", - "signedIdentity": { - "type": "matchRepository" - } - } - ] - } -+ .' $FILE > $TMP -mv -f $TMP $FILE +# Run each module +MODULES=$(get_yaml_array '.modules') -cp /usr/etc/containers/registries.d/ublue-os.yaml /usr/etc/containers/registries.d/"$NAME".yaml -sed -i "s ghcr.io/ublue-os $IMAGE_REGISTRY g" /usr/etc/containers/registries.d/"$NAME".yaml +for module in "${MODULES[@]}"; do + TYPE=$(yq r <(echo "$module") '.type') -# Run "post" scripts. -run_scripts "post" + echo "Launching module of type: $TYPE" +done \ No newline at end of file From 6b150ccf0a921d0c96848ce900c75d699fbcdaf6 Mon Sep 17 00:00:00 2001 From: ER Date: Wed, 9 Aug 2023 20:31:57 +0300 Subject: [PATCH 03/79] chore: rewriting some parts, new recipe location --- .github/workflows/build.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 43434f0b74..3699ec2e1c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,10 +33,10 @@ on: env: IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} +# Only deploys the branch named "live". Ignores all other branches, to allow +# having "development" branches without interfering with GHCR image uploads. jobs: push-ghcr: - # Only deploys the branch named "live". Ignores all other branches, to allow - # having "development" branches without interfering with GHCR image uploads. name: Build and push image runs-on: ubuntu-22.04 permissions: @@ -46,6 +46,9 @@ jobs: strategy: fail-fast: false matrix: + + # Add recipes for all the images you want to build here. + # Don't add module configuration files, you will get errors. recipe: - recipe.yml @@ -54,15 +57,15 @@ jobs: - name: Checkout Push to Registry action uses: actions/checkout@v3 - - name: Add yq for reading recipe.yml + - name: Add yq (for reading recipe.yml) uses: mikefarah/yq@v4.34.2 - name: Gather image data from recipe run: | - echo "IMAGE_NAME=$(yq '.name' ./${{ matrix.recipe }})" >> $GITHUB_ENV - echo "IMAGE_DESCRIPTION=$(yq '.description' ./${{ matrix.recipe }})" >> $GITHUB_ENV - echo "FEDORA_MAJOR_VERSION=$(yq '.fedora-version' ./${{ matrix.recipe }})" >> $GITHUB_ENV - echo "BASE_IMAGE_URL=$(yq '.base-image' ./${{ matrix.recipe }})" >> $GITHUB_ENV + echo "IMAGE_NAME=$(yq '.name' ./config/${{ matrix.recipe }})" >> $GITHUB_ENV + echo "IMAGE_DESCRIPTION=$(yq '.description' ./config/${{ matrix.recipe }})" >> $GITHUB_ENV + echo "FEDORA_MAJOR_VERSION=$(yq '.fedora-version' ./config/${{ matrix.recipe }})" >> $GITHUB_ENV + echo "BASE_IMAGE_URL=$(yq '.base-image' ./config/${{ matrix.recipe }})" >> $GITHUB_ENV - name: Get current version id: labels From 40be6880741c6967c690f2c525047839520ed661 Mon Sep 17 00:00:00 2001 From: ER Date: Wed, 9 Aug 2023 20:37:39 +0300 Subject: [PATCH 04/79] chore: also copy modules directory into img build --- Containerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Containerfile b/Containerfile index 195fb6fe5a..d76888bc60 100644 --- a/Containerfile +++ b/Containerfile @@ -46,8 +46,12 @@ COPY --from=ghcr.io/ublue-os/bling:latest /files/usr/bin/ublue-nix* /usr/bin # Copied from the official container image since it's not available as an RPM. COPY --from=docker.io/mikefarah/yq /usr/bin/yq /usr/bin/yq +# Copy build script; this is what parses your recipe COPY build.sh /tmp/build.sh +# Copy modules to a temporary directory, they'll only to be executed during the build +COPY modules /tmp/modules/ + # Run the build script, then clean up temp files and finalize container build. # TODO move this rpm-ostree cmd somewhere else RUN rpm-ostree install /tmp/ublue-os-wallpapers-0.1-1.fc38.noarch.rpm && \ From 6b64c6e5a2dd86efb8a7c34b223c604e06671a00 Mon Sep 17 00:00:00 2001 From: ER Date: Wed, 9 Aug 2023 20:50:16 +0300 Subject: [PATCH 05/79] chore: remove wallpaper rpm installation (for now) --- Containerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Containerfile b/Containerfile index d76888bc60..e1387b7892 100644 --- a/Containerfile +++ b/Containerfile @@ -53,9 +53,9 @@ COPY build.sh /tmp/build.sh COPY modules /tmp/modules/ # Run the build script, then clean up temp files and finalize container build. -# TODO move this rpm-ostree cmd somewhere else -RUN rpm-ostree install /tmp/ublue-os-wallpapers-0.1-1.fc38.noarch.rpm && \ - chmod +x /tmp/build.sh && \ - /tmp/build.sh && \ - rm -rf /tmp/* /var/* && \ - ostree container commit +RUN chmod +x /tmp/build.sh && /tmp/build.sh && \ + rm -rf /tmp/* /var/* && ostree container commit + +# Storage +# TODO turn this bling installation stuff into a module +# rpm-ostree install /tmp/ublue-os-wallpapers-0.1-1.fc38.noarch.rpm \ No newline at end of file From 7b9faf690c97f19e0de0373c3ed78722b7566498 Mon Sep 17 00:00:00 2001 From: ER Date: Wed, 9 Aug 2023 20:57:03 +0300 Subject: [PATCH 06/79] fix: bad yq command syntax * I'm never trusting AI again! --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index bc487b0b64..1ab7e395eb 100644 --- a/build.sh +++ b/build.sh @@ -29,7 +29,7 @@ echo "Building $IMAGE_NAME from Fedora $FEDORA_VERSION ($BASE_IMAGE)." MODULES=$(get_yaml_array '.modules') for module in "${MODULES[@]}"; do - TYPE=$(yq r <(echo "$module") '.type') + TYPE=$(echo "$module" | yq '.type') echo "Launching module of type: $TYPE" done \ No newline at end of file From e537d657e567503556fe2709c46cb4e5d95ef2f6 Mon Sep 17 00:00:00 2001 From: ER Date: Wed, 9 Aug 2023 21:02:06 +0300 Subject: [PATCH 07/79] chore: investigate reading module array --- build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.sh b/build.sh index 1ab7e395eb..ff544c3786 100644 --- a/build.sh +++ b/build.sh @@ -27,8 +27,11 @@ echo "Building $IMAGE_NAME from Fedora $FEDORA_VERSION ($BASE_IMAGE)." # Run each module MODULES=$(get_yaml_array '.modules') +echo "$MODULES" for module in "${MODULES[@]}"; do + echo "$module" + TYPE=$(echo "$module" | yq '.type') echo "Launching module of type: $TYPE" From 2b633ff5c87af2e3d47de0534fbe81abef04c553 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 15:00:21 +0300 Subject: [PATCH 08/79] fix: make get_yaml_array work apparently it's not possible to return an array from a function (eventhough doing so would be nice) --- build.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/build.sh b/build.sh index ff544c3786..b4008671d9 100644 --- a/build.sh +++ b/build.sh @@ -6,11 +6,11 @@ set -oue pipefail # Absolute path to recipe file RECIPE_FILE="/usr/share/ublue-os/startingpoint/${RECIPE}" +# https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#yq-in-a-bash-loop get_yaml_array() { - local array=() - mapfile -t array < <(yq -- "\$1" "$RECIPE_FILE") - printf '%s\n' "${array[@]}" + readarray "$1" < <(yq -o=j -I=0 "$2" "$RECIPE_FILE" ) } + get_yaml_string() { yq -- "${1}" "${RECIPE_FILE}" } @@ -26,12 +26,9 @@ IMAGE_NAME="$(get_yaml_string '.name')" echo "Building $IMAGE_NAME from Fedora $FEDORA_VERSION ($BASE_IMAGE)." # Run each module -MODULES=$(get_yaml_array '.modules') -echo "$MODULES" +get_yaml_array MODULES '.modules[]' for module in "${MODULES[@]}"; do - echo "$module" - TYPE=$(echo "$module" | yq '.type') echo "Launching module of type: $TYPE" From 245fc69b138a5d2bd01ca46f889865a216e22193 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 15:09:40 +0300 Subject: [PATCH 09/79] chore: launch modules, detect if module inline --- build.sh | 12 +++++++----- modules/rpm-ostree/rpm-ostree.sh | 2 ++ modules/script/script.sh | 4 +++- modules/yafti/yafti.sh | 4 +++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/build.sh b/build.sh index b4008671d9..e02f61ea42 100644 --- a/build.sh +++ b/build.sh @@ -3,8 +3,8 @@ # Tell build process to exit if there are any errors. set -oue pipefail -# Absolute path to recipe file RECIPE_FILE="/usr/share/ublue-os/startingpoint/${RECIPE}" +MODULE_DIRECTORY="/tmp/modules/" # https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#yq-in-a-bash-loop get_yaml_array() { @@ -28,8 +28,10 @@ echo "Building $IMAGE_NAME from Fedora $FEDORA_VERSION ($BASE_IMAGE)." # Run each module get_yaml_array MODULES '.modules[]' -for module in "${MODULES[@]}"; do - TYPE=$(echo "$module" | yq '.type') - - echo "Launching module of type: $TYPE" +for MODULE in "${MODULES[@]}"; do + TYPE=$(echo "$MODULE" | yq '.type') + if [[ "$TYPE" != "null" ]]; then + echo "Launching module of type: $TYPE" + bash "$MODULE_DIRECTORY/$TYPE/$TYPE.sh" "$MODULE" + fi done \ No newline at end of file diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index a777d0feb9..e74eaead99 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -2,3 +2,5 @@ # Tell build process to exit if there are any errors. set -oue pipefail + +echo "$1" \ No newline at end of file diff --git a/modules/script/script.sh b/modules/script/script.sh index 0fac16cd67..e74eaead99 100644 --- a/modules/script/script.sh +++ b/modules/script/script.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash # Tell build process to exit if there are any errors. -set -oue pipefail \ No newline at end of file +set -oue pipefail + +echo "$1" \ No newline at end of file diff --git a/modules/yafti/yafti.sh b/modules/yafti/yafti.sh index 0fac16cd67..e74eaead99 100644 --- a/modules/yafti/yafti.sh +++ b/modules/yafti/yafti.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash # Tell build process to exit if there are any errors. -set -oue pipefail \ No newline at end of file +set -oue pipefail + +echo "$1" \ No newline at end of file From 057b45a45f12465bb271f39f273236b457873997 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 15:19:55 +0300 Subject: [PATCH 10/79] refactor: remove get yml string, add configdir var --- build.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/build.sh b/build.sh index e02f61ea42..2894e81c33 100644 --- a/build.sh +++ b/build.sh @@ -3,7 +3,8 @@ # Tell build process to exit if there are any errors. set -oue pipefail -RECIPE_FILE="/usr/share/ublue-os/startingpoint/${RECIPE}" +CONFIG_DIRECTORY="/usr/share/ublue-os/startingpoint/" +RECIPE_FILE="$CONFIG_DIRECTORY/$RECIPE" MODULE_DIRECTORY="/tmp/modules/" # https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#yq-in-a-bash-loop @@ -11,16 +12,12 @@ get_yaml_array() { readarray "$1" < <(yq -o=j -I=0 "$2" "$RECIPE_FILE" ) } -get_yaml_string() { - yq -- "${1}" "${RECIPE_FILE}" -} - # Automatically determine which Fedora version we're building. FEDORA_VERSION="$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)" # Read configuration variables. -BASE_IMAGE="$(get_yaml_string '.base-image')" -IMAGE_NAME="$(get_yaml_string '.name')" +BASE_IMAGE="$(yq '.base-image' "$RECIPE_FILE")" +IMAGE_NAME="$(yq '.name' "$RECIPE_FILE")" # Welcome. echo "Building $IMAGE_NAME from Fedora $FEDORA_VERSION ($BASE_IMAGE)." From d0c6deeb9b6e8620dea209dfb16da7c41855393b Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 15:20:34 +0300 Subject: [PATCH 11/79] feat: running modules from files --- build.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build.sh b/build.sh index 2894e81c33..39f4ec1284 100644 --- a/build.sh +++ b/build.sh @@ -30,5 +30,12 @@ for MODULE in "${MODULES[@]}"; do if [[ "$TYPE" != "null" ]]; then echo "Launching module of type: $TYPE" bash "$MODULE_DIRECTORY/$TYPE/$TYPE.sh" "$MODULE" + else + FILE=$(echo "$MODULE" | yq '.from-file') + MODULE_CONFIG=$(yq -o=j -I=0 '.' "$CONFIG_DIRECTORY/$FILE") + + TYPE=$(echo "$MODULE_CONFIG" | yq '.type') + echo "Launching module of type: $TYPE" + bash "$MODULE_DIRECTORY/$TYPE/$TYPE.sh" "$MODULE_CONFIG" fi done \ No newline at end of file From 59e16045a857c2e93cc91f1dfe075b6122c52462 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 15:24:11 +0300 Subject: [PATCH 12/79] fix: remove trailing slashes from directory vars --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 39f4ec1284..88d18cf198 100644 --- a/build.sh +++ b/build.sh @@ -3,9 +3,9 @@ # Tell build process to exit if there are any errors. set -oue pipefail -CONFIG_DIRECTORY="/usr/share/ublue-os/startingpoint/" +CONFIG_DIRECTORY="/usr/share/ublue-os/startingpoint" RECIPE_FILE="$CONFIG_DIRECTORY/$RECIPE" -MODULE_DIRECTORY="/tmp/modules/" +MODULE_DIRECTORY="/tmp/modules" # https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#yq-in-a-bash-loop get_yaml_array() { From 055ef73ad5ae471e5a4447c338cbe62617b7620f Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 15:51:53 +0300 Subject: [PATCH 13/79] fix: bad indentation in common-packages.yml --- config/common-packages.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config/common-packages.yml b/config/common-packages.yml index 926d1b71c4..59f07c7a5f 100644 --- a/config/common-packages.yml +++ b/config/common-packages.yml @@ -1,9 +1,9 @@ type: rpm-ostree - repos: - # - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%FEDORA_VERSION%/atim-starship-fedora-%FEDORA_VERSION%.repo - install: - - python3-pip - - libadwaita - remove: - - firefox - - firefox-langpacks +repos: + # - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%FEDORA_VERSION%/atim-starship-fedora-%FEDORA_VERSION%.repo +install: + - python3-pip + - libadwaita +remove: + - firefox + - firefox-langpacks From cb0631831cfb458351692986449d9c9bf874b7fa Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 16:06:44 +0300 Subject: [PATCH 14/79] chore: export config directory --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 88d18cf198..29a1798e29 100644 --- a/build.sh +++ b/build.sh @@ -3,7 +3,7 @@ # Tell build process to exit if there are any errors. set -oue pipefail -CONFIG_DIRECTORY="/usr/share/ublue-os/startingpoint" +export CONFIG_DIRECTORY="/usr/share/ublue-os/startingpoint" RECIPE_FILE="$CONFIG_DIRECTORY/$RECIPE" MODULE_DIRECTORY="/tmp/modules" From e03ac5de80b62f25db8031bf1a31a395e18ff3cf Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 16:08:31 +0300 Subject: [PATCH 15/79] feat: script runner module --- modules/script/script.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/script/script.sh b/modules/script/script.sh index e74eaead99..d71a78aacc 100644 --- a/modules/script/script.sh +++ b/modules/script/script.sh @@ -3,4 +3,11 @@ # Tell build process to exit if there are any errors. set -oue pipefail -echo "$1" \ No newline at end of file +readarray RUN < <(yq -o=j -I=0 '.run[]' "$1" ) + +cd "$CONFIG_DIRECTORY/scripts" + +for CMD in "${RUN[@]}"; do + echo "Running command: $CMD" + $CMD +done \ No newline at end of file From c27685fae21ca767c47c63665a03cae55c47fc13 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 16:12:57 +0300 Subject: [PATCH 16/79] refactor: export get_yaml_array --- build.sh | 1 + modules/script/script.sh | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 29a1798e29..3125c8d6b6 100644 --- a/build.sh +++ b/build.sh @@ -11,6 +11,7 @@ MODULE_DIRECTORY="/tmp/modules" get_yaml_array() { readarray "$1" < <(yq -o=j -I=0 "$2" "$RECIPE_FILE" ) } +export -f get_yaml_array # Automatically determine which Fedora version we're building. FEDORA_VERSION="$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)" diff --git a/modules/script/script.sh b/modules/script/script.sh index d71a78aacc..c5ac89fb16 100644 --- a/modules/script/script.sh +++ b/modules/script/script.sh @@ -3,10 +3,9 @@ # Tell build process to exit if there are any errors. set -oue pipefail -readarray RUN < <(yq -o=j -I=0 '.run[]' "$1" ) - cd "$CONFIG_DIRECTORY/scripts" +get_yaml_array RUN '.run[]' for CMD in "${RUN[@]}"; do echo "Running command: $CMD" $CMD From 18d1b3d4cd79f3e2f37759558e8a9d83b7bcc613 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 16:15:22 +0300 Subject: [PATCH 17/79] Revert "refactor: export get_yaml_array" This reverts commit c27685fae21ca767c47c63665a03cae55c47fc13. (get_yaml_array can't be used in modules since it reads from the $RECIPE_FILE) --- build.sh | 1 - modules/script/script.sh | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 3125c8d6b6..29a1798e29 100644 --- a/build.sh +++ b/build.sh @@ -11,7 +11,6 @@ MODULE_DIRECTORY="/tmp/modules" get_yaml_array() { readarray "$1" < <(yq -o=j -I=0 "$2" "$RECIPE_FILE" ) } -export -f get_yaml_array # Automatically determine which Fedora version we're building. FEDORA_VERSION="$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)" diff --git a/modules/script/script.sh b/modules/script/script.sh index c5ac89fb16..d71a78aacc 100644 --- a/modules/script/script.sh +++ b/modules/script/script.sh @@ -3,9 +3,10 @@ # Tell build process to exit if there are any errors. set -oue pipefail +readarray RUN < <(yq -o=j -I=0 '.run[]' "$1" ) + cd "$CONFIG_DIRECTORY/scripts" -get_yaml_array RUN '.run[]' for CMD in "${RUN[@]}"; do echo "Running command: $CMD" $CMD From 9ad0048fc35448746b1385b5665c09dbb9437ed8 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 16:59:23 +0300 Subject: [PATCH 18/79] refactor: global get_yaml_array function --- build.sh | 6 ++++-- modules/script/script.sh | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 29a1798e29..a980201dbe 100644 --- a/build.sh +++ b/build.sh @@ -9,8 +9,10 @@ MODULE_DIRECTORY="/tmp/modules" # https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#yq-in-a-bash-loop get_yaml_array() { - readarray "$1" < <(yq -o=j -I=0 "$2" "$RECIPE_FILE" ) + # creates array $1 with content at key $2 from $3 + readarray "$1" < <(echo "$3" | yq -o=j -I=0 "$2" ) } +export -f get_yaml_array # this makes the function available to all modules # Automatically determine which Fedora version we're building. FEDORA_VERSION="$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)" @@ -23,7 +25,7 @@ IMAGE_NAME="$(yq '.name' "$RECIPE_FILE")" echo "Building $IMAGE_NAME from Fedora $FEDORA_VERSION ($BASE_IMAGE)." # Run each module -get_yaml_array MODULES '.modules[]' +readarray MODULES < <(yq -o=j -I=0 '.modules[]' "$RECIPE_FILE" ) for MODULE in "${MODULES[@]}"; do TYPE=$(echo "$MODULE" | yq '.type') diff --git a/modules/script/script.sh b/modules/script/script.sh index d71a78aacc..22fec4db31 100644 --- a/modules/script/script.sh +++ b/modules/script/script.sh @@ -3,7 +3,7 @@ # Tell build process to exit if there are any errors. set -oue pipefail -readarray RUN < <(yq -o=j -I=0 '.run[]' "$1" ) +get_yaml_array RUN '.run[]' "$1" cd "$CONFIG_DIRECTORY/scripts" From b2034c7a1cd64baa781c9e56b85a2633cc3bf24b Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 17:05:06 +0300 Subject: [PATCH 19/79] feat: rpm-ostree module --- build.sh | 2 +- modules/rpm-ostree/rpm-ostree.sh | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index a980201dbe..587f1b3b67 100644 --- a/build.sh +++ b/build.sh @@ -15,7 +15,7 @@ get_yaml_array() { export -f get_yaml_array # this makes the function available to all modules # Automatically determine which Fedora version we're building. -FEDORA_VERSION="$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)" +export FEDORA_VERSION="$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)" # Read configuration variables. BASE_IMAGE="$(yq '.base-image' "$RECIPE_FILE")" diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index e74eaead99..0fcb78a9dc 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -3,4 +3,25 @@ # Tell build process to exit if there are any errors. set -oue pipefail -echo "$1" \ No newline at end of file +get_yaml_array REPOS '.repos[]' "$1" +if [[ ${#REPOS[@]} -gt 0 ]]; then + echo "Adding repositories" + for REPO in "${REPOS[@]}"; do + REPO="${REPO//%FEDORA_VERSION%/${FEDORA_VERSION}}" + wget "${REPO}" -P "/etc/yum.repos.d/" + done +fi + +get_yaml_array INSTALL '.install[]' "$1" +if [[ ${#INSTALL[@]} -gt 0 ]]; then + echo "Installing RPMs" + echo "Installing: ${INSTALL[*]}" + rpm-ostree install "${INSTALL[@]}" +fi + +get_yaml_array REMOVE '.remove[]' "$1" +if [[ ${#REMOVE[@]} -gt 0 ]]; then + echo "Removing RPMs" + echo "Removing: ${REMOVE[*]}" + rpm-ostree override remove "${REMOVE[@]}" +fi \ No newline at end of file From 290075c1c77c7a936e247f6ee0c1f07c9464eea4 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 17:14:39 +0300 Subject: [PATCH 20/79] feat: yafti module --- modules/yafti/yafti.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/yafti/yafti.sh b/modules/yafti/yafti.sh index e74eaead99..b62343d8f2 100644 --- a/modules/yafti/yafti.sh +++ b/modules/yafti/yafti.sh @@ -3,4 +3,16 @@ # Tell build process to exit if there are any errors. set -oue pipefail -echo "$1" \ No newline at end of file +YAFTI_FILE="/usr/share/ublue-os/firstboot/yafti.yml" + +get_yaml_array FLATPAKS '.custom-flatpaks[]' "$1" +if [[ ${#FLATPAKS[@]} -gt 0 ]]; then + echo "Adding Flatpaks to yafti.yml" + yq -i '.screens.applications.values.groups.Custom.description = "Flatpaks suggested by the image maintainer."' "${YAFTI_FILE}" + yq -i '.screens.applications.values.groups.Custom.default = true' "${YAFTI_FILE}" + + for pkg in "${FLATPAKS[@]}"; do + echo "Adding to yafti: ${pkg}" + yq -i ".screens.applications.values.groups.Custom.packages += [$pkg]" "${YAFTI_FILE}" + done +fi \ No newline at end of file From 8e80937db089188ef6dea2469aa49952178b8379 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 17:20:25 +0300 Subject: [PATCH 21/79] docs: better inline docs and prints --- build.sh | 11 ++++++++--- config/recipe.yml | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 587f1b3b67..cbb0292bb9 100644 --- a/build.sh +++ b/build.sh @@ -10,7 +10,7 @@ MODULE_DIRECTORY="/tmp/modules" # https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#yq-in-a-bash-loop get_yaml_array() { # creates array $1 with content at key $2 from $3 - readarray "$1" < <(echo "$3" | yq -o=j -I=0 "$2" ) + readarray "$1" < <(echo "$3" | yq -o=j -I=0 "$2") } export -f get_yaml_array # this makes the function available to all modules @@ -30,14 +30,19 @@ readarray MODULES < <(yq -o=j -I=0 '.modules[]' "$RECIPE_FILE" ) for MODULE in "${MODULES[@]}"; do TYPE=$(echo "$MODULE" | yq '.type') if [[ "$TYPE" != "null" ]]; then - echo "Launching module of type: $TYPE" + # If type is found, that means that the module config + # has been declared inline, and thus is safe to pass to the module + echo "=== Launching module of type: $TYPE ===" bash "$MODULE_DIRECTORY/$TYPE/$TYPE.sh" "$MODULE" else + # If the type is not found, that means that the module config + # is in a separate file, and has to be read from it FILE=$(echo "$MODULE" | yq '.from-file') MODULE_CONFIG=$(yq -o=j -I=0 '.' "$CONFIG_DIRECTORY/$FILE") TYPE=$(echo "$MODULE_CONFIG" | yq '.type') - echo "Launching module of type: $TYPE" + echo "=== Launching module of type: $TYPE ===" bash "$MODULE_DIRECTORY/$TYPE/$TYPE.sh" "$MODULE_CONFIG" fi + echo "======" done \ No newline at end of file diff --git a/config/recipe.yml b/config/recipe.yml index 62aa62ab76..53476a7cd3 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -15,7 +15,7 @@ modules: - ./autorun.sh post - type: yafti # no need for an enable-disable key, inclusion implicitly enables - # config: yafti.yml # if not specified, would use a default config + # config: yafti.yml # if not specified, would use a default config TODO custom-flatpaks: - Celluloid: io.github.celluloid_player.Celluloid - Krita: org.kde.krita \ No newline at end of file From 93cd25fe017ffa5f5bc7ed846ff2bee544669510 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 17:24:20 +0300 Subject: [PATCH 22/79] fix: also install and enable yafti in yafti module oops, forgot this one there's currently no removing of the firstboot data, though, but that doesn't affect people much ig --- modules/yafti/yafti.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/yafti/yafti.sh b/modules/yafti/yafti.sh index b62343d8f2..6659355dff 100644 --- a/modules/yafti/yafti.sh +++ b/modules/yafti/yafti.sh @@ -3,7 +3,15 @@ # Tell build process to exit if there are any errors. set -oue pipefail -YAFTI_FILE="/usr/share/ublue-os/firstboot/yafti.yml" +FIRSTBOOT_DATA="/usr/share/ublue-os/firstboot" +FIRSTBOOT_LINK="/usr/etc/profile.d/ublue-firstboot.sh" +echo "Installing and enabling yafti" +pip install --prefix=/usr yafti +# Create symlink to our profile script, which creates the per-user "autorun yafti" links. +mkdir -p "$(dirname "${FIRSTBOOT_LINK}")" +ln -s "${FIRSTBOOT_DATA}/launcher/login-profile.sh" "${FIRSTBOOT_LINK}" + +YAFTI_FILE="$FIRSTBOOT_DATA/yafti.yml" get_yaml_array FLATPAKS '.custom-flatpaks[]' "$1" if [[ ${#FLATPAKS[@]} -gt 0 ]]; then From 8f0aa9cec99f97cf49ed3dbb2dcdd5d36017dd4e Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 17:29:11 +0300 Subject: [PATCH 23/79] chore: export more vars as readonly --- build.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index cbb0292bb9..4c8339a427 100644 --- a/build.sh +++ b/build.sh @@ -14,13 +14,16 @@ get_yaml_array() { } export -f get_yaml_array # this makes the function available to all modules -# Automatically determine which Fedora version we're building. -export FEDORA_VERSION="$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)" +# Declare dynamically generated variables as read-only and exported +declare -rx IMAGE_NAME BASE_IMAGE FEDORA_VERSION # Read configuration variables. BASE_IMAGE="$(yq '.base-image' "$RECIPE_FILE")" IMAGE_NAME="$(yq '.name' "$RECIPE_FILE")" +# Automatically determine which Fedora version we're building. +FEDORA_VERSION="$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)" + # Welcome. echo "Building $IMAGE_NAME from Fedora $FEDORA_VERSION ($BASE_IMAGE)." From 1d7b14b38fe95f53bc82760de5a3575d764eec3e Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 17:36:21 +0300 Subject: [PATCH 24/79] feat: signing script --- config/recipe.yml | 3 +++ config/scripts/signing.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 config/scripts/signing.sh diff --git a/config/recipe.yml b/config/recipe.yml index 53476a7cd3..61834950f6 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -12,8 +12,11 @@ modules: - type: script run: + # this sets up the proper policy & signing files for signed images to work + - ./signing.sh - ./autorun.sh post + - type: yafti # no need for an enable-disable key, inclusion implicitly enables # config: yafti.yml # if not specified, would use a default config TODO custom-flatpaks: diff --git a/config/scripts/signing.sh b/config/scripts/signing.sh new file mode 100644 index 0000000000..fc42de9c90 --- /dev/null +++ b/config/scripts/signing.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail + +echo "Setting up container signing in policy.json and cosign.yaml for $IMAGE_NAME" +echo "Registry to write: $IMAGE_REGISTRY" + +cp /usr/share/ublue-os/cosign.pub /usr/etc/pki/containers/"$IMAGE_NAME".pub + +FILE=/usr/etc/containers/policy.json + +yq -i -o=j '.transports.docker |= + {"'"$IMAGE_REGISTRY"'": [ + { + "type": "sigstoreSigned", + "keyPath": "/usr/etc/pki/containers/'"$IMAGE_NAME"'.pub", + "signedIdentity": { + "type": "matchRepository" + } + } + ] + } ++ .' "$FILE" + +cp /usr/etc/containers/registries.d/ublue-os.yaml /usr/etc/containers/registries.d/"$IMAGE_NAME".yaml +sed -i "s ghcr.io/ublue-os $IMAGE_REGISTRY g" /usr/etc/containers/registries.d/"$IMAGE_NAME".yaml \ No newline at end of file From 38dda90a23ba183b6aaf34026d5f046cad5c5122 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 18:00:58 +0300 Subject: [PATCH 25/79] refactor: rename fedora version to os version this change makes sense for when in the future it's possible to build other OS's with this same system it was done now, because i'm bundling a bunch of breaking changes into a single update --- .github/workflows/build.yml | 8 ++++---- Containerfile | 4 ++-- build.sh | 6 +++--- config/common-packages.yml | 2 +- config/recipe.yml | 2 +- modules/rpm-ostree/rpm-ostree.sh | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3699ec2e1c..82c729c4b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,8 +45,8 @@ jobs: id-token: write strategy: fail-fast: false - matrix: + matrix: # Add recipes for all the images you want to build here. # Don't add module configuration files, you will get errors. recipe: @@ -64,13 +64,13 @@ jobs: run: | echo "IMAGE_NAME=$(yq '.name' ./config/${{ matrix.recipe }})" >> $GITHUB_ENV echo "IMAGE_DESCRIPTION=$(yq '.description' ./config/${{ matrix.recipe }})" >> $GITHUB_ENV - echo "FEDORA_MAJOR_VERSION=$(yq '.fedora-version' ./config/${{ matrix.recipe }})" >> $GITHUB_ENV + echo "IMAGE_MAJOR_VERSION=$(yq '.image-version' ./config/${{ matrix.recipe }})" >> $GITHUB_ENV echo "BASE_IMAGE_URL=$(yq '.base-image' ./config/${{ matrix.recipe }})" >> $GITHUB_ENV - name: Get current version id: labels run: | - ver=$(skopeo inspect docker://${{ env.BASE_IMAGE_URL }}:${{ env.FEDORA_MAJOR_VERSION }} | jq -r '.Labels["org.opencontainers.image.version"]') + ver=$(skopeo inspect docker://${{ env.BASE_IMAGE_URL }}:${{ env.IMAGE_MAJOR_VERSION }} | jq -r '.Labels["org.opencontainers.image.version"]') echo "VERSION=$ver" >> $GITHUB_OUTPUT - name: Generate tags @@ -146,7 +146,7 @@ jobs: tags: | ${{ steps.generate-tags.outputs.alias_tags }} build-args: | - FEDORA_MAJOR_VERSION=${{ env.FEDORA_MAJOR_VERSION }} + IMAGE_MAJOR_VERSION=${{ env.IMAGE_MAJOR_VERSION }} BASE_IMAGE_URL=${{ env.BASE_IMAGE_URL }} RECIPE=${{ matrix.recipe }} IMAGE_REGISTRY=${{ steps.registry_case.outputs.lowercase }} diff --git a/Containerfile b/Containerfile index e1387b7892..2c0bdef053 100644 --- a/Containerfile +++ b/Containerfile @@ -5,11 +5,11 @@ # in the cloud. The ARGs have default values, but changing those # does nothing if the image is built in the cloud. -ARG FEDORA_MAJOR_VERSION=38 +ARG IMAGE_MAJOR_VERSION=38 # Warning: changing this might not do anything for you. Read comment above. ARG BASE_IMAGE_URL=ghcr.io/ublue-os/silverblue-main -FROM ${BASE_IMAGE_URL}:${FEDORA_MAJOR_VERSION} +FROM ${BASE_IMAGE_URL}:${IMAGE_MAJOR_VERSION} # The default recipe set to the recipe's default filename # so that `podman build` should just work for many people. diff --git a/build.sh b/build.sh index 4c8339a427..37506290df 100644 --- a/build.sh +++ b/build.sh @@ -15,17 +15,17 @@ get_yaml_array() { export -f get_yaml_array # this makes the function available to all modules # Declare dynamically generated variables as read-only and exported -declare -rx IMAGE_NAME BASE_IMAGE FEDORA_VERSION +declare -rx IMAGE_NAME BASE_IMAGE OS_VERSION # Read configuration variables. BASE_IMAGE="$(yq '.base-image' "$RECIPE_FILE")" IMAGE_NAME="$(yq '.name' "$RECIPE_FILE")" # Automatically determine which Fedora version we're building. -FEDORA_VERSION="$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)" +OS_VERSION="$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)" # Welcome. -echo "Building $IMAGE_NAME from Fedora $FEDORA_VERSION ($BASE_IMAGE)." +echo "Building $IMAGE_NAME from $BASE_IMAGE:$OS_VERSION." # Run each module readarray MODULES < <(yq -o=j -I=0 '.modules[]' "$RECIPE_FILE" ) diff --git a/config/common-packages.yml b/config/common-packages.yml index 59f07c7a5f..17ab30f4f9 100644 --- a/config/common-packages.yml +++ b/config/common-packages.yml @@ -1,6 +1,6 @@ type: rpm-ostree repos: - # - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%FEDORA_VERSION%/atim-starship-fedora-%FEDORA_VERSION%.repo + # - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%OS_VERSION%/atim-starship-fedora-%OS_VERSION%.repo install: - python3-pip - libadwaita diff --git a/config/recipe.yml b/config/recipe.yml index 61834950f6..53684aea9e 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -1,7 +1,7 @@ name: startingpoint description: A starting point for further customization of uBlue images. Make your own! https://ublue.it/making-your-own/ base-image: ghcr.io/ublue-os/silverblue-main -fedora-version: 38 +image-version: 38 modules: - type: script diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index 0fcb78a9dc..a55bfa00a7 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -7,7 +7,7 @@ get_yaml_array REPOS '.repos[]' "$1" if [[ ${#REPOS[@]} -gt 0 ]]; then echo "Adding repositories" for REPO in "${REPOS[@]}"; do - REPO="${REPO//%FEDORA_VERSION%/${FEDORA_VERSION}}" + REPO="${REPO//%OS_VERSION%/${OS_VERSION}}" wget "${REPO}" -P "/etc/yum.repos.d/" done fi From 14d78ee2a7dd6023d338464bf12d1bd8e0b69bd7 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 18:14:06 +0300 Subject: [PATCH 26/79] fix: can't set readonly var after declaration (duh) --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 37506290df..916cda9bfa 100644 --- a/build.sh +++ b/build.sh @@ -15,7 +15,7 @@ get_yaml_array() { export -f get_yaml_array # this makes the function available to all modules # Declare dynamically generated variables as read-only and exported -declare -rx IMAGE_NAME BASE_IMAGE OS_VERSION +declare -x IMAGE_NAME BASE_IMAGE OS_VERSION # Read configuration variables. BASE_IMAGE="$(yq '.base-image' "$RECIPE_FILE")" From c4b274bb77cdbd48917ab8146edd547f7c84f3cf Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 18:15:54 +0300 Subject: [PATCH 27/79] chore: investigate "no such file or directory" --- modules/script/script.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/script/script.sh b/modules/script/script.sh index 22fec4db31..528b5f7116 100644 --- a/modules/script/script.sh +++ b/modules/script/script.sh @@ -7,6 +7,8 @@ get_yaml_array RUN '.run[]' "$1" cd "$CONFIG_DIRECTORY/scripts" +pwd + for CMD in "${RUN[@]}"; do echo "Running command: $CMD" $CMD From 3e0aa46c12bba76274737e3bf7c10b32a8000f6a Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 18:23:10 +0300 Subject: [PATCH 28/79] chore: investigate "no such file or directory" --- modules/script/script.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/script/script.sh b/modules/script/script.sh index 528b5f7116..f9792887c5 100644 --- a/modules/script/script.sh +++ b/modules/script/script.sh @@ -7,9 +7,8 @@ get_yaml_array RUN '.run[]' "$1" cd "$CONFIG_DIRECTORY/scripts" -pwd - for CMD in "${RUN[@]}"; do echo "Running command: $CMD" - $CMD + ls + eval "$CMD" done \ No newline at end of file From bbb1cc8b88ed036ceda01d973f48ab8308ddfa12 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 18:31:12 +0300 Subject: [PATCH 29/79] fix: give executable permission to scripts --- modules/script/script.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/script/script.sh b/modules/script/script.sh index f9792887c5..ac76171755 100644 --- a/modules/script/script.sh +++ b/modules/script/script.sh @@ -7,8 +7,9 @@ get_yaml_array RUN '.run[]' "$1" cd "$CONFIG_DIRECTORY/scripts" +find "$PWD" -type f -exec chmod +x {} \; + for CMD in "${RUN[@]}"; do echo "Running command: $CMD" - ls eval "$CMD" done \ No newline at end of file From dc97fa42015335ee46a84aa12f4d54621c70e64d Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 18:36:49 +0300 Subject: [PATCH 30/79] fix: don't run arbitrary commands with script * scripts are now called with their absolute paths instead of ./ --- config/recipe.yml | 10 +++++----- modules/script/script.sh | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/recipe.yml b/config/recipe.yml index 53684aea9e..327a9d7379 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -5,16 +5,16 @@ image-version: 38 modules: - type: script - run: # commands directly run inside scripts directory - - ./autorun.sh pre + scripts: + - autorun.sh pre - from-file: common-packages.yml # paths relative to "config" directory - type: script - run: + scripts: # this sets up the proper policy & signing files for signed images to work - - ./signing.sh - - ./autorun.sh post + - signing.sh + - autorun.sh post - type: yafti # no need for an enable-disable key, inclusion implicitly enables diff --git a/modules/script/script.sh b/modules/script/script.sh index ac76171755..3290f02d08 100644 --- a/modules/script/script.sh +++ b/modules/script/script.sh @@ -3,13 +3,13 @@ # Tell build process to exit if there are any errors. set -oue pipefail -get_yaml_array RUN '.run[]' "$1" +get_yaml_array SCRIPTS '.scripts[]' "$1" cd "$CONFIG_DIRECTORY/scripts" find "$PWD" -type f -exec chmod +x {} \; -for CMD in "${RUN[@]}"; do - echo "Running command: $CMD" - eval "$CMD" +for SCRIPT in "${SCRIPTS[@]}"; do + echo "Running script $SCRIPT" + eval "$PWD/$SCRIPT" done \ No newline at end of file From c07131b37dd2b1fa9ab6b5eaef7f5b456681de0e Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 13 Aug 2023 18:46:00 +0300 Subject: [PATCH 31/79] docs: move & start rewriting configuration docs --- README.md | 68 +++------------------------------------ config/README.md | 19 +++++++++++ config/scripts/autorun.sh | 0 3 files changed, 24 insertions(+), 63 deletions(-) create mode 100644 config/README.md mode change 100644 => 100755 config/scripts/autorun.sh diff --git a/README.md b/README.md index 380aec5438..2324e24b71 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ See the [Make Your Own-page in the documentation](https://universal-blue.org/tin Don't worry, it only requires some basic knowledge about using the terminal and git. +After setup, it is recommended you update this README to describe your custom image. + > **Note** > Everywhere in this repository, make sure to replace `ublue-os/startingpoint` with the details of your own repository. Unless you used [`create-ublue-image`](https://github.com/EinoHR/create-ublue-image), in which case the previous repo identifier should already be your repo's details. @@ -20,66 +22,7 @@ Don't worry, it only requires some basic knowledge about using the terminal and ## Customization -The easiest way to start customizing is by looking at and modifying `recipe.yml`. It's documented using comments and should be pretty easy to understand. - -For the base-image field, you can use any other native container image. You will get all the features of that image, plus the ones added here! Check out the [uBlue images list](https://universal-blue.org/images/) to decide what to use! - -If you want to add custom configuration files, you can just add them in the `usr/etc/` directory, which is the official OSTree "configuration template" directory. If you need to add other directories, you can look at the Containerfile to see how it's done. Writing to `/etc` or `/var` in Fedora's immutable OSTree-based distros *isn't supported* and will not work, as those are user-managed locations! - -> **Note** -> The configuration files you put in `/usr/etc/` will automatically be applied to your local `/etc/` by `systemd` whenever you rebase an OSTree system or update the image. If a config file in `/etc/` has been *modified* (compared to the same deployment's defaults), then OSTree [won't overwrite it](https://github.com/ostreedev/ostree/blob/16cb47489e582da9c139fee20acdac7079867843/docs/atomic-upgrades.md?plain=1#L76), but the new version will be available in `/usr/etc/`. Run `sudo ostree admin config-diff` to see the difference between `/etc/` and `/usr/etc/` (`man ostree-admin-config-diff` for further documentation). - -### Custom build scripts - -If you want to execute custom shell scripts or commands in the image build, you shouldn't edit the `scripts/build.sh` or the `Containerfile` directly. - -Instead, you should create your own custom shell scripts in the `scripts/` directory (look at the `example.sh`). After creating your scripts, enable them in the `scripts:` section of your `recipe.yml`, within the specific "build stage" category where the scripts are intended to be executed. Alternatively, enable the `autorun.sh` helper script in your recipe to automatically execute your custom scripts. - -Read [the README in the `scripts/` directory](https://github.com/ublue-os/startingpoint/blob/main/scripts/README.md) for more information. - -### 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. - -You can use this to add [COPR repositories](https://copr.fedorainfracloud.org/) to your image. -COPR is like the Arch User Repository for Fedora, where you can find extra packages that wouldn't otherwise be available. The repositories are community-created, so use them at your own risk. [Read more](https://docs.pagure.org/copr.copr/user_documentation.html) - -Tip: You can use the magic string `%FEDORA_VERSION%` in your repo URLs, to automatically refer to the correct repository for your current Fedora version. - -If your `.repo` file is not available as a hosted URL and you need to copy it manually, you can upload the file in your github repository or a gist and add the raw link to the file under `rpm.repos:`. Another option in this scenario would be to create a folder for `.repo` files in your repository and add `COPY repos /etc/yum.repos.d/` in the `Containerfile`. - -### Building multiple images - -You can build multiple images using multiple `recipe.yml` files. They will share the Containerfile and everything else, but things like packages declared in the recipe will be different between the images. For a more robust multibuild setup, you could consider forking from the [ublue-os/main](https://github.com/ublue-os/main/) repo, which was built from the purpose. - -In order to build multiple recipes, you need to declare each one below line ~33 in `build.yml`. The files should be in the root of the repository. - -Example: Adding a new recipe called `recipe-2.yml` (snippets from the `matrix` section of `build.yml`) - -Before: - -```yml -matrix: - recipe: - - recipe.yml -``` - -After: - -```yml -matrix: - recipe: - - recipe.yml - - recipe-2.yml -``` - -### [yafti](https://github.com/ublue-os/yafti/) - -`yafti` is the uBlue "first boot" installer. It shows up the first time a user logs into uBlue. By default, the menu also shows up again anytime the image's yafti configuration differs from the user's last encounter, so feel free to expand or modify your custom image's yafti configuration over time. Your users will then see the yafti menu again after the OS update, and will be given a chance to install any new additions. - -Its configuration can be found in `/usr/share/ublue-os/firstboot/yafti.yml` of the installed OS. It includes an optional selection of Flatpaks to install, along with a new group that's automatically added for all Flatpaks declared in `recipe.yml`. You can look at what's done in the `yafti.yml` config and modify it to your liking (in the repository, before building the image, since the installed system file is immutable). - -If you want to completely disable yafti, simply set the recipe's `firstboot.yafti` flag to `false`, which then removes all yafti-related files and configurations from your final image. The files in `usr/share/ublue-os/firstboot/` are responsible for automatically running yafti at login, and they will *only* be bundled in your image if `yafti` is enabled in your recipe! +For information about customization, see [the README in the config directory](config/README.md) ## Installation @@ -88,7 +31,7 @@ If you want to completely disable yafti, simply set the recipe's `firstboot.yaft To rebase an existing Silverblue/Kinoite installation to the latest build: -- First rebase to the image unsigned, to get the proper signing keys and policies installed: +- First rebase to the unsigned image, to get the proper signing keys and policies installed: ``` sudo rpm-ostree rebase ostree-unverified-registry:ghcr.io/ublue-os/startingpoint:latest ``` @@ -105,14 +48,13 @@ To rebase an existing Silverblue/Kinoite installation to the latest build: systemctl reboot ``` - This repository builds date tags as well, so if you want to rebase to a particular day's build: ``` sudo rpm-ostree rebase ostree-image-signed:docker://ghcr.io/ublue-os/startingpoint:20230403 ``` -This repository by default also supports signing +This repository by default also supports signing. The `latest` tag will automatically point to the latest build. That build will still always use the Fedora version specified in `recipe.yml`, so you won't get accidentally updated to the next major version. diff --git a/config/README.md b/config/README.md new file mode 100644 index 0000000000..fff821ee2a --- /dev/null +++ b/config/README.md @@ -0,0 +1,19 @@ +# Configuring your image + +The main file of your is *the recipe file*. You can have multiple recipe files, and the ones to build are declared in the matrix section of [build.yml](../.github/workflows/build.yml). + +## Basic options + +At the top of the recipe, there are four mandatory configuration options. + +`name:` is the name of the image that is used when rebasing to it. For example, the name "sapphire" would result in the final URL of the container being `ghcr.io//sapphire`. + +`description:` is a short description of your image that will be attached to your image's metadata. + +`base-image:` is the URL of the image your image will be built upon. + +`image-version:` is the version tag of the `base-image` that will be pulled. For example, Universal Blue's images build with Fedora version tags (`38`, `39`), with the `latest` tag for the latest major version, and [many other tags](https://github.com/ublue-os/main/pkgs/container/base-main/versions?filters%5Bversion_type%5D=tagged). + +## Modules + +The core of startingpoint's configuration is built around the idea of modules. To be continued... \ No newline at end of file diff --git a/config/scripts/autorun.sh b/config/scripts/autorun.sh old mode 100644 new mode 100755 From c0bc388160c2ebd0a04b804eec6db72555411847 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 13:19:30 +0300 Subject: [PATCH 32/79] chore: remove changelog * this was added earlier when making the ISO pr, and it is not going to be updated anymore --- CHANGELOG.md | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 943a71c4e9..0000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,46 +0,0 @@ -# Changelog - -## [1.1.0](https://github.com/ublue-os/base/compare/v1.0.0...v1.1.0) (2023-03-03) - - -### Features - -* add fedora 38 build ([#45](https://github.com/ublue-os/base/issues/45)) ([69fd4d7](https://github.com/ublue-os/base/commit/69fd4d7a57c5ce39331e47e8dedeb2a2f643190f)) -* add how to review a PR ([#76](https://github.com/ublue-os/base/issues/76)) ([ae2e25b](https://github.com/ublue-os/base/commit/ae2e25b92f5ebebed2fcaad53ecfab651a639d12)) -* ease customization by reading flatpaks and rpms to install from a recipe.yml. ([#79](https://github.com/ublue-os/base/issues/79)) ([a5e90a5](https://github.com/ublue-os/base/commit/a5e90a588f58a938405bf513d1032955be34028e)) -* gha for building / publishing on pr ([#87](https://github.com/ublue-os/base/issues/87)) ([1726d18](https://github.com/ublue-os/base/commit/1726d182ee95ce5eb13f47212799a68b63c5aefc)) -* Install VanillaOS' first-setup ([#55](https://github.com/ublue-os/base/issues/55)) ([43ddf0a](https://github.com/ublue-os/base/commit/43ddf0a123911f9dedc3a76dcfc314a7cb37e871)) -* leave a warning for people to move to new repo ([#99](https://github.com/ublue-os/base/issues/99)) ([ffcb397](https://github.com/ublue-os/base/commit/ffcb3973bd540d679ab033ed94de6336b903e7dd)) -* split flatpak update units into user and system ([#72](https://github.com/ublue-os/base/issues/72)) ([99c15be](https://github.com/ublue-os/base/commit/99c15be6f012cb590891c5ef16b2613dc538d144)) -* swap out custom build for RPM of vanilla-first-setup ([#59](https://github.com/ublue-os/base/issues/59)) ([6927892](https://github.com/ublue-os/base/commit/6927892581dadf8f31419a0d9b070bb7268513ba)) - - -### Bug Fixes - -* add a warning that we change the flatpak configuration ([#80](https://github.com/ublue-os/base/issues/80)) ([9a349e2](https://github.com/ublue-os/base/commit/9a349e2625791b90c11f640938060344ec3e4bd5)) -* Add vte dependency for first-setup ([#56](https://github.com/ublue-os/base/issues/56)) ([f8917a3](https://github.com/ublue-os/base/commit/f8917a3258196f85b8e3805f5ebcb1c9c0db06a7)) -* allow forks to push to registry with label ([#86](https://github.com/ublue-os/base/issues/86)) ([14b1b7c](https://github.com/ublue-os/base/commit/14b1b7cb044ec616817aa30075609469dcb9986b)) -* artifact upload/extract ([#88](https://github.com/ublue-os/base/issues/88)) ([6590066](https://github.com/ublue-os/base/commit/6590066ebcf72d6c4a56730dd682088db17d7df0)) -* re-tag image ([#92](https://github.com/ublue-os/base/issues/92)) ([a831ce0](https://github.com/ublue-os/base/commit/a831ce00df84d94e2bdb48013f650bcbb5b39568)) -* remove 38 ([#89](https://github.com/ublue-os/base/issues/89)) ([8a6f343](https://github.com/ublue-os/base/commit/8a6f3433ad45b0f9f3da974a691001c02f498fb1)) -* remove 38 builds and fix logo metadata ([#62](https://github.com/ublue-os/base/issues/62)) ([521f0ad](https://github.com/ublue-os/base/commit/521f0adcda598a1bf494d969df375f0c0a03a10c)) -* remove if statements ([#96](https://github.com/ublue-os/base/issues/96)) ([0c7bc17](https://github.com/ublue-os/base/commit/0c7bc17666ae038a0504d24a0e683f724c734527)) -* remove old pr workflow sections ([#98](https://github.com/ublue-os/base/issues/98)) ([4a21580](https://github.com/ublue-os/base/commit/4a21580f4e4d40692449bae61a75a555e8569be1)) -* rename package back to `base` ([#97](https://github.com/ublue-os/base/issues/97)) ([785b8f0](https://github.com/ublue-os/base/commit/785b8f0d8adb8513bbe94b8918bfc0033ee0ca45)) -* restore download artifact step, support multi-line tags ([#90](https://github.com/ublue-os/base/issues/90)) ([c40bddf](https://github.com/ublue-os/base/commit/c40bddfdf39a61545700ecb8123a02abd24a4f8f)) -* update cosign action ([#94](https://github.com/ublue-os/base/issues/94)) ([0aff9ba](https://github.com/ublue-os/base/commit/0aff9bac374c3494f57a360fd4426afe705bfee9)) - -## 1.0.0 (2023-02-04) - - -### Features - -* Add code-of-conduct ([#39](https://github.com/ublue-os/base/issues/39)) ([aab8078](https://github.com/ublue-os/base/commit/aab8078cfdc7d2354e057a0ca4771d3a53d2df4c)) -* add conventional commit linting and release notes generator ([b7820b4](https://github.com/ublue-os/base/commit/b7820b4ba312ca939d0dc977ed9f6a08d135324b)) -* tag PR builds independently from matrix.version, latest, and stable ([b022183](https://github.com/ublue-os/base/commit/b02218386235e6d40a11a48b5b1171e9acf8d1eb)) - - -### Bug Fixes - -* Don't generate an image when README.md is updated ([#36](https://github.com/ublue-os/base/issues/36)) ([8c170cf](https://github.com/ublue-os/base/commit/8c170cfe89dd306eec0940f4dc50ed245c94bc2b)) -* only generate date tag for main branch ([94aa5bb](https://github.com/ublue-os/base/commit/94aa5bb8df2aac0985d4c9422b19b0c03a3f25b0)) From bca8b81e16599be1a05b4f3cb6e25bdc61d6714f Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 14:05:42 +0300 Subject: [PATCH 33/79] docs: a ginormous amount of docs for the modules --- build.sh | 7 +++++- config/README.md | 42 +++++++++++++++++++++++++++++++++++- config/recipe.yml | 1 - modules/rpm-ostree/README.md | 22 +++++++++++++++++++ modules/script/README.md | 10 +++++++++ modules/yafti/README.md | 15 +++++++++++++ modules/yafti/yafti.sh | 2 ++ 7 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 modules/rpm-ostree/README.md create mode 100644 modules/script/README.md create mode 100644 modules/yafti/README.md diff --git a/build.sh b/build.sh index 916cda9bfa..1b248c1f6c 100644 --- a/build.sh +++ b/build.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +# This script executes the modules in order. +# If you have some custom commands you need to run, you should not put them here. +# Instead, you should probably include them as custom scripts. +# Editing this file directly is an unsupported configuration. + # Tell build process to exit if there are any errors. set -oue pipefail @@ -14,7 +19,7 @@ get_yaml_array() { } export -f get_yaml_array # this makes the function available to all modules -# Declare dynamically generated variables as read-only and exported +# Declare dynamically generated variables as exported declare -x IMAGE_NAME BASE_IMAGE OS_VERSION # Read configuration variables. diff --git a/config/README.md b/config/README.md index fff821ee2a..7725c48fd0 100644 --- a/config/README.md +++ b/config/README.md @@ -16,4 +16,44 @@ At the top of the recipe, there are four mandatory configuration options. ## Modules -The core of startingpoint's configuration is built around the idea of modules. To be continued... \ No newline at end of file +The core of startingpoint's configuration is built around the idea of modules. Modules are scripts in the [`../modules`](../modules/) directory that you list out under `modules:` in the recipe. They are executed in order, and can run arbitrary shell commands and write any files. + +This repository comes with three modules out of the box, [`rpm-ostree`](../modules/rpm-ostree) for pseudo-declarative package management, [`yafti`](../modules/yafti) for installing [yafti](https://github.com/ublue-os/yafti) and easing basic configuration, and [`script`](../modules/script) for running small custom scripts at the build stage, like pulling in configuration or setting up `rpm-ostree` support for proper signing (see [`signing.sh`](./scripts/signing.sh)). + +For more in-depth documentation on each module, check out the README.md files in each module folder. + +### Including modules from other files and building multiple images + +To build multiple images, you need to create another recipe.yml file, which you should name based on what kind of image you want it to build. Then, edit the [`build.yml`](../.github/workflows/build.yml) file. Inside the file, under `jobs: strategy: matrix:`, there's a list of recipe files to build images, which you need to add your new recipe file to. These should be paths to files inside the `config` directory. + +Module configuration can be included from other files using the `from-file` syntax. The valye should be a path to a file inside the `config` directory. For example, the following snippet could be used to include the configuration for installing a set of packages common to multiple images. +```yml +modules: + - from-file: common-packages.yml +``` + +### Making modules + +If you want to extend startingpoint with custom functionality that requires configuration, you should create a module. Modules are scripts in the subdirectories of the [`../modules`](../modules/) directory. The `type:` key in the recipe.yml should be used as both the name of the folder and script, with the script having an additional `.sh` suffix. + +Each module intended for public usage should include a `README.md` file inside it's directory with a short description of the module and documentation for each configuration option. + +Modules get only the configuration options given to them in the recipe.yml, not the configuration of other modules or any top-level keys. The configuration is given as the first argument as a single-line json string. You can check out the default modules for examples on how to parse such string using `yq` or `jq`. + +Additionally, each module has access to four environment variables, `CONFIG_DIRECTORY` pointing to the startingpoint directory in `/usr/share/ublue-os/`, `IMAGE_NAME` being the name of the image as declared in the recipe, `BASE_IMAGE` being the URL of the container image used as the base (FROM) in the image, and `OS_VERSION` being the `VERSION_ID` from `/usr/lib/os-release`. + +A helper bash function called `get_yaml_array` is exported from the main build script. Syntax: +```bash +# "$1" read from the first cli argument, being the module configuration. +# If you need to read from some other JSON string, just replace "$1" with "$VARNAME". +get_yaml_array OUTPUT_VAR_NAME '.yq.key.to.array[]' "$1" +for THING in "${OUTPUT_VAR_NAME[@]}"; do + echo "$THING" +done +``` + +All bash-based modules should start with the following lines to ensure the image builds fail on errors, and that the correct shell is used to run them. +```bash +#!/usr/bin/env bash +set -oue pipefail +``` \ No newline at end of file diff --git a/config/recipe.yml b/config/recipe.yml index 327a9d7379..8d26b496d6 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -16,7 +16,6 @@ modules: - signing.sh - autorun.sh post - - type: yafti # no need for an enable-disable key, inclusion implicitly enables # config: yafti.yml # if not specified, would use a default config TODO custom-flatpaks: diff --git a/modules/rpm-ostree/README.md b/modules/rpm-ostree/README.md new file mode 100644 index 0000000000..0768070e91 --- /dev/null +++ b/modules/rpm-ostree/README.md @@ -0,0 +1,22 @@ +# [`rpm-ostree`](https://coreos.github.io/rpm-ostree/) module for startingpoint + +The `rpm-ostree` module offers pseudo-declarative package and repository management using `rpm-ostree`. + +The module first downloads the repository files from repositories declared under `repos:` into `/etc/yum.repos.d/`. The magic string `%OS_VERSION%` is substituted with the current VERSION_ID (major Fedora version), which can be used, for example, for pulling correct versions of repositories from [Fedora's Copr](https://copr.fedorainfracloud.org/). + +Then the module installs the packages declared under `install:` using `rpm-ostree install`, and lastly, it removes the packages declared under `remove:` using `rpm-ostree override remove`. + +Unfortunately, currently `rpm-ostree override remove`, and this module, might not be able to remove packages installed in image builds. Packages included by Fedora, such as Firefox can still be removed, though. + +Example configuration: +```yml +type: rpm-ostree +repos: + - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%OS_VERSION%/atim-starship-fedora-%OS_VERSION%.repo +install: + - python3-pip + - libadwaita +remove: + - firefox + - firefox-langpacks +``` \ No newline at end of file diff --git a/modules/script/README.md b/modules/script/README.md new file mode 100644 index 0000000000..28d3c9593c --- /dev/null +++ b/modules/script/README.md @@ -0,0 +1,10 @@ +# `script` module for startingpoint + +The `script` module can be used to run arbitrary scripts at image build time that take no or minimal external configuration (in the form of command line arguments). +The scripts, which are run from the `config/scripts` directory, are declared under `scripts:`. + +```yml +type: script +scripts: + - signing.sh +``` \ No newline at end of file diff --git a/modules/yafti/README.md b/modules/yafti/README.md new file mode 100644 index 0000000000..de318b67f7 --- /dev/null +++ b/modules/yafti/README.md @@ -0,0 +1,15 @@ +# [`yafti`](https://github.com/ublue-os/yafti) module for startingpoint + +If included, the `yafti` module will install `yafti` and set it up to run on first boot. + +Optionally, a list of Flatpak names and IDs can be included under `custom-flatpaks:`. These will be enabled by default under their own section on the Flatpak installation screen of `yafti`. + +The main `yafti` configuration file, `yafti.yml`, is in `/usr/share/ublue-os/firstboot/yafti.yml` and can be edited for a more custom first-boot experience. + +Example configuration: +```yml +type: yafti +custom-flatpaks: + - Celluloid: io.github.celluloid_player.Celluloid + - Krita: org.kde.krita +``` \ No newline at end of file diff --git a/modules/yafti/yafti.sh b/modules/yafti/yafti.sh index 6659355dff..cf3e475de4 100644 --- a/modules/yafti/yafti.sh +++ b/modules/yafti/yafti.sh @@ -5,8 +5,10 @@ set -oue pipefail FIRSTBOOT_DATA="/usr/share/ublue-os/firstboot" FIRSTBOOT_LINK="/usr/etc/profile.d/ublue-firstboot.sh" + echo "Installing and enabling yafti" pip install --prefix=/usr yafti + # Create symlink to our profile script, which creates the per-user "autorun yafti" links. mkdir -p "$(dirname "${FIRSTBOOT_LINK}")" ln -s "${FIRSTBOOT_DATA}/launcher/login-profile.sh" "${FIRSTBOOT_LINK}" From 9e301cec00721cab2dd021b24907dcf3caa6d8fb Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 14:12:31 +0300 Subject: [PATCH 34/79] chore!: remove autorun.sh i think the existence of multiple built-in ways to add scripts makes it more complicated, and paradoxically, autorun was made to uncomplicate things with the removal of clear "pre" and "post" hooks, only a linear list of modules, the filesystem-based method is ever more complicated if such a feature is ever wanted again, it should be implemented inside the script module --- config/recipe.yml | 5 ---- config/scripts/autorun.sh | 48 ------------------------------------ config/scripts/post/.gitkeep | 0 config/scripts/pre/.gitkeep | 0 4 files changed, 53 deletions(-) delete mode 100755 config/scripts/autorun.sh delete mode 100644 config/scripts/post/.gitkeep delete mode 100644 config/scripts/pre/.gitkeep diff --git a/config/recipe.yml b/config/recipe.yml index 8d26b496d6..58bbe213ae 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -4,17 +4,12 @@ base-image: ghcr.io/ublue-os/silverblue-main image-version: 38 modules: - - type: script - scripts: - - autorun.sh pre - - from-file: common-packages.yml # paths relative to "config" directory - type: script scripts: # this sets up the proper policy & signing files for signed images to work - signing.sh - - autorun.sh post - type: yafti # no need for an enable-disable key, inclusion implicitly enables # config: yafti.yml # if not specified, would use a default config TODO diff --git a/config/scripts/autorun.sh b/config/scripts/autorun.sh deleted file mode 100755 index 3b9b1c2c01..0000000000 --- a/config/scripts/autorun.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/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. -# - -# Helper functions. -yell() { echo "${0}: ${*}"; } -abort() { yell "${*}"; exit 0; } -die() { yell "${*}"; exit 1; } - -# Determine which directory and script category we're executing under. -SCRIPT_DIR="$(dirname -- "${BASH_SOURCE[0]}")" -SCRIPT_MODE="${1:-}" -if [[ -z "${SCRIPT_MODE}" ]]; then - die "Missing script mode argument." -fi - -# Ensure that a "scripts/" sub-directory exists for the "script category". -# Note that symlinks to other directories will be accepted by the `-d` check. -RUN_DIR="${SCRIPT_DIR}/${SCRIPT_MODE}" -if [[ ! -d "${RUN_DIR}" ]]; then - abort "Nothing to do, since \"${RUN_DIR}\" doesn't exist." -fi - -# Generate a numerically sorted array of all scripts (or symlinks to scripts), -# without traversing into deeper subdirectories (to allow the user to store -# helper libraries in subfolders without accidental execution). Sorting is -# necessary for manually controlling the execution order via numeric prefixes. -mapfile -t buildscripts < <(find -L "${RUN_DIR}" -maxdepth 1 -type f -name "*.sh" | sort -n) - -# Exit if there aren't any scripts in the directory. -if [[ ${#buildscripts[@]} -eq 0 ]]; then - abort "Nothing to do, since \"${RUN_DIR}\" doesn't contain any scripts in its top-level directory." -fi - -# Now simply execute all of the discovered scripts, and provide the name of the -# current "script category" as an argument, to match the behavior of "build.sh". -for script in "${buildscripts[@]}"; do - echo "[autorun.sh] Running [${SCRIPT_MODE}]: ${script}" - "$script" "${SCRIPT_MODE}" -done diff --git a/config/scripts/post/.gitkeep b/config/scripts/post/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/config/scripts/pre/.gitkeep b/config/scripts/pre/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 From 618401dec4f8586a246651e60f7324884270f18e Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 14:16:57 +0300 Subject: [PATCH 35/79] chore: bring recipe.yml to a default state --- config/common-packages.yml | 9 --------- config/recipe.yml | 23 ++++++++++++++++++----- 2 files changed, 18 insertions(+), 14 deletions(-) delete mode 100644 config/common-packages.yml diff --git a/config/common-packages.yml b/config/common-packages.yml deleted file mode 100644 index 17ab30f4f9..0000000000 --- a/config/common-packages.yml +++ /dev/null @@ -1,9 +0,0 @@ -type: rpm-ostree -repos: - # - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%OS_VERSION%/atim-starship-fedora-%OS_VERSION%.repo -install: - - python3-pip - - libadwaita -remove: - - firefox - - firefox-langpacks diff --git a/config/recipe.yml b/config/recipe.yml index 58bbe213ae..d6f76cd5c6 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -1,18 +1,31 @@ +# image will be published to ghcr.io// name: startingpoint +# description will be included in the image's metadata description: A starting point for further customization of uBlue images. Make your own! https://ublue.it/making-your-own/ + +# the base image to build on top of (FROM) and the version tag to use base-image: ghcr.io/ublue-os/silverblue-main -image-version: 38 +image-version: 38 # latest is also supported if you want new updates ASAP +# list of modules that will be executed in order +# you can include multiple of the same module modules: - - from-file: common-packages.yml # paths relative to "config" directory + - type: rpm-ostree + repos: + # - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%OS_VERSION%/atim-starship-fedora-%OS_VERSION%.repo + install: + - python3-pip + - libadwaita + remove: + - firefox + - firefox-langpacks - type: script scripts: # this sets up the proper policy & signing files for signed images to work - signing.sh - - type: yafti # no need for an enable-disable key, inclusion implicitly enables - # config: yafti.yml # if not specified, would use a default config TODO - custom-flatpaks: + - type: yafti # if included, https://github.com/ublue-os/yafti will be installed and set up + custom-flatpaks: # this section is optional - Celluloid: io.github.celluloid_player.Celluloid - Krita: org.kde.krita \ No newline at end of file From 1d7a3a92b617ab928695d46f1214d43cfa62def7 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 14:18:31 +0300 Subject: [PATCH 36/79] chore: remove outdated script-related docs --- config/scripts/README.md | 55 ---------------------------------------- modules/script/README.md | 16 +++++++++++- 2 files changed, 15 insertions(+), 56 deletions(-) delete mode 100644 config/scripts/README.md diff --git a/config/scripts/README.md b/config/scripts/README.md deleted file mode 100644 index 6c434a1faf..0000000000 --- a/config/scripts/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# 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 argument is provided for both manually declared scripts and scripts ran by `autorun.sh`. - -## Creating a script - -Look at `example.sh` for an example shell script. You can rename and copy the file for your own purposes. In order for the script to be executed, either move it to `scripts/pre/` or `scripts/post/` (if using `autorun.sh`) or declare it in the `recipe.yml`. - -All commands from RPMs you've declared in the `recipe.yml` should be available when running scripts at the `post` execution phase. - -When creating a script, please make sure - -- ...its filename ends with `.sh`. - - This follows convention for (especially bash) shell scripts. - - `autorun.sh` only executes files that match `*.sh`. -- ...it starts with a [shebang]() like `#!/usr/bin/env bash`. - - This ensures the script is ran with the correct interpreter / shell. -- ...it contains the command `set -oue pipefail` near the start. - - This will make the image build fail if your script fails. If you do not care if your script works or not, you can omit this line. - -## `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.sh` will 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 `pre` and `post` stages, you could simply symlink individual - scripts or the entire `pre` and `post` directories 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.s` would always execute before - another script named `99-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.yml` should - be stored directly within `scripts/`, or in a custom subdirectory that - doesn't match any of the execution phases. For example, you could - set the `pre:` section of `recipe.yml` to execute both `autorun.sh` - and `fizzwidget/something.sh`, and then place a bunch of auto-executed - scripts under `scripts/pre/` for the autorunner. This makes it very simple - to reuse common scripts between multiple different `recipe.yml` files, - while also having some scripts be specific to different `recipe.yml`s. -- You can safely specify `autorun.sh` as a script in `recipe.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. diff --git a/modules/script/README.md b/modules/script/README.md index 28d3c9593c..0be8b52f25 100644 --- a/modules/script/README.md +++ b/modules/script/README.md @@ -7,4 +7,18 @@ The scripts, which are run from the `config/scripts` directory, are declared und type: script scripts: - signing.sh -``` \ No newline at end of file +``` + +## Creating a script + +Look at `example.sh` for an example shell script. You can rename and copy the file for your own purposes. In order for the script to be executed, declare it in the recipe + +When creating a script, please make sure + +- ...its filename ends with `.sh`. + - This follows convention for (especially bash) shell scripts. + - `autorun.sh` only executes files that match `*.sh`. +- ...it starts with a [shebang]() like `#!/usr/bin/env bash`. + - This ensures the script is ran with the correct interpreter / shell. +- ...it contains the command `set -oue pipefail` near the start. + - This will make the image build fail if your script fails. If you do not care if your script works or not, you can omit this line. \ No newline at end of file From 81dca63764db37ff48539f5b44ea268d9aa06669 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 14:57:43 +0300 Subject: [PATCH 37/79] chore: clean up bling a bit --- Containerfile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Containerfile b/Containerfile index 2c0bdef053..935be850bd 100644 --- a/Containerfile +++ b/Containerfile @@ -1,4 +1,7 @@ -# This is the Containerfile for your custom image. +# This is the Containerfile for your custom image. + +# Instead of adding RUN statements here, you should consider creating a script +# in `config/scripts/`. Read more in `modules/script/README.md` # It takes in the recipe, version, and base image as arguments, # all of which are provided by build.yml when doing builds @@ -27,19 +30,16 @@ ARG IMAGE_REGISTRY=ghcr.io/ublue-os # See issue #28 (https://github.com/ublue-os/startingpoint/issues/28). COPY usr /usr -# Copy public key COPY cosign.pub /usr/share/ublue-os/cosign.pub -# Copy the config folder COPY config /usr/share/ublue-os/startingpoint -# Copy nix install script and Universal Blue wallpapers RPM from Bling image +# Copy the bling from ublue-os/bling into the image: +# * wallpapers +# * justfiles +# * nix installer COPY --from=ghcr.io/ublue-os/bling:latest /rpms/ublue-os-wallpapers-0.1-1.fc38.noarch.rpm /tmp/ublue-os-wallpapers-0.1-1.fc38.noarch.rpm - -# Integrate bling justfiles onto image COPY --from=ghcr.io/ublue-os/bling:latest /files/usr/share/ublue-os/just /usr/share/ublue-os/just - -# Copy dnkmmr's nix installer COPY --from=ghcr.io/ublue-os/bling:latest /files/usr/bin/ublue-nix* /usr/bin # "yq" used in build.sh and the "setup-flatpaks" just-action to read recipe.yml. From 7b036d3d1024da1ab29df1f4c1feea12a7a9d326 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 15:52:28 +0300 Subject: [PATCH 38/79] feat: ublue-os/bling module this makes all bling components optional, while making more of them accessible --- Containerfile | 15 ++++--------- config/README.md | 2 +- config/recipe.yml | 22 ++++++++++++++----- modules/bling/README.md | 19 ++++++++++++++++ modules/bling/bling.sh | 17 ++++++++++++++ modules/bling/installers/dconf-update-service | 6 +++++ modules/bling/installers/devpod.sh | 6 +++++ modules/bling/installers/fonts.sh | 6 +++++ modules/bling/installers/justfiles.sh | 6 +++++ modules/bling/installers/nix-installer.sh | 6 +++++ .../bling/installers/ublue-os-wallpapers.sh | 6 +++++ modules/bling/installers/ublue-update.sh | 6 +++++ 12 files changed, 100 insertions(+), 17 deletions(-) create mode 100644 modules/bling/README.md create mode 100644 modules/bling/bling.sh create mode 100644 modules/bling/installers/dconf-update-service create mode 100644 modules/bling/installers/devpod.sh create mode 100644 modules/bling/installers/fonts.sh create mode 100644 modules/bling/installers/justfiles.sh create mode 100644 modules/bling/installers/nix-installer.sh create mode 100644 modules/bling/installers/ublue-os-wallpapers.sh create mode 100644 modules/bling/installers/ublue-update.sh diff --git a/Containerfile b/Containerfile index 935be850bd..a622d04079 100644 --- a/Containerfile +++ b/Containerfile @@ -34,13 +34,10 @@ COPY cosign.pub /usr/share/ublue-os/cosign.pub COPY config /usr/share/ublue-os/startingpoint -# Copy the bling from ublue-os/bling into the image: -# * wallpapers -# * justfiles -# * nix installer -COPY --from=ghcr.io/ublue-os/bling:latest /rpms/ublue-os-wallpapers-0.1-1.fc38.noarch.rpm /tmp/ublue-os-wallpapers-0.1-1.fc38.noarch.rpm -COPY --from=ghcr.io/ublue-os/bling:latest /files/usr/share/ublue-os/just /usr/share/ublue-os/just -COPY --from=ghcr.io/ublue-os/bling:latest /files/usr/bin/ublue-nix* /usr/bin +# Copy the bling from ublue-os/bling into tmp, to be installed later by the bling module +# Feel free to remove these lines if you want to speed up image builds and don't want any bling +COPY --from=ghcr.io/ublue-os/bling:latest /rpms /tmp/bling/rpms +COPY --from=ghcr.io/ublue-os/bling:latest /files /tmp/bling/files # "yq" used in build.sh and the "setup-flatpaks" just-action to read recipe.yml. # Copied from the official container image since it's not available as an RPM. @@ -55,7 +52,3 @@ COPY modules /tmp/modules/ # Run the build script, then clean up temp files and finalize container build. RUN chmod +x /tmp/build.sh && /tmp/build.sh && \ rm -rf /tmp/* /var/* && ostree container commit - -# Storage -# TODO turn this bling installation stuff into a module -# rpm-ostree install /tmp/ublue-os-wallpapers-0.1-1.fc38.noarch.rpm \ No newline at end of file diff --git a/config/README.md b/config/README.md index 7725c48fd0..42dd6fd6ba 100644 --- a/config/README.md +++ b/config/README.md @@ -18,7 +18,7 @@ At the top of the recipe, there are four mandatory configuration options. The core of startingpoint's configuration is built around the idea of modules. Modules are scripts in the [`../modules`](../modules/) directory that you list out under `modules:` in the recipe. They are executed in order, and can run arbitrary shell commands and write any files. -This repository comes with three modules out of the box, [`rpm-ostree`](../modules/rpm-ostree) for pseudo-declarative package management, [`yafti`](../modules/yafti) for installing [yafti](https://github.com/ublue-os/yafti) and easing basic configuration, and [`script`](../modules/script) for running small custom scripts at the build stage, like pulling in configuration or setting up `rpm-ostree` support for proper signing (see [`signing.sh`](./scripts/signing.sh)). +This repository comes with three modules out of the box, [`rpm-ostree`](../modules/rpm-ostree) for pseudo-declarative package management, [`yafti`](../modules/yafti) for installing [yafti](https://github.com/ublue-os/yafti) and easing basic configuration, [`bling`](../modules/bling) for pulling extra components from [`ublue-os/bling`](https://github.com/ublue-os/bling), and [`script`](../modules/script) for running small custom scripts at the build stage, like pulling in configuration or setting up `rpm-ostree` support for proper signing (see [`signing.sh`](./scripts/signing.sh)). For more in-depth documentation on each module, check out the README.md files in each module folder. diff --git a/config/recipe.yml b/config/recipe.yml index d6f76cd5c6..24f60e18d0 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -20,12 +20,24 @@ modules: - firefox - firefox-langpacks - - type: script - scripts: - # this sets up the proper policy & signing files for signed images to work - - signing.sh + - type: bling # configure what to pull in from ublue-os/bling + install: + - fonts # selection of common good free fonts + - justfiles # add "!include /usr/share/ublue-os/just/bling.just" + # in your custom.just (added by default) or local justfile + - nix-installer # these are the silverblue nix installer scripts from dnkmmr69420 + - ublue-os-wallpapers + # - ublue-update # https://github.com/ublue-os/ublue-update + # - dconf-update-service # a service unit that updates the dconf db on boot + # - devpod # https://devpod.sh/ as an rpm + - type: yafti # if included, https://github.com/ublue-os/yafti will be installed and set up custom-flatpaks: # this section is optional - Celluloid: io.github.celluloid_player.Celluloid - - Krita: org.kde.krita \ No newline at end of file + - Krita: org.kde.krita + + - type: script + scripts: + # this sets up the proper policy & signing files for signed images to work + - signing.sh \ No newline at end of file diff --git a/modules/bling/README.md b/modules/bling/README.md new file mode 100644 index 0000000000..e342c4a5d0 --- /dev/null +++ b/modules/bling/README.md @@ -0,0 +1,19 @@ +# [`bling`](https://github.com/ublue-os/bling) module for startingpoint + +The `bling` module allows you to easily declare which general parts of `ublue-os/bling` to pull in to your custom image. It requires the `rpms` and `files` directories from the `bling` container to already exist inside `/tmp/bling/` (pulled inside the Containerfile by default). + +The blingbling to pull in is declared under `install:`, and the code for installing them is all in simple named scripts under the `installers/` directory. The basic code for the `bling` module is very similar to the code of the `script` module. + +Example configuration: +```yml +type: bling # configure what to pull in from ublue-os/bling +install: + - fonts # selection of common good free fonts + - justfiles # add "!include /usr/share/ublue-os/just/bling.just" + # in your custom.just (added by default) or local justfile + - nix-installer # these are the silverblue nix installer scripts from dnkmmr69420 + - ublue-os-wallpapers + # - ublue-update # https://github.com/ublue-os/ublue-update + # - dconf-update-service # a service unit that updates the dconf db on boot + # - devpod # https://devpod.sh/ as an rpm +``` \ No newline at end of file diff --git a/modules/bling/bling.sh b/modules/bling/bling.sh new file mode 100644 index 0000000000..be6fd17248 --- /dev/null +++ b/modules/bling/bling.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail + +get_yaml_array INSTALL '.install[]' "$1" + +export BLING_DIRECTORY="/tmp/bling" + +cd "/tmp/modules/bling/installers" + +find "$PWD" -type f -exec chmod +x {} \; + +for ITEM in "${INSTALL[@]}"; do + echo "Pulling from bling: $ITEM" + eval "$PWD/$ITEM.sh" +done \ No newline at end of file diff --git a/modules/bling/installers/dconf-update-service b/modules/bling/installers/dconf-update-service new file mode 100644 index 0000000000..25aa0c78f4 --- /dev/null +++ b/modules/bling/installers/dconf-update-service @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail + +cp -r "$BLING_DIRECTORY/files/usr/etc/systemd/system/dconf-update.service" "/usr/etc/systemd/system/dconf-update.service" \ No newline at end of file diff --git a/modules/bling/installers/devpod.sh b/modules/bling/installers/devpod.sh new file mode 100644 index 0000000000..9bb86993ed --- /dev/null +++ b/modules/bling/installers/devpod.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail + +rpm-ostree install "$BLING_DIRECTORY"/rpms/devpod*.rpm \ No newline at end of file diff --git a/modules/bling/installers/fonts.sh b/modules/bling/installers/fonts.sh new file mode 100644 index 0000000000..0e8015f4a8 --- /dev/null +++ b/modules/bling/installers/fonts.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail + +cp -r "$BLING_DIRECTORY/files/usr/share/fonts" "/usr/share/fonts" \ No newline at end of file diff --git a/modules/bling/installers/justfiles.sh b/modules/bling/installers/justfiles.sh new file mode 100644 index 0000000000..34e9814b63 --- /dev/null +++ b/modules/bling/installers/justfiles.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail + +cp -r "$BLING_DIRECTORY/files/usr/share/ublue-os/just" "/usr/share/ublue-os/just" \ No newline at end of file diff --git a/modules/bling/installers/nix-installer.sh b/modules/bling/installers/nix-installer.sh new file mode 100644 index 0000000000..88c6e86b39 --- /dev/null +++ b/modules/bling/installers/nix-installer.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail + +cp -r "$BLING_DIRECTORY/files/usr/bin/ublue-nix-install" "/usr/bin/ublue-nix-uninstall" \ No newline at end of file diff --git a/modules/bling/installers/ublue-os-wallpapers.sh b/modules/bling/installers/ublue-os-wallpapers.sh new file mode 100644 index 0000000000..6598bb7d54 --- /dev/null +++ b/modules/bling/installers/ublue-os-wallpapers.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail + +rpm-ostree install "$BLING_DIRECTORY"/rpms/ublue-os-wallpapers*.rpm \ No newline at end of file diff --git a/modules/bling/installers/ublue-update.sh b/modules/bling/installers/ublue-update.sh new file mode 100644 index 0000000000..c8b71263f9 --- /dev/null +++ b/modules/bling/installers/ublue-update.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail + +rpm-ostree install "$BLING_DIRECTORY"/rpms/ublue-update*.rpm \ No newline at end of file From 74017635d3208e0eae43bbb14396dfcba0e993a2 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 16:11:04 +0300 Subject: [PATCH 39/79] chore: clean build.yml, make matrix more visible there were huge blocks of good documentation, but it was in the way of easy access to the matrix section, which ordinary users have to update it was also only about build triggers, which is a pretty clear topic much more valuable would be explaining each build step i condesensed the docs into a smaller section atop with only generally useful information --- .github/workflows/build.yml | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 82c729c4b5..07950493ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,33 +1,17 @@ +# This workflow builds every branch of the repository daily at 20:22 UTC, one hour after ublue-os/nvidia builds. +# The images are also built after pushuing changes or pull requests. +# The builds can also be triggered manually in the Actions tab thanks to workflow dispatch. +# Only the branch called `live` is published. + + name: build-ublue -on: - # Build *every* branch at 10:20pm UTC every day (1 hr delay after "nvidia" builds), - # regardless of the branch names. (Not just "live, template and main" branches.) - # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule +on: # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows schedule: - cron: "20 22 * * *" - # Build automatically after pushing commits or tags to the "live", "template" - # or "main" branches, except when the commit only affects "documentation" text files. - # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push push: - branches: - - live - - template - - main - paths-ignore: + paths-ignore: # don't rebuild if only documentation has changed - "**.md" - - "**.txt" - # Build pull requests whenever they are opened or updated, to make sure they - # work. The build won't be deployed, since we filter out PRs in the deployment - # stage. Note that submitted PRs run the workflow of the *fork's* own primary - # branch, using the fork's own secrets/environment. Please be sure to sync - # your primary branch with upstream's latest workflow before submitting PRs! - # For pull requests, we build *any* branch regardless of name, to allow "build - # checks" to succeed for typical PR branch names such as "fix-something". - # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request pull_request: - # Build when manually triggering this workflow for a branch. This allows you - # to build any branch, even if it's not listed in the automated triggers above. - # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch workflow_dispatch: env: @@ -47,10 +31,12 @@ jobs: fail-fast: false matrix: +# !!! # Add recipes for all the images you want to build here. # Don't add module configuration files, you will get errors. recipe: - recipe.yml +# !!! steps: # Checkout push-to-registry action GitHub repository From 3c773d76a8fdd0b5565ad681833f875a9fd99f45 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 16:11:50 +0300 Subject: [PATCH 40/79] chore: remove empty usr/bin dir --- usr/bin/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 usr/bin/.gitkeep diff --git a/usr/bin/.gitkeep b/usr/bin/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 From 5cd245cc856149931a37f809eecdf7ee0660a552 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 16:36:33 +0300 Subject: [PATCH 41/79] docs: expand main customization section --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2324e24b71..af2e8515fc 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,15 @@ After setup, it is recommended you update this README to describe your custom im ## Customization -For information about customization, see [the README in the config directory](config/README.md) +The easiest way to start customizing is by looking at and modifying `config/recipe.yml`. It's documented using comments and should be pretty easy to understand. + +If you want to add custom configuration files, you can just add them in the `/usr/etc/` directory, which is the official OSTree "configuration template" directory and will be applied to `/etc/` on boot. `usr` is copied into your image by default. If you need to add other directories in the root of your image, that can be done in the Containerfile. Writing to `/var/` in the image builds of OSTree-based distros isn't supported and will not work, as that is a local user-managed directory! + +For more information about customization, see [the README in the config directory](config/README.md) + +Documentation around making custom images exists / should be written in two separate places: +* [The Tinkerer's Guide on the website](https://universal-blue.org/tinker/make-your-own/) for general documentation around making custom images, best practices, tutorials, and so on. +* Inside this repository for documentation specific to the ins and outs of the template, how it works, how to customize it, and some essential guidance on how to make custom images. ## Installation From fc2f4bb038f48fc7cd33b4c0f8fbba065617351b Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 16:45:24 +0300 Subject: [PATCH 42/79] chore!: remove setup-flatpaks * it doesn't make sense with the module system anymore --- usr/share/ublue-os/just/custom.just | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/usr/share/ublue-os/just/custom.just b/usr/share/ublue-os/just/custom.just index 80387faa29..023304a93c 100644 --- a/usr/share/ublue-os/just/custom.just +++ b/usr/share/ublue-os/just/custom.just @@ -1,13 +1,3 @@ !include /usr/share/ublue-os/just/bling.just -# Install all flatpaks defined in recipe.yml -setup-flatpaks: - #!/usr/bin/env bash - echo 'Installing flatpaks from the ublue recipe ...' - flatpaks=$(yq -- '.firstboot.flatpaks[]' "/usr/share/ublue-os/recipe.yml") - for pkg in $flatpaks; do \ - echo "Installing: ${pkg}" && \ - flatpak install --user --noninteractive flathub $pkg; \ - done - # Include some of your custom scripts here! From 09c22d55003bf2088a41eae9fd8afafea872b7df Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 16:46:45 +0300 Subject: [PATCH 43/79] docs: rewrite the just section --- README.md | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index af2e8515fc..984b7f1aa4 100644 --- a/README.md +++ b/README.md @@ -76,34 +76,18 @@ The Action uses [isogenerator](https://github.com/ublue-os/isogenerator) and wor Note that this release-iso action is not a replacement for a full-blown release automation like [release-please](https://github.com/googleapis/release-please). -## Just +## `just` -The `just` task runner is included in `ublue-os/main`-derived images, and we have provided several template commands which help you perform further customization after first boot. +The [`just`](https://just.systems/) command runner is included in all `ublue-os/main`-derived images. -You can merge our template justfiles into your own local configuration. When `just` supports [include directives](https://just.systems/man/en/chapter_52.html), you will instead be able to simply include these paths into your own justfile, without having to copy anything manually. - -Run the following commands when you're logged into the operating system, to merge uBlue's provided configurations into your own user config. (The "touch" command is only necessary on certain shells which won't let you merge into non-existent files.) - -```sh -touch ~/.justfile -cat /usr/share/ublue-os/just/main.just >> ~/.justfile -cat /usr/share/ublue-os/just/custom.just >> ~/.justfile +You need to have a `~/.justfile` with the following contents and `just` aliased to `just --unstable` (default in posix-compatible shells on ublue) to get started with just locally. ``` +!include /usr/share/ublue-os/just/main.just +!include /usr/share/ublue-os/just/nvidia.just +!include /usr/share/ublue-os/just/custom.just +``` +Then type `just` to list the just recipes available. -After doing that, you'll be able to run the following commands: - -- `just` - Show all tasks, more will be added in the future -- `just bios` - Reboot into the system bios (Useful for dualbooting) -- `just changelogs` - Show the changelogs of the pending update -- Set up distroboxes for the following images: - - `just distrobox-boxkit` - - `just distrobox-debian` - - `just distrobox-opensuse` - - `just distrobox-ubuntu` -- `just setup-flatpaks` - Install all of the flatpaks declared in recipe.yml -- `just setup-gaming` - Install Steam, Heroic Game Launcher, OBS Studio, Discord, Boatswain, Bottles, and ProtonUp-Qt. MangoHud is installed and enabled by default, hit right Shift-F12 to toggle -- `just nix-me-up` - Install Nix with dnkmmr69420's Nix Silverblue install script -- `just update` - Update rpm-ostree, flatpaks, and distroboxes in one command - -Check the [just website](https://just.systems) for tips on modifying and adding your own recipes. +The file `/usr/share/ublue-os/just/custom.just` is intended for the custom just commands (recipes) you wish to include in your image. By default, it includes the justfiles from [`ublue-os/bling`](https://github.com/ublue-os/bling), if you wish to disable that, you need to just remove the line that includes bling.just. +See [the just-page in the Universal Blue documentation](https://universal-blue.org/guide/just/) for more information. \ No newline at end of file From c2367e0d56d6832c2383eb1d4d7c1d69d3d3999f Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 16:49:21 +0300 Subject: [PATCH 44/79] chore: re-add branch selection for push * same-repo PRs build twice --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07950493ed..cd7ca7a339 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,10 @@ on: # https://docs.github.com/en/actions/using-workflows/events-that-trigger-wor schedule: - cron: "20 22 * * *" push: + branches: + - live + - template + - main paths-ignore: # don't rebuild if only documentation has changed - "**.md" pull_request: From e27eb25b8014dc5fd22777565beb4bcbf0ad731c Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 17:10:08 +0300 Subject: [PATCH 45/79] fix: newlines in rpm-ostree cmds errors i'm not sure if this approach is better than iterating over the array but it should now work in the same way it did previously --- modules/rpm-ostree/rpm-ostree.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index a55bfa00a7..137fb35423 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -15,13 +15,15 @@ fi get_yaml_array INSTALL '.install[]' "$1" if [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Installing RPMs" - echo "Installing: ${INSTALL[*]}" - rpm-ostree install "${INSTALL[@]}" + INSTALL_STR=$(echo "${INSTALL[*]}" | tr -d '\n') + echo "Installing: $INSTALL_STR" + rpm-ostree install "$INSTALL_STR" fi get_yaml_array REMOVE '.remove[]' "$1" if [[ ${#REMOVE[@]} -gt 0 ]]; then echo "Removing RPMs" - echo "Removing: ${REMOVE[*]}" - rpm-ostree override remove "${REMOVE[@]}" + REMOVE_STR=$(echo "${REMOVE[*]}" | tr -d '\n') + echo "Removing: $REMOVE" + rpm-ostree override remove "$REMOVE_STR" fi \ No newline at end of file From 2740320a51040493b18c4038301c1e0bc5554258 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 17:20:45 +0300 Subject: [PATCH 46/79] fix: don't output yaml array as json --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 1b248c1f6c..5640c57bbd 100644 --- a/build.sh +++ b/build.sh @@ -15,7 +15,7 @@ MODULE_DIRECTORY="/tmp/modules" # https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#yq-in-a-bash-loop get_yaml_array() { # creates array $1 with content at key $2 from $3 - readarray "$1" < <(echo "$3" | yq -o=j -I=0 "$2") + readarray "$1" < <(echo "$3" | yq -I=0 "$2") } export -f get_yaml_array # this makes the function available to all modules From 26e4f0cf033e1a5d5b2110bb1f5b3b4d5db107e8 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 17:25:22 +0300 Subject: [PATCH 47/79] chore: revert e27eb25 fix --- modules/rpm-ostree/rpm-ostree.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index 137fb35423..a55bfa00a7 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -15,15 +15,13 @@ fi get_yaml_array INSTALL '.install[]' "$1" if [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Installing RPMs" - INSTALL_STR=$(echo "${INSTALL[*]}" | tr -d '\n') - echo "Installing: $INSTALL_STR" - rpm-ostree install "$INSTALL_STR" + echo "Installing: ${INSTALL[*]}" + rpm-ostree install "${INSTALL[@]}" fi get_yaml_array REMOVE '.remove[]' "$1" if [[ ${#REMOVE[@]} -gt 0 ]]; then echo "Removing RPMs" - REMOVE_STR=$(echo "${REMOVE[*]}" | tr -d '\n') - echo "Removing: $REMOVE" - rpm-ostree override remove "$REMOVE_STR" + echo "Removing: ${REMOVE[*]}" + rpm-ostree override remove "${REMOVE[@]}" fi \ No newline at end of file From d2eeae7fb641751e42b4449e29ec055fc7e7b7d1 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 26 Aug 2023 17:29:59 +0300 Subject: [PATCH 48/79] docs: document added/removed packages --- config/recipe.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/recipe.yml b/config/recipe.yml index 24f60e18d0..fa639f101f 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -14,11 +14,11 @@ modules: repos: # - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%OS_VERSION%/atim-starship-fedora-%OS_VERSION%.repo install: - - python3-pip - - libadwaita + - python3-pip # required for yafti + - libadwaita # required for yafti remove: - - firefox - - firefox-langpacks + - firefox # default firefox removed in favor of flatpak + - firefox-langpacks # langpacks needs to also be removed to prevent dependency problems - type: bling # configure what to pull in from ublue-os/bling install: From 80c4094524a57431d2d8e2a7f89e35cf0f72165c Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 27 Aug 2023 13:47:12 +0300 Subject: [PATCH 49/79] chore: rm ublue-os/startingpoint in iso docs * automatic setup replaces it with the repository's details, which makes it confusing to read --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 984b7f1aa4..f53917efce 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ The `latest` tag will automatically point to the latest build. That build will s This template includes a simple Github Action to build and release an ISO of your image. -To run the action, simply edit the `boot_menu.yml` by changing all the references to `ublue-os/startingpoint` to your repository. This should trigger the action automatically. +To run the action, simply edit the `boot_menu.yml` by changing all the references to startingpoint to your repository. This should trigger the action automatically. The Action uses [isogenerator](https://github.com/ublue-os/isogenerator) and works in a similar manner to the official Universal Blue ISO. If you have any issues, you should first check [the documentation page on installation](https://universal-blue.org/installation/). The ISO is a netinstaller and should always pull the latest version of your image. From 5a1a68747622ebc72c05073b40eae504fd9fe36c Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 27 Aug 2023 16:06:40 +0300 Subject: [PATCH 50/79] chore: use same package inst/rm logic as upstream upstream referring to build.sh in main and bluefin --- modules/rpm-ostree/rpm-ostree.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index a55bfa00a7..303af9293a 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -13,14 +13,18 @@ if [[ ${#REPOS[@]} -gt 0 ]]; then fi get_yaml_array INSTALL '.install[]' "$1" -if [[ ${#INSTALL[@]} -gt 0 ]]; then +get_yaml_array REMOVE '.remove[]' "$1" + +if [[ ${#INSTALL[@]} -gt 0 && ${#REMOVE[@]} -gt 0 ]]; then + echo "Installing & Removing RPMs" + echo "Installing: ${INSTALL[*]}" + echo "Removing: ${REMOVE[*]}" + rpm-ostree override remove "${REMOVE[@]}" $(printf -- "--install=%s " ${INSTALL[@]}) +elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Installing RPMs" echo "Installing: ${INSTALL[*]}" rpm-ostree install "${INSTALL[@]}" -fi - -get_yaml_array REMOVE '.remove[]' "$1" -if [[ ${#REMOVE[@]} -gt 0 ]]; then +elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Removing RPMs" echo "Removing: ${REMOVE[*]}" rpm-ostree override remove "${REMOVE[@]}" From 3f35fe7645b1871c9e7564555a2b09e81633f3e4 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 27 Aug 2023 16:11:36 +0300 Subject: [PATCH 51/79] chore: try removing pkgs to remove? --- config/recipe.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/recipe.yml b/config/recipe.yml index fa639f101f..9e23b7e0d8 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -17,8 +17,8 @@ modules: - python3-pip # required for yafti - libadwaita # required for yafti remove: - - firefox # default firefox removed in favor of flatpak - - firefox-langpacks # langpacks needs to also be removed to prevent dependency problems + # - firefox # default firefox removed in favor of flatpak + # - firefox-langpacks # langpacks needs to also be removed to prevent dependency problems - type: bling # configure what to pull in from ublue-os/bling install: From 961dff33f41bc8ffedbf6d814c32715203ac2e26 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 27 Aug 2023 16:22:20 +0300 Subject: [PATCH 52/79] fix: put .sh suffix outside of quotes? --- modules/bling/bling.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/bling/bling.sh b/modules/bling/bling.sh index be6fd17248..99ee0071fc 100644 --- a/modules/bling/bling.sh +++ b/modules/bling/bling.sh @@ -13,5 +13,5 @@ find "$PWD" -type f -exec chmod +x {} \; for ITEM in "${INSTALL[@]}"; do echo "Pulling from bling: $ITEM" - eval "$PWD/$ITEM.sh" + eval "$PWD/$ITEM".sh done \ No newline at end of file From 949b06f1f9b44c960516537595e7dfaa1e435cf6 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 27 Aug 2023 16:48:19 +0300 Subject: [PATCH 53/79] fix: remove trailing newline from $ITEM using a clever bash-ism --- modules/bling/bling.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/bling/bling.sh b/modules/bling/bling.sh index 99ee0071fc..6888a4a3ec 100644 --- a/modules/bling/bling.sh +++ b/modules/bling/bling.sh @@ -13,5 +13,5 @@ find "$PWD" -type f -exec chmod +x {} \; for ITEM in "${INSTALL[@]}"; do echo "Pulling from bling: $ITEM" - eval "$PWD/$ITEM".sh + eval "$PWD/${ITEM%$'\n'}.sh" done \ No newline at end of file From 019603f11eda229f0b5094fc2249b9ad3ad5858d Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 27 Aug 2023 16:56:47 +0300 Subject: [PATCH 54/79] docs: some more inline docs for modules (only confusing parts) --- modules/bling/bling.sh | 2 ++ modules/rpm-ostree/rpm-ostree.sh | 1 + modules/script/script.sh | 1 + 3 files changed, 4 insertions(+) diff --git a/modules/bling/bling.sh b/modules/bling/bling.sh index 6888a4a3ec..053a0e2342 100644 --- a/modules/bling/bling.sh +++ b/modules/bling/bling.sh @@ -9,9 +9,11 @@ export BLING_DIRECTORY="/tmp/bling" cd "/tmp/modules/bling/installers" +# Make every bling installer executable find "$PWD" -type f -exec chmod +x {} \; for ITEM in "${INSTALL[@]}"; do echo "Pulling from bling: $ITEM" + # The trainling newline from $ITEM is removed eval "$PWD/${ITEM%$'\n'}.sh" done \ No newline at end of file diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index 303af9293a..06346f1342 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -19,6 +19,7 @@ if [[ ${#INSTALL[@]} -gt 0 && ${#REMOVE[@]} -gt 0 ]]; then echo "Installing & Removing RPMs" echo "Installing: ${INSTALL[*]}" echo "Removing: ${REMOVE[*]}" + # Doing both actions in one command allows for replacing required packages with alternatives rpm-ostree override remove "${REMOVE[@]}" $(printf -- "--install=%s " ${INSTALL[@]}) elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Installing RPMs" diff --git a/modules/script/script.sh b/modules/script/script.sh index 3290f02d08..fe63e0f0d1 100644 --- a/modules/script/script.sh +++ b/modules/script/script.sh @@ -7,6 +7,7 @@ get_yaml_array SCRIPTS '.scripts[]' "$1" cd "$CONFIG_DIRECTORY/scripts" +# Make every script executable find "$PWD" -type f -exec chmod +x {} \; for SCRIPT in "${SCRIPTS[@]}"; do From 5ff623b496043d4a1f6dc2f3bede3ff438041a7b Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 27 Aug 2023 17:01:52 +0300 Subject: [PATCH 55/79] chore: try removing something other than ff removing firefox gives some cryptic errors, let's try removing something else to investigate --- config/recipe.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/recipe.yml b/config/recipe.yml index 9e23b7e0d8..bd662fba69 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -17,6 +17,7 @@ modules: - python3-pip # required for yafti - libadwaita # required for yafti remove: + - vi # - firefox # default firefox removed in favor of flatpak # - firefox-langpacks # langpacks needs to also be removed to prevent dependency problems From 00b692013311f1893ec3ce1006e3b6f6661342e6 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 27 Aug 2023 17:08:25 +0300 Subject: [PATCH 56/79] fix: rm newlines from rpm-ostree cmds basically re-adds the e27eb25 changes which were later reverted in favor of the way packages.json apparently worked --- modules/rpm-ostree/rpm-ostree.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index 06346f1342..cae83f672c 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -15,18 +15,21 @@ fi get_yaml_array INSTALL '.install[]' "$1" get_yaml_array REMOVE '.remove[]' "$1" +INSTALL_STR=$(echo "${INSTALL[*]}" | tr -d '\n') +REMOVE_STR=$(echo "${REMOVE[*]}" | tr -d '\n') + if [[ ${#INSTALL[@]} -gt 0 && ${#REMOVE[@]} -gt 0 ]]; then echo "Installing & Removing RPMs" - echo "Installing: ${INSTALL[*]}" - echo "Removing: ${REMOVE[*]}" + echo "Installing: ${INSTALL_STR[*]}" + echo "Removing: ${REMOVE_STR[*]}" # Doing both actions in one command allows for replacing required packages with alternatives - rpm-ostree override remove "${REMOVE[@]}" $(printf -- "--install=%s " ${INSTALL[@]}) + rpm-ostree override remove "${REMOVE_STR[@]}" $(printf -- "--install=%s " ${INSTALL_STR[@]}) elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Installing RPMs" - echo "Installing: ${INSTALL[*]}" - rpm-ostree install "${INSTALL[@]}" + echo "Installing: ${INSTALL_STR[*]}" + rpm-ostree install "${INSTALL_STR[@]}" elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Removing RPMs" - echo "Removing: ${REMOVE[*]}" - rpm-ostree override remove "${REMOVE[@]}" + echo "Removing: ${REMOVE_STR[*]}" + rpm-ostree override remove "${REMOVE_STR[@]}" fi \ No newline at end of file From fd2ca7650298af23a56257b98ba02b7969cd4423 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 27 Aug 2023 17:16:25 +0300 Subject: [PATCH 57/79] chore: revert recipe to default configuration --- config/recipe.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/recipe.yml b/config/recipe.yml index bd662fba69..fa639f101f 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -17,9 +17,8 @@ modules: - python3-pip # required for yafti - libadwaita # required for yafti remove: - - vi - # - firefox # default firefox removed in favor of flatpak - # - firefox-langpacks # langpacks needs to also be removed to prevent dependency problems + - firefox # default firefox removed in favor of flatpak + - firefox-langpacks # langpacks needs to also be removed to prevent dependency problems - type: bling # configure what to pull in from ublue-os/bling install: From 4ce8e919b9d7186738a96d06470d43c6fe93613a Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 27 Aug 2023 18:04:08 +0300 Subject: [PATCH 58/79] fix: ? remove quotes, add wordsplitting --- modules/rpm-ostree/rpm-ostree.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index cae83f672c..469f8b8939 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -23,13 +23,13 @@ if [[ ${#INSTALL[@]} -gt 0 && ${#REMOVE[@]} -gt 0 ]]; then echo "Installing: ${INSTALL_STR[*]}" echo "Removing: ${REMOVE_STR[*]}" # Doing both actions in one command allows for replacing required packages with alternatives - rpm-ostree override remove "${REMOVE_STR[@]}" $(printf -- "--install=%s " ${INSTALL_STR[@]}) + rpm-ostree override remove ${REMOVE_STR[@]} $(printf -- "--install=%s " ${INSTALL_STR[@]}) elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Installing RPMs" echo "Installing: ${INSTALL_STR[*]}" - rpm-ostree install "${INSTALL_STR[@]}" + rpm-ostree install ${INSTALL_STR[@]} elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Removing RPMs" echo "Removing: ${REMOVE_STR[*]}" - rpm-ostree override remove "${REMOVE_STR[@]}" + rpm-ostree override remove ${REMOVE_STR[@]} fi \ No newline at end of file From ac8be6e92bcef06efc48274c84ae2755b2cb100c Mon Sep 17 00:00:00 2001 From: ER Date: Tue, 29 Aug 2023 19:48:40 +0300 Subject: [PATCH 59/79] chore: back to array syntax in rpm-ostree --- modules/rpm-ostree/rpm-ostree.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index 469f8b8939..00fc91aac4 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -15,21 +15,18 @@ fi get_yaml_array INSTALL '.install[]' "$1" get_yaml_array REMOVE '.remove[]' "$1" -INSTALL_STR=$(echo "${INSTALL[*]}" | tr -d '\n') -REMOVE_STR=$(echo "${REMOVE[*]}" | tr -d '\n') - if [[ ${#INSTALL[@]} -gt 0 && ${#REMOVE[@]} -gt 0 ]]; then echo "Installing & Removing RPMs" - echo "Installing: ${INSTALL_STR[*]}" - echo "Removing: ${REMOVE_STR[*]}" + echo "Installing: $(echo "${INSTALL[*]}" | tr -d '\n')" + echo "Removing: $(echo "${REMOVE[*]}" | tr -d '\n')" # Doing both actions in one command allows for replacing required packages with alternatives - rpm-ostree override remove ${REMOVE_STR[@]} $(printf -- "--install=%s " ${INSTALL_STR[@]}) + rpm-ostree override remove "${REMOVE[@]}" $(printf -- "--install=%s " ${INSTALL[@]}) elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Installing RPMs" - echo "Installing: ${INSTALL_STR[*]}" - rpm-ostree install ${INSTALL_STR[@]} + echo "Installing: $(echo "${INSTALL[*]}" | tr -d '\n')" + rpm-ostree install "${INSTALL[@]}" elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Removing RPMs" - echo "Removing: ${REMOVE_STR[*]}" - rpm-ostree override remove ${REMOVE_STR[@]} + echo "Removing: $(echo "${REMOVE[*]}" | tr -d '\n')" + rpm-ostree override remove "${REMOVE[@]}" fi \ No newline at end of file From 77699e8f430d740890630a1486c2fe5e33870c8d Mon Sep 17 00:00:00 2001 From: ER Date: Tue, 29 Aug 2023 19:59:28 +0300 Subject: [PATCH 60/79] chore: Revert "chore: back to array syntax in rpm-ostree" This reverts commit ac8be6e92bcef06efc48274c84ae2755b2cb100c. --- modules/rpm-ostree/rpm-ostree.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index 00fc91aac4..469f8b8939 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -15,18 +15,21 @@ fi get_yaml_array INSTALL '.install[]' "$1" get_yaml_array REMOVE '.remove[]' "$1" +INSTALL_STR=$(echo "${INSTALL[*]}" | tr -d '\n') +REMOVE_STR=$(echo "${REMOVE[*]}" | tr -d '\n') + if [[ ${#INSTALL[@]} -gt 0 && ${#REMOVE[@]} -gt 0 ]]; then echo "Installing & Removing RPMs" - echo "Installing: $(echo "${INSTALL[*]}" | tr -d '\n')" - echo "Removing: $(echo "${REMOVE[*]}" | tr -d '\n')" + echo "Installing: ${INSTALL_STR[*]}" + echo "Removing: ${REMOVE_STR[*]}" # Doing both actions in one command allows for replacing required packages with alternatives - rpm-ostree override remove "${REMOVE[@]}" $(printf -- "--install=%s " ${INSTALL[@]}) + rpm-ostree override remove ${REMOVE_STR[@]} $(printf -- "--install=%s " ${INSTALL_STR[@]}) elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Installing RPMs" - echo "Installing: $(echo "${INSTALL[*]}" | tr -d '\n')" - rpm-ostree install "${INSTALL[@]}" + echo "Installing: ${INSTALL_STR[*]}" + rpm-ostree install ${INSTALL_STR[@]} elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Removing RPMs" - echo "Removing: $(echo "${REMOVE[*]}" | tr -d '\n')" - rpm-ostree override remove "${REMOVE[@]}" + echo "Removing: ${REMOVE_STR[*]}" + rpm-ostree override remove ${REMOVE_STR[@]} fi \ No newline at end of file From 2208ea88e50bb504c440783912dd0cd56f62d008 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 2 Sep 2023 12:27:38 +0300 Subject: [PATCH 61/79] fix: remove ub update services in ub updater inst --- modules/bling/installers/ublue-update.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/bling/installers/ublue-update.sh b/modules/bling/installers/ublue-update.sh index c8b71263f9..1fec23fad1 100644 --- a/modules/bling/installers/ublue-update.sh +++ b/modules/bling/installers/ublue-update.sh @@ -3,4 +3,8 @@ # Tell build process to exit if there are any errors. set -oue pipefail +# Check if ublue-os-update-services rpm is installed, these services conflict with ublue-update +if rpm -q ublue-os-update-services > /dev/null; then + rpm-ostree override remove ublue-os-update-services +fi rpm-ostree install "$BLING_DIRECTORY"/rpms/ublue-update*.rpm \ No newline at end of file From 54cd605f113fde7948ee2c0814df46f0805b3782 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 2 Sep 2023 12:51:13 +0300 Subject: [PATCH 62/79] feat: integrate optfix into rpm-ostree module Co-Authored By: @AuraHerreroRuiz bulk of the code from: github.com/AuraHerreroRuiz/auraos/ blob/f83e90ea9f1dddc50630f4634d835f085adf4a99/scripts/pre/optpackages.sh --- modules/rpm-ostree/README.md | 2 ++ modules/rpm-ostree/rpm-ostree.sh | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/modules/rpm-ostree/README.md b/modules/rpm-ostree/README.md index 0768070e91..469b8ffd36 100644 --- a/modules/rpm-ostree/README.md +++ b/modules/rpm-ostree/README.md @@ -8,6 +8,8 @@ Then the module installs the packages declared under `install:` using `rpm-ostre Unfortunately, currently `rpm-ostree override remove`, and this module, might not be able to remove packages installed in image builds. Packages included by Fedora, such as Firefox can still be removed, though. +Additionally, the `rpm-ostree` module supports a temporary (waiting for `rpm-ostree` issue [#233](https://github.com/coreos/rpm-ostree/issues/233)) fix for packages that install into `/opt/`. Installation for packages that install into folder names declared under `optfix:` are fixed using some symlinks. + Example configuration: ```yml type: rpm-ostree diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index 469f8b8939..e60ea8d00b 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -3,6 +3,7 @@ # Tell build process to exit if there are any errors. set -oue pipefail +# Pull in repos get_yaml_array REPOS '.repos[]' "$1" if [[ ${#REPOS[@]} -gt 0 ]]; then echo "Adding repositories" @@ -12,12 +13,33 @@ if [[ ${#REPOS[@]} -gt 0 ]]; then done fi +# Create symlinks to fix packages that create directories in /opt +get_yaml_array OPTFIX '.optfix[]' "$1" +if [[ ${#OPTFIX[@]} -gt 0 ]]; then + echo "Creating symlinks to fix packages that install to /opt" + # Create symlink for /opt to /var/opt since it is not created in the image yet + mkdir -p "/var/opt" + ln -s "/var/opt" "/opt" + # Create symlinks for each directory specified in recipe.yml + for OPTPKG in "${OPTFIX[@]}"; do + OPTPKG="${OPTPKG%\"}" + OPTPKG="${OPTPKG#\"}" + mkdir -p "/usr/lib/opt/${OPTPKG}" + ln -s "../../usr/lib/opt/${OPTPKG}" "/var/opt/${OPTPKG}" + echo "Created symlinks for ${OPTPKG}" + done +fi + get_yaml_array INSTALL '.install[]' "$1" get_yaml_array REMOVE '.remove[]' "$1" +# The installation is done with some wordsplitting hacks +# because of errors when doing array destructuring at the installation step. +# This is different from other ublue projects and could be investigated further. INSTALL_STR=$(echo "${INSTALL[*]}" | tr -d '\n') REMOVE_STR=$(echo "${REMOVE[*]}" | tr -d '\n') +# Install and remove RPM packages if [[ ${#INSTALL[@]} -gt 0 && ${#REMOVE[@]} -gt 0 ]]; then echo "Installing & Removing RPMs" echo "Installing: ${INSTALL_STR[*]}" From 25ac5dd6ef41c41d6a1593f1a54522d0b3f608c9 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 2 Sep 2023 16:03:41 +0300 Subject: [PATCH 63/79] docs: fix: it's not dnkmmr it's determinate --- config/recipe.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/recipe.yml b/config/recipe.yml index fa639f101f..0ca857ab1c 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -25,7 +25,7 @@ modules: - fonts # selection of common good free fonts - justfiles # add "!include /usr/share/ublue-os/just/bling.just" # in your custom.just (added by default) or local justfile - - nix-installer # these are the silverblue nix installer scripts from dnkmmr69420 + - nix-installer # shell shortcuts for determinate system's nix installers - ublue-os-wallpapers # - ublue-update # https://github.com/ublue-os/ublue-update # - dconf-update-service # a service unit that updates the dconf db on boot From 60fa5ca3260e484328c3dd76c8edca7f92a8df11 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 2 Sep 2023 19:52:49 +0300 Subject: [PATCH 64/79] fix: remove newlines before wget including the newlines causes filenames to be postfixed with %0A and thus the repo files to not work this commit uses the same bashism as above line to remove newlines from the $REPO var before using it in the wget command --- modules/rpm-ostree/rpm-ostree.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index e60ea8d00b..5c89744c62 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -9,7 +9,7 @@ if [[ ${#REPOS[@]} -gt 0 ]]; then echo "Adding repositories" for REPO in "${REPOS[@]}"; do REPO="${REPO//%OS_VERSION%/${OS_VERSION}}" - wget "${REPO}" -P "/etc/yum.repos.d/" + wget "${REPO//[$'\t\r\n ']}" -P "/etc/yum.repos.d/" done fi From d2ab95c9e44116d07afa6b437bbcf4437ac11a05 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 2 Sep 2023 20:52:34 +0300 Subject: [PATCH 65/79] fix: bling justfile installer nested just dir idon't create another just directory inside the basic just directory, just copy the contents --- modules/bling/installers/justfiles.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/bling/installers/justfiles.sh b/modules/bling/installers/justfiles.sh index 34e9814b63..9c44945c1d 100644 --- a/modules/bling/installers/justfiles.sh +++ b/modules/bling/installers/justfiles.sh @@ -3,4 +3,4 @@ # Tell build process to exit if there are any errors. set -oue pipefail -cp -r "$BLING_DIRECTORY/files/usr/share/ublue-os/just" "/usr/share/ublue-os/just" \ No newline at end of file +cp -r "$BLING_DIRECTORY/files/usr/share/ublue-os/just/*" "/usr/share/ublue-os/just" \ No newline at end of file From e5fdb304b4e2c0a2933288b5b4d336ab5a39d061 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 2 Sep 2023 20:55:49 +0300 Subject: [PATCH 66/79] fix: some more bling installer file copy issues (brainfarts), the nix install one is just... --- modules/bling/installers/fonts.sh | 2 +- modules/bling/installers/nix-installer.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/bling/installers/fonts.sh b/modules/bling/installers/fonts.sh index 0e8015f4a8..40a866bfe0 100644 --- a/modules/bling/installers/fonts.sh +++ b/modules/bling/installers/fonts.sh @@ -3,4 +3,4 @@ # Tell build process to exit if there are any errors. set -oue pipefail -cp -r "$BLING_DIRECTORY/files/usr/share/fonts" "/usr/share/fonts" \ No newline at end of file +cp -r "$BLING_DIRECTORY/files/usr/share/fonts/*" "/usr/share/fonts" \ No newline at end of file diff --git a/modules/bling/installers/nix-installer.sh b/modules/bling/installers/nix-installer.sh index 88c6e86b39..9f678ac360 100644 --- a/modules/bling/installers/nix-installer.sh +++ b/modules/bling/installers/nix-installer.sh @@ -3,4 +3,5 @@ # Tell build process to exit if there are any errors. set -oue pipefail -cp -r "$BLING_DIRECTORY/files/usr/bin/ublue-nix-install" "/usr/bin/ublue-nix-uninstall" \ No newline at end of file +cp "$BLING_DIRECTORY/files/usr/bin/ublue-nix-install" "/usr/bin/ublue-nix-install" +cp "$BLING_DIRECTORY/files/usr/bin/ublue-nix-uninstall" "/usr/bin/ublue-nix-uninstall" \ No newline at end of file From eb37ec35b4723fe1ea0d748e0a768ea39e0017a8 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 2 Sep 2023 20:59:04 +0300 Subject: [PATCH 67/79] fix: move globs outside of "" --- modules/bling/installers/fonts.sh | 2 +- modules/bling/installers/justfiles.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/bling/installers/fonts.sh b/modules/bling/installers/fonts.sh index 40a866bfe0..dda91f7747 100644 --- a/modules/bling/installers/fonts.sh +++ b/modules/bling/installers/fonts.sh @@ -3,4 +3,4 @@ # Tell build process to exit if there are any errors. set -oue pipefail -cp -r "$BLING_DIRECTORY/files/usr/share/fonts/*" "/usr/share/fonts" \ No newline at end of file +cp -r "$BLING_DIRECTORY"/files/usr/share/fonts/* "/usr/share/fonts" \ No newline at end of file diff --git a/modules/bling/installers/justfiles.sh b/modules/bling/installers/justfiles.sh index 9c44945c1d..d976305981 100644 --- a/modules/bling/installers/justfiles.sh +++ b/modules/bling/installers/justfiles.sh @@ -3,4 +3,4 @@ # Tell build process to exit if there are any errors. set -oue pipefail -cp -r "$BLING_DIRECTORY/files/usr/share/ublue-os/just/*" "/usr/share/ublue-os/just" \ No newline at end of file +cp -r "$BLING_DIRECTORY"/files/usr/share/ublue-os/just/* "/usr/share/ublue-os/just" \ No newline at end of file From cc90a917336aa64b17aebb0d565999d839536476 Mon Sep 17 00:00:00 2001 From: gerblesh <101901964+gerblesh@users.noreply.github.com> Date: Tue, 5 Sep 2023 08:56:42 -0700 Subject: [PATCH 68/79] feat: added systemd and files module (#142) * feat: add files and systemd module * fix: yaml formatting * fix: yaml formatting * fix: remove comment completely * fix: yaml formatting * docs: add back inline comment * reformat: rename variables * fix: fix systemd escaped string * fix: fix systemd service formatting with printf * fix: attempting to fix systemd module problems * chore: remove debug config and code from systemd module * docs: added WIP docs for systemd, reworked files README * docs: added more detail for systemd module * docs: update READMEs to be more consistent * docs: remove unneeded sentence * docs: remove unneeded sentence * chore: fix issues described in PR review * docs: fix markdown formatting * docs: fix markdown formatting * docs: better markdown --- .github/workflows/build.yml | 2 +- Containerfile | 11 +---- build.sh | 4 +- .../firstboot/launcher/autostart.desktop | 0 .../ublue-os/firstboot/launcher/autostart.sh | 0 .../firstboot/launcher/launcher-flowchart.png | Bin .../firstboot/launcher/login-profile.sh | 0 .../usr}/share/ublue-os/firstboot/yafti.yml | 0 .../usr}/share/ublue-os/just/custom.just | 0 config/recipe.yml | 18 +++++++- modules/bling/README.md | 7 +-- modules/files/README.md | 16 +++++++ modules/files/files.sh | 33 ++++++++++++++ modules/rpm-ostree/README.md | 13 +++--- modules/script/README.md | 8 ++-- modules/systemd/README.md | 41 ++++++++++++++++++ modules/systemd/systemd.sh | 35 +++++++++++++++ modules/yafti/README.md | 7 +-- 18 files changed, 164 insertions(+), 31 deletions(-) rename {usr => config/files/usr}/share/ublue-os/firstboot/launcher/autostart.desktop (100%) rename {usr => config/files/usr}/share/ublue-os/firstboot/launcher/autostart.sh (100%) rename {usr => config/files/usr}/share/ublue-os/firstboot/launcher/launcher-flowchart.png (100%) rename {usr => config/files/usr}/share/ublue-os/firstboot/launcher/login-profile.sh (100%) rename {usr => config/files/usr}/share/ublue-os/firstboot/yafti.yml (100%) rename {usr => config/files/usr}/share/ublue-os/just/custom.just (100%) create mode 100644 modules/files/README.md create mode 100644 modules/files/files.sh create mode 100644 modules/systemd/README.md create mode 100644 modules/systemd/systemd.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3f7c1b2a1c..e20fb15bc5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,6 @@ # This workflow builds every branch of the repository daily at 20:22 UTC, one hour after ublue-os/nvidia builds. # The images are also built after pushuing changes or pull requests. -# The builds can also be triggered manually in the Actions tab thanks to workflow dispatch. +# The builds can also be triggered manually in the Actions tab thanks to workflow dispatch. # Only the branch called `live` is published. diff --git a/Containerfile b/Containerfile index a622d04079..5ea9284bf3 100644 --- a/Containerfile +++ b/Containerfile @@ -21,18 +21,9 @@ ARG RECIPE=recipe.yml # The default image registry to write to policy.json and cosign.yaml ARG IMAGE_REGISTRY=ghcr.io/ublue-os -# Copy static configurations and component files. -# Warning: If you want to place anything in "/etc" of the final image, you MUST -# place them in "./usr/etc" in your repo, so that they're written to "/usr/etc" -# on the final system. That is the proper directory for "system" configuration -# templates on immutable Fedora distros, whereas the normal "/etc" is ONLY meant -# for manual overrides and editing by the machine's admin AFTER installation! -# See issue #28 (https://github.com/ublue-os/startingpoint/issues/28). -COPY usr /usr - COPY cosign.pub /usr/share/ublue-os/cosign.pub -COPY config /usr/share/ublue-os/startingpoint +COPY config /tmp/config # Copy the bling from ublue-os/bling into tmp, to be installed later by the bling module # Feel free to remove these lines if you want to speed up image builds and don't want any bling diff --git a/build.sh b/build.sh index 5640c57bbd..7d33c221a0 100644 --- a/build.sh +++ b/build.sh @@ -8,7 +8,7 @@ # Tell build process to exit if there are any errors. set -oue pipefail -export CONFIG_DIRECTORY="/usr/share/ublue-os/startingpoint" +export CONFIG_DIRECTORY="/tmp/config" RECIPE_FILE="$CONFIG_DIRECTORY/$RECIPE" MODULE_DIRECTORY="/tmp/modules" @@ -53,4 +53,4 @@ for MODULE in "${MODULES[@]}"; do bash "$MODULE_DIRECTORY/$TYPE/$TYPE.sh" "$MODULE_CONFIG" fi echo "======" -done \ No newline at end of file +done diff --git a/usr/share/ublue-os/firstboot/launcher/autostart.desktop b/config/files/usr/share/ublue-os/firstboot/launcher/autostart.desktop similarity index 100% rename from usr/share/ublue-os/firstboot/launcher/autostart.desktop rename to config/files/usr/share/ublue-os/firstboot/launcher/autostart.desktop diff --git a/usr/share/ublue-os/firstboot/launcher/autostart.sh b/config/files/usr/share/ublue-os/firstboot/launcher/autostart.sh similarity index 100% rename from usr/share/ublue-os/firstboot/launcher/autostart.sh rename to config/files/usr/share/ublue-os/firstboot/launcher/autostart.sh diff --git a/usr/share/ublue-os/firstboot/launcher/launcher-flowchart.png b/config/files/usr/share/ublue-os/firstboot/launcher/launcher-flowchart.png similarity index 100% rename from usr/share/ublue-os/firstboot/launcher/launcher-flowchart.png rename to config/files/usr/share/ublue-os/firstboot/launcher/launcher-flowchart.png diff --git a/usr/share/ublue-os/firstboot/launcher/login-profile.sh b/config/files/usr/share/ublue-os/firstboot/launcher/login-profile.sh similarity index 100% rename from usr/share/ublue-os/firstboot/launcher/login-profile.sh rename to config/files/usr/share/ublue-os/firstboot/launcher/login-profile.sh diff --git a/usr/share/ublue-os/firstboot/yafti.yml b/config/files/usr/share/ublue-os/firstboot/yafti.yml similarity index 100% rename from usr/share/ublue-os/firstboot/yafti.yml rename to config/files/usr/share/ublue-os/firstboot/yafti.yml diff --git a/usr/share/ublue-os/just/custom.just b/config/files/usr/share/ublue-os/just/custom.just similarity index 100% rename from usr/share/ublue-os/just/custom.just rename to config/files/usr/share/ublue-os/just/custom.just diff --git a/config/recipe.yml b/config/recipe.yml index 0ca857ab1c..8e70381a84 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -8,10 +8,23 @@ base-image: ghcr.io/ublue-os/silverblue-main image-version: 38 # latest is also supported if you want new updates ASAP # list of modules that will be executed in order + # you can include multiple of the same module + modules: + - type: files + files: + - usr: /usr + # Copy static configurations and component files. + # Warning: If you want to place anything in "/etc" of the final image, you MUST + # place them in "./usr/etc" in your repo, so that they're written to "/usr/etc" + # on the final system. That is the proper directory for "system" configuration + # templates on immutable Fedora distros, whereas the normal "/etc" is ONLY meant + # for manual overrides and editing by the machine's admin AFTER installation! + # See issue #28 (https://github.com/ublue-os/startingpoint/issues/28). + - type: rpm-ostree - repos: + repos: # - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%OS_VERSION%/atim-starship-fedora-%OS_VERSION%.repo install: - python3-pip # required for yafti @@ -40,4 +53,5 @@ modules: - type: script scripts: # this sets up the proper policy & signing files for signed images to work - - signing.sh \ No newline at end of file + - signing.sh + diff --git a/modules/bling/README.md b/modules/bling/README.md index e342c4a5d0..c76fa71c6f 100644 --- a/modules/bling/README.md +++ b/modules/bling/README.md @@ -1,10 +1,11 @@ -# [`bling`](https://github.com/ublue-os/bling) module for startingpoint +# [`bling`](https://github.com/ublue-os/bling) Module for Startingpoint The `bling` module allows you to easily declare which general parts of `ublue-os/bling` to pull in to your custom image. It requires the `rpms` and `files` directories from the `bling` container to already exist inside `/tmp/bling/` (pulled inside the Containerfile by default). The blingbling to pull in is declared under `install:`, and the code for installing them is all in simple named scripts under the `installers/` directory. The basic code for the `bling` module is very similar to the code of the `script` module. -Example configuration: +## Example configuration: + ```yml type: bling # configure what to pull in from ublue-os/bling install: @@ -16,4 +17,4 @@ install: # - ublue-update # https://github.com/ublue-os/ublue-update # - dconf-update-service # a service unit that updates the dconf db on boot # - devpod # https://devpod.sh/ as an rpm -``` \ No newline at end of file +``` diff --git a/modules/files/README.md b/modules/files/README.md new file mode 100644 index 0000000000..7e1e7d17dd --- /dev/null +++ b/modules/files/README.md @@ -0,0 +1,16 @@ +# `files` Module for Startingpoint + +The `files` module simplifies the process of copying files to the image during the build time. These files are sourced from the `config/files` directory, which is located at `/tmp/config/files` inside the image. + +> **Warning** +> If you want to place anything in `/etc` of the final image, you MUST place them in `/usr/etc` in your repo, so that they're written to `/usr/etc` on the final system. That is the proper directory for "system" configuration templates on immutable Fedora distros, whereas the normal `/etc` is ONLY meant for manual overrides and editing by the machine's admin AFTER installation! See issue https://github.com/ublue-os/startingpoint/issues/28. + +## Example Configuration: + +```yaml +type: files +files: + usr: /usr +``` + +In the example above, `usr` represents the directory located inside the `config/files` in the repository, while `/usr` designates the corresponding destination within the image. diff --git a/modules/files/files.sh b/modules/files/files.sh new file mode 100644 index 0000000000..8320dbc19b --- /dev/null +++ b/modules/files/files.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail + +get_yaml_array FILES '.files[]' "$1" + +cd "$CONFIG_DIRECTORY/files" + +if [[ ${#FILES[@]} -gt 0 ]]; then + echo "Adding files to image" + for pair in "${FILES[@]}"; do + FILE="$PWD/$(echo $pair | yq 'to_entries | .[0].key')" + DEST=$(echo $pair | yq 'to_entries | .[0].value') + if [ -d "$FILE" ]; then + if [ ! -d "$DEST" ]; then + mkdir -p "$DEST" + fi + echo "Copying $FILE to $DEST" + cp -r "$FILE"/* $DEST + elif [ -f "$FILE" ]; then + DEST_DIR=$(dirname "$DEST") + if [ ! -d "$DEST_DIR" ]; then + mkdir -p "$DEST_DIR" + fi + echo "Copying $FILE to $DEST" + cp $FILE $DEST + else + echo "File or Directory $FILE Does Not Exist in $CONFIG_DIRECTORY/files" + exit 1 + fi + done +fi diff --git a/modules/rpm-ostree/README.md b/modules/rpm-ostree/README.md index 469b8ffd36..c1baf5753f 100644 --- a/modules/rpm-ostree/README.md +++ b/modules/rpm-ostree/README.md @@ -1,4 +1,4 @@ -# [`rpm-ostree`](https://coreos.github.io/rpm-ostree/) module for startingpoint +# [`rpm-ostree`](https://coreos.github.io/rpm-ostree/) Module for Startingpoint The `rpm-ostree` module offers pseudo-declarative package and repository management using `rpm-ostree`. @@ -6,14 +6,13 @@ The module first downloads the repository files from repositories declared under Then the module installs the packages declared under `install:` using `rpm-ostree install`, and lastly, it removes the packages declared under `remove:` using `rpm-ostree override remove`. -Unfortunately, currently `rpm-ostree override remove`, and this module, might not be able to remove packages installed in image builds. Packages included by Fedora, such as Firefox can still be removed, though. - Additionally, the `rpm-ostree` module supports a temporary (waiting for `rpm-ostree` issue [#233](https://github.com/coreos/rpm-ostree/issues/233)) fix for packages that install into `/opt/`. Installation for packages that install into folder names declared under `optfix:` are fixed using some symlinks. - -Example configuration: + +## Example Configuration: + ```yml type: rpm-ostree -repos: +repos: - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%OS_VERSION%/atim-starship-fedora-%OS_VERSION%.repo install: - python3-pip @@ -21,4 +20,4 @@ install: remove: - firefox - firefox-langpacks -``` \ No newline at end of file +``` diff --git a/modules/script/README.md b/modules/script/README.md index 0be8b52f25..b2419c50e4 100644 --- a/modules/script/README.md +++ b/modules/script/README.md @@ -1,15 +1,17 @@ -# `script` module for startingpoint +# `script` Module for Startingpoint The `script` module can be used to run arbitrary scripts at image build time that take no or minimal external configuration (in the form of command line arguments). The scripts, which are run from the `config/scripts` directory, are declared under `scripts:`. +## Example Configuration + ```yml type: script scripts: - signing.sh ``` -## Creating a script +## Creating a Script Look at `example.sh` for an example shell script. You can rename and copy the file for your own purposes. In order for the script to be executed, declare it in the recipe @@ -21,4 +23,4 @@ When creating a script, please make sure - ...it starts with a [shebang]() like `#!/usr/bin/env bash`. - This ensures the script is ran with the correct interpreter / shell. - ...it contains the command `set -oue pipefail` near the start. - - This will make the image build fail if your script fails. If you do not care if your script works or not, you can omit this line. \ No newline at end of file + - This will make the image build fail if your script fails. If you do not care if your script works or not, you can omit this line. diff --git a/modules/systemd/README.md b/modules/systemd/README.md new file mode 100644 index 0000000000..4b122b84be --- /dev/null +++ b/modules/systemd/README.md @@ -0,0 +1,41 @@ +# `systemd` Module for Startingpoint + +The `systemd` module streamlines the management of systemd units during image building. Units are divided into `system` and `user` categories, with `system` units managed directly using `systemctl` and `user` units using `systemctl --user`. You can specify which units to enable or disable under each category. + +## Example Configuration: + +```yaml +type: systemd +system: + enable: + - example.service + disable: + - example.target +user: + enable: + - example.timer + disable: + - example.service +``` + +In this example: + +### System Units +- `example.service`: Enabled (runs on system boot) +- `example.target`: Disabled (does not run on system boot) + +### User Units +- `example.timer`: Enabled (runs for the user) +- `example.service`: Disabled (does not run for the user) + +This configuration achieves the same results as the following commands: + +```sh +# System Units +systemctl enable example.service +systemctl disable example.target + +# User Units +systemctl --user enable example.timer +systemctl --user disable example.service +``` diff --git a/modules/systemd/systemd.sh b/modules/systemd/systemd.sh new file mode 100644 index 0000000000..a9aeb5e730 --- /dev/null +++ b/modules/systemd/systemd.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -oue pipefail + +get_yaml_array ENABLED '.system.enabled[]' "$1" +get_yaml_array DISABLED '.system.disabled[]' "$1" +get_yaml_array USER_ENABLED '.user.enabled[]' "$1" +get_yaml_array USER_DISABLED '.user.disabled[]' "$1" + + +if [[ ${#ENABLED[@]} -gt 0 ]]; then + for unit in "${ENABLED[@]}"; do + unit=$(printf "$unit") + systemctl enable $unit + done +fi +if [[ ${#DISABLED[@]} -gt 0 ]]; then + for unit in "${DISABLED[@]}"; do + unit=$(printf "$unit") + systemctl disable $unit + done +fi +if [[ ${#USER_ENABLED[@]} -gt 0 ]]; then + for unit in "${ENABLED[@]}"; do + unit=$(printf "$unit") + systemctl --user enable $unit + done +fi +if [[ ${#USER_DISABLED[@]} -gt 0 ]]; then + for unit in "${DISABLED[@]}"; do + unit=$(printf "$unit") + systemctl --user disable $unit + done +fi diff --git a/modules/yafti/README.md b/modules/yafti/README.md index de318b67f7..a67cf0d95c 100644 --- a/modules/yafti/README.md +++ b/modules/yafti/README.md @@ -1,4 +1,4 @@ -# [`yafti`](https://github.com/ublue-os/yafti) module for startingpoint +# [`yafti`](https://github.com/ublue-os/yafti) Module for Startingpoint If included, the `yafti` module will install `yafti` and set it up to run on first boot. @@ -6,10 +6,11 @@ Optionally, a list of Flatpak names and IDs can be included under `custom-flatpa The main `yafti` configuration file, `yafti.yml`, is in `/usr/share/ublue-os/firstboot/yafti.yml` and can be edited for a more custom first-boot experience. -Example configuration: +## Example configuration: + ```yml type: yafti custom-flatpaks: - Celluloid: io.github.celluloid_player.Celluloid - Krita: org.kde.krita -``` \ No newline at end of file +``` From 3f2ef2846ef8e4a4d53d278a0b60ec16b2f4da10 Mon Sep 17 00:00:00 2001 From: gerblesh <101901964+gerblesh@users.noreply.github.com> Date: Fri, 8 Sep 2023 02:52:10 -0700 Subject: [PATCH 69/79] fix: removed issues in rpm-ostree module and ublue-update bling installer (#144) * fix(rpm-ostree): format string in optfix This fixes optfix and makes the symlink not broken * fix: change rpm-ostreed auto update policy in ublue-update installer --- modules/bling/installers/ublue-update.sh | 12 +++++++++++- modules/rpm-ostree/rpm-ostree.sh | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/bling/installers/ublue-update.sh b/modules/bling/installers/ublue-update.sh index 1fec23fad1..33a1831b87 100644 --- a/modules/bling/installers/ublue-update.sh +++ b/modules/bling/installers/ublue-update.sh @@ -7,4 +7,14 @@ set -oue pipefail if rpm -q ublue-os-update-services > /dev/null; then rpm-ostree override remove ublue-os-update-services fi -rpm-ostree install "$BLING_DIRECTORY"/rpms/ublue-update*.rpm \ No newline at end of file + +# Change the conflicting update policy for rpm-ostreed +RPM_OSTREE_CONFIG="/usr/etc/rpm-ostreed.conf" + +if [[ -f $RPM_OSTREE_CONFIG ]]; then + if [[ "$(get_config_value AutomaticUpdatePolicy $RPM_OSTREE_CONFIG)" == "stage" ]]; then + set_config_value AutomaticUpdatePolicy none $RPM_OSTREE_CONFIG + fi +fi + +rpm-ostree install "$BLING_DIRECTORY"/rpms/ublue-update*.rpm diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index 5c89744c62..c4ee3f78fa 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -24,6 +24,7 @@ if [[ ${#OPTFIX[@]} -gt 0 ]]; then for OPTPKG in "${OPTFIX[@]}"; do OPTPKG="${OPTPKG%\"}" OPTPKG="${OPTPKG#\"}" + OPTPKG=$(printf "$OPTPKG") mkdir -p "/usr/lib/opt/${OPTPKG}" ln -s "../../usr/lib/opt/${OPTPKG}" "/var/opt/${OPTPKG}" echo "Created symlinks for ${OPTPKG}" @@ -54,4 +55,4 @@ elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Removing RPMs" echo "Removing: ${REMOVE_STR[*]}" rpm-ostree override remove ${REMOVE_STR[@]} -fi \ No newline at end of file +fi From b3ddcd885131453e18e63fa07a973787b0b24cd2 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 9 Sep 2023 11:49:42 +0300 Subject: [PATCH 70/79] fix: add .sh suffix for dconf update service inst --- .../installers/{dconf-update-service => dconf-update-service.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename modules/bling/installers/{dconf-update-service => dconf-update-service.sh} (100%) diff --git a/modules/bling/installers/dconf-update-service b/modules/bling/installers/dconf-update-service.sh similarity index 100% rename from modules/bling/installers/dconf-update-service rename to modules/bling/installers/dconf-update-service.sh From 15b3d394b8ff00b1dd9fc331cf45745a5ada402d Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 9 Sep 2023 12:08:20 +0300 Subject: [PATCH 71/79] docs: some docs fixes, better formatting, etc --- Containerfile | 27 ++++++++++++--------------- README.md | 4 ++-- config/README.md | 12 ++++++------ config/recipe.yml | 24 +++++++++--------------- modules/README.md | 3 +++ modules/files/README.md | 2 +- 6 files changed, 33 insertions(+), 39 deletions(-) create mode 100644 modules/README.md diff --git a/Containerfile b/Containerfile index 5ea9284bf3..8ebeab6b53 100644 --- a/Containerfile +++ b/Containerfile @@ -3,42 +3,39 @@ # Instead of adding RUN statements here, you should consider creating a script # in `config/scripts/`. Read more in `modules/script/README.md` -# It takes in the recipe, version, and base image as arguments, +# This Containerfile takes in the recipe, version, and base image as arguments, # all of which are provided by build.yml when doing builds # in the cloud. The ARGs have default values, but changing those # does nothing if the image is built in the cloud. +# !! Warning: changing these might not do anything for you. Read comment above. ARG IMAGE_MAJOR_VERSION=38 -# Warning: changing this might not do anything for you. Read comment above. ARG BASE_IMAGE_URL=ghcr.io/ublue-os/silverblue-main FROM ${BASE_IMAGE_URL}:${IMAGE_MAJOR_VERSION} -# The default recipe set to the recipe's default filename -# so that `podman build` should just work for many people. -ARG RECIPE=recipe.yml - +# The default recipe is set to the recipe's default filename +# so that `podman build` should just work for most people. +ARG RECIPE=recipe.yml # The default image registry to write to policy.json and cosign.yaml ARG IMAGE_REGISTRY=ghcr.io/ublue-os -COPY cosign.pub /usr/share/ublue-os/cosign.pub -COPY config /tmp/config +COPY cosign.pub /usr/share/ublue-os/cosign.pub # Copy the bling from ublue-os/bling into tmp, to be installed later by the bling module # Feel free to remove these lines if you want to speed up image builds and don't want any bling COPY --from=ghcr.io/ublue-os/bling:latest /rpms /tmp/bling/rpms COPY --from=ghcr.io/ublue-os/bling:latest /files /tmp/bling/files -# "yq" used in build.sh and the "setup-flatpaks" just-action to read recipe.yml. -# Copied from the official container image since it's not available as an RPM. -COPY --from=docker.io/mikefarah/yq /usr/bin/yq /usr/bin/yq - -# Copy build script; this is what parses your recipe +# Copy build scripts & configuration COPY build.sh /tmp/build.sh - -# Copy modules to a temporary directory, they'll only to be executed during the build COPY modules /tmp/modules/ +COPY config /tmp/config/ + +# `yq` is used for parsing the yaml configuration +# It is copied from the official container image since it's not available as an RPM. +COPY --from=docker.io/mikefarah/yq /usr/bin/yq /usr/bin/yq # Run the build script, then clean up temp files and finalize container build. RUN chmod +x /tmp/build.sh && /tmp/build.sh && \ diff --git a/README.md b/README.md index f53917efce..631e32d984 100644 --- a/README.md +++ b/README.md @@ -30,12 +30,12 @@ For more information about customization, see [the README in the config director Documentation around making custom images exists / should be written in two separate places: * [The Tinkerer's Guide on the website](https://universal-blue.org/tinker/make-your-own/) for general documentation around making custom images, best practices, tutorials, and so on. -* Inside this repository for documentation specific to the ins and outs of the template, how it works, how to customize it, and some essential guidance on how to make custom images. +* Inside this repository for documentation specific to the ins and outs of the template (like module documentation), and just some essential guidance on how to make custom images. ## Installation > **Warning** -> This is an experimental feature and should not be used in production, try it in a VM for a while! +> [This is an experimental feature](https://www.fedoraproject.org/wiki/Changes/OstreeNativeContainerStable) and should not be used in production, try it in a VM for a while! To rebase an existing Silverblue/Kinoite installation to the latest build: diff --git a/config/README.md b/config/README.md index 42dd6fd6ba..8e99a7030e 100644 --- a/config/README.md +++ b/config/README.md @@ -4,7 +4,7 @@ The main file of your is *the recipe file*. You can have multiple recipe files, ## Basic options -At the top of the recipe, there are four mandatory configuration options. +At the top of the recipe, there are four *mandatory* configuration options. `name:` is the name of the image that is used when rebasing to it. For example, the name "sapphire" would result in the final URL of the container being `ghcr.io//sapphire`. @@ -18,7 +18,7 @@ At the top of the recipe, there are four mandatory configuration options. The core of startingpoint's configuration is built around the idea of modules. Modules are scripts in the [`../modules`](../modules/) directory that you list out under `modules:` in the recipe. They are executed in order, and can run arbitrary shell commands and write any files. -This repository comes with three modules out of the box, [`rpm-ostree`](../modules/rpm-ostree) for pseudo-declarative package management, [`yafti`](../modules/yafti) for installing [yafti](https://github.com/ublue-os/yafti) and easing basic configuration, [`bling`](../modules/bling) for pulling extra components from [`ublue-os/bling`](https://github.com/ublue-os/bling), and [`script`](../modules/script) for running small custom scripts at the build stage, like pulling in configuration or setting up `rpm-ostree` support for proper signing (see [`signing.sh`](./scripts/signing.sh)). +This repository comes with some modules out of the box, like [`rpm-ostree`](../modules/rpm-ostree) for pseudo-declarative package management, [`bling`](../modules/bling) for pulling extra components from [`ublue-os/bling`](https://github.com/ublue-os/bling), and [`files`](../modules/files) for copying files from the `config/files/` directory into your image. For more in-depth documentation on each module, check out the README.md files in each module folder. @@ -34,17 +34,17 @@ modules: ### Making modules -If you want to extend startingpoint with custom functionality that requires configuration, you should create a module. Modules are scripts in the subdirectories of the [`../modules`](../modules/) directory. The `type:` key in the recipe.yml should be used as both the name of the folder and script, with the script having an additional `.sh` suffix. +If you want to extend Startingpoint with custom functionality that requires configuration, you should create a module. Modules are scripts in the subdirectories of the [`../modules`](../modules/) directory. The `type:` key in the recipe.yml should be used as both the name of the folder and script, with the script having an additional `.sh` suffix. Each module intended for public usage should include a `README.md` file inside it's directory with a short description of the module and documentation for each configuration option. Modules get only the configuration options given to them in the recipe.yml, not the configuration of other modules or any top-level keys. The configuration is given as the first argument as a single-line json string. You can check out the default modules for examples on how to parse such string using `yq` or `jq`. -Additionally, each module has access to four environment variables, `CONFIG_DIRECTORY` pointing to the startingpoint directory in `/usr/share/ublue-os/`, `IMAGE_NAME` being the name of the image as declared in the recipe, `BASE_IMAGE` being the URL of the container image used as the base (FROM) in the image, and `OS_VERSION` being the `VERSION_ID` from `/usr/lib/os-release`. +Additionally, each module has access to four environment variables, `CONFIG_DIRECTORY` pointing to the Startingpoint directory in `/usr/share/ublue-os/`, `IMAGE_NAME` being the name of the image as declared in the recipe, `BASE_IMAGE` being the URL of the container image used as the base (FROM) in the image, and `OS_VERSION` being the `VERSION_ID` from `/usr/lib/os-release`. -A helper bash function called `get_yaml_array` is exported from the main build script. Syntax: +A helper bash function called `get_yaml_array` is exported from the main build script. ```bash -# "$1" read from the first cli argument, being the module configuration. +# "$1" is the first cli argument, being the module configuration. # If you need to read from some other JSON string, just replace "$1" with "$VARNAME". get_yaml_array OUTPUT_VAR_NAME '.yq.key.to.array[]' "$1" for THING in "${OUTPUT_VAR_NAME[@]}"; do diff --git a/config/recipe.yml b/config/recipe.yml index 8e70381a84..1533f85103 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -7,21 +7,16 @@ description: A starting point for further customization of uBlue images. Make yo base-image: ghcr.io/ublue-os/silverblue-main image-version: 38 # latest is also supported if you want new updates ASAP -# list of modules that will be executed in order - -# you can include multiple of the same module - +# list of modules, executed in order +# you can include multiple instancesof the same module modules: + - type: files files: - - usr: /usr - # Copy static configurations and component files. - # Warning: If you want to place anything in "/etc" of the final image, you MUST - # place them in "./usr/etc" in your repo, so that they're written to "/usr/etc" - # on the final system. That is the proper directory for "system" configuration - # templates on immutable Fedora distros, whereas the normal "/etc" is ONLY meant - # for manual overrides and editing by the machine's admin AFTER installation! - # See issue #28 (https://github.com/ublue-os/startingpoint/issues/28). + - usr: /usr # copy static configurations + # configuration you wish to end up in /etc/ on the booted system should be + # added into /usr/etc/ as that is the proper "distro" config directory on ostree + # read more in the files module's README - type: rpm-ostree repos: @@ -47,11 +42,10 @@ modules: - type: yafti # if included, https://github.com/ublue-os/yafti will be installed and set up custom-flatpaks: # this section is optional - - Celluloid: io.github.celluloid_player.Celluloid - - Krita: org.kde.krita + # - Celluloid: io.github.celluloid_player.Celluloid + # - Krita: org.kde.krita - type: script scripts: # this sets up the proper policy & signing files for signed images to work - signing.sh - diff --git a/modules/README.md b/modules/README.md new file mode 100644 index 0000000000..3910e923c3 --- /dev/null +++ b/modules/README.md @@ -0,0 +1,3 @@ +# Modules + +This directory includes all the different modules for Startingpoint. Refer to the README files inside each module's corresponding directory for in-depth documentation, and the README inside `config/` for more general documentation. \ No newline at end of file diff --git a/modules/files/README.md b/modules/files/README.md index 7e1e7d17dd..20cf75dcc5 100644 --- a/modules/files/README.md +++ b/modules/files/README.md @@ -3,7 +3,7 @@ The `files` module simplifies the process of copying files to the image during the build time. These files are sourced from the `config/files` directory, which is located at `/tmp/config/files` inside the image. > **Warning** -> If you want to place anything in `/etc` of the final image, you MUST place them in `/usr/etc` in your repo, so that they're written to `/usr/etc` on the final system. That is the proper directory for "system" configuration templates on immutable Fedora distros, whereas the normal `/etc` is ONLY meant for manual overrides and editing by the machine's admin AFTER installation! See issue https://github.com/ublue-os/startingpoint/issues/28. +> If you want to place anything in `/etc` of the final image, you MUST place them in `/usr/etc` in your repo, so that they're written to `/usr/etc` on the final system. That is the proper directory for "system" configuration templates on immutable Fedora distros, whereas the normal `/etc` is meant for manual overrides and editing by the machine's admin AFTER installation! See issue https://github.com/ublue-os/startingpoint/issues/28. ## Example Configuration: From 61ed4839f5e1bcdf97893f2899bdbe13b2f29db5 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 9 Sep 2023 12:14:58 +0300 Subject: [PATCH 72/79] feat: yafti module installs yafti deps --- config/recipe.yml | 7 ++++--- modules/yafti/yafti.sh | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/config/recipe.yml b/config/recipe.yml index 1533f85103..7931fd848e 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -22,8 +22,8 @@ modules: repos: # - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%OS_VERSION%/atim-starship-fedora-%OS_VERSION%.repo install: - - python3-pip # required for yafti - - libadwaita # required for yafti + # - micro + # - starship remove: - firefox # default firefox removed in favor of flatpak - firefox-langpacks # langpacks needs to also be removed to prevent dependency problems @@ -40,7 +40,8 @@ modules: # - devpod # https://devpod.sh/ as an rpm - - type: yafti # if included, https://github.com/ublue-os/yafti will be installed and set up + - type: yafti # if included, yafti and it's dependencies (pip & libadwaita) + # will be installed and set up custom-flatpaks: # this section is optional # - Celluloid: io.github.celluloid_player.Celluloid # - Krita: org.kde.krita diff --git a/modules/yafti/yafti.sh b/modules/yafti/yafti.sh index cf3e475de4..4625120c1c 100644 --- a/modules/yafti/yafti.sh +++ b/modules/yafti/yafti.sh @@ -6,6 +6,9 @@ set -oue pipefail FIRSTBOOT_DATA="/usr/share/ublue-os/firstboot" FIRSTBOOT_LINK="/usr/etc/profile.d/ublue-firstboot.sh" +echo "Installing python3-pip and libadwaita" +rpm-ostree install python3-pip libadwaita + echo "Installing and enabling yafti" pip install --prefix=/usr yafti From dcefa76cb29fcbda26d5a3ec5c3e1e12fe579d78 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 9 Sep 2023 12:36:34 +0300 Subject: [PATCH 73/79] docs: missing space --- config/recipe.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/recipe.yml b/config/recipe.yml index 7931fd848e..90d4cb16fa 100644 --- a/config/recipe.yml +++ b/config/recipe.yml @@ -8,7 +8,7 @@ base-image: ghcr.io/ublue-os/silverblue-main image-version: 38 # latest is also supported if you want new updates ASAP # list of modules, executed in order -# you can include multiple instancesof the same module +# you can include multiple instances of the same module modules: - type: files From c3bc555ff4673a61588778e2d453332873f7191d Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 9 Sep 2023 12:41:14 +0300 Subject: [PATCH 74/79] feat: enable dconf update service in installer --- modules/bling/installers/dconf-update-service.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/bling/installers/dconf-update-service.sh b/modules/bling/installers/dconf-update-service.sh index 25aa0c78f4..d03e29946f 100644 --- a/modules/bling/installers/dconf-update-service.sh +++ b/modules/bling/installers/dconf-update-service.sh @@ -3,4 +3,5 @@ # Tell build process to exit if there are any errors. set -oue pipefail -cp -r "$BLING_DIRECTORY/files/usr/etc/systemd/system/dconf-update.service" "/usr/etc/systemd/system/dconf-update.service" \ No newline at end of file +cp -r "$BLING_DIRECTORY/files/usr/etc/systemd/system/dconf-update.service" "/usr/etc/systemd/system/dconf-update.service" +systemctl enable dconf-update.services \ No newline at end of file From c10f7e7a98cab61375355c2b84c9bfac6c55281d Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 9 Sep 2023 13:02:34 +0300 Subject: [PATCH 75/79] docs: mention depsolve & more info in walkthrough --- modules/rpm-ostree/README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/rpm-ostree/README.md b/modules/rpm-ostree/README.md index c1baf5753f..fd51263640 100644 --- a/modules/rpm-ostree/README.md +++ b/modules/rpm-ostree/README.md @@ -4,7 +4,7 @@ The `rpm-ostree` module offers pseudo-declarative package and repository managem The module first downloads the repository files from repositories declared under `repos:` into `/etc/yum.repos.d/`. The magic string `%OS_VERSION%` is substituted with the current VERSION_ID (major Fedora version), which can be used, for example, for pulling correct versions of repositories from [Fedora's Copr](https://copr.fedorainfracloud.org/). -Then the module installs the packages declared under `install:` using `rpm-ostree install`, and lastly, it removes the packages declared under `remove:` using `rpm-ostree override remove`. +Then the module installs the packages declared under `install:` using `rpm-ostree install`, it removes the packages declared under `remove:` using `rpm-ostree override remove`. If there are packages declared under both `install:` and `remove:` a hybrid command `rpm-ostree remove --install ` is used, which should allow you to switch required packages for other ones. Additionally, the `rpm-ostree` module supports a temporary (waiting for `rpm-ostree` issue [#233](https://github.com/coreos/rpm-ostree/issues/233)) fix for packages that install into `/opt/`. Installation for packages that install into folder names declared under `optfix:` are fixed using some symlinks. @@ -21,3 +21,13 @@ remove: - firefox - firefox-langpacks ``` + + +## Known issues + +When removing certain packages, some problem probably in upstream `rpm-ostree` causes a `depsolve` issue similar to below. [Removed packages are still present in the underlying ostree repository](https://coreos.github.io/rpm-ostree/administrator-handbook/#removing-a-base-package), what `remove` does is "hide" them from the system, it doesn't reclaim disk space. +``` +Resolving dependencies...done +error: Could not depsolve transaction; 1 problem detected: +Problem: conflicting requests +``` \ No newline at end of file From 311dfe2860f44cd2b686ff3e3db6c763a082ae36 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 9 Sep 2023 13:05:54 +0300 Subject: [PATCH 76/79] chore: don't use _STR like array --- modules/rpm-ostree/rpm-ostree.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh index c4ee3f78fa..995904f404 100644 --- a/modules/rpm-ostree/rpm-ostree.sh +++ b/modules/rpm-ostree/rpm-ostree.sh @@ -46,13 +46,13 @@ if [[ ${#INSTALL[@]} -gt 0 && ${#REMOVE[@]} -gt 0 ]]; then echo "Installing: ${INSTALL_STR[*]}" echo "Removing: ${REMOVE_STR[*]}" # Doing both actions in one command allows for replacing required packages with alternatives - rpm-ostree override remove ${REMOVE_STR[@]} $(printf -- "--install=%s " ${INSTALL_STR[@]}) + rpm-ostree override remove $REMOVE_STR $(printf -- "--install=%s " $INSTALL_STR) elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Installing RPMs" echo "Installing: ${INSTALL_STR[*]}" - rpm-ostree install ${INSTALL_STR[@]} + rpm-ostree install $INSTALL_STR elif [[ ${#INSTALL[@]} -gt 0 ]]; then echo "Removing RPMs" echo "Removing: ${REMOVE_STR[*]}" - rpm-ostree override remove ${REMOVE_STR[@]} + rpm-ostree override remove $REMOVE_STR fi From b4d1d0d04333e4dd47e4071f6d56c6a20fb0aecf Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 9 Sep 2023 14:15:06 +0300 Subject: [PATCH 77/79] docs: add notice of rewrite --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 631e32d984..418d1613f9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # Starting point +> **Warning** +> Startingpoint was recently rewritten, and this version is considered a "1.0" *semi-*stable release. +> There are breaking changes between this and the previous version. +> If you are merging changes from the previous (v0) version, please refer to [the heads-up blog post](https://universal-blue.org/blog/2023/09/02/startingpoint-rewrite-heads-up-what-you-need-to-know/). + [![build-ublue](https://github.com/ublue-os/startingpoint/actions/workflows/build.yml/badge.svg)](https://github.com/ublue-os/startingpoint/actions/workflows/build.yml) This is a constantly updating template repository for creating [a native container image](https://fedoraproject.org/wiki/Changes/OstreeNativeContainerStable) designed to be customized however you want. GitHub will build your image for you, and then host it for you on [ghcr.io](https://github.com/features/packages). You then just tell your computer to boot off of that image. GitHub keeps 90 days worth image backups for you, thanks Microsoft! From 393d54ec8e5fe0c4d3ec14a1151012198b51f0a3 Mon Sep 17 00:00:00 2001 From: ER Date: Sat, 9 Sep 2023 14:18:29 +0300 Subject: [PATCH 78/79] docs: point reader toward discovering new features --- config/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/README.md b/config/README.md index 8e99a7030e..ceceb71f7f 100644 --- a/config/README.md +++ b/config/README.md @@ -18,7 +18,7 @@ At the top of the recipe, there are four *mandatory* configuration options. The core of startingpoint's configuration is built around the idea of modules. Modules are scripts in the [`../modules`](../modules/) directory that you list out under `modules:` in the recipe. They are executed in order, and can run arbitrary shell commands and write any files. -This repository comes with some modules out of the box, like [`rpm-ostree`](../modules/rpm-ostree) for pseudo-declarative package management, [`bling`](../modules/bling) for pulling extra components from [`ublue-os/bling`](https://github.com/ublue-os/bling), and [`files`](../modules/files) for copying files from the `config/files/` directory into your image. +This repository comes with some modules out of the box, like [`rpm-ostree`](../modules/rpm-ostree) for pseudo-declarative package management, [`bling`](../modules/bling) for pulling extra components from [`ublue-os/bling`](https://github.com/ublue-os/bling), and [`files`](../modules/files) for copying files from the `config/files/` directory into your image. For a comprehensive list of modules, check out [the modules directory](../modules/). For more in-depth documentation on each module, check out the README.md files in each module folder. From 4e0095bc965a8b2e9b74d1580fcc9e84aab24341 Mon Sep 17 00:00:00 2001 From: ER Date: Sun, 10 Sep 2023 17:31:25 +0300 Subject: [PATCH 79/79] refactor: fetch modules from bling --- Containerfile | 7 ++- config/README.md | 30 +--------- modules/README.md | 26 ++++++++- modules/bling/README.md | 20 ------- modules/bling/bling.sh | 19 ------ .../bling/installers/dconf-update-service.sh | 7 --- modules/bling/installers/devpod.sh | 6 -- modules/bling/installers/fonts.sh | 6 -- modules/bling/installers/justfiles.sh | 6 -- modules/bling/installers/nix-installer.sh | 7 --- .../bling/installers/ublue-os-wallpapers.sh | 6 -- modules/bling/installers/ublue-update.sh | 20 ------- modules/files/README.md | 16 ----- modules/files/files.sh | 33 ----------- modules/rpm-ostree/README.md | 33 ----------- modules/rpm-ostree/rpm-ostree.sh | 58 ------------------- modules/script/README.md | 26 --------- modules/script/script.sh | 16 ----- modules/systemd/README.md | 41 ------------- modules/systemd/systemd.sh | 35 ----------- modules/yafti/README.md | 16 ----- modules/yafti/yafti.sh | 31 ---------- 22 files changed, 31 insertions(+), 434 deletions(-) delete mode 100644 modules/bling/README.md delete mode 100644 modules/bling/bling.sh delete mode 100644 modules/bling/installers/dconf-update-service.sh delete mode 100644 modules/bling/installers/devpod.sh delete mode 100644 modules/bling/installers/fonts.sh delete mode 100644 modules/bling/installers/justfiles.sh delete mode 100644 modules/bling/installers/nix-installer.sh delete mode 100644 modules/bling/installers/ublue-os-wallpapers.sh delete mode 100644 modules/bling/installers/ublue-update.sh delete mode 100644 modules/files/README.md delete mode 100644 modules/files/files.sh delete mode 100644 modules/rpm-ostree/README.md delete mode 100644 modules/rpm-ostree/rpm-ostree.sh delete mode 100644 modules/script/README.md delete mode 100644 modules/script/script.sh delete mode 100644 modules/systemd/README.md delete mode 100644 modules/systemd/systemd.sh delete mode 100644 modules/yafti/README.md delete mode 100644 modules/yafti/yafti.sh diff --git a/Containerfile b/Containerfile index 8ebeab6b53..084869aa1e 100644 --- a/Containerfile +++ b/Containerfile @@ -30,9 +30,14 @@ COPY --from=ghcr.io/ublue-os/bling:latest /files /tmp/bling/files # Copy build scripts & configuration COPY build.sh /tmp/build.sh -COPY modules /tmp/modules/ COPY config /tmp/config/ +# Copy modules +# The default modules are inside ublue-os/bling +COPY --from=ghcr.io/ublue-os/bling:latest /modules /tmp/modules/ +# Custom modules overwrite defaults +COPY modules /tmp/modules/ + # `yq` is used for parsing the yaml configuration # It is copied from the official container image since it's not available as an RPM. COPY --from=docker.io/mikefarah/yq /usr/bin/yq /usr/bin/yq diff --git a/config/README.md b/config/README.md index ceceb71f7f..1e07befff2 100644 --- a/config/README.md +++ b/config/README.md @@ -18,9 +18,7 @@ At the top of the recipe, there are four *mandatory* configuration options. The core of startingpoint's configuration is built around the idea of modules. Modules are scripts in the [`../modules`](../modules/) directory that you list out under `modules:` in the recipe. They are executed in order, and can run arbitrary shell commands and write any files. -This repository comes with some modules out of the box, like [`rpm-ostree`](../modules/rpm-ostree) for pseudo-declarative package management, [`bling`](../modules/bling) for pulling extra components from [`ublue-os/bling`](https://github.com/ublue-os/bling), and [`files`](../modules/files) for copying files from the `config/files/` directory into your image. For a comprehensive list of modules, check out [the modules directory](../modules/). - -For more in-depth documentation on each module, check out the README.md files in each module folder. +This repository fetches some useful default modules from [`ublue-os/bling`](https://github.com/ublue-os/bling/), like [`rpm-ostree`](../modules/rpm-ostree) for pseudo-declarative package management, [`bling`](../modules/bling) for pulling extra components from [`ublue-os/bling`](https://github.com/ublue-os/bling), and [`files`](../modules/files) for copying files from the `config/files/` directory into your image. For a comprehensive list of modules and their in-depth documentation, check out [the modules page on the website](https://universal-blue.org/tinker/modules/). ### Including modules from other files and building multiple images @@ -30,30 +28,4 @@ Module configuration can be included from other files using the `from-file` synt ```yml modules: - from-file: common-packages.yml -``` - -### Making modules - -If you want to extend Startingpoint with custom functionality that requires configuration, you should create a module. Modules are scripts in the subdirectories of the [`../modules`](../modules/) directory. The `type:` key in the recipe.yml should be used as both the name of the folder and script, with the script having an additional `.sh` suffix. - -Each module intended for public usage should include a `README.md` file inside it's directory with a short description of the module and documentation for each configuration option. - -Modules get only the configuration options given to them in the recipe.yml, not the configuration of other modules or any top-level keys. The configuration is given as the first argument as a single-line json string. You can check out the default modules for examples on how to parse such string using `yq` or `jq`. - -Additionally, each module has access to four environment variables, `CONFIG_DIRECTORY` pointing to the Startingpoint directory in `/usr/share/ublue-os/`, `IMAGE_NAME` being the name of the image as declared in the recipe, `BASE_IMAGE` being the URL of the container image used as the base (FROM) in the image, and `OS_VERSION` being the `VERSION_ID` from `/usr/lib/os-release`. - -A helper bash function called `get_yaml_array` is exported from the main build script. -```bash -# "$1" is the first cli argument, being the module configuration. -# If you need to read from some other JSON string, just replace "$1" with "$VARNAME". -get_yaml_array OUTPUT_VAR_NAME '.yq.key.to.array[]' "$1" -for THING in "${OUTPUT_VAR_NAME[@]}"; do - echo "$THING" -done -``` - -All bash-based modules should start with the following lines to ensure the image builds fail on errors, and that the correct shell is used to run them. -```bash -#!/usr/bin/env bash -set -oue pipefail ``` \ No newline at end of file diff --git a/modules/README.md b/modules/README.md index 3910e923c3..fc9113a41a 100644 --- a/modules/README.md +++ b/modules/README.md @@ -1,3 +1,25 @@ -# Modules +# Making modules -This directory includes all the different modules for Startingpoint. Refer to the README files inside each module's corresponding directory for in-depth documentation, and the README inside `config/` for more general documentation. \ No newline at end of file +If you want to extend Startingpoint with custom functionality that requires configuration, you should create a module. Modules are scripts in the subdirectories of this directory. The `type:` key in the recipe.yml should be used as both the name of the folder and script, with the script having an additional `.sh` suffix. Creating a custom module with the same name as a default module will override it. + +Each module intended for public usage should include a `README.md` file inside it's directory with a short description of the module and documentation for each configuration option. + +Modules get only the configuration options given to them in the recipe.yml, not the configuration of other modules or any top-level keys. The configuration is given as the first argument as a single-line json string. You can check out the default modules for examples on how to parse such string using `yq` or `jq`. + +Additionally, each module has access to four environment variables, `CONFIG_DIRECTORY` pointing to the Startingpoint directory in `/usr/share/ublue-os/`, `IMAGE_NAME` being the name of the image as declared in the recipe, `BASE_IMAGE` being the URL of the container image used as the base (FROM) in the image, and `OS_VERSION` being the `VERSION_ID` from `/usr/lib/os-release`. + +A helper bash function called `get_yaml_array` is exported from the main build script. +```bash +# "$1" is the first cli argument, being the module configuration. +# If you need to read from some other JSON string, just replace "$1" with "$VARNAME". +get_yaml_array OUTPUT_VAR_NAME '.yq.key.to.array[]' "$1" +for THING in "${OUTPUT_VAR_NAME[@]}"; do + echo "$THING" +done +``` + +All bash-based modules should start with the following lines to ensure the image builds fail on errors, and that the correct shell is used to run them. +```bash +#!/usr/bin/env bash +set -oue pipefail +``` \ No newline at end of file diff --git a/modules/bling/README.md b/modules/bling/README.md deleted file mode 100644 index c76fa71c6f..0000000000 --- a/modules/bling/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# [`bling`](https://github.com/ublue-os/bling) Module for Startingpoint - -The `bling` module allows you to easily declare which general parts of `ublue-os/bling` to pull in to your custom image. It requires the `rpms` and `files` directories from the `bling` container to already exist inside `/tmp/bling/` (pulled inside the Containerfile by default). - -The blingbling to pull in is declared under `install:`, and the code for installing them is all in simple named scripts under the `installers/` directory. The basic code for the `bling` module is very similar to the code of the `script` module. - -## Example configuration: - -```yml -type: bling # configure what to pull in from ublue-os/bling -install: - - fonts # selection of common good free fonts - - justfiles # add "!include /usr/share/ublue-os/just/bling.just" - # in your custom.just (added by default) or local justfile - - nix-installer # these are the silverblue nix installer scripts from dnkmmr69420 - - ublue-os-wallpapers - # - ublue-update # https://github.com/ublue-os/ublue-update - # - dconf-update-service # a service unit that updates the dconf db on boot - # - devpod # https://devpod.sh/ as an rpm -``` diff --git a/modules/bling/bling.sh b/modules/bling/bling.sh deleted file mode 100644 index 053a0e2342..0000000000 --- a/modules/bling/bling.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -# Tell build process to exit if there are any errors. -set -oue pipefail - -get_yaml_array INSTALL '.install[]' "$1" - -export BLING_DIRECTORY="/tmp/bling" - -cd "/tmp/modules/bling/installers" - -# Make every bling installer executable -find "$PWD" -type f -exec chmod +x {} \; - -for ITEM in "${INSTALL[@]}"; do - echo "Pulling from bling: $ITEM" - # The trainling newline from $ITEM is removed - eval "$PWD/${ITEM%$'\n'}.sh" -done \ No newline at end of file diff --git a/modules/bling/installers/dconf-update-service.sh b/modules/bling/installers/dconf-update-service.sh deleted file mode 100644 index d03e29946f..0000000000 --- a/modules/bling/installers/dconf-update-service.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -# Tell build process to exit if there are any errors. -set -oue pipefail - -cp -r "$BLING_DIRECTORY/files/usr/etc/systemd/system/dconf-update.service" "/usr/etc/systemd/system/dconf-update.service" -systemctl enable dconf-update.services \ No newline at end of file diff --git a/modules/bling/installers/devpod.sh b/modules/bling/installers/devpod.sh deleted file mode 100644 index 9bb86993ed..0000000000 --- a/modules/bling/installers/devpod.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# Tell build process to exit if there are any errors. -set -oue pipefail - -rpm-ostree install "$BLING_DIRECTORY"/rpms/devpod*.rpm \ No newline at end of file diff --git a/modules/bling/installers/fonts.sh b/modules/bling/installers/fonts.sh deleted file mode 100644 index dda91f7747..0000000000 --- a/modules/bling/installers/fonts.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# Tell build process to exit if there are any errors. -set -oue pipefail - -cp -r "$BLING_DIRECTORY"/files/usr/share/fonts/* "/usr/share/fonts" \ No newline at end of file diff --git a/modules/bling/installers/justfiles.sh b/modules/bling/installers/justfiles.sh deleted file mode 100644 index d976305981..0000000000 --- a/modules/bling/installers/justfiles.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# Tell build process to exit if there are any errors. -set -oue pipefail - -cp -r "$BLING_DIRECTORY"/files/usr/share/ublue-os/just/* "/usr/share/ublue-os/just" \ No newline at end of file diff --git a/modules/bling/installers/nix-installer.sh b/modules/bling/installers/nix-installer.sh deleted file mode 100644 index 9f678ac360..0000000000 --- a/modules/bling/installers/nix-installer.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -# Tell build process to exit if there are any errors. -set -oue pipefail - -cp "$BLING_DIRECTORY/files/usr/bin/ublue-nix-install" "/usr/bin/ublue-nix-install" -cp "$BLING_DIRECTORY/files/usr/bin/ublue-nix-uninstall" "/usr/bin/ublue-nix-uninstall" \ No newline at end of file diff --git a/modules/bling/installers/ublue-os-wallpapers.sh b/modules/bling/installers/ublue-os-wallpapers.sh deleted file mode 100644 index 6598bb7d54..0000000000 --- a/modules/bling/installers/ublue-os-wallpapers.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# Tell build process to exit if there are any errors. -set -oue pipefail - -rpm-ostree install "$BLING_DIRECTORY"/rpms/ublue-os-wallpapers*.rpm \ No newline at end of file diff --git a/modules/bling/installers/ublue-update.sh b/modules/bling/installers/ublue-update.sh deleted file mode 100644 index 33a1831b87..0000000000 --- a/modules/bling/installers/ublue-update.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -# Tell build process to exit if there are any errors. -set -oue pipefail - -# Check if ublue-os-update-services rpm is installed, these services conflict with ublue-update -if rpm -q ublue-os-update-services > /dev/null; then - rpm-ostree override remove ublue-os-update-services -fi - -# Change the conflicting update policy for rpm-ostreed -RPM_OSTREE_CONFIG="/usr/etc/rpm-ostreed.conf" - -if [[ -f $RPM_OSTREE_CONFIG ]]; then - if [[ "$(get_config_value AutomaticUpdatePolicy $RPM_OSTREE_CONFIG)" == "stage" ]]; then - set_config_value AutomaticUpdatePolicy none $RPM_OSTREE_CONFIG - fi -fi - -rpm-ostree install "$BLING_DIRECTORY"/rpms/ublue-update*.rpm diff --git a/modules/files/README.md b/modules/files/README.md deleted file mode 100644 index 20cf75dcc5..0000000000 --- a/modules/files/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# `files` Module for Startingpoint - -The `files` module simplifies the process of copying files to the image during the build time. These files are sourced from the `config/files` directory, which is located at `/tmp/config/files` inside the image. - -> **Warning** -> If you want to place anything in `/etc` of the final image, you MUST place them in `/usr/etc` in your repo, so that they're written to `/usr/etc` on the final system. That is the proper directory for "system" configuration templates on immutable Fedora distros, whereas the normal `/etc` is meant for manual overrides and editing by the machine's admin AFTER installation! See issue https://github.com/ublue-os/startingpoint/issues/28. - -## Example Configuration: - -```yaml -type: files -files: - usr: /usr -``` - -In the example above, `usr` represents the directory located inside the `config/files` in the repository, while `/usr` designates the corresponding destination within the image. diff --git a/modules/files/files.sh b/modules/files/files.sh deleted file mode 100644 index 8320dbc19b..0000000000 --- a/modules/files/files.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -# Tell build process to exit if there are any errors. -set -oue pipefail - -get_yaml_array FILES '.files[]' "$1" - -cd "$CONFIG_DIRECTORY/files" - -if [[ ${#FILES[@]} -gt 0 ]]; then - echo "Adding files to image" - for pair in "${FILES[@]}"; do - FILE="$PWD/$(echo $pair | yq 'to_entries | .[0].key')" - DEST=$(echo $pair | yq 'to_entries | .[0].value') - if [ -d "$FILE" ]; then - if [ ! -d "$DEST" ]; then - mkdir -p "$DEST" - fi - echo "Copying $FILE to $DEST" - cp -r "$FILE"/* $DEST - elif [ -f "$FILE" ]; then - DEST_DIR=$(dirname "$DEST") - if [ ! -d "$DEST_DIR" ]; then - mkdir -p "$DEST_DIR" - fi - echo "Copying $FILE to $DEST" - cp $FILE $DEST - else - echo "File or Directory $FILE Does Not Exist in $CONFIG_DIRECTORY/files" - exit 1 - fi - done -fi diff --git a/modules/rpm-ostree/README.md b/modules/rpm-ostree/README.md deleted file mode 100644 index fd51263640..0000000000 --- a/modules/rpm-ostree/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# [`rpm-ostree`](https://coreos.github.io/rpm-ostree/) Module for Startingpoint - -The `rpm-ostree` module offers pseudo-declarative package and repository management using `rpm-ostree`. - -The module first downloads the repository files from repositories declared under `repos:` into `/etc/yum.repos.d/`. The magic string `%OS_VERSION%` is substituted with the current VERSION_ID (major Fedora version), which can be used, for example, for pulling correct versions of repositories from [Fedora's Copr](https://copr.fedorainfracloud.org/). - -Then the module installs the packages declared under `install:` using `rpm-ostree install`, it removes the packages declared under `remove:` using `rpm-ostree override remove`. If there are packages declared under both `install:` and `remove:` a hybrid command `rpm-ostree remove --install ` is used, which should allow you to switch required packages for other ones. - -Additionally, the `rpm-ostree` module supports a temporary (waiting for `rpm-ostree` issue [#233](https://github.com/coreos/rpm-ostree/issues/233)) fix for packages that install into `/opt/`. Installation for packages that install into folder names declared under `optfix:` are fixed using some symlinks. - -## Example Configuration: - -```yml -type: rpm-ostree -repos: - - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%OS_VERSION%/atim-starship-fedora-%OS_VERSION%.repo -install: - - python3-pip - - libadwaita -remove: - - firefox - - firefox-langpacks -``` - - -## Known issues - -When removing certain packages, some problem probably in upstream `rpm-ostree` causes a `depsolve` issue similar to below. [Removed packages are still present in the underlying ostree repository](https://coreos.github.io/rpm-ostree/administrator-handbook/#removing-a-base-package), what `remove` does is "hide" them from the system, it doesn't reclaim disk space. -``` -Resolving dependencies...done -error: Could not depsolve transaction; 1 problem detected: -Problem: conflicting requests -``` \ No newline at end of file diff --git a/modules/rpm-ostree/rpm-ostree.sh b/modules/rpm-ostree/rpm-ostree.sh deleted file mode 100644 index 995904f404..0000000000 --- a/modules/rpm-ostree/rpm-ostree.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash - -# Tell build process to exit if there are any errors. -set -oue pipefail - -# Pull in repos -get_yaml_array REPOS '.repos[]' "$1" -if [[ ${#REPOS[@]} -gt 0 ]]; then - echo "Adding repositories" - for REPO in "${REPOS[@]}"; do - REPO="${REPO//%OS_VERSION%/${OS_VERSION}}" - wget "${REPO//[$'\t\r\n ']}" -P "/etc/yum.repos.d/" - done -fi - -# Create symlinks to fix packages that create directories in /opt -get_yaml_array OPTFIX '.optfix[]' "$1" -if [[ ${#OPTFIX[@]} -gt 0 ]]; then - echo "Creating symlinks to fix packages that install to /opt" - # Create symlink for /opt to /var/opt since it is not created in the image yet - mkdir -p "/var/opt" - ln -s "/var/opt" "/opt" - # Create symlinks for each directory specified in recipe.yml - for OPTPKG in "${OPTFIX[@]}"; do - OPTPKG="${OPTPKG%\"}" - OPTPKG="${OPTPKG#\"}" - OPTPKG=$(printf "$OPTPKG") - mkdir -p "/usr/lib/opt/${OPTPKG}" - ln -s "../../usr/lib/opt/${OPTPKG}" "/var/opt/${OPTPKG}" - echo "Created symlinks for ${OPTPKG}" - done -fi - -get_yaml_array INSTALL '.install[]' "$1" -get_yaml_array REMOVE '.remove[]' "$1" - -# The installation is done with some wordsplitting hacks -# because of errors when doing array destructuring at the installation step. -# This is different from other ublue projects and could be investigated further. -INSTALL_STR=$(echo "${INSTALL[*]}" | tr -d '\n') -REMOVE_STR=$(echo "${REMOVE[*]}" | tr -d '\n') - -# Install and remove RPM packages -if [[ ${#INSTALL[@]} -gt 0 && ${#REMOVE[@]} -gt 0 ]]; then - echo "Installing & Removing RPMs" - echo "Installing: ${INSTALL_STR[*]}" - echo "Removing: ${REMOVE_STR[*]}" - # Doing both actions in one command allows for replacing required packages with alternatives - rpm-ostree override remove $REMOVE_STR $(printf -- "--install=%s " $INSTALL_STR) -elif [[ ${#INSTALL[@]} -gt 0 ]]; then - echo "Installing RPMs" - echo "Installing: ${INSTALL_STR[*]}" - rpm-ostree install $INSTALL_STR -elif [[ ${#INSTALL[@]} -gt 0 ]]; then - echo "Removing RPMs" - echo "Removing: ${REMOVE_STR[*]}" - rpm-ostree override remove $REMOVE_STR -fi diff --git a/modules/script/README.md b/modules/script/README.md deleted file mode 100644 index b2419c50e4..0000000000 --- a/modules/script/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# `script` Module for Startingpoint - -The `script` module can be used to run arbitrary scripts at image build time that take no or minimal external configuration (in the form of command line arguments). -The scripts, which are run from the `config/scripts` directory, are declared under `scripts:`. - -## Example Configuration - -```yml -type: script -scripts: - - signing.sh -``` - -## Creating a Script - -Look at `example.sh` for an example shell script. You can rename and copy the file for your own purposes. In order for the script to be executed, declare it in the recipe - -When creating a script, please make sure - -- ...its filename ends with `.sh`. - - This follows convention for (especially bash) shell scripts. - - `autorun.sh` only executes files that match `*.sh`. -- ...it starts with a [shebang]() like `#!/usr/bin/env bash`. - - This ensures the script is ran with the correct interpreter / shell. -- ...it contains the command `set -oue pipefail` near the start. - - This will make the image build fail if your script fails. If you do not care if your script works or not, you can omit this line. diff --git a/modules/script/script.sh b/modules/script/script.sh deleted file mode 100644 index fe63e0f0d1..0000000000 --- a/modules/script/script.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -# Tell build process to exit if there are any errors. -set -oue pipefail - -get_yaml_array SCRIPTS '.scripts[]' "$1" - -cd "$CONFIG_DIRECTORY/scripts" - -# Make every script executable -find "$PWD" -type f -exec chmod +x {} \; - -for SCRIPT in "${SCRIPTS[@]}"; do - echo "Running script $SCRIPT" - eval "$PWD/$SCRIPT" -done \ No newline at end of file diff --git a/modules/systemd/README.md b/modules/systemd/README.md deleted file mode 100644 index 4b122b84be..0000000000 --- a/modules/systemd/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# `systemd` Module for Startingpoint - -The `systemd` module streamlines the management of systemd units during image building. Units are divided into `system` and `user` categories, with `system` units managed directly using `systemctl` and `user` units using `systemctl --user`. You can specify which units to enable or disable under each category. - -## Example Configuration: - -```yaml -type: systemd -system: - enable: - - example.service - disable: - - example.target -user: - enable: - - example.timer - disable: - - example.service -``` - -In this example: - -### System Units -- `example.service`: Enabled (runs on system boot) -- `example.target`: Disabled (does not run on system boot) - -### User Units -- `example.timer`: Enabled (runs for the user) -- `example.service`: Disabled (does not run for the user) - -This configuration achieves the same results as the following commands: - -```sh -# System Units -systemctl enable example.service -systemctl disable example.target - -# User Units -systemctl --user enable example.timer -systemctl --user disable example.service -``` diff --git a/modules/systemd/systemd.sh b/modules/systemd/systemd.sh deleted file mode 100644 index a9aeb5e730..0000000000 --- a/modules/systemd/systemd.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash - -# Tell build process to exit if there are any errors. -set -oue pipefail - -get_yaml_array ENABLED '.system.enabled[]' "$1" -get_yaml_array DISABLED '.system.disabled[]' "$1" -get_yaml_array USER_ENABLED '.user.enabled[]' "$1" -get_yaml_array USER_DISABLED '.user.disabled[]' "$1" - - -if [[ ${#ENABLED[@]} -gt 0 ]]; then - for unit in "${ENABLED[@]}"; do - unit=$(printf "$unit") - systemctl enable $unit - done -fi -if [[ ${#DISABLED[@]} -gt 0 ]]; then - for unit in "${DISABLED[@]}"; do - unit=$(printf "$unit") - systemctl disable $unit - done -fi -if [[ ${#USER_ENABLED[@]} -gt 0 ]]; then - for unit in "${ENABLED[@]}"; do - unit=$(printf "$unit") - systemctl --user enable $unit - done -fi -if [[ ${#USER_DISABLED[@]} -gt 0 ]]; then - for unit in "${DISABLED[@]}"; do - unit=$(printf "$unit") - systemctl --user disable $unit - done -fi diff --git a/modules/yafti/README.md b/modules/yafti/README.md deleted file mode 100644 index a67cf0d95c..0000000000 --- a/modules/yafti/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# [`yafti`](https://github.com/ublue-os/yafti) Module for Startingpoint - -If included, the `yafti` module will install `yafti` and set it up to run on first boot. - -Optionally, a list of Flatpak names and IDs can be included under `custom-flatpaks:`. These will be enabled by default under their own section on the Flatpak installation screen of `yafti`. - -The main `yafti` configuration file, `yafti.yml`, is in `/usr/share/ublue-os/firstboot/yafti.yml` and can be edited for a more custom first-boot experience. - -## Example configuration: - -```yml -type: yafti -custom-flatpaks: - - Celluloid: io.github.celluloid_player.Celluloid - - Krita: org.kde.krita -``` diff --git a/modules/yafti/yafti.sh b/modules/yafti/yafti.sh deleted file mode 100644 index 4625120c1c..0000000000 --- a/modules/yafti/yafti.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash - -# Tell build process to exit if there are any errors. -set -oue pipefail - -FIRSTBOOT_DATA="/usr/share/ublue-os/firstboot" -FIRSTBOOT_LINK="/usr/etc/profile.d/ublue-firstboot.sh" - -echo "Installing python3-pip and libadwaita" -rpm-ostree install python3-pip libadwaita - -echo "Installing and enabling yafti" -pip install --prefix=/usr yafti - -# Create symlink to our profile script, which creates the per-user "autorun yafti" links. -mkdir -p "$(dirname "${FIRSTBOOT_LINK}")" -ln -s "${FIRSTBOOT_DATA}/launcher/login-profile.sh" "${FIRSTBOOT_LINK}" - -YAFTI_FILE="$FIRSTBOOT_DATA/yafti.yml" - -get_yaml_array FLATPAKS '.custom-flatpaks[]' "$1" -if [[ ${#FLATPAKS[@]} -gt 0 ]]; then - echo "Adding Flatpaks to yafti.yml" - yq -i '.screens.applications.values.groups.Custom.description = "Flatpaks suggested by the image maintainer."' "${YAFTI_FILE}" - yq -i '.screens.applications.values.groups.Custom.default = true' "${YAFTI_FILE}" - - for pkg in "${FLATPAKS[@]}"; do - echo "Adding to yafti: ${pkg}" - yq -i ".screens.applications.values.groups.Custom.packages += [$pkg]" "${YAFTI_FILE}" - done -fi \ No newline at end of file