aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2019-08-20 09:57:44 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2019-08-20 09:57:44 +0000
commitd7813394d5e3bb7699bd7e2a28d6045dfcd3a794 (patch)
tree0eb5529e59eaa08f5fc81402065924ea33393978
parentabb05d9e951ea5bfb2277c828467557cc68d605d (diff)
downloadcpt-d7813394d5e3bb7699bd7e2a28d6045dfcd3a794.tar.gz
misc: cleanup
FossilOrigin-Name: b26f5dbe213c6fecf8840e79a0b05863807e8c718e45c16f636b4748fdcd3fb8
-rwxr-xr-xkiss29
1 files changed, 12 insertions, 17 deletions
diff --git a/kiss b/kiss
index 16d2e24..413b034 100755
--- a/kiss
+++ b/kiss
@@ -62,7 +62,8 @@ pkg_search() {
[ "$KISS_PATH" ] || die "\$KISS_PATH needs to be set"
# Find the repository containing a package.
- # Searches installed packages if the package is absent from the repositories.
+ # Searches installed packages if the package is absent
+ # from the repositories.
set -- "$1" $(IFS=:; find $KISS_PATH "$KISS_ROOT/$pkg_db" \
-maxdepth 1 -name "$1")
@@ -771,7 +772,7 @@ pkg_install() {
log "[$pkg_name] Installing package"
- # Block being able to abort the script with 'Ctrl+C' during installation.
+ # Block being able to abort the script with Ctrl+C during installation.
# Removes all risk of the user aborting a package installation leaving
# an incomplete package installed.
trap '' INT
@@ -782,13 +783,13 @@ pkg_install() {
cp -f "$KISS_ROOT/$pkg_db/$pkg_name/manifest" "$cac_dir/m-$pkg_name"
# This is repeated multiple times. Better to make it a function.
- rsync_pkg() {
+ pkg_rsync() {
rsync -HKav --exclude etc -- "$tar_dir/$pkg_name/" "$KISS_ROOT/"
}
# Install the package by using 'rsync' and overwrite any existing files
# (excluding '/etc/').
- rsync_pkg
+ pkg_rsync
# If '/etc/' exists in the package, install it but don't overwrite.
[ -d "$tar_dir/$pkg_name/etc" ] &&
@@ -813,8 +814,8 @@ pkg_install() {
# Install the package again to fix any non-leftover files being
# removed above.
- rsync_pkg ||:
- rsync_pkg ||:
+ pkg_rsync ||:
+ pkg_rsync ||:
# Reset 'trap' to its original value. Installation is done so
# we no longer need to block 'Ctrl+C'.
@@ -947,8 +948,10 @@ args() {
# Rerun the script with 'sudo' if the user isn't root.
# Cheeky but 'sudo' can't be used on shell functions themselves.
- [ "$(id -u)" = 0 ] ||
- exec sudo KISS_PATH=$KISS_PATH kiss "$action" "$@"
+ [ "$(id -u)" = 0 ] || {
+ sudo KISS_PATH=$KISS_PATH kiss "$action" "$@"
+ return
+ }
;;
esac
@@ -1036,15 +1039,7 @@ args() {
s|search)
for pkg; do
- # Create a list of all matching packages.
- set -- $(IFS=:; find $KISS_PATH -mindepth 1 \
- -maxdepth 1 -name "$pkg")
-
- # Print all matches. If there aren't any, print an error.
- printf '%s\n' "${@:-$(log "[$pkg] Not found")}"
-
- # Exit with an error if a search fails.
- [ "$1" ] || exit 1
+ pkg_search "$pkg"
done
;;