From dba11ac3f2902e9594dfecb042f0760ad0995e1c Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Sat, 29 Jun 2019 15:09:07 +0000 Subject: kiss-new: Added package stripping. FossilOrigin-Name: 3c9ac3670356e71820021023c00c4c31c89766fa7d67e2f76ee3f8eb596ec9a6 --- 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. -- cgit v1.2.3