From 303a80c9d93d1134ed5a74c39215bb290fd400cf Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 29 Jun 2019 18:09:07 +0300 Subject: [PATCH] kiss-new: Added package stripping. --- kiss-new | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/kiss-new b/kiss-new index 3449306..c9befe5 100755 --- a/kiss-new +++ b/kiss-new @@ -319,20 +319,54 @@ pkg_build() { # structure. repo_dir=$(pkg_search "$pkg") + # Install built packages to a directory under the package name + # to avod collisions with other packages. + mkdir -p "$pkg_dir/$pkg/var/db/$kiss" + # Move to the build directory and call the build script. - (cd "$mak_dir/$pkg"; "$repo_dir/build" "$pkg_dir") || + (cd "$mak_dir/$pkg"; "$repo_dir/build" "$pkg_dir/$pkg") || die "[$pkg]: Build failed." # Copy the repository files to the package directory. # This acts as the database entry. - cp -Rf "$repo_dir" "$pkg_db" + cp -Rf "$repo_dir" "$pkg_dir/$pkg/var/db/$kiss" log "[$pkg]: Sucessfully built package." # Create the manifest file early and make it empty. # This ensure that the manifest is added to the manifest... - : > "$pkg_db/$pkg/manifest" + : > "$pkg_dir/$pkg/var/db/$kiss/$pkg/manifest" done + + log "Stripping packages..." + for pkg; do + # Find the package's repository files. This needs to keep + # happening as we can't store this data in any kind of data + # structure. + repo_dir=$(pkg_search "$pkg") + + # Package has stripping disabled, stop here. + [ -f "$repo_dir/nostrip" ] && continue + + log "[$pkg]: Stripping binaries and libraries..." + + find "$pkg_dir/$pkg" -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 ;; + + *) continue ;; + esac + + strip "$strip_opts" "$binary" 2>/dev/null + done + done + + log "Stripped all binaries and libraries." } pkg_checksums() { @@ -397,7 +431,7 @@ setup_caching() { die "Couldn't create build directory ($mak_dir)." # Package directory. - mkdir -p "${pkg_db:=${pkg_dir:=$cac_dir/pkg-$pid}/var/db/$kiss}" || + mkdir -p "${pkg_dir:=$cac_dir/pkg-$pid}" || die "Couldn't create package directory ($pkg_dir)." # Tar directory.