[pacman-dev] [PATCH] libmakepkg: move helper functions into tidy/strip
Allan McRae
allan at archlinux.org
Sun Mar 8 02:08:14 UTC 2015
Signed-off-by: Allan McRae <allan at archlinux.org>
---
scripts/libmakepkg/tidy/strip.sh.in | 50 +++++++++++++++++++++++++++++++++++++
scripts/makepkg.sh.in | 48 -----------------------------------
2 files changed, 50 insertions(+), 48 deletions(-)
diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in
index 15d92be..12a7eee 100644
--- a/scripts/libmakepkg/tidy/strip.sh.in
+++ b/scripts/libmakepkg/tidy/strip.sh.in
@@ -30,6 +30,56 @@ source "$LIBRARY/util/option.sh"
packaging_options+=('strip' 'debug')
tidy_modify+=('tidy_strip')
+
+build_id() {
+ LANG=C readelf -n $1 | sed -n '/Build ID/ { s/.*: //p; q; }'
+}
+
+strip_file() {
+ local binary=$1; shift
+
+ if check_option "debug" "y"; then
+ local bid=$(build_id "$binary")
+
+ # has this file already been stripped
+ if [[ -n "$bid" ]]; then
+ if [[ -f "$dbgdir/.build-id/${bid:0:2}/${bid:2}.debug" ]]; then
+ return
+ fi
+ elif [[ -f "$dbgdir/$binary.debug" ]]; then
+ return
+ fi
+
+ mkdir -p "$dbgdir/${binary%/*}"
+ objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug"
+ objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary"
+
+ # create any needed hardlinks
+ while read -rd '' file ; do
+ if [[ "${binary}" -ef "${file}" && ! -f "$dbgdir/${file}.debug" ]]; then
+ mkdir -p "$dbgdir/${file%/*}"
+ ln "$dbgdir/${binary}.debug" "$dbgdir/${file}.debug"
+ fi
+ done < <(find . -type f -perm -u+w -print0 2>/dev/null)
+
+ if [[ -n "$bid" ]]; then
+ local target
+ mkdir -p "$dbgdir/.build-id/${bid:0:2}"
+
+ target="../../../../../${binary#./}"
+ target="${target/..\/..\/usr\/lib\/}"
+ target="${target/..\/usr\/}"
+ ln -s "$target" "$dbgdir/.build-id/${bid:0:2}/${bid:2}"
+
+ target="../../${binary#./}.debug"
+ ln -s "$target" "$dbgdir/.build-id/${bid:0:2}/${bid:2}.debug"
+ fi
+ fi
+
+ strip $@ "$binary"
+}
+
+
tidy_strip() {
if check_option "strip" "y"; then
msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")"
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index a9c2ebb..168f334 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1615,54 +1615,6 @@ run_package() {
run_function_safe "$pkgfunc"
}
-build_id() {
- LANG=C readelf -n $1 | sed -n '/Build ID/ { s/.*: //p; q; }'
-}
-
-strip_file() {
- local binary=$1; shift
-
- if check_option "debug" "y"; then
- local bid=$(build_id "$binary")
-
- # has this file already been stripped
- if [[ -n "$bid" ]]; then
- if [[ -f "$dbgdir/.build-id/${bid:0:2}/${bid:2}.debug" ]]; then
- return
- fi
- elif [[ -f "$dbgdir/$binary.debug" ]]; then
- return
- fi
-
- mkdir -p "$dbgdir/${binary%/*}"
- objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug"
- objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary"
-
- # create any needed hardlinks
- while read -rd '' file ; do
- if [[ "${binary}" -ef "${file}" && ! -f "$dbgdir/${file}.debug" ]]; then
- mkdir -p "$dbgdir/${file%/*}"
- ln "$dbgdir/${binary}.debug" "$dbgdir/${file}.debug"
- fi
- done < <(find . -type f -perm -u+w -print0 2>/dev/null)
-
- if [[ -n "$bid" ]]; then
- local target
- mkdir -p "$dbgdir/.build-id/${bid:0:2}"
-
- target="../../../../../${binary#./}"
- target="${target/..\/..\/usr\/lib\/}"
- target="${target/..\/usr\/}"
- ln -s "$target" "$dbgdir/.build-id/${bid:0:2}/${bid:2}"
-
- target="../../${binary#./}.debug"
- ln -s "$target" "$dbgdir/.build-id/${bid:0:2}/${bid:2}.debug"
- fi
- fi
-
- strip $@ "$binary"
-}
-
find_libdepends() {
local d sodepends;
--
2.3.1
More information about the pacman-dev
mailing list