2023-05-09 15:34:59 +02:00
|
|
|
#!/usr/bin/env bash
|
2023-05-09 15:26:26 +02:00
|
|
|
|
|
|
|
# Tell build process to exit if there are any errors.
|
2023-05-09 16:29:59 +02:00
|
|
|
set -oue pipefail
|
2023-05-09 15:26:26 +02:00
|
|
|
|
2023-05-09 16:56:23 +02:00
|
|
|
# Helper functions.
|
|
|
|
get_yaml_array() {
|
|
|
|
mapfile -t "$1" < <(yq "$2" < /usr/etc/ublue-recipe.yml)
|
|
|
|
}
|
|
|
|
|
2023-05-09 15:41:11 +02:00
|
|
|
# Add custom repos.
|
2023-05-09 16:56:23 +02:00
|
|
|
get_yaml_array repos '.extrarepos[]'
|
|
|
|
if [[ ${#repos[@]} -gt 0 ]]; then
|
2023-05-09 15:41:11 +02:00
|
|
|
echo "-- Adding repos defined in recipe.yml --"
|
2023-05-09 16:56:23 +02:00
|
|
|
for repo in "${repos[@]}"; do
|
|
|
|
wget "$repo" -P /etc/yum.repos.d/
|
2023-05-09 15:41:11 +02:00
|
|
|
done
|
|
|
|
echo "---"
|
|
|
|
fi
|
|
|
|
|
2023-05-09 15:33:49 +02:00
|
|
|
# Run scripts.
|
2023-05-09 16:56:23 +02:00
|
|
|
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
|
2023-04-24 20:40:51 +02:00
|
|
|
|
2023-05-09 18:00:12 +02:00
|
|
|
# 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
|
2023-04-02 10:44:44 +02:00
|
|
|
|
2023-05-09 15:41:11 +02:00
|
|
|
# Install RPMs.
|
2023-05-09 18:00:12 +02:00
|
|
|
get_yaml_array install_rpms '.rpm-install[]'
|
2023-05-09 16:56:23 +02:00
|
|
|
if [[ ${#install_rpms[@]} -gt 0 ]]; then
|
|
|
|
echo "-- Installing RPMs defined in recipe.yml --"
|
2023-05-09 17:12:12 +02:00
|
|
|
echo "Installing: ${install_rpms[@]}"
|
|
|
|
rpm-ostree install "${install_rpms[@]}"
|
2023-05-09 16:56:23 +02:00
|
|
|
echo "---"
|
|
|
|
fi
|
2023-04-02 11:00:58 +02:00
|
|
|
|
2023-05-09 15:33:49 +02:00
|
|
|
# Install yafti to install flatpaks on first boot, https://github.com/ublue-os/yafti.
|
2023-04-02 11:24:32 +02:00
|
|
|
pip install --prefix=/usr yafti
|
|
|
|
|
2023-05-09 16:56:23 +02:00
|
|
|
# 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 --"
|
2023-04-26 18:49:26 +02:00
|
|
|
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
|
2023-05-09 16:56:23 +02:00
|
|
|
for pkg in "${flatpaks[@]}"; do
|
|
|
|
echo "Adding to yafti: ${pkg}"
|
2023-04-26 18:49:26 +02:00
|
|
|
yq -i ".screens.applications.values.groups.Custom.packages += [{\"$pkg\": \"$pkg\"}]" /usr/etc/yafti.yml
|
|
|
|
done
|
2023-05-09 16:56:23 +02:00
|
|
|
echo "---"
|
|
|
|
fi
|