diff --git a/steps/helpers.sh b/steps/helpers.sh index c4836d6d..8ef96049 100755 --- a/steps/helpers.sh +++ b/steps/helpers.sh @@ -447,6 +447,20 @@ default_src_install() { 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_src_postprocess() { 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 find "${DESTDIR}" -type f | while read f; do case "$(file -bi "${f}")" in - application/x-executable*) strip "${f}" ;; + application/x-executable*) _do_strip "${f}" ;; application/x-sharedlib*|application/x-pie-executable*) machine_set="$(file -b "${f}")" case "${machine_set}" in *no\ machine*) ;; # don't strip ELF container-only - *) strip --strip-unneeded "${f}" ;; + *) _do_strip --strip-unneeded "${f}" ;; esac ;; - application/x-archive*) strip --strip-debug "${f}" ;; + application/x-archive*) _do_strip --strip-debug "${f}" ;; esac done fi diff --git a/steps/perl-5.32.1/pass1.sh b/steps/perl-5.32.1/pass1.sh index ef78d084..c834f45a 100755 --- a/steps/perl-5.32.1/pass1.sh +++ b/steps/perl-5.32.1/pass1.sh @@ -51,7 +51,4 @@ src_install() { # Improve reproducibility. hostcat might be empty or set to "cat /etc/hosts" # 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" - - # There are strange permissions on installed files. - find "${DESTDIR}${PREFIX}/lib" -type f -exec chmod 644 {} \; } diff --git a/steps/perl-5.8.9/pass1.sh b/steps/perl-5.8.9/pass1.sh index feed0656..29564c39 100755 --- a/steps/perl-5.8.9/pass1.sh +++ b/steps/perl-5.8.9/pass1.sh @@ -80,7 +80,4 @@ src_install() { # Remove messed up manpages rm "${DESTDIR}/"*.0 - - # There are strange permissions on installed files. - find "${DESTDIR}${PREFIX}/lib" -type f -exec chmod 644 {} \; }