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 #!/bin/sh
# Generate sources for rust packages.
[ "$1" ] || { [ "$1" ] || {
printf 'usage: kiss-carg-urlgen [crate-ver] [crate-ver]\n' printf 'usage: kiss-cargo-urlgen [crate-ver] [crate-ver]\n'
exit 1 exit 1
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,5 @@
#!/bin/sh -ef #!/bin/sh -ef
# # Find the maintainer of a package.
# kiss-maintainer - find the maintainer of a package.
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) ||:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,4 @@
#!/bin/sh #!/bin/sh
# # Display a package's original dependencies.
# kiss-repodepends
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 #!/bin/sh -ef
# Remove all packages except for the base.
# #
# Disable word-splittng warnings as they're safe here. # Disable word-splittng warnings as they're safe here.
# shellcheck disable=SC2046 # shellcheck disable=SC2046
#
# kiss-reset: Remove all packages except for the base.
set -- set --

View File

@ -1,6 +1,5 @@
#!/bin/sh -e #!/bin/sh -e
# # Display packages which depend on package.
# kiss-revdepends - Display packages which depend on package.
# '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'.

View File

@ -1,6 +1,5 @@
#!/bin/sh -ef #!/bin/sh -ef
# # Show the size on disk for a package.
# kiss-size - Show the size on disk for a package.
db_dir=$KISS_ROOT/var/db/kiss/installed/${1-null} db_dir=$KISS_ROOT/var/db/kiss/installed/${1-null}

44
kiss
View File

@ -125,7 +125,7 @@ pkg_find() {
set +f set +f
for path2 in "$path/"$query; do for path2 in "$path/"$query; do
[ -d "$path2" ] && set -f -- "$@" "$path2" [ -e "$path2" ] && set -f -- "$@" "$path2"
done done
done done
@ -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 ] && printf '%s\n' "$@" || printf '%s\n' "$1" [ -t 1 ] || [ "$2" ] && printf '%s\n' "$@" || printf '%s\n' "$1"
} }
pkg_list() { pkg_list() {
@ -1334,18 +1334,38 @@ args() {
h|help|-h|--help|'') h|help|-h|--help|'')
log 'kiss [a|b|c|i|l|r|s|u|v] [pkg] [pkg] [pkg]' log 'kiss [a|b|c|i|l|r|s|u|v] [pkg] [pkg] [pkg]'
log 'alternatives: List and swap to alternatives' log 'alternatives List and swap to alternatives'
log 'build: Build a package' log 'build Build a package'
log 'checksum: Generate checksums' log 'checksum Generate checksums'
log 'install: Install a package' log 'install Install a package'
log 'list: List installed packages' log 'list List installed packages'
log 'remove: Remove a package' log 'remove Remove a package'
log 'search: Search for a package' log 'search Search for a package'
log 'update: Check for updates' log 'update Check for updates'
log 'version: Package manager version' 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 esac
} }