From c2974e017962aa890bee1da31a9aa5c0777bd498 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Mon, 10 Jun 2019 11:43:55 +0700 Subject: [PATCH 1/4] pkg_strip: add initial support --- puke | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/puke b/puke index 12df0972..1caaccc7 100755 --- a/puke +++ b/puke @@ -83,6 +83,19 @@ pkg_build() { log "Sucessfully built $pkg." 2> "$pkg_db/$name/manifest" } +pkg_strip() { + find "$pkg_dir" -type f | while read -r binary; do + case "$(file -bi "$binary")" in + application/x-sharedlib*|application/x-pie-executable*) + strip_opts="--strip-unneeded" + ;; + application/x-archive*) strip_opts="--strip-debug" ;; + application/x-executable*) strip_opts="--strip-all" ;; + esac + strip "$strip_opts" "$binary" 2>/dev/null + done +} + pkg_manifest() { (cd "$pkg_dir" && find ./*) | sed ss.ss | tac | tee manifest > "$pkg_db/$name/manifest" @@ -147,6 +160,7 @@ args() { pkg_verify pkg_extract pkg_build + pkg_strip pkg_manifest pkg_tar ;; From 5cbd9149576beb1b77fbe4cd557d4974b6f51938 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Mon, 10 Jun 2019 11:44:47 +0700 Subject: [PATCH 2/4] pkg_strip: logging, and don't strip if nostrip file exists --- puke | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/puke b/puke index 1caaccc7..6b67d3b6 100755 --- a/puke +++ b/puke @@ -84,6 +84,7 @@ pkg_build() { } pkg_strip() { + log "Stripping unneeded symbols from binaries and libraries" find "$pkg_dir" -type f | while read -r binary; do case "$(file -bi "$binary")" in application/x-sharedlib*|application/x-pie-executable*) @@ -160,7 +161,7 @@ args() { pkg_verify pkg_extract pkg_build - pkg_strip + [ ! -f nostrip ] && pkg_strip pkg_manifest pkg_tar ;; From fa262255faa74940f0ad35593fded9b594b4b2bd Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Mon, 10 Jun 2019 17:53:30 +0700 Subject: [PATCH 3/4] pkg_strip: continue the loop if file is not a bin/lib --- puke | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/puke b/puke index 6b67d3b6..016de112 100755 --- a/puke +++ b/puke @@ -92,8 +92,9 @@ pkg_strip() { ;; application/x-archive*) strip_opts="--strip-debug" ;; application/x-executable*) strip_opts="--strip-all" ;; + *) continue ;; esac - strip "$strip_opts" "$binary" 2>/dev/null + strip "$strip_opts" "$binary" done } From 12a7607893f803a6f2750d07b43fd5be5bb0283c Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Mon, 10 Jun 2019 21:31:13 +0700 Subject: [PATCH 4/4] pkg_strip: lint --- puke | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/puke b/puke index 016de112..dd3ec729 100755 --- a/puke +++ b/puke @@ -85,13 +85,14 @@ pkg_build() { pkg_strip() { log "Stripping unneeded symbols from binaries and libraries" + find "$pkg_dir" -type f | while read -r binary; do - case "$(file -bi "$binary")" in + case $(file -bi "$binary") in application/x-sharedlib*|application/x-pie-executable*) - strip_opts="--strip-unneeded" + strip_opts=--strip-unneeded ;; - application/x-archive*) strip_opts="--strip-debug" ;; - application/x-executable*) strip_opts="--strip-all" ;; + application/x-archive*) strip_opts=--strip-debug ;; + application/x-executable*) strip_opts=--strip-all ;; *) continue ;; esac strip "$strip_opts" "$binary" @@ -162,7 +163,7 @@ args() { pkg_verify pkg_extract pkg_build - [ ! -f nostrip ] && pkg_strip + [ -f nostrip ] || pkg_strip pkg_manifest pkg_tar ;;