contrib: clean up

This commit is contained in:
Dylan Araps 2020-02-25 22:56:41 +02:00
parent a4d26034c7
commit 7b36eb0f99
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
8 changed files with 40 additions and 92 deletions

View File

@ -8,6 +8,7 @@ log() {
clean() {
log "Destroying chroot"
su -c "rm -rf chroot-$pid" || clean
}

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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' "$#"