aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-07-24 08:22:39 +0000
committermerakor <cem@ckyln.com>2020-07-24 08:22:39 +0000
commit87b7b5e6f85f1d84e0aadab1df6901febc871be1 (patch)
tree74aaad41c2f7548ab8d4d1cb2532d43fd2c990a5
parent8c5271501560c0cf491b5b8b34f67a00158591a1 (diff)
downloadcpt-87b7b5e6f85f1d84e0aadab1df6901febc871be1.tar.gz
cpt: add packaging tools
FossilOrigin-Name: 99d5c6ac9e3077e0441a7431c1c9a4bc9e365d23e894c7c92d2f8f1006b4cda0
-rwxr-xr-xtools/cpt-alternatives32
-rwxr-xr-xtools/cpt-build12
-rwxr-xr-xtools/cpt-checksum29
-rwxr-xr-xtools/cpt-download15
-rwxr-xr-xtools/cpt-fetch11
-rwxr-xr-xtools/cpt-install35
-rwxr-xr-xtools/cpt-list11
-rwxr-xr-xtools/cpt-remove31
-rwxr-xr-xtools/cpt-search19
-rwxr-xr-xtools/cpt-update24
10 files changed, 219 insertions, 0 deletions
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