From: Michael Tremer Date: Tue, 31 Dec 2024 12:12:43 +0000 (+0000) Subject: scripts: Remove the old strip script X-Git-Tag: 0.9.30~637 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d683065f1df79ddb3d030272ee03096b7ac60c2;p=pakfire.git scripts: Remove the old strip script Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 54fbe480b..1f31c9f9a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1063,8 +1063,7 @@ dist_scripts_SCRIPTS = \ src/scripts/find-requires \ src/scripts/mkimage \ src/scripts/perl.prov \ - src/scripts/perl.req \ - src/scripts/strip + src/scripts/perl.req # ------------------------------------------------------------------------------ diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index 49a6e1a62..56a2ad2c6 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -1273,7 +1273,6 @@ ERROR: static const char* post_build_scripts[] = { "compress-man-pages", - // "strip", NULL, }; diff --git a/src/scripts/strip b/src/scripts/strip deleted file mode 100644 index 18e672831..000000000 --- a/src/scripts/strip +++ /dev/null @@ -1,180 +0,0 @@ -#!/bin/bash -############################################################################### -# # -# Pakfire - The IPFire package management system # -# Copyright (C) 2021 Pakfire development team # -# # -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation, either version 3 of the License, or # -# (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program. If not, see . # -# # -############################################################################### - -# XXX should this be hardcoded? -SOURCE_DIR="/builddir/source" - -DEBUG_DIR="/usr/lib/debug" -DEBUG_SOURCE_DIR="/usr/src/debug" - -error() { - echo "$@" >&2 -} - -build_id() { - local file="${1}" - - LANG=C readelf -n "${file}" | sed -n "/Build ID/ { s/.*: //p; q; }" -} - -process_file() { - local file="${1}" - - # The path of the file in BUILDROOT - local path="${file/${buildroot}/}" - - echo " ${path}" - - local build_id="$(build_id "${file}")" - - # Check if this file has already been stripped - if [ -n "${build_id}" ]; then - if [ -f "${debug_dir}/.build-id/${build_id:0:2}/${build_id:2}.debug" ]; then - return 0 - fi - else - if [ -f "${debug_dir}/${path}.debug" ]; then - return 0 - fi - fi - - # Fetch any capabilities - local capabilities="$(getfattr --no-dereference --name="security.capability" \ - --absolute-names --dump "${file}" 2>/dev/null)" - - mkdir -p "${debug_dir}${path%/*}" - - # Copy all debug sections to the debug directory - if ! objcopy --only-keep-debug "${file}" "${debug_dir}/${path}.debug"; then - error "Could not extract debug information of ${path}" - return 1 - fi - - local tempfile="$(mktemp "${file}.XXXXXX")" - - # Add a debuglink section to the binary - if ! objcopy --add-gnu-debuglink="${debug_dir}/${path}.debug" "${file}" "${tempfile}"; then - error "Could not add debuglink section to ${path}" - rm -f "${tempfile}" - return 1 - fi - - # Create any hardlinks - local link - for link in $(find "${buildroot}" -not -path "${file}" -samefile "${file}"); do - # Strip BUILDROOT - link="${link#${buildroot}}" - - mkdir -p "${debug_dir}/${link%/*}" - if ! ln "${debug_dir}/${path}.debug" "${debug_dir}/${link}.debug"; then - return 1 - fi - done - - # Create links using build_id - if [ -n "${build_id}" ]; then - mkdir -p "${debug_dir}/.build-id/${build_id:0:2}" - - # Link to the binary - if ! ln -s --relative "${file}" \ - "${debug_dir}/.build-id/${build_id:0:2}/${build_id:2}"; then - return 1 - fi - - # Link the debug files - if ! ln -s --relative "${debug_dir}/${path}.debug" \ - "${debug_dir}/.build-id/${build_id:0:2}/${build_id:2}.debug"; then - return 1 - fi - fi - - # Strip all debug symbols - if ! strip --strip-debug "${file}" -o "${tempfile}"; then - error "Could not strip ${path}" - rm -f "${tempfile}" - return 1 - fi - - # Copy back the stripped file - cat "${tempfile}" > "${file}" - rm -f "${tempfile}" - - # Restore capabilities - if [ -n "${capabilities}" ]; then - setfattr --no-dereference --restore=<(echo "${capabilities}") - fi - - return 0 -} - -main() { - local buildroot="${1}" - shift - - # Check if BUILDROOT exists - if [ ! -d "${buildroot}" ]; then - error "BUILDROOT does not exist" - return 1 - fi - - echo "Stripping unneeded symbols from binaries and libraries..." - - local debug_dir="${buildroot}${DEBUG_DIR}" - local debug_source_dir="${buildroot}${DEBUG_SOURCE_DIR}" - - local file - for file in $(find "${buildroot}" -type f \ - \( -perm -0100 -or -perm -0010 -or -perm -0001 \) | sort); do - # Determine the file type - local type="$(readelf -h "${file}" 2>/dev/null)" - - case "${type}" in - # Libraries and Relocatable binaries - *Type:*"DYN (Position-Independent Executable file)"*) - ;; - - *Type:*"DYN (Shared object file)"*) - ;; - - # Binaries - *Type:*"EXEC (Executable file)"*) - ;; - - # Static libraries - *Type:*"REL (Relocatable file)"*) - ;; - - # Skip any unrecognised files - *) - continue - ;; - esac - - if ! process_file "${file}"; then - error "Could not strip ${file/${buildroot}/}" - return 1 - fi - done - - return 0 -} - -main "$@" || exit $?