diff --git a/README.md b/README.md index cdd7526..ce95d9d 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ If you want to add custom package repositories to your image, you can include th 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 repo for your recipe's `fedora-version`. +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. ### Building multiple images diff --git a/build.sh b/build.sh index 6a4885c..7771846 100644 --- a/build.sh +++ b/build.sh @@ -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 "---" diff --git a/recipe.yml b/recipe.yml index 683225a..18ecbf1 100644 --- a/recipe.yml +++ b/recipe.yml @@ -29,8 +29,8 @@ scripts: 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 the Fedora version defined in `fedora-version`, + # 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):