cpt

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

commit d12e6b3f58677f132a4497298e49203130b261f9
parent e1e3b4d2215d3c3a280c749b47915ced75082b7c
Author: Cem Keylan <cem@ckyln.com>
Date:   Mon, 20 Apr 2020 21:11:43 +0300

contrib: additions, usage, simplifications

Diffstat:
Mcontrib/kiss-cargo-urlgen | 2+-
Mcontrib/kiss-cargolock-urlgen | 9+++++----
Mcontrib/kiss-cat | 2+-
Mcontrib/kiss-chbuild | 4+---
Mcontrib/kiss-chroot | 4+++-
Mcontrib/kiss-depends | 7+++----
Mcontrib/kiss-depends-finder | 4+++-
Mcontrib/kiss-export | 2++
Mcontrib/kiss-fork | 12+++++++++---
Mcontrib/kiss-link | 2+-
Mcontrib/kiss-maintainer | 1+
Mcontrib/kiss-manifest | 8+++-----
Mcontrib/kiss-manifest-tree | 8+++-----
Mcontrib/kiss-new | 53+++++++++++++++++------------------------------------
Mcontrib/kiss-orphans | 3+++
15 files changed, 56 insertions(+), 65 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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