Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
refactor: remove get yml string, add configdir var
Browse files Browse the repository at this point in the history
  • Loading branch information
xynydev committed Aug 13, 2023
1 parent 245fc69 commit 057b45a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@
# 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
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)."
Expand Down

0 comments on commit 057b45a

Please sign in to comment.