pkgmeek: refactor the strip-binaries routine

This commit is contained in:
John McQuah 2023-02-16 18:14:27 -05:00
parent 46dba884e9
commit 57aaef22eb

View File

@ -75,8 +75,8 @@ rm -rf "$work"; mkdir -p "$work"/{src,pkg} && cd "$work"
here="${_local_[$u]}"; url="${source[$u]}";
# at least one of the following commands should put a file of the
# appropriate name in the current directory
[ -e "$here" ] || [ "$src_dir" = "" ] || [ ! -e "$src_dir/$here" ] || ln -sf "$src_dir/$here" ;
[ -e "$here" ] || [ ! -e "$PKGMK_ROOT/$here" ] || ln -sf "$PKGMK_ROOT/$here" ;
[ -e "$here" ] || [ "$src_dir" = "" ] || [ ! -e "$src_dir/$here" ] || ln -sf "$src_dir/$here" . ;
[ -e "$here" ] || [ ! -e "$PKGMK_ROOT/$here" ] || ln -sf "$PKGMK_ROOT/$here" . ;
[ -e "$here" ] || fetch_url "$url" "$here"; # <-- should also be able to resume partial downloads
[ -e "$here" ] || { error "failed to download $here. Check connection and try again."; errDL+=1; }
done ; }
@ -160,13 +160,13 @@ if [ "$pkg_utd" = 0 ] || [ "$PKGMK_FORCE" = "yes" ]; then
|| { error "Unsuccessful build!"; cleanup_work; exit "$E_BUILD"; }
[ -f "$PKGMK_ROOT/.nostrip" ] && ns_filter="| grep -v -f $PKGMK_ROOT/.nostrip"
find pkg -type f $ns_filter | while read -r f; do
{ while read -r f; do
case $(file -b "$f") in
*ELF*executable*not\ stripped*) strip --strip-all "$f" ;;
*ELF*shared\ object*not\ stripped*) strip --strip-unneeded "$f" ;;
current\ ar\ archive) strip --strip-debug "$f" ;;
esac
done
done } < <(eval find pkg -type f $ns_filter)
find pkg -type f -path "*/man/man*/*" | grep -v '.gz$' | xargs -r -I{} gzip -9 '{}'
find pkg -xtype l -path "*/man/man*/*" | while read f; do
@ -345,7 +345,7 @@ check_pkg_mtime() { # can be called even if some sources are missing
utd=1
while [ $li -lt ${#_local_[@]} ] && [ "$utd" = 1 ]; do
[ ! -e "${_local_[$li]}" ] || \
[ "$pkgdir$package" -nt $(realpath "${_local_[$li]}") ] || utd=0
[ "$pkg_dir$package" -nt $(realpath "${_local_[$li]}") ] || utd=0
li=$(( li+1 ))
done
[ ! -e "$PKGMK_ROOT/Pkgfile" ] || [ "$pkg_dir$package" -nt "$PKGMK_ROOT/Pkgfile" ] || utd=0