Restore permissions on stripped files

This commit is contained in:
fosslinux 2025-07-23 10:41:50 +10:00 committed by Samuel Tyler
parent 1fbc21935f
commit 614482220c
3 changed files with 17 additions and 9 deletions

View file

@ -447,6 +447,20 @@ default_src_install() {
make -f Makefile install PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" make -f Makefile install PREFIX="${PREFIX}" DESTDIR="${DESTDIR}"
} }
# Helper function for permissions
_do_strip() {
# shellcheck disable=SC2124
local f="${@: -1}"
if ! [ -w "${f}" ]; then
local perms="$(stat -c %a "${f}")"
chmod u+w "${f}"
fi
strip "$@"
if [ -n "${perms}" ]; then
chmod "${perms}" "${f}"
fi
}
# Default function for postprocessing binaries. # Default function for postprocessing binaries.
default_src_postprocess() { default_src_postprocess() {
if (command -v find && command -v file && command -v strip) >/dev/null 2>&1; then if (command -v find && command -v file && command -v strip) >/dev/null 2>&1; then
@ -454,15 +468,15 @@ default_src_postprocess() {
# shellcheck disable=SC2162 # shellcheck disable=SC2162
find "${DESTDIR}" -type f | while read f; do find "${DESTDIR}" -type f | while read f; do
case "$(file -bi "${f}")" in case "$(file -bi "${f}")" in
application/x-executable*) strip "${f}" ;; application/x-executable*) _do_strip "${f}" ;;
application/x-sharedlib*|application/x-pie-executable*) application/x-sharedlib*|application/x-pie-executable*)
machine_set="$(file -b "${f}")" machine_set="$(file -b "${f}")"
case "${machine_set}" in case "${machine_set}" in
*no\ machine*) ;; # don't strip ELF container-only *no\ machine*) ;; # don't strip ELF container-only
*) strip --strip-unneeded "${f}" ;; *) _do_strip --strip-unneeded "${f}" ;;
esac esac
;; ;;
application/x-archive*) strip --strip-debug "${f}" ;; application/x-archive*) _do_strip --strip-debug "${f}" ;;
esac esac
done done
fi fi

View file

@ -51,7 +51,4 @@ src_install() {
# Improve reproducibility. hostcat might be empty or set to "cat /etc/hosts" # Improve reproducibility. hostcat might be empty or set to "cat /etc/hosts"
# depending on whether /etc/hosts was available during the build. # depending on whether /etc/hosts was available during the build.
sed -i "s_^hostcat='.*'\$_hostcat=''_g" "${DESTDIR}${PREFIX}/lib/perl5/5.32.1/i386-linux/Config_heavy.pl" sed -i "s_^hostcat='.*'\$_hostcat=''_g" "${DESTDIR}${PREFIX}/lib/perl5/5.32.1/i386-linux/Config_heavy.pl"
# There are strange permissions on installed files.
find "${DESTDIR}${PREFIX}/lib" -type f -exec chmod 644 {} \;
} }

View file

@ -80,7 +80,4 @@ src_install() {
# Remove messed up manpages # Remove messed up manpages
rm "${DESTDIR}/"*.0 rm "${DESTDIR}/"*.0
# There are strange permissions on installed files.
find "${DESTDIR}${PREFIX}/lib" -type f -exec chmod 644 {} \;
} }