diff --git a/build.sh b/build.sh index 7b2fcb0..7b465f8 100755 --- a/build.sh +++ b/build.sh @@ -38,6 +38,16 @@ bash ./1password.sh rm 1password.sh +### Fix for packages that install into /opt + +mkdir -p /var/opt +ln -sf /var/opt /opt + +mkdir -p /usr/lib/opt/zen +ln -sf /usr/lib/opt/zen /var/opt/zen + +systemctl enable azure-optfix + ### Install packages grep -v '^#' /tmp/packages | xargs rpm-ostree install diff --git a/files/usr/lib/systemd/system/azure-optfix.service b/files/usr/lib/systemd/system/azure-optfix.service new file mode 100644 index 0000000..fdd70c8 --- /dev/null +++ b/files/usr/lib/systemd/system/azure-optfix.service @@ -0,0 +1,11 @@ +[Unit] +Description=Create symbolic links for directories in /usr/lib/opt/ to /var/opt/ +After=multi-user.target + +[Service] +Type=oneshot +ExecStart=/usr/libexec/azure-optfix +RemainAfterExit=no + +[Install] +WantedBy=default.target diff --git a/files/usr/libexec/azure-optfix b/files/usr/libexec/azure-optfix new file mode 100755 index 0000000..2a33403 --- /dev/null +++ b/files/usr/libexec/azure-optfix @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SOURCE_DIR="/usr/lib/opt/" +TARGET_DIR="/var/opt/" + +# Ensure the target directory exists +mkdir -p "$TARGET_DIR" + +# Loop through directories in the source directory +for dir in "$SOURCE_DIR"*/; do + if [ -d "$dir" ]; then + # Get the base name of the directory + dir_name=$(basename "$dir") + + # Check if the symlink already exists in the target directory + if [ -L "$TARGET_DIR/$dir_name" ]; then + echo "Symlink already exists for $dir_name, skipping." + continue + fi + + # Create the symlink + ln -s "$dir" "$TARGET_DIR/$dir_name" + echo "Created symlink for $dir_name" + fi +done