Skip to content

Commit ea36440

Browse files
author
Evgeniy Kukhtinov
committed
fix_xdg: ensure write permissions before modifying .desktop files
Add a check to verify that each .desktop file is writable before attempting to modify it with sed. If the file is not writable, try to set the user-writeable bit (u+w). If this fails, skip the file instead of aborting the entire script. This prevents build failures when input files are read-only, improving robustness in RPM build environments.
1 parent 19af4ec commit ea36440

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

fix_xdg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ fi
1313

1414
# Find .desktop files
1515
find "$RPM_BUILD_ROOT" -name "*.desktop" -type f -print | while read f; do
16+
# Ensure we have write permissions
17+
[ -w "$f" ] || chmod u+w "$f" 2>/dev/null || continue
18+
1619
# Add trailing semicolons to lines starting with 'Actions=' or 'MimeType='
1720
# if these lines do not end with '='
1821
sed -i 's/^\(Actions=.*\|MimeType=.*\|OnlyShowIn=.*\|Categories=.*\)\([[:alnum:]]\)[[:space:]]*$/\1\2;/' "$f"

0 commit comments

Comments
 (0)