1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-12-22 23:20:06 -07:00

kiss: Unify usage outputs for all contrib scripts.

Seeing as how these utilities are now better integrated,
more effort should go into the overall interface between
what should be the "benchmark" or example kiss scripts.
This commit is contained in:
Dylan Araps 2020-04-18 12:11:56 +03:00
parent fdf2775640
commit 6786d2ca0a
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
13 changed files with 68 additions and 31 deletions

View File

@ -12,7 +12,7 @@ clean() {
} }
pid=$$ pid=$$
url=https://github.com/kisslinux/repo/releases/download/1.9.0/ url=https://github.com/kisslinux/repo/releases/download/1.9.11/
cd "${cac_dir:=$KISS_ROOT${XDG_CACHE_HOME:-$HOME/.cache}/kiss}" cd "${cac_dir:=$KISS_ROOT${XDG_CACHE_HOME:-$HOME/.cache}/kiss}"
@ -23,7 +23,7 @@ cd "${cac_dir:=$KISS_ROOT${XDG_CACHE_HOME:-$HOME/.cache}/kiss}"
[ -d kiss-chroot ] || { [ -d kiss-chroot ] || {
log "Extracting chroot" log "Extracting chroot"
tar xvf kiss-chroot.tar.xz tar xf kiss-chroot.tar.xz
} }
log "Creating temporary chroot" log "Creating temporary chroot"

View File

@ -1,8 +1,11 @@
#!/bin/sh -ef #!/bin/sh -ef
# Display a package's dependencies. # Display a package's dependencies.
kiss l "${1:-null}" >/dev/null # Ignore shellcheck as we want the warning's behavior.
# shellcheck disable=2015
[ "$1" ] && kiss l "${1:-null}" >/dev/null || {
printf 'usage: kiss-depends [pkg]\n'
exit 1
}
db_dir=$KISS_ROOT/var/db/kiss/installed/${1:-null} cat "$KISS_ROOT/var/db/kiss/installed/$1/depends" 2>/dev/null
cat "$db_dir/depends" 2>/dev/null

View File

@ -1,7 +1,12 @@
#!/bin/sh -e #!/bin/sh -e
# Find missing dependencies by parsing 'ldd'. # Find missing dependencies by parsing 'ldd'.
kiss l "${1:-null}" >/dev/null # Ignore shellcheck as we want the warning's behavior.
# shellcheck disable=2015
[ "$1" ] && kiss l "${1:-null}" >/dev/null || {
printf 'usage: kiss-depends-finder [pkg]\n'
exit 1
}
db_dir=$KISS_ROOT/var/db/kiss/installed db_dir=$KISS_ROOT/var/db/kiss/installed
grep=$(command -v ggrep) || grep='grep' grep=$(command -v ggrep) || grep='grep'
@ -29,7 +34,7 @@ while read -r file; do
# Skip listing these packages as dependencies. # Skip listing these packages as dependencies.
case $pkg in case $pkg in
musl|gcc|$1) ;; musl|gcc|"$1") ;;
*) printf '%s\n' "$pkg" ;; *) printf '%s\n' "$pkg" ;;
esac esac
done done

View File

@ -1,11 +1,15 @@
#!/bin/sh -ef #!/bin/sh -ef
# Turn an installed package into a KISS tarball. # Turn an installed package into a KISS tarball.
kiss l "${1:-null}" >/dev/null # Ignore shellcheck as we want the warning's behavior.
# shellcheck disable=2015
[ "$1" ] && kiss l "${1:-null}" >/dev/null || {
printf 'usage: kiss-export [pkg]\n'
exit 1
}
# Grab the package's version.. # Grab the package's version..
read -r ver rel 2>/dev/null < \ read -r ver rel 2>/dev/null < "$KISS_ROOT/var/db/kiss/installed/$1/version"
"$KISS_ROOT/var/db/kiss/installed/$1/version"
# Reset the argument list. # Reset the argument list.
pkg=$1 pkg=$1

View File

@ -1,8 +1,10 @@
#!/bin/sh -ef #!/bin/sh -ef
# Copy a package's repository files into the current directory. # Copy a package's repository files into the current directory.
kiss s "${1:-null}" >/dev/null || { # Ignore shellcheck as we want the warning's behavior.
printf 'usage: kiss-fork pkg_name\n' # shellcheck disable=2015
[ "$1" ] && kiss s "${1:-null}" >/dev/null || {
printf 'usage: kiss-fork [pkg]\n'
exit 1 exit 1
} }

View File

@ -1,6 +1,11 @@
#!/bin/sh -ef #!/bin/sh -ef
# Find the maintainer of a package. # Find the maintainer of a package.
[ "$1" ] || {
printf 'usage: kiss-maintainer [pkg]\n'
exit 1
}
kiss s "$1" | while read -r repo; do cd "$repo" kiss s "$1" | while read -r repo; do cd "$repo"
m=$(git log -1 version 2>/dev/null) ||: m=$(git log -1 version 2>/dev/null) ||:
m=${m##*Author: } m=${m##*Author: }

View File

@ -1,8 +1,11 @@
#!/bin/sh -ef #!/bin/sh -ef
# Display all files owned by a package. # Display all files owned by a package.
kiss l "${1:-null}" >/dev/null # Ignore shellcheck as we want the warning's behavior.
# shellcheck disable=2015
[ "$1" ] && kiss l "${1:-null}" >/dev/null || {
printf 'usage: kiss-manifest [pkg]\n'
exit 1
}
db_dir=$KISS_ROOT/var/db/kiss/installed/${1:-null} cat "$KISS_ROOT/var/db/kiss/installed/$1/manifest" 2>/dev/null
cat "$db_dir/manifest" 2>/dev/null

View File

@ -1,9 +1,12 @@
#!/bin/sh -ef #!/bin/sh -ef
# Display all files owned by a package in a tree. # Display all files owned by a package in a tree.
kiss l "${1:-null}" # Ignore shellcheck as we want the warning's behavior.
# shellcheck disable=2015
db_dir=$KISS_ROOT/var/db/kiss/installed/${1:-null} [ "$1" ] && kiss l "${1:-null}" >/dev/null || {
printf 'usage: kiss-manifest-tree [pkg]\n'
exit 1
}
printf '%s\n' "[$1]:" printf '%s\n' "[$1]:"
tree -C --fromfile "$db_dir/manifest" | tail -n +2 tree -C --fromfile "$KISS_ROOT/var/db/kiss/installed/$1/manifest" | tail -n +2

View File

@ -5,9 +5,8 @@
# follow symlinks. # follow symlinks.
file=$(readlink -f "$KISS_ROOT/${1##$KISS_ROOT}") file=$(readlink -f "$KISS_ROOT/${1##$KISS_ROOT}")
# Check if the file exists and exit if it is not.
[ -f "$file" ] || { [ -f "$file" ] || {
printf '%s\n' "error: file '$1' doesn't exist." >&2 printf 'usage: kiss-owns [/path/to/file]\n'
exit 1 exit 1
} }

View File

@ -1,4 +1,11 @@
#!/bin/sh #!/bin/sh
# Display a package's original dependencies. # Display a package's original dependencies.
# Ignore shellcheck as we want the warning's behavior.
# shellcheck disable=2015
[ "$1" ] && kiss s "${1:-null}" >/dev/null || {
printf 'usage: kiss-repodepends [pkg]\n'
exit 1
}
cat "$(kiss s "$1")/depends" 2>/dev/null cat "$(kiss s "$1")/depends" 2>/dev/null

View File

@ -1,6 +1,13 @@
#!/bin/sh -e #!/bin/sh -e
# Display packages which depend on package. # Display packages which depend on package.
# Ignore shellcheck as we want the warning's behavior.
# shellcheck disable=2015
[ "$1" ] && kiss l "${1:-null}" >/dev/null || {
printf 'usage: kiss-revdepends [pkg]\n'
exit 1
}
# 'cd' to the database directory as a simple way of # 'cd' to the database directory as a simple way of
# stripping the path and performing a 'basename'. # stripping the path and performing a 'basename'.
cd "$KISS_ROOT/var/db/kiss/installed" cd "$KISS_ROOT/var/db/kiss/installed"

View File

@ -1,17 +1,16 @@
#!/bin/sh -ef #!/bin/sh -ef
# Show the size on disk for a package. # Show the size on disk for a package.
db_dir=$KISS_ROOT/var/db/kiss/installed/${1-null} # Ignore shellcheck as we want the warning's behavior.
# shellcheck disable=2015
# Check if package is installed and exit if it is not. [ "$1" ] && kiss l "${1:-null}" >/dev/null || {
[ -d "$db_dir" ] || { printf 'usage: kiss-size [pkg]\n'
printf '%s\n' "error: '$1' not installed." >&2
exit 1 exit 1
} }
# Filter directories from manifest and leave only files. # Filter directories from manifest and leave only files.
# Directories in the manifest end in a trailing '/'. # Directories in the manifest end in a trailing '/'.
files=$(sed 's|.*/$||' "$db_dir/manifest") files=$(sed 's|.*/$||' "$KISS_ROOT/var/db/kiss/installed/$1/manifest")
# Send the file list to 'du'. # Send the file list to 'du'.
# This unquoted variable is safe as word splitting is intended # This unquoted variable is safe as word splitting is intended

4
kiss
View File

@ -115,7 +115,7 @@ pkg_find() {
# Figure out which repository a package belongs to by # Figure out which repository a package belongs to by
# searching for directories matching the package name # searching for directories matching the package name
# in $KISS_PATH/*. # in $KISS_PATH/*.
query=$1 IFS=:; set -- query=$1 all=$2 IFS=:; set --
# Both counts of word-splitting are intentional here. # Both counts of word-splitting are intentional here.
# Firstly to split the repositories and secondly to # Firstly to split the repositories and secondly to
@ -137,7 +137,7 @@ pkg_find() {
# Show all search results if called from 'kiss search', else # Show all search results if called from 'kiss search', else
# print only the first match. # print only the first match.
[ -t 1 ] || [ "$2" ] && printf '%s\n' "$@" || printf '%s\n' "$1" [ -t 1 ] || [ "$all" ] && printf '%s\n' "$@" || printf '%s\n' "$1"
} }
pkg_list() { pkg_list() {