fix: automatically determine current fedora version during build

This fixes the issue where someone specifies `fedora-version: latest`, which won't be known until build-time.

I also added a small "welcome" banner to the build log. It's really just there to retain a somewhat contrived use-case example for how to use `get_yaml_string()`, for other programmers who want to extend this in the future.
This commit is contained in:
Arcitec
2023-05-09 19:56:25 +02:00
committed by Eino Rauhala
parent bd9104a0f2
commit 946f3d82ee
3 changed files with 11 additions and 5 deletions

View File

@@ -12,15 +12,21 @@ get_yaml_string() {
yq -- "$1" "$RECIPE_FILE"
}
# Automatically determine which Fedora version we're building.
FEDORA_VERSION="$(cat /usr/lib/os-release | grep '^VERSION_ID=' | head -1 | sed 's,^VERSION_ID=,,')"
# Read configuration variables.
fedora_version="$(get_yaml_string '.fedora-version')"
base_image="$(get_yaml_string '.base-image')"
# 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}}"
repo="${repo//%FEDORA_VERSION%/${FEDORA_VERSION}}"
wget "$repo" -P /etc/yum.repos.d/
done
echo "---"