kiss: Integrate with user scripts.

kiss' help output will now include all executables found in $PATH
which begin with kiss-*. A comment string is optionally usable via
setting the second line of the script to a string.

Example:

...

This also means that 'kiss <script name>' is also possible now.
If I have a script in my $PATH called kiss-depends, I can now use
it via kiss with 'kiss depends'.
This commit is contained in:
Dylan Araps 2020-04-18 11:39:37 +03:00
parent afda171053
commit fdf2775640
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
20 changed files with 50 additions and 41 deletions

View File

@ -1,7 +1,8 @@
#!/bin/sh
# Generate sources for rust packages.
[ "$1" ] || {
printf 'usage: kiss-carg-urlgen [crate-ver] [crate-ver]\n'
printf 'usage: kiss-cargo-urlgen [crate-ver] [crate-ver]\n'
exit 1
}

View File

@ -1,5 +1,4 @@
#!/bin/sh -e
#
# Create/destroy temporary chroots.
log() {

View File

@ -1,6 +1,5 @@
#!/bin/sh -e
#
# kiss-chroot: Enter a chroot.
# Enter a kiss chroot.
log() {
printf '\033[32m->\033[m %s.\n' "$*"

View File

@ -1,6 +1,5 @@
#!/bin/sh -ef
#
# kiss-depends - Display a package's dependencies.
# Display a package's dependencies.
kiss l "${1:-null}" >/dev/null

View File

@ -1,5 +1,4 @@
#!/bin/sh -e
#
# Find missing dependencies by parsing 'ldd'.
kiss l "${1:-null}" >/dev/null

View File

@ -1,6 +1,5 @@
#!/bin/sh -ef
#
# kiss-export - Turn an installed package into a KISS tarball.
# Turn an installed package into a KISS tarball.
kiss l "${1:-null}" >/dev/null

View File

@ -1,4 +1,5 @@
#!/bin/sh -ef
# Copy a package's repository files into the current directory.
kiss s "${1:-null}" >/dev/null || {
printf 'usage: kiss-fork pkg_name\n'

View File

@ -1,4 +1,5 @@
#!/bin/sh -ef
# Link a repository file to another repository.
[ "$1" ] || {
printf 'usage: kiss-link file\n'

View File

@ -1,6 +1,5 @@
#!/bin/sh -ef
#
# kiss-maintainer - find the maintainer of a package.
# Find the maintainer of a package.
kiss s "$1" | while read -r repo; do cd "$repo"
m=$(git log -1 version 2>/dev/null) ||:

View File

@ -1,6 +1,5 @@
#!/bin/sh -ef
#
# kiss-manifest - Display all files owned by a package.
# Display all files owned by a package.
kiss l "${1:-null}" >/dev/null

View File

@ -1,6 +1,5 @@
#!/bin/sh -ef
#
# kiss-manifest-tree - Display all files owned by a package.
# Display all files owned by a package in a tree.
kiss l "${1:-null}"

View File

@ -1,4 +1,5 @@
#!/bin/sh
# Create a boilerplate package.
die() {
printf 'error: %s.\n' "$*" >&2

View File

@ -1,6 +1,5 @@
#!/bin/sh -e
#
# kiss-orphans - List orphaned packages.
# List orphaned packages.
cd "$KISS_ROOT/var/db/kiss/installed/"

View File

@ -1,5 +1,4 @@
#!/bin/sh
#
# Check installed packages for updates.
old_IFS=$IFS

View File

@ -1,6 +1,5 @@
#!/bin/sh -e
#
# kiss-owns - Check which package owns a file.
# Check which package owns a file.
# Strip 'KISS_ROOT' from the file path if passed and
# follow symlinks.

View File

@ -1,5 +1,4 @@
#!/bin/sh
#
# kiss-repodepends
# Display a package's original dependencies.
cat "$(kiss s "$1" | sed 1q)/depends" 2>/dev/null
cat "$(kiss s "$1")/depends" 2>/dev/null

View File

@ -1,9 +1,8 @@
#!/bin/sh -ef
# Remove all packages except for the base.
#
# Disable word-splittng warnings as they're safe here.
# shellcheck disable=SC2046
#
# kiss-reset: Remove all packages except for the base.
set --

View File

@ -1,6 +1,5 @@
#!/bin/sh -e
#
# kiss-revdepends - Display packages which depend on package.
# Display packages which depend on package.
# 'cd' to the database directory as a simple way of
# stripping the path and performing a 'basename'.

View File

@ -1,6 +1,5 @@
#!/bin/sh -ef
#
# kiss-size - 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}

44
kiss
View File

@ -125,7 +125,7 @@ pkg_find() {
set +f
for path2 in "$path/"$query; do
[ -d "$path2" ] && set -f -- "$@" "$path2"
[ -e "$path2" ] && set -f -- "$@" "$path2"
done
done
@ -137,7 +137,7 @@ pkg_find() {
# Show all search results if called from 'kiss search', else
# print only the first match.
[ -t 1 ] && printf '%s\n' "$@" || printf '%s\n' "$1"
[ -t 1 ] || [ "$2" ] && printf '%s\n' "$@" || printf '%s\n' "$1"
}
pkg_list() {
@ -1334,18 +1334,38 @@ args() {
h|help|-h|--help|'')
log 'kiss [a|b|c|i|l|r|s|u|v] [pkg] [pkg] [pkg]'
log 'alternatives: List and swap to alternatives'
log 'build: Build a package'
log 'checksum: Generate checksums'
log 'install: Install a package'
log 'list: List installed packages'
log 'remove: Remove a package'
log 'search: Search for a package'
log 'update: Check for updates'
log 'version: Package manager version'
log 'alternatives List and swap to alternatives'
log 'build Build a package'
log 'checksum Generate checksums'
log 'install Install a package'
log 'list List installed packages'
log 'remove Remove a package'
log 'search Search for a package'
log 'update Check for updates'
log 'version Package manager version
'
log "Installed extensions (kiss-* in \$PATH)"
KISS_PATH=$PATH
for path in $(pkg_find kiss-\* all); do
set -- "${path#*/kiss-}" "$@"
max=$((${#1} > max ? ${#1} : max))
done
for path do
printf '\033[31;1m->\033[m %-*s ' "$max" "${path#*/kiss-}"
sed -n 's/^# *//;2p' "$(command -v "kiss-$path")"
done | sort -uk1 >&2
;;
*) die "'kiss $action' is not a valid command" ;;
*)
command -v "kiss-$action" >/dev/null ||
die "'kiss $action' is not a valid command"
"kiss-$action" "$@"
;;
esac
}