chore: Remove usage of yq in favor of jq (#369)

* chore: Remove usage of `yq` in favor of `jq`

* fix: Missed bracket in `default-flatpaks`

* fix: `get_json_array` complaining about unpopulated arrays

* fix(files): Forgot to input `-r` flag for some `jq` calls

* fix(gschema-overrides): Use `try` in `get_json_array`

* chore(default-flatpaks): Replace `yq` with `jq` in run-time setup binaries

* chore: Switch to simplified `jq` syntax without brackets

* chore(default-flatpaks): Switch `repo-info` file from `yml` to `json`

* fix(default-flatpaks): Some `yq` calls

* chore: Revert back to bracket syntax for more reliable `jq` parsing

* chore(files): Missed bracket syntax

* chore: Approve bot suggestion about quoting

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update modules/files/files.sh

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(yafti): Populating custom flatpaks

It's populated in reverse order compared to the format in recipe, but it works

* fix(fonts): Variable substitution is needed

* fix: Typo

* fix(fonts): Forgot to assign FONTS variable

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
fiftydinar 2024-12-02 20:02:13 +01:00 committed by GitHub
parent ab654c9f16
commit 189048b119
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 90 additions and 88 deletions

View file

@ -22,7 +22,7 @@ if "${previously_not_installed_rpm_fusion}"; then
fi
}
get_yaml_array INSTALL '.install[]' "$1"
get_json_array INSTALL 'try .["install"][]' "$1"
if [[ ${#INSTALL[@]} -lt 1 ]]; then
echo "ERROR: You didn't specify any akmod for installation!"

View file

@ -3,7 +3,7 @@
# Tell build process to exit if there are any errors.
set -euo pipefail
get_yaml_array INSTALL '.install[]' "$1"
get_json_array INSTALL 'try .["install"][]' "$1"
cd "/tmp/modules/bling/installers"

View file

@ -39,42 +39,42 @@ fi
MODULE_DIRECTORY="${MODULE_DIRECTORY:-/tmp/modules}"
# Configuration values
AUTO_UPDATE=$(echo "${1}" | yq -I=0 ".auto-update")
AUTO_UPDATE=$(echo "${1}" | jq -r 'try .["auto-update"]')
if [[ -z "${AUTO_UPDATE}" || "${AUTO_UPDATE}" == "null" ]]; then
AUTO_UPDATE=true
fi
UPDATE_INTERVAL=$(echo "${1}" | yq -I=0 ".update-interval")
UPDATE_INTERVAL=$(echo "${1}" | jq -r 'try .["update-interval"]')
if [[ -z "${UPDATE_INTERVAL}" || "${UPDATE_INTERVAL}" == "null" ]]; then
UPDATE_INTERVAL="6h"
fi
UPDATE_WAIT_AFTER_BOOT=$(echo "${1}" | yq -I=0 ".update-wait-after-boot")
UPDATE_WAIT_AFTER_BOOT=$(echo "${1}" | jq -r 'try .["update-wait-after-boot"]')
if [[ -z "${UPDATE_WAIT_AFTER_BOOT}" || "${UPDATE_WAIT_AFTER_BOOT}" == "null" ]]; then
UPDATE_WAIT_AFTER_BOOT="10min"
fi
AUTO_UPGRADE=$(echo "${1}" | yq -I=0 ".auto-upgrade")
AUTO_UPGRADE=$(echo "${1}" | jq -r 'try .["auto-upgrade"]')
if [[ -z "${AUTO_UPGRADE}" || "${AUTO_UPGRADE}" == "null" ]]; then
AUTO_UPGRADE=true
fi
UPGRADE_INTERVAL=$(echo "$1" | yq -I=0 ".upgrade-interval")
UPGRADE_INTERVAL=$(echo "$1" | jq -r 'try .["upgrade-interval"]')
if [[ -z "${UPGRADE_INTERVAL}" || "${UPGRADE_INTERVAL}" == "null" ]]; then
UPGRADE_INTERVAL="8h"
fi
UPGRADE_WAIT_AFTER_BOOT=$(echo "${1}" | yq -I=0 ".upgrade-wait-after-boot")
UPGRADE_WAIT_AFTER_BOOT=$(echo "${1}" | jq -r 'try .["upgrade-wait-after-boot"]')
if [[ -z "${UPGRADE_WAIT_AFTER_BOOT}" || "${UPGRADE_WAIT_AFTER_BOOT}" == "null" ]]; then
UPGRADE_WAIT_AFTER_BOOT="30min"
fi
NOFILE_LIMITS=$(echo "${1}" | yq -I=0 ".nofile-limits")
NOFILE_LIMITS=$(echo "${1}" | jq -r 'try .["nofile-limits"]')
if [[ -z "${NOFILE_LIMITS}" || "${NOFILE_LIMITS}" == "null" ]]; then
NOFILE_LIMITS=false
fi
BREW_ANALYTICS=$(echo "${1}" | yq -I=0 ".brew-analytics")
BREW_ANALYTICS=$(echo "${1}" | jq -r 'try .["brew-analytics"]')
if [[ -z "${BREW_ANALYTICS}" || "${BREW_ANALYTICS}" == "null" ]]; then
BREW_ANALYTICS=true
fi

View file

@ -16,9 +16,9 @@ if [[ $DEBUG == true ]]; then
fi
# The repository with your chezmoi dotfiles. (default: null)
DOTFILE_REPOSITORY=$(echo "$1" | yq -I=0 ".repository") # (string)
DOTFILE_REPOSITORY=$(echo "$1" | jq -r 'try .["repository"]') # (string)
# The chezmoi repository branch to use.
DOTFILE_BRANCH=$(echo "$1" | yq -I=0 ".branch")
DOTFILE_BRANCH=$(echo "$1" | jq -r 'try .["branch"]')
if [[ -n "${DOTFILE_BRANCH}" && "${DOTFILE_BRANCH}" != "null" ]]; then
INIT_BRANCH_FLAG="--branch ${DOTFILE_BRANCH}"
else
@ -36,7 +36,7 @@ fi
#
# To turn on lingering for a given user, run the following commmand with sudo:
# 'sudo loginctl enable-linger <username>'
ALL_USERS=$(echo "$1" | yq -I=0 ".all-users") # (boolean)
ALL_USERS=$(echo "$1" | jq -r 'try .["all-users"]') # (boolean)
if [[ -z $ALL_USERS || $ALL_USERS == "null" ]]; then
ALL_USERS=true
fi
@ -45,24 +45,24 @@ fi
# This string is passed on directly to systemd's OnUnitInactiveSec. Complete syntax is described here:
# https://www.freedesktop.org/software/systemd/man/latest/systemd.time.html#
# Examples: '1d' (1 day - default), '6h' (6 hours), '10m' (10 minutes)
RUN_EVERY=$(echo "$1" | yq -I=0 ".run-every") # (string)
RUN_EVERY=$(echo "$1" | jq -r 'try .["run-every"]') # (string)
if [[ -z $RUN_EVERY || $RUN_EVERY == "null" ]]; then
RUN_EVERY="1d"
fi
# chezmoi-update.service will also run this much time after the system has booted.
# Same syntax as RUN_EVERY (default: '5m')
WAIT_AFTER_BOOT=$(echo "$1" | yq -I=0 ".wait-after-boot") # (string)
WAIT_AFTER_BOOT=$(echo "$1" | jq -r 'try .["wait-after-boot"]') # (string)
if [[ -z $WAIT_AFTER_BOOT || $WAIT_AFTER_BOOT == "null" ]]; then
WAIT_AFTER_BOOT="5m"
fi
# If true, disables automatic initialization of chezmoi if no dotfile directory is found. (default: false)
DISABLE_INIT=$(echo "$1" | yq -I=0 ".disable-init") # (boolean)
DISABLE_INIT=$(echo "$1" | jq -r 'try .["disable-init"]') # (boolean)
if [[ -z $DISABLE_INIT || $DISABLE_INIT == "null" ]]; then
DISABLE_INIT=false
fi
# If true, disables automatic activation of 'chezmoi-update.timer'. (default: false)
DISABLE_UPDATE=$(echo "$1" | yq -I=0 ".disable-update") # (boolean)
DISABLE_UPDATE=$(echo "$1" | jq -r 'try .["disable-update"]') # (boolean)
if [[ -z $DISABLE_UPDATE || $DISABLE_UPDATE == "null" ]]; then
DISABLE_UPDATE=false
fi
@ -70,7 +70,7 @@ fi
# Determines how chezmoi handles conflicting files. (default: "skip")
# "skip" will not replace files that have changed.
# "replace" will overwrite all files that have changed.
FILE_CONFLICT_POLICY=$(echo "$1" | yq -I=0 ".file-conflict-policy") # (string)
FILE_CONFLICT_POLICY=$(echo "$1" | jq -r 'try .["file-conflict-policy"]') # (string)
if [[ -z $FILE_CONFLICT_POLICY || $FILE_CONFLICT_POLICY == "null" ]]; then
FILE_CONFLICT_POLICY="skip"
fi

View file

@ -16,17 +16,17 @@ cp -r "$MODULE_DIRECTORY"/default-flatpaks/user-flatpak-setup.timer /usr/lib/sys
configure_flatpak_repo () {
CONFIG_FILE=$1
INSTALL_LEVEL=$2
REPO_INFO="/usr/share/bluebuild/default-flatpaks/$INSTALL_LEVEL/repo-info.yml"
get_yaml_array INSTALL ".$INSTALL_LEVEL.install[]" "$CONFIG_FILE"
REPO_INFO="/usr/share/bluebuild/default-flatpaks/$INSTALL_LEVEL/repo-info.json"
get_json_array INSTALL "try .$INSTALL_LEVEL.install[]" "$CONFIG_FILE"
# Checks pre-configured repo info, if exists
if [[ -f $REPO_INFO ]]; then
echo "Existing $INSTALL_LEVEL configuration found:"
cat $REPO_INFO
CONFIG_URL=$(yq ".repo-url" "$REPO_INFO")
CONFIG_NAME=$(yq ".repo-name" "$REPO_INFO")
CONFIG_TITLE=$(yq ".repo-title" "$REPO_INFO")
CONFIG_URL=$(jq -r 'try .["repo-url"]' "$REPO_INFO")
CONFIG_NAME=$(jq -r 'try .["repo-name"]' "$REPO_INFO")
CONFIG_TITLE=$(jq -r 'try .["repo-title"]' "$REPO_INFO")
else
CONFIG_URL="null"
CONFIG_NAME="null"
@ -34,9 +34,9 @@ configure_flatpak_repo () {
fi
echo "Configuring $INSTALL_LEVEL repo in $REPO_INFO"
REPO_URL=$(echo "$CONFIG_FILE" | yq -I=0 ".$INSTALL_LEVEL.repo-url")
REPO_NAME=$(echo "$CONFIG_FILE" | yq -I=0 ".$INSTALL_LEVEL.repo-name")
REPO_TITLE=$(echo "$CONFIG_FILE" | yq -I=0 ".$INSTALL_LEVEL.repo-title")
REPO_URL=$(echo "$CONFIG_FILE" | jq -r --arg INSTALL_LEVEL "$INSTALL_LEVEL" 'try getpath([$INSTALL_LEVEL, "repo-url"])')
REPO_NAME=$(echo "$CONFIG_FILE" | jq -r --arg INSTALL_LEVEL "$INSTALL_LEVEL" 'try getpath([$INSTALL_LEVEL, "repo-name"])')
REPO_TITLE=$(echo "$CONFIG_FILE" | jq -r --arg INSTALL_LEVEL "$INSTALL_LEVEL" 'try getpath([$INSTALL_LEVEL, "repo-title"])')
# If repo-name isn't configured, use flathub as fallback
# Checked separately from URL to allow custom naming
@ -68,10 +68,12 @@ configure_flatpak_repo () {
touch $REPO_INFO
# EOF breaks if the contents are indented,
# so the below lines are intentionally un-indented
cat > $REPO_INFO <<EOF
repo-url: "$REPO_URL"
repo-name: "$REPO_NAME"
repo-title: "$REPO_TITLE"
cat > $REPO_INFO <<EOF
{
"repo-url": "$REPO_URL",
"repo-name": "$REPO_NAME",
"repo-title": "$REPO_TITLE"
}
EOF
# Show results of repo configuration
@ -83,8 +85,8 @@ configure_lists () {
INSTALL_LEVEL=$2
INSTALL_LIST="/usr/share/bluebuild/default-flatpaks/$INSTALL_LEVEL/install"
REMOVE_LIST="/usr/share/bluebuild/default-flatpaks/$INSTALL_LEVEL/remove"
get_yaml_array INSTALL ".$INSTALL_LEVEL.install[]" "$CONFIG_FILE"
get_yaml_array REMOVE ".$INSTALL_LEVEL.remove[]" "$CONFIG_FILE"
get_json_array INSTALL "try .$INSTALL_LEVEL.install[]" "$CONFIG_FILE"
get_json_array REMOVE "try .$INSTALL_LEVEL.remove[]" "$CONFIG_FILE"
echo "Creating $INSTALL_LEVEL Flatpak install list at $INSTALL_LIST"
if [[ ${#INSTALL[@]} -gt 0 ]]; then
@ -104,13 +106,13 @@ configure_lists () {
}
check_flatpak_id_validity_from_flathub () {
if [[ -f "/usr/share/bluebuild/default-flatpaks/system/repo-info.yml" ]]; then
SYSTEM_FLATHUB_REPO=$(yq .repo-url "/usr/share/bluebuild/default-flatpaks/system/repo-info.yml")
if [[ -f "/usr/share/bluebuild/default-flatpaks/system/repo-info.json" ]]; then
SYSTEM_FLATHUB_REPO=$(jq -r 'try .["repo-url"]' "/usr/share/bluebuild/default-flatpaks/system/repo-info.json")
else
SYSTEM_FLATHUB_REPO=""
fi
if [[ -f "/usr/share/bluebuild/default-flatpaks/user/repo-info.yml" ]]; then
USER_FLATHUB_REPO=$(yq .repo-url "/usr/share/bluebuild/default-flatpaks/user/repo-info.yml")
if [[ -f "/usr/share/bluebuild/default-flatpaks/user/repo-info.json" ]]; then
USER_FLATHUB_REPO=$(jq -r 'try .["repo-url"]' "/usr/share/bluebuild/default-flatpaks/user/repo-info.json")
else
USER_FLATHUB_REPO=""
fi
@ -118,8 +120,8 @@ check_flatpak_id_validity_from_flathub () {
URL="https://flathub.org/apps"
CONFIG_FILE="${1}"
INSTALL_LEVEL="${2}"
get_yaml_array INSTALL ".$INSTALL_LEVEL.install[]" "${CONFIG_FILE}"
get_yaml_array REMOVE ".$INSTALL_LEVEL.remove[]" "${CONFIG_FILE}"
get_json_array INSTALL "try .$INSTALL_LEVEL.install[]" "${CONFIG_FILE}"
get_json_array REMOVE "try .$INSTALL_LEVEL.remove[]" "${CONFIG_FILE}"
if [[ "${SYSTEM_FLATHUB_REPO}" == "${FLATHUB_REPO_LINK}" ]] || [[ "${USER_FLATHUB_REPO}" == "${FLATHUB_REPO_LINK}" ]]; then
echo "Safe-checking if ${INSTALL_LEVEL} flatpak IDs are typed correctly. If test fails, build also fails"
if [[ ${#INSTALL[@]} -gt 0 ]]; then
@ -153,7 +155,7 @@ systemctl enable -f system-flatpak-setup.timer
systemctl enable -f --global user-flatpak-setup.timer
# Check that `system` is present before configuring. Also copy template list files before writing Flatpak IDs.
if [[ ! $(echo "$1" | yq -I=0 ".system") == "null" ]]; then
if [[ $(echo "$1" | jq -r 'try .["system"]') != "null" ]]; then
configure_flatpak_repo "$1" "system"
if [ ! -f "/usr/share/bluebuild/default-flatpaks/system/install" ]; then
cp -r "$MODULE_DIRECTORY"/default-flatpaks/config/system/install /usr/share/bluebuild/default-flatpaks/system/install
@ -165,7 +167,7 @@ if [[ ! $(echo "$1" | yq -I=0 ".system") == "null" ]]; then
fi
# Check that `user` is present before configuring. Also copy template list files before writing Flatpak IDs.
if [[ ! $(echo "$1" | yq -I=0 ".user") == "null" ]]; then
if [[ $(echo "$1" | jq -r 'try .["user"]') != "null" ]]; then
configure_flatpak_repo "$1" "user"
if [ ! -f "/usr/share/bluebuild/default-flatpaks/user/install" ]; then
cp -r "$MODULE_DIRECTORY"/default-flatpaks/config/user/install /usr/share/bluebuild/default-flatpaks/user/install
@ -181,7 +183,7 @@ check_flatpak_id_validity_from_flathub "${1}" "system"
check_flatpak_id_validity_from_flathub "${1}" "user"
echo "Configuring default-flatpaks notifications"
NOTIFICATIONS=$(echo "$1" | yq -I=0 ".notify")
NOTIFICATIONS=$(echo "$1" | jq -r 'try .["notify"]')
CONFIG_NOTIFICATIONS="/usr/share/bluebuild/default-flatpaks/notifications"
cp -r "${MODULE_DIRECTORY}/default-flatpaks/config/notifications" "${CONFIG_NOTIFICATIONS}"
if [[ -z "${NOTIFICATIONS}" ]] || [[ "${NOTIFICATIONS}" == "null" ]]; then

View file

@ -21,10 +21,10 @@ check_internet_connection() {
return 1
}
REPO_INFO="/usr/share/bluebuild/default-flatpaks/system/repo-info.yml"
REPO_URL=$(yq '.repo-url' $REPO_INFO)
REPO_NAME=$(yq '.repo-name' $REPO_INFO)
REPO_TITLE=$(yq '.repo-title' $REPO_INFO)
REPO_INFO="/usr/share/bluebuild/default-flatpaks/system/repo-info.json"
REPO_URL=$(jq -r 'try .["repo-url"]' $REPO_INFO)
REPO_NAME=$(jq -r 'try .["repo-name"]' $REPO_INFO)
REPO_TITLE=$(jq -r 'try .["repo-title"]' $REPO_INFO)
# Opt out of and remove Fedora's system flatpak repos
FLATPAK_SYSTEM_REMOTES=($(flatpak --system remotes))

View file

@ -21,10 +21,10 @@ check_internet_connection() {
return 1
}
REPO_INFO="/usr/share/bluebuild/default-flatpaks/user/repo-info.yml"
REPO_URL=$(yq '.repo-url' $REPO_INFO)
REPO_NAME=$(yq '.repo-name' $REPO_INFO)
REPO_TITLE=$(yq '.repo-title' $REPO_INFO)
REPO_INFO="/usr/share/bluebuild/default-flatpaks/user/repo-info.json"
REPO_URL=$(jq -r 'try .["repo-url"]' $REPO_INFO)
REPO_NAME=$(jq -r 'try .["repo-name"]' $REPO_INFO)
REPO_TITLE=$(jq -r 'try .["repo-title"]' $REPO_INFO)
# Remove Fedora's flatpak user repos, if they exist
FLATPAK_USER_REMOTES=($(flatpak --user remotes))

View file

@ -3,7 +3,7 @@
# Tell build process to exit if there are any errors.
set -euo pipefail
get_yaml_array FILES '.files[]' "$1"
get_json_array FILES 'try .["files"][]' "$1"
# Support for legacy "/tmp/config/" to satisfy transition period to "/tmp/files/"
if [[ "${CONFIG_DIRECTORY}" == "/tmp/config" ]]; then
@ -19,17 +19,17 @@ if [[ ${#FILES[@]} -gt 0 ]]; then
echo "Adding files to image"
for pair in "${FILES[@]}"; do
# Support for legacy recipe format to satisfy transition period to new source/destination recipe format
if [[ $(echo $pair | yq '.source') == "null" || -z $(echo $pair | yq '.source') ]] && [[ $(echo $pair | yq '.destination') == "null" || -z $(echo $pair | yq '.destination') ]]; then
if [[ $(echo "$pair" | jq -r 'try .["source"]') == "null" || -z $(echo "$pair" | jq -r 'try .["source"]') ]] && [[ $(echo "$pair" | jq -r 'try .["destination"]') == "null" || -z $(echo "$pair" | jq -r 'try .["destination"]') ]]; then
echo "ATTENTION: You are using the legacy module recipe format"
echo " It is advised to switch to new module recipe format,"
echo " which contains 'source' & 'destination' YAML keys"
echo " For more details, please visit 'files' module documentation:"
echo " https://blue-build.org/reference/modules/files/"
FILE="$PWD/$(echo $pair | yq 'to_entries | .[0].key')"
DEST=$(echo $pair | yq 'to_entries | .[0].value')
FILE="$PWD/$(echo $pair | jq -r 'to_entries | .[0].key')"
DEST=$(echo $pair | jq -r 'to_entries | .[0].value')
else
FILE="$PWD/$(echo $pair | yq '.source')"
DEST=$(echo $pair | yq '.destination')
FILE="$PWD/$(echo "$pair" | jq -r 'try .["source"]')"
DEST=$(echo "$pair" | jq -r 'try .["destination"]')
fi
if [ -d "$FILE" ]; then
if [ ! -d "$DEST" ]; then

View file

@ -1,19 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
# Workaround for fonts module failing on legacy templates (with build.sh)
get_yaml_array() {
# creates array $1 with content at key $2 from $3
readarray "$1" < <(echo "$3" | yq -I=0 "$2")
}
MODULE_DIRECTORY="${MODULE_DIRECTORY:-"/tmp/modules"}"
for SOURCE in "$MODULE_DIRECTORY"/fonts/sources/*.sh; do
chmod +x "${SOURCE}"
# get array of fonts for current source
FILENAME=$(basename -- "${SOURCE}")
get_yaml_array FONTS ".fonts.${FILENAME%.*}[]" "$1"
ARRAY_NAME="${FILENAME%.*}"
FONTS=("$(echo "${1}" | jq -c -r --arg ARRAY_NAME "${ARRAY_NAME}" 'try .[$ARRAY_NAME][]')")
if [ ${#FONTS[@]} -gt 0 ]; then
bash "${SOURCE}" "${FONTS[@]}"

View file

@ -4,8 +4,8 @@
# Tell build process to exit if there are any errors.
set -euo pipefail
get_yaml_array INSTALL '.install[]' "$1"
get_yaml_array UNINSTALL '.uninstall[]' "$1"
get_json_array INSTALL 'try .["install"][]' "$1"
get_json_array UNINSTALL 'try .["uninstall"][]' "$1"
if [[ ${#INSTALL[@]} -lt 1 ]] && [[ ${#UNINSTALL[@]} -lt 1 ]]; then
echo "ERROR: You did not specify the extension to install or uninstall in module recipe file"

View file

@ -2,7 +2,7 @@
set -euo pipefail
get_yaml_array INCLUDE '.include[]' "$1"
get_json_array INCLUDE 'try .["include"][]' "$1"
SCHEMA_INCLUDE_LOCATION="${CONFIG_DIRECTORY}/gschema-overrides"
SCHEMA_TEST_LOCATION="/tmp/bluebuild-schema-test"

View file

@ -2,8 +2,8 @@
set -euo pipefail
get_yaml_array CONFIG_SELECTION '.include[]' "$1"
VALIDATE="$(echo "$1" | yq -I=0 ".validate")"
get_json_array CONFIG_SELECTION 'try .["include"][]' "$1"
VALIDATE="$(echo "$1" | jq -r 'try .["validate"]')"
IMPORT_FILE="/usr/share/ublue-os/just/60-custom.just"
CONFIG_FOLDER="${CONFIG_DIRECTORY}/justfiles"

View file

@ -4,7 +4,7 @@
set -euo pipefail
# Pull in repos
get_yaml_array REPOS '.repos[]' "$1"
get_json_array REPOS 'try .["repos"][]' "$1"
if [[ ${#REPOS[@]} -gt 0 ]]; then
echo "Adding repositories"
for REPO in "${REPOS[@]}"; do
@ -30,7 +30,7 @@ if [[ ${#REPOS[@]} -gt 0 ]]; then
done
fi
get_yaml_array KEYS '.keys[]' "$1"
get_json_array KEYS 'try .["keys"][]' "$1"
if [[ ${#KEYS[@]} -gt 0 ]]; then
echo "Adding keys"
for KEY in "${KEYS[@]}"; do
@ -40,7 +40,7 @@ if [[ ${#KEYS[@]} -gt 0 ]]; then
fi
# Create symlinks to fix packages that create directories in /opt
get_yaml_array OPTFIX '.optfix[]' "$1"
get_json_array OPTFIX 'try .["optfix"][]' "$1"
if [[ ${#OPTFIX[@]} -gt 0 ]]; then
echo "Creating symlinks to fix packages that install to /opt"
# Create symlink for /opt to /var/opt since it is not created in the image yet
@ -56,8 +56,8 @@ if [[ ${#OPTFIX[@]} -gt 0 ]]; then
done
fi
get_yaml_array INSTALL_PKGS '.install[]' "$1"
get_yaml_array REMOVE_PKGS '.remove[]' "$1"
get_json_array INSTALL_PKGS 'try .["install"][]' "$1"
get_json_array REMOVE_PKGS 'try .["remove"][]' "$1"
CLASSIC_INSTALL=false
HTTPS_INSTALL=false
@ -133,14 +133,14 @@ elif [[ ${#REMOVE_PKGS[@]} -gt 0 ]]; then
rpm-ostree override remove "${REMOVE_PKGS[@]}"
fi
get_yaml_array REPLACE '.replace[]' "$1"
get_json_array REPLACE 'try .["replace"][]' "$1"
# Override-replace RPM packages
if [[ ${#REPLACE[@]} -gt 0 ]]; then
for REPLACEMENT in "${REPLACE[@]}"; do
# Get repository
REPO=$(echo "${REPLACEMENT}" | yq -I=0 ".from-repo")
REPO=$(echo "${REPLACEMENT}" | jq -r 'try .["from-repo"]')
REPO="${REPO//%OS_VERSION%/${OS_VERSION}}"
# Ensure repository is provided
@ -155,7 +155,7 @@ if [[ ${#REPLACE[@]} -gt 0 ]]; then
FILE_NAME=$(awk -F'/' '{print $9}' <<< "${REPO}" | sed 's/\?.*//') # Remove params after '?'
# Get packages to replace
get_yaml_array PACKAGES '.packages[]' "${REPLACEMENT}"
get_json_array PACKAGES 'try .["packages"][]' "${REPLACEMENT}"
REPLACE_STR="$(echo "${PACKAGES[*]}" | tr -d '\n')"
# Ensure packages are provided

View file

@ -3,8 +3,8 @@
# Tell build process to exit if there are any errors.
set -euo pipefail
get_yaml_array SCRIPTS '.scripts[]' "$1"
get_yaml_array SNIPPETS '.snippets[]' "$1"
get_json_array SCRIPTS 'try .["scripts"][]' "$1"
get_json_array SNIPPETS 'try .["snippets"][]' "$1"
# shellcheck disable=SC2153
if [[ ${#SCRIPTS[@]} -gt 0 ]]; then

View file

@ -23,14 +23,14 @@ if [[ -d "$USER_UNIT_INCLUDE" ]]; then
fi
# Systemd units configuration (enable, disable, unmask & mask)
get_yaml_array ENABLED '.system.enabled[]' "$1"
get_yaml_array DISABLED '.system.disabled[]' "$1"
get_yaml_array UNMASKED '.system.unmasked[]' "$1"
get_yaml_array MASKED '.system.masked[]' "$1"
get_yaml_array USER_ENABLED '.user.enabled[]' "$1"
get_yaml_array USER_DISABLED '.user.disabled[]' "$1"
get_yaml_array USER_UNMASKED '.user.unmasked[]' "$1"
get_yaml_array USER_MASKED '.user.masked[]' "$1"
get_json_array ENABLED 'try .["system"].["enabled"][]' "$1"
get_json_array DISABLED 'try .["system"].["disabled"][]' "$1"
get_json_array UNMASKED 'try .["system"].["unmasked"][]' "$1"
get_json_array MASKED 'try .["system"].["masked"][]' "$1"
get_json_array USER_ENABLED 'try .["user"].["enabled"][]' "$1"
get_json_array USER_DISABLED 'try .["user"].["disabled"][]' "$1"
get_json_array USER_UNMASKED 'try .["user"].["unmasked"][]' "$1"
get_json_array USER_MASKED 'try .["user"].["masked"][]' "$1"
if [[ ${#ENABLED[@]} -gt 0 ]]; then
for unit in "${ENABLED[@]}"; do

View file

@ -55,11 +55,16 @@ YAFTI_FILE="${FIRSTBOOT_DATA}/yafti.yml"
get_yaml_array FLATPAKS '.custom-flatpaks[]' "$1"
if [[ ${#FLATPAKS[@]} -gt 0 ]]; then
echo "Adding Flatpaks to yafti.yml"
yq -i '.screens.applications.values.groups.Custom.description = "Flatpaks suggested by the image maintainer."' "${YAFTI_FILE}"
yq -i '.screens.applications.values.groups.Custom.default = true' "${YAFTI_FILE}"
sed -i -e '/- Boatswain for Streamdeck: com.feaneron.Boatswain/a \
Custom:\n description: Flatpaks suggested by the image maintainer.\n default: true' "${YAFTI_FILE}"
for pkg in "${FLATPAKS[@]}"; do
echo "Adding to yafti: ${pkg}"
yq -i ".screens.applications.values.groups.Custom.packages += [$pkg]" "${YAFTI_FILE}"
sed -i '/^[[:space:]]*Custom:/ {
n; n; n;
i\
- REPLACEMEHERE
}' "${YAFTI_FILE}"
sed -i "s/ - REPLACEMEHERE/ - ${pkg}/g" "${YAFTI_FILE}"
done
fi