particle-os-modules/modules/yafti/yafti.sh
Micah Abbott 623834bb3b
chore: force create firstboot symlink in yafti module (#82)
I switched my custom ublue image from using
"ublue-os/silverblue-nvidia" to "ublue-os/bazzite-gnome-nvidia" and
received the following error when the build action kicked off:

`ln: failed to create symbolic link '/usr/etc/profile.d/ublue-firstboot.sh': File exists`

The yafti module should be the only thing creating this symlink, so it
should be safe to use the `-f` flag to force creating it.

Signed-off-by: Micah Abbott <miabbott@redhat.com>
2023-12-21 05:59:33 +00:00

39 lines
No EOL
1.3 KiB
Bash

#!/usr/bin/env bash
# Tell build process to exit if there are any errors.
set -oue pipefail
FIRSTBOOT_DATA="/usr/share/ublue-os/firstboot"
FIRSTBOOT_SCRIPT="${FIRSTBOOT_DATA}/launcher/login-profile.sh"
PROFILED_DIR="/usr/etc/profile.d"
FIRSTBOOT_LINK="${PROFILED_DIR}/ublue-firstboot.sh"
echo "Installing python3-pip and libadwaita"
rpm-ostree install python3-pip libadwaita
echo "Installing and enabling yafti"
pip install --prefix=/usr yafti
# If the profile.d directory doesn't exist, create it
if [ ! -d "${PROFILED_DIR}" ]; then
mkdir -p "${PROFILED_DIR}"
fi
# Create symlink to our profile script, which creates the per-user "autorun yafti" links.
if [ -f "${FIRSTBOOT_SCRIPT}" ]; then
ln -sf "${FIRSTBOOT_SCRIPT}" "${FIRSTBOOT_LINK}"
fi
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}"
for pkg in "${FLATPAKS[@]}"; do
echo "Adding to yafti: ${pkg}"
yq -i ".screens.applications.values.groups.Custom.packages += [$pkg]" "${YAFTI_FILE}"
done
fi