From 87b7b5e6f85f1d84e0aadab1df6901febc871be1 Mon Sep 17 00:00:00 2001 From: merakor Date: Fri, 24 Jul 2020 08:22:39 +0000 Subject: cpt: add packaging tools FossilOrigin-Name: 99d5c6ac9e3077e0441a7431c1c9a4bc9e365d23e894c7c92d2f8f1006b4cda0 --- tools/cpt-alternatives | 32 ++++++++++++++++++++++++++++++++ tools/cpt-build | 12 ++++++++++++ tools/cpt-checksum | 29 +++++++++++++++++++++++++++++ tools/cpt-download | 15 +++++++++++++++ tools/cpt-fetch | 11 +++++++++++ tools/cpt-install | 35 +++++++++++++++++++++++++++++++++++ tools/cpt-list | 11 +++++++++++ tools/cpt-remove | 31 +++++++++++++++++++++++++++++++ tools/cpt-search | 19 +++++++++++++++++++ tools/cpt-update | 24 ++++++++++++++++++++++++ 10 files changed, 219 insertions(+) create mode 100755 tools/cpt-alternatives create mode 100755 tools/cpt-build create mode 100755 tools/cpt-checksum create mode 100755 tools/cpt-download create mode 100755 tools/cpt-fetch create mode 100755 tools/cpt-install create mode 100755 tools/cpt-list create mode 100755 tools/cpt-remove create mode 100755 tools/cpt-search create mode 100755 tools/cpt-update diff --git a/tools/cpt-alternatives b/tools/cpt-alternatives new file mode 100755 index 0000000..5b0007e --- /dev/null +++ b/tools/cpt-alternatives @@ -0,0 +1,32 @@ +#!/bin/sh -ef + +# shellcheck disable=1091 +if command -v cpt-lib >/dev/null; then . cpt-lib; else . ../lib.sh; fi + +case "$1" in --version|--help|-v|-h|'') ;; *) + [ -w "$CPT_ROOT/" ] || [ "$uid" = 0 ] || { + as_root "$0" "$@" + exit $? + } +esac + +case "$1" in + --help|-h) + out "usage: ${0##*/} [-] [pkg file]" + exit 1 + ;; + --version|-v) version ;; + -) + while read -r pkg path; do + pkg_swap "$pkg" "$path" + done + ;; + '') + # Go over each alternative and format the file name for listing. + # (pkg_name>usr>bin>ls) + set +f; for pkg in "$sys_db/../choices/"*; do + printf '%s\n' "${pkg##*/}" + done | sed 's|>| /|; s|>|/|g; /\*/d' + ;; + *) pkg_swap "$@" ;; +esac diff --git a/tools/cpt-build b/tools/cpt-build new file mode 100755 index 0000000..40ae4fd --- /dev/null +++ b/tools/cpt-build @@ -0,0 +1,12 @@ +#!/bin/sh + +# shellcheck disable=1091 +if command -v cpt-lib >/dev/null; then . cpt-lib; else . ../lib.sh; fi + +case "$1" in + '') set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH ;; + --help|-h) out "usage: ${0##*/} [pkg...]"; exit 1 ;; + --version|-v) version ;; +esac + +pkg_build "$@" diff --git a/tools/cpt-checksum b/tools/cpt-checksum new file mode 100755 index 0000000..c9651bf --- /dev/null +++ b/tools/cpt-checksum @@ -0,0 +1,29 @@ +#!/bin/sh -ef + +# shellcheck disable=1091 +if command -v cpt-lib >/dev/null; then . cpt-lib; else . ../lib.sh; fi + +case "$1" in + --help|-h) out "usage: ${0##*/} [pkg...]"; exit 1 ;; + --version|-v) version ;; + '') set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH ;; +esac + +for pkg; do pkg_lint "$pkg" c; done +for pkg; do pkg_sources "$pkg" c; done + +for pkg; do + pkg_checksums "$pkg" | { + repo_dir=$(pkg_find "$pkg") + + if [ -w "$repo_dir" ]; then + tee "$repo_dir/checksums" + else + log "$pkg" "Need permissions to generate checksums" + + user=$(cpt-stat "$repo_dir") as_root tee "$repo_dir/checksums" + fi + } + + log "$pkg" "Generated checksums" +done diff --git a/tools/cpt-download b/tools/cpt-download new file mode 100755 index 0000000..77087b9 --- /dev/null +++ b/tools/cpt-download @@ -0,0 +1,15 @@ +#!/bin/sh -ef + +# shellcheck disable=1091 +if command -v cpt-lib >/dev/null; then . cpt-lib; else . ../lib.sh; fi + +case "$1" in + --help|-h) + out "usage: ${0##*/} [pkg...]" + exit 1 + ;; + --version|-v) version ;; + '') set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH +esac + +for pkg; do pkg_sources "$pkg"; done diff --git a/tools/cpt-fetch b/tools/cpt-fetch new file mode 100755 index 0000000..e244b13 --- /dev/null +++ b/tools/cpt-fetch @@ -0,0 +1,11 @@ +#!/bin/sh -ef + +# shellcheck disable=1091 +if command -v cpt-lib >/dev/null; then . cpt-lib; else . ../lib.sh; fi + +case "$1" in + --help|-h) out "usage: ${0##*/}"; exit 1 ;; + --version|-v) version ;; +esac + +pkg_fetch diff --git a/tools/cpt-install b/tools/cpt-install new file mode 100755 index 0000000..9c7a3c5 --- /dev/null +++ b/tools/cpt-install @@ -0,0 +1,35 @@ +#!/bin/sh + +# shellcheck disable=1091 +if command -v cpt-lib >/dev/null; then . cpt-lib; else . ../lib.sh; fi + +while [ "$1" ]; do + case "$1" in + --help|-h) + out "usage: ${0##*/} [options] [pkg...]" "" \ + " Options:" \ + " --force Force installation" \ + " --root [rootdir] Use an alternate root directory" + exit 1 + ;; + --version|-v) version ;; + --force) export CPT_FORCE=1 ;; + --root) export CPT_ROOT=$2; shift 2 ;; + --) break ;; + -*) die "Unknown argument '$1'" ;; + '') set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH ;; + *) break ;; + esac +done + +[ -w "$CPT_ROOT/" ] || [ "$uid" = 0 ] || { + as_root "$0" "$@" + exit $? +} + +pkg_order "$@" + +# shellcheck disable=2154 +for pkg in $order; do + pkg_isbuilt "$pkg" || [ "$nobuild" != 1 ] || pkg_build "$pkg" +done diff --git a/tools/cpt-list b/tools/cpt-list new file mode 100755 index 0000000..d248efc --- /dev/null +++ b/tools/cpt-list @@ -0,0 +1,11 @@ +#!/bin/sh -ef + +# shellcheck disable=1091 +if command -v cpt-lib >/dev/null; then . cpt-lib; else . ../lib.sh; fi + +case "$1" in + --help|-h) out "usage: ${0##*/} [pkg...]"; exit 1 ;; + --version|-v) version ;; +esac + +pkg_list "$@" diff --git a/tools/cpt-remove b/tools/cpt-remove new file mode 100755 index 0000000..0263e4e --- /dev/null +++ b/tools/cpt-remove @@ -0,0 +1,31 @@ +#!/bin/sh -ef + +# shellcheck disable=1091 +if command -v cpt-lib >/dev/null; then . cpt-lib; else . ../lib.sh; fi + +while [ "$1" ]; do + case "$1" in + --help|-h) + out "usage: ${0##*/} [options] [pkg...]" "" \ + " Options:" \ + " --force Force Removal" \ + " --root [rootdir] Use an alternate root directory" + exit 1 + ;; + --version|-v) version ;; + --force) export CPT_FORCE=1; shift ;; + --root) export CPT_ROOT=$2; shift 2 ;; + --) break ;; + -*) die "Unknown argument '$1'" ;; + '') set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH ;; + *) break ;; + esac +done + +[ -w "$CPT_ROOT/" ] || [ "$uid" = 0 ] || { + as_root "$0" "$@" + exit $? +} + +pkg_order "$@" +for pkg in $redro; do pkg_remove "$pkg" "${CPT_FORCE:-check}"; done diff --git a/tools/cpt-search b/tools/cpt-search new file mode 100755 index 0000000..1e48f97 --- /dev/null +++ b/tools/cpt-search @@ -0,0 +1,19 @@ +#!/bin/sh -ef +if command -v cpt-lib >/dev/null; then . cpt-lib; else . ../lib.sh; fi + +# By default we are showing all instances of a package. This value can be unset +# in order to only find the first instance of a package. +all=1 + +case "$1" in + --help|-h|'') + out "usage: ${0##*/} [--single] [pkg...]" "" \ + " Options:" \ + " --single Only show the first instance of a package" + exit 0 + ;; + --version|-v) version ;; + --single) unset all; shift ;; +esac + +for pkg; do pkg_find "$pkg" "${all:+all}"; done diff --git a/tools/cpt-update b/tools/cpt-update new file mode 100755 index 0000000..77be11d --- /dev/null +++ b/tools/cpt-update @@ -0,0 +1,24 @@ +#!/bin/sh -ef + +# shellcheck disable=1091 +if command -v cpt-lib >/dev/null; then . cpt-lib; else . ../lib.sh; fi + +while [ "$1" ]; do + case "$1" in + --help|-h) + out "usage: ${0##*/} [options]" "" \ + " Options:" \ + " -d --download Only download updatable packages" \ + " --no-fetch Do not refresh the repositories" \ + " --root [rootdir] Use an alternate root directory" + exit 1 + ;; + --version|-v) version ;; + --no-fetch) export CPT_FETCH=0; shift ;; + --root) export CPT_ROOT=$2; shift 2 ;; + --download|-d) export download_only=1; shift ;; + *) die "Unknown option '$1'" ;; + esac +done + +pkg_updates -- cgit v1.2.3