From 8dad5a743678c11bdbbfb173f72d98845e2b38d7 Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Thu, 21 May 2026 18:44:09 -0400 Subject: [PATCH] omarchy-iso-make: lint that executable airootfs files have file_permissions entries --- bin/omarchy-iso-make | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/bin/omarchy-iso-make b/bin/omarchy-iso-make index e79e116..d2d3e22 100755 --- a/bin/omarchy-iso-make +++ b/bin/omarchy-iso-make @@ -57,6 +57,41 @@ if [[ -n $LOCAL_INSTALLER_PATH ]]; then LOCAL_PKGS_PATH=$(realpath "$LOCAL_PKGS_PATH") fi +lint_file_permissions() { + local profiledef="configs/profiledef.sh" + local -A declared=() + local missing=() + + while IFS= read -r path; do + [[ -n $path ]] && declared["$path"]=1 + done < <(grep -oP '^\s*\["\K[^"]+(?="\])' "$profiledef" || true) + + while IFS= read -r f; do + [[ -f $f ]] || continue + + local rel="${f#configs/airootfs}" + local mode + mode=$(git ls-files --stage -- "$f" | awk '{print $1}') + + if [[ $mode != 100755 && $(head -c 2 "$f") != "#!" ]]; then + continue + fi + + if [[ -z ${declared[$rel]+x} ]]; then + missing+=("$rel") + fi + done < <(find configs/airootfs/usr/local/bin configs/airootfs/root -type f 2>/dev/null) + + if (( ${#missing[@]} > 0 )); then + echo "ERROR: the following executable files are missing from $profiledef file_permissions:" >&2 + printf ' %s\n' "${missing[@]}" >&2 + echo "Add entries like [\"\"]=\"0:0:755\" to profiledef.sh and retry." >&2 + exit 1 + fi +} + +lint_file_permissions + # Clear out old packages sudo rm -rf /var/cache/pacman/pkg/*