aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-04-20 18:11:43 +0000
committermerakor <cem@ckyln.com>2020-04-20 18:11:43 +0000
commit7a4fcf554c75c5f73bf51f840e72ba7fbedb7e60 (patch)
tree4e0c47c6a2d14295a7f48553793d11008fed24cc
parent395d0f1a6019c176de72ce3aa30f57eb810b0d9b (diff)
downloadcpt-7a4fcf554c75c5f73bf51f840e72ba7fbedb7e60.tar.gz
contrib: additions, usage, simplifications
FossilOrigin-Name: 8d7d95914b0d1d981416c4fe1511987af3dd0170d436ee2176de9cb279988dd0
-rwxr-xr-xcontrib/kiss-cargo-urlgen2
-rwxr-xr-xcontrib/kiss-cargolock-urlgen9
-rwxr-xr-xcontrib/kiss-cat2
-rwxr-xr-xcontrib/kiss-chbuild4
-rwxr-xr-xcontrib/kiss-chroot4
-rwxr-xr-xcontrib/kiss-depends7
-rwxr-xr-xcontrib/kiss-depends-finder4
-rwxr-xr-xcontrib/kiss-export2
-rwxr-xr-xcontrib/kiss-fork12
-rwxr-xr-xcontrib/kiss-link2
-rwxr-xr-xcontrib/kiss-maintainer1
-rwxr-xr-xcontrib/kiss-manifest8
-rwxr-xr-xcontrib/kiss-manifest-tree8
-rwxr-xr-xcontrib/kiss-new53
-rwxr-xr-xcontrib/kiss-orphans3
15 files changed, 56 insertions, 65 deletions
diff --git a/contrib/kiss-cargo-urlgen b/contrib/kiss-cargo-urlgen
index 9174edc..3e453ff 100755
--- a/contrib/kiss-cargo-urlgen
+++ b/contrib/kiss-cargo-urlgen
@@ -1,7 +1,7 @@
#!/bin/sh
[ "$1" ] || {
- printf 'usage: kiss-carg-urlgen [crate+ver] [crate+ver]\n'
+ printf '\033[1;33m-> \033[musage: kiss-cargo-urlgen [crate+ver] [crate+ver]\n'
exit 1
}
diff --git a/contrib/kiss-cargolock-urlgen b/contrib/kiss-cargolock-urlgen
index a67b374..f9f377a 100755
--- a/contrib/kiss-cargolock-urlgen
+++ b/contrib/kiss-cargolock-urlgen
@@ -2,10 +2,11 @@
# Converts the given Cargo.lock file to static cargo urls
-[ -r "$1" ] || {
- printf 'usage: %s <Cargo.lock file>\n' "${0##*/}"
- exit 1
-}
+case "$1" in
+ -) set -- /dev/stdin ;;
+ '') printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <Cargo.lock file>" "" \
+ "'-' can be used to read from stdin." ; exit 0
+esac
# Word splitting is intentional
# shellcheck disable=2046
diff --git a/contrib/kiss-cat b/contrib/kiss-cat
index 49b5695..987c10a 100755
--- a/contrib/kiss-cat
+++ b/contrib/kiss-cat
@@ -3,7 +3,7 @@
# Concatanate package files in the installed package database.
# File names are printed to stderr.
-[ "$1" ] || { printf 'usage: %s <pkg> [file] [file]\n' "${0##*/}" ; exit 1;}
+[ "$1" ] || { printf '\033[1;33m-> \033[musage: %s <pkg> [file] [file]\n' "${0##*/}" ; exit 1;}
kiss l "${pkg:=$1}" >/dev/null ; shift
for file in ${*:-build depends sources version} ; do
diff --git a/contrib/kiss-chbuild b/contrib/kiss-chbuild
index 9df18cc..aefeb10 100755
--- a/contrib/kiss-chbuild
+++ b/contrib/kiss-chbuild
@@ -2,9 +2,7 @@
#
# Create/destroy temporary chroots.
-log() {
- printf '\033[31;1m->\033[m %s.\n' "$@"
-}
+log() { printf '\033[31;1m->\033[m %s.\n' "$@" ;}
clean() {
log "Destroying chroot"
diff --git a/contrib/kiss-chroot b/contrib/kiss-chroot
index 71bfbb2..cf0f31d 100755
--- a/contrib/kiss-chroot
+++ b/contrib/kiss-chroot
@@ -6,6 +6,8 @@ log() {
printf '\033[32m->\033[m %s.\n' "$*"
}
+usage() { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <directory>" ; exit 0 ;}
+
die() {
log "$*" >&2
exit 1
@@ -24,7 +26,7 @@ clean() {
}
main() {
- [ -z "$1" ] && die Need a path to the chroot
+ [ "$1" ] || usage
[ -d "$1" ] || die Given path does not exist
[ "$(id -u)" = 0 ] || die Script needs to be run as root
diff --git a/contrib/kiss-depends b/contrib/kiss-depends
index 185a80b..811b4a9 100755
--- a/contrib/kiss-depends
+++ b/contrib/kiss-depends
@@ -2,8 +2,7 @@
#
# kiss-depends - Display a package's dependencies.
-kiss l "${1:-null}" >/dev/null
+[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;}
-db_dir=$KISS_ROOT/var/db/kiss/installed/${1:-null}
-
-cat "$db_dir/depends" 2>/dev/null
+kiss l "$1" >/dev/null
+cat "$KISS_ROOT/var/db/kiss/installed/$1/depends" 2>/dev/null
diff --git a/contrib/kiss-depends-finder b/contrib/kiss-depends-finder
index 432a105..403723e 100755
--- a/contrib/kiss-depends-finder
+++ b/contrib/kiss-depends-finder
@@ -2,7 +2,9 @@
#
# Find missing dependencies by parsing 'ldd'.
-kiss l "${1:-null}" >/dev/null
+[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;}
+
+kiss l "$1" >/dev/null
db_dir=$KISS_ROOT/var/db/kiss/installed
grep=$(command -v ggrep) || grep='grep'
diff --git a/contrib/kiss-export b/contrib/kiss-export
index 0645228..7fce122 100755
--- a/contrib/kiss-export
+++ b/contrib/kiss-export
@@ -2,6 +2,8 @@
#
# kiss-export - Turn an installed package into a KISS tarball.
+[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;}
+
kiss l "${1:-null}" >/dev/null
# Grab the package's version..
diff --git a/contrib/kiss-fork b/contrib/kiss-fork
index 6e1245c..a20d142 100755
--- a/contrib/kiss-fork
+++ b/contrib/kiss-fork
@@ -1,10 +1,16 @@
#!/bin/sh -ef
-kiss s "${1:-null}" >/dev/null || {
- printf 'usage: kiss-fork pkg_name\n'
- exit 1
+[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;}
+[ "$KISS_FORCE" ] || {
+ [ -d "$1" ] && {
+ printf '\033[1;31m!> \033[m%s\n' "$1 already exists on the current directory" \
+ "You can set KISS_FORCE=1 to ignore this."
+ exit 1
+ }
}
+kiss s "$1" >/dev/null
+
# Disable this warning as globbing is disabled and word splitting
# is intentional. This grabs the location of the package's files.
# shellcheck disable=2046
diff --git a/contrib/kiss-link b/contrib/kiss-link
index 1c0b2db..dd73864 100755
--- a/contrib/kiss-link
+++ b/contrib/kiss-link
@@ -1,6 +1,6 @@
#!/bin/sh -ef
-[ "$1" ] || { printf 'usage: kiss-link [file] [file]\n' ; exit 0 ;}
+[ "$1" ] || { printf '\033[1;33m-> \033[musage: kiss-link [file] [file]\n' ; exit 0 ;}
# Check if the package exists in a repository and error out here
# if it does not. The error message from the package manager will
diff --git a/contrib/kiss-maintainer b/contrib/kiss-maintainer
index 5039002..2c2d3ed 100755
--- a/contrib/kiss-maintainer
+++ b/contrib/kiss-maintainer
@@ -1,6 +1,7 @@
#!/bin/sh -ef
#
# kiss-maintainer - find the maintainer of a package.
+[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;}
kiss s "$1" | while read -r repo; do cd "$repo"
m=$(git log -1 version 2>/dev/null) ||:
diff --git a/contrib/kiss-manifest b/contrib/kiss-manifest
index 39a01d9..167738c 100755
--- a/contrib/kiss-manifest
+++ b/contrib/kiss-manifest
@@ -1,9 +1,7 @@
#!/bin/sh -ef
#
# kiss-manifest - Display all files owned by a package.
+[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;}
-kiss l "${1:-null}" >/dev/null
-
-db_dir=$KISS_ROOT/var/db/kiss/installed/${1:-null}
-
-cat "$db_dir/manifest" 2>/dev/null
+kiss l "$1" >/dev/null
+cat "$KISS_ROOT/var/db/kiss/installed/$1/manifest" 2>/dev/null
diff --git a/contrib/kiss-manifest-tree b/contrib/kiss-manifest-tree
index 7fcfb8c..609121a 100755
--- a/contrib/kiss-manifest-tree
+++ b/contrib/kiss-manifest-tree
@@ -2,9 +2,7 @@
#
# kiss-manifest-tree - Display all files owned by a package.
-kiss l "${1:-null}"
-
-db_dir=$KISS_ROOT/var/db/kiss/installed/${1:-null}
-
+[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;}
+kiss l "$1" >/dev/null
printf '%s\n' "[$1]:"
-tree -C --fromfile "$db_dir/manifest" | tail -n +2
+tree -C --fromfile "$KISS_ROOT/var/db/kiss/installed/$1/manifest" | sed 1,2d
diff --git a/contrib/kiss-new b/contrib/kiss-new
index c5ded48..d50cc5b 100755
--- a/contrib/kiss-new
+++ b/contrib/kiss-new
@@ -1,45 +1,26 @@
-#!/bin/sh
+#!/bin/sh -e
-die() {
- printf 'error: %s.\n' "$*" >&2
- exit 1
-}
+out() { printf '\033[1;33m-> \033[m%s\n' "$@" >&2 ;}
+die() { printf '\033[1;31m!> \033[m%s\n' "$@" >&2 ; exit 1 ;}
-log() {
- printf '=> %s.\n' "$*"
+[ "$1" ] || {
+ out "usage: ${0##*/} <name> [version] [source]" \
+ "Create boilerplate kiss packages"
+ exit 0
}
-main() {
- [ "$1" ] || {
- log Create boilerplate KISS packages
- log Usage: kiss-new name version source
-
- exit
- }
-
- [ -d "$1" ] &&
- die Package "$1" already exists.
+[ -d "$1" ] && die "Package '$1' already exists."
- mkdir -p "$1" ||
- die Couldn\'t create directory in "$PWD"
+# Create the directory
+mkdir -p "$1"
- cd "$1" ||
- die Couldn\'t enter directory "$1/"
+# Create the build file
+printf '%s\n' "#!/bin/sh -e" > "$1/build" ; chmod +x "$1/build"
- log Creating build file; {
- printf '#!/bin/sh -e\n' > build
- chmod +x build
- }
+# Create the version file
+printf '%s\n' "$2 1" > "$1/version"
- log Creating version file with "'${2%% *} 1'"; {
- printf '%s\n' "${2%% *} 1" > version
- }
-
- log Creating sources file with "'$3'"; {
- printf '%s\n' "$3" > sources
- }
-
- log Package "$1" created in "$PWD"
-}
+# Create the sources file
+printf '%s\n' "$3" > "$1/sources"
-main "$@"
+out "Package '$1' created to '$PWD/$1'"
diff --git a/contrib/kiss-orphans b/contrib/kiss-orphans
index ff9530d..3228b1c 100755
--- a/contrib/kiss-orphans
+++ b/contrib/kiss-orphans
@@ -13,3 +13,6 @@ for pkg in *; do
grep -q "^$pkg$" ./*/depends || printf '%s\n' "$pkg"
done
+
+printf '\033[1;33m-> \033[m%s\n' "kiss-orphans: lists packages that do not" \
+ "have any packages depending on them" >&2