cpt

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

commit f99ebb99f8618acf46a5dd7b8b7caa48c78bd991
parent 4da37a2095f88ba90c8116edd0b23baceecd40f3
Author: Cem Keylan <cem@ckyln.com>
Date:   Fri, 24 Jul 2020 11:22:39 +0300

cpt: add packaging tools

Diffstat:
Atools/cpt-alternatives | 32++++++++++++++++++++++++++++++++
Atools/cpt-build | 12++++++++++++
Atools/cpt-checksum | 29+++++++++++++++++++++++++++++
Atools/cpt-download | 15+++++++++++++++
Atools/cpt-fetch | 11+++++++++++
Atools/cpt-install | 35+++++++++++++++++++++++++++++++++++
Atools/cpt-list | 11+++++++++++
Atools/cpt-remove | 31+++++++++++++++++++++++++++++++
Atools/cpt-search | 19+++++++++++++++++++
Atools/cpt-update | 24++++++++++++++++++++++++
10 files changed, 219 insertions(+), 0 deletions(-)

diff --git a/tools/cpt-alternatives 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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