Skip to content

Commit

Permalink
fix: get_json_array complaining about unpopulated arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftydinar authored Dec 1, 2024
1 parent 5008b92 commit a0518d5
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion modules/akmods/akmods.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if "${previously_not_installed_rpm_fusion}"; then
fi
}

get_json_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!"
Expand Down
2 changes: 1 addition & 1 deletion modules/bling/bling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Tell build process to exit if there are any errors.
set -euo pipefail

get_json_array INSTALL '.install[]' "$1"
get_json_array INSTALL 'try .install[]' "$1"

cd "/tmp/modules/bling/installers"

Expand Down
10 changes: 5 additions & 5 deletions modules/default-flatpaks/v1/default-flatpaks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ configure_flatpak_repo () {
CONFIG_FILE=$1
INSTALL_LEVEL=$2
REPO_INFO="/usr/share/bluebuild/default-flatpaks/$INSTALL_LEVEL/repo-info.yml"
get_json_array INSTALL ".$INSTALL_LEVEL.install[]" "$CONFIG_FILE"
get_json_array INSTALL "try .$INSTALL_LEVEL.install[]" "$CONFIG_FILE"


# Checks pre-configured repo info, if exists
Expand Down Expand Up @@ -85,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_json_array INSTALL ".$INSTALL_LEVEL.install[]" "$CONFIG_FILE"
get_json_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
Expand Down Expand Up @@ -120,8 +120,8 @@ check_flatpak_id_validity_from_flathub () {
URL="https://flathub.org/apps"
CONFIG_FILE="${1}"
INSTALL_LEVEL="${2}"
get_json_array INSTALL ".$INSTALL_LEVEL.install[]" "${CONFIG_FILE}"
get_json_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
Expand Down
2 changes: 1 addition & 1 deletion modules/files/files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Tell build process to exit if there are any errors.
set -euo pipefail

get_json_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
Expand Down
2 changes: 1 addition & 1 deletion modules/fonts/fonts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ for SOURCE in "$MODULE_DIRECTORY"/fonts/sources/*.sh; do

# get array of fonts for current source
FILENAME=$(basename -- "${SOURCE}")
get_json_array FONTS ".fonts.${FILENAME%.*}[]" "$1"
get_json_array FONTS "try .fonts.${FILENAME%.*}[]" "$1"

if [ ${#FONTS[@]} -gt 0 ]; then
bash "${SOURCE}" "${FONTS[@]}"
Expand Down
4 changes: 2 additions & 2 deletions modules/gnome-extensions/gnome-extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Tell build process to exit if there are any errors.
set -euo pipefail

get_json_array INSTALL '.install[]' "$1"
get_json_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"
Expand Down
2 changes: 1 addition & 1 deletion modules/justfiles/justfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -euo pipefail

get_json_array CONFIG_SELECTION '.include[]' "$1"
get_json_array CONFIG_SELECTION 'try .include[]' "$1"
VALIDATE="$(echo "$1" | jq -r '.["validate"]')"

IMPORT_FILE="/usr/share/ublue-os/just/60-custom.just"
Expand Down
14 changes: 7 additions & 7 deletions modules/rpm-ostree/rpm-ostree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
set -euo pipefail

# Pull in repos
get_json_array REPOS '.repos[]' "$1"
get_json_array REPOS 'try .repos[]' "$1"
if [[ ${#REPOS[@]} -gt 0 ]]; then
echo "Adding repositories"
for REPO in "${REPOS[@]}"; do
Expand All @@ -30,7 +30,7 @@ if [[ ${#REPOS[@]} -gt 0 ]]; then
done
fi

get_json_array KEYS '.keys[]' "$1"
get_json_array KEYS 'try .keys[]' "$1"
if [[ ${#KEYS[@]} -gt 0 ]]; then
echo "Adding keys"
for KEY in "${KEYS[@]}"; do
Expand All @@ -40,7 +40,7 @@ if [[ ${#KEYS[@]} -gt 0 ]]; then
fi

# Create symlinks to fix packages that create directories in /opt
get_json_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
Expand All @@ -56,8 +56,8 @@ if [[ ${#OPTFIX[@]} -gt 0 ]]; then
done
fi

get_json_array INSTALL_PKGS '.install[]' "$1"
get_json_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
Expand Down Expand Up @@ -133,7 +133,7 @@ elif [[ ${#REMOVE_PKGS[@]} -gt 0 ]]; then
rpm-ostree override remove "${REMOVE_PKGS[@]}"
fi

get_json_array REPLACE '.replace[]' "$1"
get_json_array REPLACE 'try .replace[]' "$1"

# Override-replace RPM packages
if [[ ${#REPLACE[@]} -gt 0 ]]; then
Expand All @@ -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_json_array PACKAGES '.packages[]' "${REPLACEMENT}"
get_json_array PACKAGES 'try .packages[]' "${REPLACEMENT}"
REPLACE_STR="$(echo "${PACKAGES[*]}" | tr -d '\n')"

# Ensure packages are provided
Expand Down
4 changes: 2 additions & 2 deletions modules/script/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Tell build process to exit if there are any errors.
set -euo pipefail

get_json_array SCRIPTS '.scripts[]' "$1"
get_json_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
Expand Down
16 changes: 8 additions & 8 deletions modules/systemd/systemd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ if [[ -d "$USER_UNIT_INCLUDE" ]]; then
fi

# Systemd units configuration (enable, disable, unmask & mask)
get_json_array ENABLED '.system.enabled[]' "$1"
get_json_array DISABLED '.system.disabled[]' "$1"
get_json_array UNMASKED '.system.unmasked[]' "$1"
get_json_array MASKED '.system.masked[]' "$1"
get_json_array USER_ENABLED '.user.enabled[]' "$1"
get_json_array USER_DISABLED '.user.disabled[]' "$1"
get_json_array USER_UNMASKED '.user.unmasked[]' "$1"
get_json_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
Expand Down
2 changes: 1 addition & 1 deletion modules/yafti/yafti.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fi

YAFTI_FILE="${FIRSTBOOT_DATA}/yafti.yml"

get_json_array FLATPAKS '.custom-flatpaks[]' "$1"
get_json_array FLATPAKS 'try .custom-flatpaks[]' "$1"
if [[ ${#FLATPAKS[@]} -gt 0 ]]; then
echo "Adding Flatpaks to yafti.yml"
sed -i '/^ Custom:/,/^ / s/description: .*/description: "Flatpaks suggested by the image maintainer."/' "${YAFTI_FILE}"
Expand Down

0 comments on commit a0518d5

Please sign in to comment.