Files
wunker-os/build.sh
Arcitec bf19fa5eca feat: implement effortless RPM removal via YAML configuration
You can now easily remove RPMs from your custom image, without having to edit the build.sh script.

This also changes the old "rpms" config key, to "rpm-install", for consistency with the new setting.
2023-05-10 18:44:25 +03:00

66 lines
2.1 KiB
Bash

#!/usr/bin/env bash
# Tell build process to exit if there are any errors.
set -oue pipefail
# Helper functions.
get_yaml_array() {
mapfile -t "$1" < <(yq "$2" < /usr/etc/ublue-recipe.yml)
}
# Add custom repos.
get_yaml_array repos '.extrarepos[]'
if [[ ${#repos[@]} -gt 0 ]]; then
echo "-- Adding repos defined in recipe.yml --"
for repo in "${repos[@]}"; do
wget "$repo" -P /etc/yum.repos.d/
done
echo "---"
fi
# Run scripts.
get_yaml_array buildscripts '.scripts[]'
if [[ ${#buildscripts[@]} -gt 0 ]]; then
echo "-- Running scripts defined in recipe.yml --"
for script in "${buildscripts[@]}"; do
echo "Running: ${script}"
/tmp/scripts/"$script"
done
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
# 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
# Install yafti to install flatpaks on first boot, https://github.com/ublue-os/yafti.
pip install --prefix=/usr yafti
# Add a new yafti "package group" called Custom, for the packages defined in recipe.yml.
# Only adds the package group if some flatpaks are defined in the recipe.
get_yaml_array flatpaks '.flatpaks[]'
if [[ ${#flatpaks[@]} -gt 0 ]]; then
echo "-- yafti: Adding Flatpaks defined in recipe.yml --"
yq -i '.screens.applications.values.groups.Custom.description = "Flatpaks defined by the image maintainer"' /usr/etc/yafti.yml
yq -i '.screens.applications.values.groups.Custom.default = true' /usr/etc/yafti.yml
for pkg in "${flatpaks[@]}"; do
echo "Adding to yafti: ${pkg}"
yq -i ".screens.applications.values.groups.Custom.packages += [{\"$pkg\": \"$pkg\"}]" /usr/etc/yafti.yml
done
echo "---"
fi