cpt

[ARCHIVED] Carbs Packaging Tools
git clone git://git.ckyln.com/~cem/cpt.git
Log | Files | Refs | README | LICENSE

commit b57fcc958856de171e445a8b91176191406b3b83
parent f1293aca2d02ac81cfe42e758a7cedf8a00a8f12
Author: Cem Keylan <cem@ckyln.com>
Date:   Wed, 13 May 2020 22:51:21 +0300

contrib: use --help and -h for usage information

Diffstat:
Mcontrib/kiss-cargo-urlgen | 5+----
Mcontrib/kiss-cargolock-urlgen | 2+-
Mcontrib/kiss-cat | 2+-
Mcontrib/kiss-changelog | 5+----
Mcontrib/kiss-chbuild | 1+
Mcontrib/kiss-chroot | 2+-
Mcontrib/kiss-depends | 2+-
Mcontrib/kiss-depends-finder | 4++--
Mcontrib/kiss-export | 2+-
Mcontrib/kiss-fork | 2+-
Mcontrib/kiss-link | 2+-
Mcontrib/kiss-maintainer | 2+-
Mcontrib/kiss-manifest | 2+-
Mcontrib/kiss-manifest-tree | 2+-
Mcontrib/kiss-message | 5+----
Mcontrib/kiss-new | 6+-----
Mcontrib/kiss-orphans | 9++++++---
Mcontrib/kiss-owns | 2+-
Mcontrib/kiss-repodepends | 2+-
Mcontrib/kiss-reporevdepends | 5+----
Mcontrib/kiss-revdepends | 2+-
Mcontrib/kiss-size | 2+-
Mcontrib/kiss-which | 2+-
23 files changed, 29 insertions(+), 41 deletions(-)

diff --git a/contrib/kiss-cargo-urlgen b/contrib/kiss-cargo-urlgen @@ -1,9 +1,6 @@ #!/bin/sh # Create static cargo sources for Rust packages -[ "$1" ] || { - printf '\033[1;33m-> \033[musage: kiss-cargo-urlgen [crate+ver] [crate+ver]\n' - exit 1 -} +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [crate+ver] [crate+ver]"; exit 0 ; esac # We convert the name-version seperator from '+' to '-' to # avoid issues that may arise from version numbers that include diff --git a/contrib/kiss-cargolock-urlgen b/contrib/kiss-cargolock-urlgen @@ -3,7 +3,7 @@ case "$1" in -) set -- /dev/stdin ;; - '') printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <Cargo.lock file>" "" \ + ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <Cargo.lock file>" "" \ "'-' can be used to read from stdin." ; exit 0 esac diff --git a/contrib/kiss-cat b/contrib/kiss-cat @@ -1,8 +1,8 @@ #!/bin/sh -e # Concatanate package files in the installed package database # File names are printed to stderr. +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[musage: %s <pkg> [file] [file]\n' "${0##*/}" ; exit 0; esac -[ "$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-changelog b/contrib/kiss-changelog @@ -1,10 +1,7 @@ #!/bin/sh -e # Print the git log of the specific package -[ "$1" ] || { - printf '\033[1;33m-> \033[musage: %s [pkg]\n' "${0##*/}" - exit 0 -} +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]"; exit 0; esac kiss s "$1" >/dev/null cd "$(kiss s "$1" | sed 1q)" diff --git a/contrib/kiss-chbuild b/contrib/kiss-chbuild @@ -1,5 +1,6 @@ #!/bin/sh -e # Create/destroy temporary chroots +case "$1" in --help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/}"; exit 0; esac log() { printf '\033[31;1m->\033[m %s.\n' "$@" ;} diff --git a/contrib/kiss-chroot b/contrib/kiss-chroot @@ -25,7 +25,7 @@ clean() { } main() { - [ "$1" ] || usage + case "$1" in ''|--help|-h) usage; esac [ -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 @@ -1,7 +1,7 @@ #!/bin/sh -ef # Display a package's dependencies -[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;} +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ; esac 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 @@ -1,7 +1,7 @@ #!/bin/sh -e # Find missing dependencies by parsing 'ldd' -[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;} +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ; esac kiss l "$1" >/dev/null @@ -31,7 +31,7 @@ while read -r file; do # Skip listing these packages as dependencies. case $pkg in - musl|gcc|$1) ;; + musl|gcc|"$1") ;; *) printf '%s\n' "$pkg" ;; esac done diff --git a/contrib/kiss-export b/contrib/kiss-export @@ -1,7 +1,7 @@ #!/bin/sh -ef # Turn an installed package into a KISS tarball -[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;} +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ; esac kiss l "${1:-null}" >/dev/null diff --git a/contrib/kiss-fork b/contrib/kiss-fork @@ -1,7 +1,7 @@ #!/bin/sh -ef # Fork a package to the current directory -[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;} +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ; esac [ "$KISS_FORCE" ] || { [ -d "$1" ] && { printf '\033[1;31m!> \033[m%s\n' "$1 already exists on the current directory" \ diff --git a/contrib/kiss-link b/contrib/kiss-link @@ -1,7 +1,7 @@ #!/bin/sh -ef # Link a forked package's files to the other repository -[ "$1" ] || { printf '\033[1;33m-> \033[musage: kiss-link [file] [file]\n' ; exit 0 ;} +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[musage: kiss-link [file] [file]\n' ; exit 0 ; esac # 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 @@ -1,7 +1,7 @@ #!/bin/sh -ef # Find the maintainer of a package -[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;} +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ; esac 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 @@ -1,6 +1,6 @@ #!/bin/sh -ef # Display all files owned by a package -[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;} +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ; esac 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 @@ -1,7 +1,7 @@ #!/bin/sh -ef # Display all files owned by a package with a tree view -[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ;} +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <pkg>" ; exit 0 ; esac kiss l "$1" >/dev/null printf '%s\n' "[$1]:" tree -C --fromfile "$KISS_ROOT/var/db/kiss/installed/$1/manifest" | sed 1,2d diff --git a/contrib/kiss-message b/contrib/kiss-message @@ -1,10 +1,7 @@ #!/bin/sh # Show messages from a package in the system database -[ "$1" ] || { - printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg] [pkg]" - exit 0 -} +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg] [pkg]"; exit 0; esac for pkg do # Apply basename stripping so a user could run diff --git a/contrib/kiss-new b/contrib/kiss-new @@ -4,11 +4,7 @@ out() { printf '\033[1;33m-> \033[m%s\n' "$@" >&2 ;} die() { printf '\033[1;31m!> \033[m%s\n' "$@" >&2 ; exit 1 ;} -[ "$1" ] || { - out "usage: ${0##*/} <name> [version] [source]" \ - "Create boilerplate kiss packages" - exit 0 -} +case "$1" in ''|--help|-h) out "usage: ${0##*/} <name> [version] [source]"; exit 0; esac [ -d "$1" ] && die "Package '$1' already exists." diff --git a/contrib/kiss-orphans b/contrib/kiss-orphans @@ -1,6 +1,12 @@ #!/bin/sh -e # List orphaned packages +case "$1" in ''|--help|-h) + printf '\033[1;33m-> \033[m%s\n' \ + "${0##*/}: lists packages that do not have any packages depending on them" >&2 + exit 0 +esac + cd "$KISS_ROOT/var/db/kiss/installed/" for pkg in *; do @@ -12,6 +18,3 @@ 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 diff --git a/contrib/kiss-owns b/contrib/kiss-owns @@ -1,7 +1,7 @@ #!/bin/sh -e # Check which package owns a file -[ "$1" ] || { printf '%s\n' "usage: kiss-owns <file>" ; exit 1 ;} +case "$1" in ''|--help|-h) printf '%s\n' "usage: kiss-owns <file>" ; exit 0 ; esac # Strip 'KISS_ROOT' from the file path if passed and # follow symlinks. diff --git a/contrib/kiss-repodepends b/contrib/kiss-repodepends @@ -1,7 +1,7 @@ #!/bin/sh -e # Display a package's dependencies in the repository -[ "$1" ] || { printf '%s\n' "usage: kiss-repodepends <pkg>" ; exit 1 ;} +case "$1" in ''|--help|-h) printf '%s\n' "usage: kiss-repodepends <pkg>" ; exit 0 ; esac kiss s "$1" >/dev/null cat "$(kiss s "$1" | sed 1q)/depends" 2>/dev/null diff --git a/contrib/kiss-reporevdepends b/contrib/kiss-reporevdepends @@ -2,10 +2,7 @@ # Display packages on the repository which depend on package # shellcheck disable=2086 -[ "$1" ] || { - printf 'usage: %s <pkg>\n' "${0##*/}" - exit 1 -} +case "$1" in ''|--help|-h) printf 'usage: %s <pkg>\n' "${0##*/}"; exit 0; esac pkg="$1" IFS=:; set -- $KISS_PATH; unset IFS diff --git a/contrib/kiss-revdepends b/contrib/kiss-revdepends @@ -1,7 +1,7 @@ #!/bin/sh -e # Display packages which depend on package -[ "$1" ] || { printf '%s\n' "usage: kiss-revdepends <pkg>" ; exit 1 ;} +case "$1" in ''|--help|-h) printf '%s\n' "usage: kiss-revdepends <pkg>" ; exit 0 ; esac kiss s "$1" >/dev/null # 'cd' to the database directory as a simple way of diff --git a/contrib/kiss-size b/contrib/kiss-size @@ -1,7 +1,7 @@ #!/bin/sh -ef # Show the size on disk for a package -[ "$1" ] || { printf '%s\n' "usage: kiss-size <pkg>" ; exit 1 ;} +case "$1" in ''|--help|-h) printf '%s\n' "usage: kiss-size <pkg>" ; exit 0 ; esac kiss s "$1" >/dev/null # Filter directories from manifest and leave only files. diff --git a/contrib/kiss-which b/contrib/kiss-which @@ -1,7 +1,7 @@ #!/bin/sh -e # Locate the first instance of a KISS package -[ "$1" ] || { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 1 ;} +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 0; esac { kiss s "$1" || exit 1 ;} | sed 1q