From d1c5fbb89c8cf66103364333dfc94da22723c591 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Thu, 7 May 2026 15:10:30 +0200 Subject: [PATCH] Faster fix-permissions.sh It takes a considerable amount of time to run but there's no need for it. --- permission-fix.sh | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/permission-fix.sh b/permission-fix.sh index 8063f35..327c323 100755 --- a/permission-fix.sh +++ b/permission-fix.sh @@ -3,23 +3,15 @@ # SPDX-FileCopyrightText: 2024 Harald Sitter # SPDX-FileCopyrightText: 2024 Bruno Pajdek -# Something in GitLab causes bogus permissions to be set for mkosi stuff, -# reset them to something sane. +# Something in GitLab causes bogus permissions to be set for mkosi input +# trees, reset them to something sane. +# +# Only touch the source directories mkosi consumes directly. In particular, +# do not recurse into generated trees such as a stale mkosi.output because +# that can make this step unexpectedly expensive. -# Enable ** for recursive globbing and include hidden files when doing so. -shopt -s globstar dotglob +DIRS="mkosi.conf.d mkosi.extra mkosi.finalize.d mkosi.repart mkosi.sandbox mkosi.skeleton" -# Loop through all mkosi files. -for FILE in mkosi.*/**/*; do - # Skip symlinks. - if [ -L "$FILE" ]; then - continue - fi - - # If the file is executable, reset permissions to 755, else to 644. - if [ -x "$FILE" ]; then - chmod 755 "$FILE" - else - chmod 644 "$FILE" - fi -done +find $DIRS -type d -exec chmod 755 {} + +find $DIRS -type f -perm /111 -exec chmod 755 {} + +find $DIRS -type f ! -perm /111 -exec chmod 644 {} +