cpt

[ARCHIVED] Carbs Packaging Tools
git clone git://git.ckyln.com/~cem/cpt.git
Log | Files | Refs | README | LICENSE

commit 7b36eb0f99dcde01d07a8854e7e0e0f13ba58826
parent a4d26034c762cfa5e21cc39eacbe256e64b33d35
Author: Dylan Araps <dylan.araps@gmail.com>
Date:   Tue, 25 Feb 2020 22:56:41 +0200

contrib: clean up

Diffstat:
Mcontrib/kiss-chbuild | 1+
Mcontrib/kiss-depends | 10+++-------
Dcontrib/kiss-depends-finder | 46----------------------------------------------
Mcontrib/kiss-export | 30++++++++++++++++++------------
Mcontrib/kiss-manifest | 10+++-------
Mcontrib/kiss-manifest-tree | 8++------
Mcontrib/kiss-orphans | 8+++-----
Mcontrib/kiss-reset | 19++++++++++---------
8 files changed, 40 insertions(+), 92 deletions(-)

diff --git a/contrib/kiss-chbuild b/contrib/kiss-chbuild @@ -8,6 +8,7 @@ log() { clean() { log "Destroying chroot" + su -c "rm -rf chroot-$pid" || clean } diff --git a/contrib/kiss-depends b/contrib/kiss-depends @@ -2,12 +2,8 @@ # # kiss-depends - Display a package's dependencies. -db_dir=$KISS_ROOT/var/db/kiss/installed/${1-null} +kiss l "${1:-null}" >/dev/null -# Check if package is installed and exit if it is not. -[ -d "$db_dir" ] || { - printf '%s\n' "error: '$1' not installed." >&2 - exit 1 -} +db_dir=$KISS_ROOT/var/db/kiss/installed/${1:-null} -[ -f "$db_dir/depends" ] && cat "$db_dir/depends" +cat "$db_dir/depends" 2>/dev/null diff --git a/contrib/kiss-depends-finder b/contrib/kiss-depends-finder @@ -1,46 +0,0 @@ -#!/bin/sh -e -# -# Find missing dependencies by parsing 'ldd'. - -db_dir=$KISS_ROOT/var/db/kiss/installed - -# Check if package is installed and exit if it is not. -[ -d "$db_dir/${1-null}" ] || { - printf '%s\n' "error: '$1' not installed." >&2 - exit 1 -} - -printf '%s\n' "=> Detected dependencies:" - -while read -r file; do - # Skip directories. - [ -d "$KISS_ROOT/$file" ] && continue - - ldd "$KISS_ROOT/$file" 2>/dev/null | while read -r dep; do - # Skip lines containing 'ldd'. - [ "${dep##*ldd*}" ] || continue - - # Extract the file path from 'ldd' output. - dep=${dep#* => } - dep=${dep% *} - - # Traverse symlinks to get the true path to the file. - pkg=$(readlink -f "$KISS_ROOT/${dep##$KISS_ROOT}") - - # Figure out which package owns the file. - pkg=$(grep -lFx "${pkg##$KISS_ROOT}" "$db_dir/"*/manifest) - pkg=${pkg%/*} - pkg=${pkg##*/} - - case $pkg in - # Skip listing these packages as dependencies. - musl|gcc|$1) ;; - *) printf '%s\n' "$pkg" ;; - esac - done & -done < "$db_dir/$1/manifest" | sort | uniq - -printf '\n%s\n' "=> Package dependencies:" - -[ -f "$db_dir/$1/depends" ] && - cat "$db_dir/$1/depends" diff --git a/contrib/kiss-export b/contrib/kiss-export @@ -2,16 +2,22 @@ # # kiss-export - Turn an installed package into a KISS tarball. -read -r ver rel 2>/dev/null < "$KISS_ROOT/var/db/kiss/installed/$1/version" || { - printf '%s\n' "error: '$1' is not installed." >&2 - exit 1 -} +kiss l "${1:-null}" >/dev/null -# This warning is safe to ignore as globs are disabled and -# word splitting is intentional. -# shellcheck disable=2046 -tar czvf "$1#$ver-$rel.tar.gz" -C / -- $( - while read -r file; do - [ -d "$KISS_ROOT/$file" ] || printf '%s\n' ".$file" - done < "$KISS_ROOT/var/db/kiss/installed/$1/manifest" -) +# Grab the package's version.. +read -r ver rel 2>/dev/null < \ + "$KISS_ROOT/var/db/kiss/installed/$1/version" + +# Reset the argument list. +pkg=$1 +set -- + +# Construct the argument list using each file. +while read -r file || [ "$file" ]; do + [ -d "$KISS_ROOT/$file" ] || set -- "$@" ".$file" +done < "$KISS_ROOT/var/db/kiss/installed/$pkg/manifest" + +# Turn the list of files back into a package. +tar czf "$pkg#$ver-$rel.tar.gz" -C / -- "$@" + +printf 'tarball created in %s\n' "$PWD/$pkg#$ver-$rel.tar.gz" diff --git a/contrib/kiss-manifest b/contrib/kiss-manifest @@ -2,12 +2,8 @@ # # kiss-manifest - Display all files owned by a package. -db_dir=$KISS_ROOT/var/db/kiss/installed/${1-null} +kiss l "${1:-null}" >/dev/null -# Check if package is installed and exit if it is not. -[ -d "$db_dir" ] || { - printf '%s\n' "error: '$1' not installed." >&2 - exit 1 -} +db_dir=$KISS_ROOT/var/db/kiss/installed/${1:-null} -cat "$db_dir/manifest" +cat "$db_dir/manifest" 2>/dev/null diff --git a/contrib/kiss-manifest-tree b/contrib/kiss-manifest-tree @@ -2,13 +2,9 @@ # # kiss-manifest-tree - Display all files owned by a package. -db_dir=$KISS_ROOT/var/db/kiss/installed/${1-null} +kiss l "${1:-null}" -# Check if package is installed and exit if it is not. -[ -d "$db_dir" ] || { - printf '%s\n' "error: '$1' not installed." >&2 - exit 1 -} +db_dir=$KISS_ROOT/var/db/kiss/installed/${1:-null} printf '%s\n' "[$1]:" tree -C --fromfile "$db_dir/manifest" | tail -n +2 diff --git a/contrib/kiss-orphans b/contrib/kiss-orphans @@ -5,12 +5,10 @@ cd "$KISS_ROOT/var/db/kiss/installed/" for pkg in *; do - # Skip these packages. case $pkg in - baseinit|baselayout|gcc|pkgconf|e2fsprogs|\ - make|busybox|bzip2|grub|automake) - continue - ;; + baseinit|baselayout|gcc|pkgconf|e2fsprogs|musl|\ + make|busybox|bzip2|grub|automake|kiss|rsync|git) + continue esac grep -q "^$pkg$" ./*/depends || printf '%s\n' "$pkg" diff --git a/contrib/kiss-reset b/contrib/kiss-reset @@ -5,16 +5,17 @@ # # kiss-reset: Remove all packages except for the base. -set -- \ - $(kiss l | while read -r pkg _; do - case $pkg in - baselayout|binutils|bison|busybox|bzip2|curl|flex|gcc|git|\ - gzip|kiss|libelf|libressl|linux-headers|m4|make|mandoc|musl|\ - perl|pkgconf|rsync|xz|zlib) ;; +set -- - *) printf '%s\n' "$pkg" ;; - esac - done) +kiss l | while read -r pkg _; do + case $pkg in + baselayout|binutils|bison|busybox|bzip2|curl|flex|gcc|git|\ + gzip|kiss|libelf|libressl|linux-headers|m4|make|musl|perl|\ + pkgconf|rsync|xz|zlib) ;; + + *) set -- "$@" "$pkg" ;; + esac +done [ "$1" ] && { printf 'WARNING: This will remove \033[1m%s\033[m package(s).\n' "$#"