diff options
-rw-r--r-- | .build.yml | 3 | ||||
-rw-r--r-- | CHANGELOG.md | 26 | ||||
-rw-r--r-- | Makefile | 8 | ||||
-rwxr-xr-x | contrib/cpt-maintainer | 49 | ||||
-rwxr-xr-x | contrib/cpt-revdepends | 10 | ||||
-rwxr-xr-x | contrib/cpt-size | 65 | ||||
-rw-r--r-- | docs/cpt.org | 42 | ||||
-rw-r--r-- | docs/cpt.texi | 41 | ||||
-rw-r--r-- | docs/cpt.txt | 41 | ||||
-rw-r--r-- | man/cpt-build.1 | 2 | ||||
-rw-r--r-- | man/cpt-install.1 | 2 | ||||
-rw-r--r-- | man/cpt-list.1 | 6 | ||||
-rw-r--r-- | man/cpt-remove.1 | 2 | ||||
-rw-r--r-- | man/cpt-search.1 | 2 | ||||
-rw-r--r-- | man/cpt-update.1 | 2 | ||||
-rw-r--r-- | spec/01_lib_spec.sh | 3 | ||||
-rw-r--r-- | src/cpt-lib.in | 92 | ||||
-rwxr-xr-x | src/cpt-list | 9 | ||||
-rwxr-xr-x | tools/mkdist.sh | 2 | ||||
-rwxr-xr-x | tools/tool2man.sh | 10 | ||||
-rw-r--r-- | www/index.md | 2 |
21 files changed, 317 insertions, 102 deletions
@@ -13,8 +13,9 @@ tasks: cd cpt make - install-pax: | - git clone https://github.com/carbslinux/otools + git clone --quiet https://github.com/carbslinux/otools cd otools + ./configure make pax sudo install -Dm755 pax /usr/bin/pax - test: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bf9e89..1ea1041 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ CHANGELOG ================================================================================ -This is the CHANGELOG for the Carbs Packaging Tools, initially a customized fork +This is the CHANGELOG for the Carbs Packaging Tools, initially a customised fork of the `kiss` package manager. The format is based on [Keep a Changelog], and this project _somewhat_ adheres to [Semantic Versioning]. @@ -9,11 +9,31 @@ this project _somewhat_ adheres to [Semantic Versioning]. [Semantic Versioning]: https://semver.org/spec/v2.0.0.html -UNRELEASED +6.1.0 - 2021-07-22 -------------------------------------------------------------------------------- +### IMPORTANT +- The package manager now enforces the usage of `pax` instead of `tar`. + +### Repository Backend + +`cpt` now has a faster and modular repository backend. `fossil` is now supported +by the package manager. During the repository fetch process, the repository +backend is stored in the cache directory so that the update takes less time on +the next pull. The usage of the repository cache can be disabled by setting +`$CPT_REPO_CACHE` to 0. + ### Added -- Added fossil support +- Added `-q, --quiet` flags to `cpt-list`. +- Re-added `cpt-maintainer`. It now supports `meta` and repository backends + other than `git`. +- The package manager now prints out `MOTD` files found on the repository root. +- Added the `$CPT_VERBOSE` variable and the `--verbose` flags to some utilities. + With the addition of these, some parts of the package manager will be more + quiet unless verbosity is explicitly requested. + +### Changed +- Reworked the package repository backend. 6.0.4 - 2021-05-12 @@ -16,10 +16,14 @@ src/cpt-lib: src/cpt-lib.in -e "s|@DOCSTRING@|Call functions from the library|g" < src/cpt-lib.in > $@ chmod 755 $@ -test: all tests/etc/cpt-hook +shellspec: all tests/etc/cpt-hook shellspec + +shellcheck: all cd src; find . ../contrib -name 'cpt*' ! -name '*.*' -exec shellcheck -e 2119 -x -f gcc {} + +test: shellspec shellcheck + tests/etc/cpt-hook: ln -s ../hook-file $@ @@ -47,4 +51,4 @@ clean: rm -rf src/cpt-lib "cpt-${VERSION}.tar.xz" coverage report rm -f tests/etc/cpt-hook -.PHONY: all dist clean install uninstall +.PHONY: all dist clean install uninstall shellspec shellcheck test diff --git a/contrib/cpt-maintainer b/contrib/cpt-maintainer new file mode 100755 index 0000000..34f212f --- /dev/null +++ b/contrib/cpt-maintainer @@ -0,0 +1,49 @@ +#!/bin/sh -e +# Find the maintainer of a package + +## SYNOPSIS: +## .Nm +## .Op Ar pkg... + +## DESCRIPTION: +## .Nm +## finds the maintainer of the given pacage. If no package name is given, +## .Nm +## will use the name of the current directory as the package. + +# shellcheck disable=1091 +. cpt-lib + +usage() { + out "usage: ${0##*/} [pkg...]" + exit +} + +case $1 in + --help|-h) usage ;; + '') set -- "${PWD##*/}" +esac + +for pkgname; do + cpt-search -d "$pkgname" | while read -r pkg; do + # Default to the 'meta' file of the package instead of jumping through + # VCS hoops to find out. + log "$pkg" " " + pkg_query_meta "$pkg" maintainer && continue + + cd "$pkg" + # Use pkg_vcs_info to find out the repository type, but don't save + # repository information to the repository cache file. + repo_type=$(CPT_REPO_CACHE=0 pkg_vcs_info) + repo_type=${repo_type##*:} + + # We use the latest author who made a change to the version file to + # identify the maintainer of a package. + case $repo_type in + git) git log -1 --format='%an <%ae>' version ;; + fossil) fossil time par cur -n 1 -p version -F "%a" | sed \$d ;; + hg) hg log -l1 -T '{user}\n' -- version ;; + *) out "Maintainer information not available" + esac + done +done diff --git a/contrib/cpt-revdepends b/contrib/cpt-revdepends index 833dea2..3529a53 100755 --- a/contrib/cpt-revdepends +++ b/contrib/cpt-revdepends @@ -22,7 +22,7 @@ ## .El parser_definition() { - setup REST help:usage -- "usage: ${0##*/} [options...] [pkg...]" + setup REST help:usage -- "usage: ${0##*/} [options...] [pkg]" flag tree -t --tree -- "Also print indirect reverse dependencies" flag make -m --make -- "Include make dependencies" global_options @@ -41,11 +41,11 @@ parser_definition() { cd "$sys_db" get_revdep() { - query="^$1\$" + pkg=$1; set -- "^$pkg\$" # Defined by parser. # shellcheck disable=2154 - [ "$make" ] && query="$query\\|^$1 *make\$" - grep "$query" -- */depends | while read -r pkg _; do + [ "$make" ] && set -- -e "$1" -e "^$pkg " + grep "$@" -- */depends | while read -r pkg _; do printf '%s\n' "${pkg%%/*}" done } @@ -53,7 +53,7 @@ get_revdep() { # Defined by parser. # shellcheck disable=2154 if [ "$tree" ]; then - create_cache nobuild + mkdir -p "$tmp_dir" :> "$tmp_dir/processed" get_revdep "$1" > "$tmp_dir/dep" while ! diff -q "$tmp_dir/dep" "$tmp_dir/processed" >/dev/null 2>&1; do diff --git a/contrib/cpt-size b/contrib/cpt-size index 2812d56..0ece039 100755 --- a/contrib/cpt-size +++ b/contrib/cpt-size @@ -11,40 +11,41 @@ ## .Ar packages ## using the files from the package manifest and outputs a total size of the ## packages along with all the files associated with them. +parser_definition() { + setup REST help:usage -- "usage: ${0##*/} [pkg...]" + disp :usage -h --help hidden:1 +} -## CAVEATS: -## .Nm -## uses the non-POSIX -## .Fl h -## and -## .Fl c -## flags for -## .Xr du 1 , -## which will not work with -## .Em sbase , -## but it is a major performance improvement compared to calculating -## total and human-readable sizes by hand. +# shellcheck source=/bin/cpt-lib +# shellcheck disable=1091 +. cpt-lib -case "$1" in - --help|-h) - printf '%s\n' "usage: ${0##*/} [pkg...]" - exit 0 - ;; - '') set -- "${PWD##*/}" -esac +# Ensure that all the packages given as arguments are installed. +pkg_list "$@" >/dev/null -for pkg; do cpt-list "$pkg" >/dev/null; done +mkdir -p "$tmp_dir" -files= -for pkg; do - while read -r file; do - # Filter directories from manifest and leave only files. - # Directories in the manifest end in a trailing '/'. - case $file in */) continue; esac - files="$files '$file'" - done < "$CPT_ROOT/var/db/cpt/installed/$pkg/manifest" -done -eval "set -- $files" +# We don't immediately pipe into awk as we want to exit in an error. +for pkg; do sed '/\/$/d;s/./\\&/g' "$sys_db/$pkg/manifest"; done | + xargs du -k > "$tmp_dir/size" -# Send the file list to 'du'. -du -shc -- "$@" 2>/dev/null +# This awk function formats the `du` output similar to the '-hc' flags. We +# could have used a shell `while read` loop to do the exact same thing, but that +# would be much much slower. +awk 'function fmtsize(s) { + if (s==0) f="" + else if (s<1024) f="K" + else if (s<(1048576)){f="M";s=s/1024;} + else if (s<(1073741824)){f="G";s=s/1048576;} + else f="" + return int(s) f + } + { + sc = $1 + size += $1 + sub(sprintf("^%s\s*", $1), "") + printf("%-6s %s\n", fmtsize(sc), $0) + } + END { + printf("%-6s total\n", fmtsize(size)) + }' "$tmp_dir/size" diff --git a/docs/cpt.org b/docs/cpt.org index d78254c..7496ec9 100644 --- a/docs/cpt.org +++ b/docs/cpt.org @@ -161,65 +161,84 @@ to provide detailed information. #+VINDEX: CPT_PATH Set the locations of your repositories. It is similar to the ~PATH~ variable. + - ~CPT_CACHE~ :: #+VINDEX: CPT_CACHE The cache directory for =cpt=. Default: ~$XDG_CACHE_HOME/cpt~. + - ~CPT_CHOICE~ :: #+VINDEX: CPT_CHOICE If this is set to 0, a package installation will be aborted on conflicts. + - ~CPT_COLOR~ :: #+VINDEX: CPT_COLOR If this is set to 1, =cpt= tools will be forced to display coloured output. If set to 0, they will be forced to display them without colours. Otherwise, =cpt= will output colour as long as it is outputting to a terminal. + - ~CPT_DEBUG~ :: #+VINDEX: CPT_DEBUG If set to 1, temporary directories will not be removed after the operation. + - ~CPT_FETCH~ :: #+VINDEX: CPT_FETCH If set to 0, ~cpt-update~ will not fetch repositories. + - ~CPT_FORCE~ :: #+VINDEX: CPT_FORCE If set to 1, =cpt= tools will force operation. + - ~CPT_HOOK~ :: #+VINDEX: CPT_HOOK Absolute path to the package manager hook file. + - ~CPT_KEEPLOG~ :: #+VINDEX: CPT_KEEPLOG If set to 1, =cpt= will keep logs regardless of operation success. + - ~CPT_PID~ :: #+VINDEX: CPT_PID Set the temporary build directory name. + - ~CPT_PROMPT~ :: #+VINDEX: CPT_PROMPT If set to 0, =cpt= will not prompt you for anything. + - ~CPT_REPO_CACHE~ :: #+VINDEX: CPT_REPO_CACHE If set to 0, =cpt= will not use or write repository information cache. + - ~CPT_ROOT~ :: #+VINDEX: CPT_ROOT If this variable is set, =cpt= will assume the given path as the system root. + - ~CPT_TEST~ :: #+VINDEX: CPT_TEST If set to 1, ~cpt-build~ will run tests whenever available. + - ~CPT_TMPDIR~ :: #+VINDEX: CPT_TMPDIR The directory to create the temporary directories. +- ~CPT_VERBOSE~ :: + + #+VINDEX: CPT_VERBOSE + If this variable is set to 1, the package manager will print more information. + *** =CPT_PATH= :PROPERTIES: :DESCRIPTION: Set the locations of your repositories @@ -534,6 +553,9 @@ license: MIT maintainer: Linux User <linux-user@example.com> #+end_example +Even though =meta= is not mandatory by the packaging system, it is a mandatory +file for submitting packages to Carbs Linux repositories. + ** post-install :PROPERTIES: :DESCRIPTION: The post-installation script @@ -705,10 +727,11 @@ be a huge issue for you. :DESCRIPTION: Communicate with the users using your repository :END: -If a file named =motd= is found on the root directory of the package repository, -its contents will be printed to the standard output when the users are updating -their repositories. This method can be used to communicate messages to the -users, such as package removals or otherwise important information. +If a file named =MOTD= (all uppercase) is found on the root directory of the +package repository, its contents will be printed to the standard output when the +users are updating their repositories. This method can be used to communicate +messages to the users, such as package removals or otherwise important +information. * Comparison Between CPT and KISS @@ -1195,14 +1218,17 @@ rsync curl zlib ca-certificates bearssl This function is used to query the [[meta][meta file]] inside package directories. It can be used to retrieve information on a package that is otherwise irrelevant to the -package manager itself. It takes two arguments, first being the package and the -second being the key to be retrieved. If the package does not have a =meta= -file or the file does not contain the requested key, the function will return -with 1. +package manager itself. It takes two arguments, first being the package (or the +full path to a package directory) and the second being the key to be retrieved. +If the package does not have a =meta= file or the file does not contain the +requested key, the function will return with 1. #+begin_src sh $ pkg_query_meta cpt description Carbs Packaging Tools + +$ pkg_query_meta /path/to/cpt license +MIT #+end_src * {{{index(Concept, cp)}}} diff --git a/docs/cpt.texi b/docs/cpt.texi index 525029c..8bdcd99 100644 --- a/docs/cpt.texi +++ b/docs/cpt.texi @@ -280,50 +280,68 @@ to provide detailed information. @item @code{CPT_PATH} @vindex CPT_PATH Set the locations of your repositories. It is similar to the @code{PATH} variable. + @item @code{CPT_CACHE} @vindex CPT_CACHE The cache directory for @samp{cpt}. Default: @code{$XDG_CACHE_HOME/cpt}. + @item @code{CPT_CHOICE} @vindex CPT_CHOICE If this is set to 0, a package installation will be aborted on conflicts. + @item @code{CPT_COLOR} @vindex CPT_COLOR If this is set to 1, @samp{cpt} tools will be forced to display coloured output. If set to 0, they will be forced to display them without colours. Otherwise, @samp{cpt} will output colour as long as it is outputting to a terminal. + @item @code{CPT_DEBUG} @vindex CPT_DEBUG If set to 1, temporary directories will not be removed after the operation. + @item @code{CPT_FETCH} @vindex CPT_FETCH If set to 0, @code{cpt-update} will not fetch repositories. + @item @code{CPT_FORCE} @vindex CPT_FORCE If set to 1, @samp{cpt} tools will force operation. + @item @code{CPT_HOOK} @vindex CPT_HOOK Absolute path to the package manager hook file. + @item @code{CPT_KEEPLOG} @vindex CPT_KEEPLOG If set to 1, @samp{cpt} will keep logs regardless of operation success. + @item @code{CPT_PID} @vindex CPT_PID Set the temporary build directory name. + @item @code{CPT_PROMPT} @vindex CPT_PROMPT If set to 0, @samp{cpt} will not prompt you for anything. + @item @code{CPT_REPO_CACHE} @vindex CPT_REPO_CACHE If set to 0, @samp{cpt} will not use or write repository information cache. + @item @code{CPT_ROOT} @vindex CPT_ROOT If this variable is set, @samp{cpt} will assume the given path as the system root. + @item @code{CPT_TEST} @vindex CPT_TEST If set to 1, @code{cpt-build} will run tests whenever available. + @item @code{CPT_TMPDIR} @vindex CPT_TMPDIR The directory to create the temporary directories. + +@item @code{CPT_VERBOSE} +@vindex CPT_VERBOSE +If this variable is set to 1, the package manager will print more information. @end table @menu @@ -671,6 +689,9 @@ license: MIT maintainer: Linux User <linux-user@@example.com> @end example +Even though @samp{meta} is not mandatory by the packaging system, it is a mandatory +file for submitting packages to Carbs Linux repositories. + @node post-install @section post-install @@ -836,10 +857,11 @@ be a huge issue for you. @node Message of the Day @section Message of the Day -If a file named @samp{motd} is found on the root directory of the package repository, -its contents will be printed to the standard output when the users are updating -their repositories. This method can be used to communicate messages to the -users, such as package removals or otherwise important information. +If a file named @samp{MOTD} (all uppercase) is found on the root directory of the +package repository, its contents will be printed to the standard output when the +users are updating their repositories. This method can be used to communicate +messages to the users, such as package removals or otherwise important +information. @node Comparison Between CPT and KISS @chapter Comparison Between CPT and KISS @@ -1358,14 +1380,17 @@ rsync curl zlib ca-certificates bearssl This function is used to query the @ref{meta, , meta file} inside package directories. It can be used to retrieve information on a package that is otherwise irrelevant to the -package manager itself. It takes two arguments, first being the package and the -second being the key to be retrieved. If the package does not have a @samp{meta} -file or the file does not contain the requested key, the function will return -with 1. +package manager itself. It takes two arguments, first being the package (or the +full path to a package directory) and the second being the key to be retrieved. +If the package does not have a @samp{meta} file or the file does not contain the +requested key, the function will return with 1. @example $ pkg_query_meta cpt description Carbs Packaging Tools + +$ pkg_query_meta /path/to/cpt license +MIT @end example @node Concept Index diff --git a/docs/cpt.txt b/docs/cpt.txt index 144ff8b..550a6a3 100644 --- a/docs/cpt.txt +++ b/docs/cpt.txt @@ -226,43 +226,61 @@ development manual for *Carbs Packaging Tools*. For development logs see `CPT_PATH' Set the locations of your repositories. It is similar to the `PATH' variable. + `CPT_CACHE' The cache directory for `cpt'. Default: `$XDG_CACHE_HOME/cpt'. + `CPT_CHOICE' If this is set to 0, a package installation will be aborted on conflicts. + `CPT_COLOR' If this is set to 1, `cpt' tools will be forced to display coloured output. If set to 0, they will be forced to display them without colours. Otherwise, `cpt' will output colour as long as it is outputting to a terminal. + `CPT_DEBUG' If set to 1, temporary directories will not be removed after the operation. + `CPT_FETCH' If set to 0, `cpt-update' will not fetch repositories. + `CPT_FORCE' If set to 1, `cpt' tools will force operation. + `CPT_HOOK' Absolute path to the package manager hook file. + `CPT_KEEPLOG' If set to 1, `cpt' will keep logs regardless of operation success. + `CPT_PID' Set the temporary build directory name. + `CPT_PROMPT' If set to 0, `cpt' will not prompt you for anything. + `CPT_REPO_CACHE' If set to 0, `cpt' will not use or write repository information cache. + `CPT_ROOT' If this variable is set, `cpt' will assume the given path as the system root. + `CPT_TEST' If set to 1, `cpt-build' will run tests whenever available. + `CPT_TMPDIR' The directory to create the temporary directories. + `CPT_VERBOSE' + If this variable is set to 1, the package manager will print + more information. + 4.2.1 `CPT_PATH' ---------------- @@ -585,6 +603,9 @@ development manual for *Carbs Packaging Tools*. For development logs see | maintainer: Linux User <linux-user@example.com> `---- + Even though `meta' is not mandatory by the packaging system, it is a + mandatory file for submitting packages to Carbs Linux repositories. + [pkg_query_meta()] See section 8.7.10 @@ -758,11 +779,11 @@ development manual for *Carbs Packaging Tools*. For development logs see 6.3 Message of the Day ~~~~~~~~~~~~~~~~~~~~~~ - If a file named `motd' is found on the root directory of the package - repository, its contents will be printed to the standard output when - the users are updating their repositories. This method can be used to - communicate messages to the users, such as package removals or - otherwise important information. + If a file named `MOTD' (all uppercase) is found on the root directory + of the package repository, its contents will be printed to the + standard output when the users are updating their repositories. This + method can be used to communicate messages to the users, such as + package removals or otherwise important information. 7 Comparison Between CPT and KISS @@ -1264,13 +1285,17 @@ development manual for *Carbs Packaging Tools*. For development logs see This function is used to query the [meta file] inside package directories. It can be used to retrieve information on a package that is otherwise irrelevant to the package manager itself. It takes two - arguments, first being the package and the second being the key to be - retrieved. If the package does not have a `meta' file or the file does - not contain the requested key, the function will return with 1. + arguments, first being the package (or the full path to a package + directory) and the second being the key to be retrieved. If the + package does not have a `meta' file or the file does not contain the + requested key, the function will return with 1. ,---- | $ pkg_query_meta cpt description | Carbs Packaging Tools + | + | $ pkg_query_meta /path/to/cpt license + | MIT `---- diff --git a/man/cpt-build.1 b/man/cpt-build.1 index 79b24c6..1393aed 100644 --- a/man/cpt-build.1 +++ b/man/cpt-build.1 @@ -33,6 +33,8 @@ Use an alternate root directory Show help message .It Fl v , -version Print version information +.It Fl -verbose +Be more verbose .El .Sh AUTHOR .An Cem Keylan Aq Mt cem@ckyln.com diff --git a/man/cpt-install.1 b/man/cpt-install.1 index 65069f3..235c2df 100644 --- a/man/cpt-install.1 +++ b/man/cpt-install.1 @@ -29,6 +29,8 @@ Use an alternate root directory Show help message .It Fl v , -version Print version information +.It Fl -verbose +Be more verbose .El .Sh AUTHOR .An Cem Keylan Aq Mt cem@ckyln.com diff --git a/man/cpt-list.1 b/man/cpt-list.1 index 292ba13..778a57d 100644 --- a/man/cpt-list.1 +++ b/man/cpt-list.1 @@ -5,7 +5,7 @@ .Nd list packages .Sh SYNOPSIS .Nm -.Op Fl c +.Op Fl cq .Ar pkg... .Nm .Fl C @@ -20,7 +20,7 @@ list the given packages. If any of the given packages are not installed on the system, .Nm will exit with an error. However, -.Fl c +.Fl C and .Fl -check flags can be used in order to change the behaviour of the utility: @@ -28,6 +28,8 @@ flags can be used in order to change the behaviour of the utility: .It Fl c , -current Assumes that the current directory is a package and will use it instead of arguments. +.It Fl q , -quiet +Make the operation quiet, only reporting exit status. .It Fl C , -check Ar package true_statement false_statement Checks whether the .Em package diff --git a/man/cpt-remove.1 b/man/cpt-remove.1 index f4bb6fb..e4c2e26 100644 --- a/man/cpt-remove.1 +++ b/man/cpt-remove.1 @@ -27,6 +27,8 @@ Use an alternate root directory Show help message .It Fl v , -version Print version information +.It Fl -verbose +Be more verbose .El .Sh AUTHOR .An Cem Keylan Aq Mt cem@ckyln.com diff --git a/man/cpt-search.1 b/man/cpt-search.1 index 05452bd..f59f7b9 100644 --- a/man/cpt-search.1 +++ b/man/cpt-search.1 @@ -24,6 +24,8 @@ package. Show help message .It Fl v , -version Print version information +.It Fl -verbose +Be more verbose .El .Sh EXAMPLES Below are usage examples for diff --git a/man/cpt-update.1 b/man/cpt-update.1 index 3af1205..bc63ea7 100644 --- a/man/cpt-update.1 +++ b/man/cpt-update.1 @@ -30,6 +30,8 @@ Use an alternate root directory Show help message .It Fl v , -version Print version information +.It Fl -verbose +Be more verbose .El .Sh AUTHOR .An Cem Keylan Aq Mt cem@ckyln.com diff --git a/spec/01_lib_spec.sh b/spec/01_lib_spec.sh index 0ff2752..113d517 100644 --- a/spec/01_lib_spec.sh +++ b/spec/01_lib_spec.sh @@ -1,4 +1,5 @@ # shellcheck disable=2091,2034 +CPT_VERBOSE=1 Describe 'CPT Library' export CPT_COLOR=0 @@ -161,7 +162,7 @@ Describe 'CPT Library' End It "doesn't log 'running hook' if no package is given" When call run_hook 2 '' destination - The stderr should eq "" + The stderr should eq "-> Running 2 hook " The output should eq "$CPT_HOOK 2 null destination" End It "uses the /etc/cpt-hook file of the root when called with a fourth arg" diff --git a/src/cpt-lib.in b/src/cpt-lib.in index ea00bb9..504829d 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -30,6 +30,29 @@ log() { "$colory" "${3:-->}" "$colre" "${2:+$colorb}" "$1" "$colre" "$2" >&2 } +warn() { + # Print a warning message + log "$1" "$2" "${3:-WARNING}" +} + +outv() { + # Call `out()` when CPT_VERBOSE is set. + [ "$CPT_VERBOSE" = 1 ] || return 0 + out "$@" +} + +logv() { + # Call `log()` when CPT_VERBOSE is set. + [ "$CPT_VERBOSE" = 1 ] || return 0 + log "$@" +} + +warnv() { + # Call `warn()` when CPT_VERBOSE is set. + [ "$CPT_VERBOSE" = 1 ] || return 0 + warn "$@" +} + die() { # Print a message and exit with '1' (error). log "$1" "$2" "!>" @@ -381,11 +404,7 @@ global_options() { param CPT_ROOT --root init:@export -- "Use an alternate root directory" disp :usage -h --help -- "Show this help message" disp :version -v --version -- "Print version information" -} - -warn() { - # Print a warning message - log "$1" "$2" "${3:-WARNING}" + flag CPT_VERBOSE --verbose init:@export -- "Be more verbose" } contains() { @@ -400,6 +419,21 @@ regesc() { sed 's|\\|\\\\|g;s|\[|\\[|g;s|\$|\\$|g;s|\.|\\.|g;s|\*|\\*|g;s|\^|\\^|g' } +pkg_download() { + # $1: URL + # $2: Output (Optional) + set -- "$1" "${2:-${1##*/}}" + case ${dl_prog##*/} in + aria2c|axel) set -- -o "$2" "$1" ;; + curl) set -- -fLo "$2" "$1" ;; + wget|wget2) set -- -O "$2" "$1" ;; + esac + + "$dl_prog" "$@" || { + rm -f "$2" + return 1 + } +} prompt() { # If a CPT_NOPROMPT variable is set, continue. @@ -438,8 +472,10 @@ as_root() { CPT_PATH="$CPT_PATH" \ CPT_PID="$CPT_PID" \ CPT_PROMPT="$CPT_PROMPT" \ + CPT_REPO_CACHE="$CPT_REPO_CACHE" \ CPT_ROOT="$CPT_ROOT" \ CPT_TMPDIR="$CPT_TMPDIR" \ + CPT_VERBOSE="$CPT_VERBOSE" \ "$@" case ${su##*/} in @@ -472,7 +508,11 @@ run_hook() { [ -f "$CPT_HOOK" ] || { CPT_HOOK=$oldCPT_HOOK; return 0 ;} - [ "$2" ] && log "$2" "Running $1 hook" + if [ "$2" ]; then + logv "$2" "Running $1 hook" + else + logv "Running $1 hook" + fi TYPE=${1:-null} PKG=${2:-null} DEST=${3:-null} . "$CPT_HOOK" CPT_HOOK=$oldCPT_HOOK @@ -534,7 +574,7 @@ pkg_lint() { repo_dir=$(pkg_find "$1") cd "$repo_dir" || die "'$repo_dir' not accessible" - [ -f sources ] || warn "$1" "Sources file not found" + [ -f sources ] || warnv "$1" "Sources file not found" [ -x build ] || die "$1" "Build file not found or not executable" [ -s version ] || die "$1" "Version file not found or empty" @@ -663,10 +703,8 @@ pkg_sources() { # interrupt, we handle this ourselves. trap_set handle-int - curl "$src" -fLo "${src##*/}" || { - rm -f "${src##*/}" - die "$1" "Failed to download $src" - } + # Download the source + pkg_download "$src" || die "$1" "Failed to download $src" # Restore original trap value. trap_set cleanup @@ -1386,17 +1424,17 @@ pkg_etc() { sum_sys=$(cd "$CPT_ROOT/"; sh256 "$file") sum_old=$("$grep" "$file$" "$mak_dir/c"); } 2>/dev/null ||: - log "$pkg_name" "Doing 3-way handshake for $file" - printf '%s\n' "Previous: ${sum_old:-null}" - printf '%s\n' "System: ${sum_sys:-null}" - printf '%s\n' "New: ${sum_new:-null}" + logv "$pkg_name" "Doing 3-way handshake for $file" + outv "Previous: ${sum_old:-null}" + outv "System: ${sum_sys:-null}" + outv "New: ${sum_new:-null}" # Use a case statement to easily compare three strings at # the same time. Pretty nifty. case ${sum_old:-null}${sum_sys:-null}${sum_new} in # old = Y, sys = X, new = Y "${sum_new}${sum_sys}${sum_old}") - log "Skipping $file" + logv "Skipping $file" continue ;; @@ -1406,7 +1444,7 @@ pkg_etc() { "${sum_old}${sum_old}${sum_old}"|\ "${sum_old:-null}${sum_sys}${sum_sys}"|\ "${sum_sys}${sum_old}"*) - log "Installing $file" + logv "Installing $file" new= ;; @@ -1618,12 +1656,12 @@ pkg_repository_update() { # Repositories can contain a "Message of the Day" file in order to # relay important information to their users. - ! [ -r "$repo_root/motd" ] || { + ! [ -r "$repo_root/MOTD" ] || { printf '%s\n%s\n%s\n\n' \ "$(_multiply_char '=' 60)" \ "Message of the Day [$PWD]" \ "$(_multiply_char '=' 60)" - cat "$repo_root/motd" + cat "$repo_root/MOTD" printf '\n%s\n' "$(_multiply_char '=' 60)" } } @@ -1977,8 +2015,11 @@ pkg_gentree() ( pkg_query_meta() { # Query the 'meta' file of the given meta package. If there is no meta file, # or the key being queried is unavailable, the function will return with - # error. - repo_dir=$(pkg_find "$1") + # error. Full path can be specified instead of package names. + case $1 in + */*) repo_dir=$1 ;; + *) repo_dir=$(pkg_find "$1") + esac [ -f "$repo_dir/meta" ] || return while IFS=': ' read -r key val; do case $key in @@ -2089,6 +2130,13 @@ create_cache() { command -v llvm-readelf || command -v eu-readelf)"} || elf_prog=ldd + dl_prog=${CPT_DOWNLOADER:="$( + command -v curl || + command -v wget || + command -v wget2 || + command -v axel || + command -v aria2c)"} || dl_prog=curl + # Make note of the user's current ID to do root checks later on. # This is used enough to warrant a place here. uid=$(id -u) @@ -2126,7 +2174,7 @@ create_cache() { # colors. This can of course be overriden if the user specifically want # colors during piping. if { [ "$CPT_COLOR" != 0 ] && [ -t 1 ] ;} || [ "$CPT_COLOR" = 1 ]; then - colory="\033[1;33m" colorb="\033[1;36m" colre="\033[m" + colory="\033[1;33m" colorb="\033[1;34m" colre="\033[m" fi } diff --git a/src/cpt-list b/src/cpt-list index 4eb7cf6..fcb1f49 100755 --- a/src/cpt-list +++ b/src/cpt-list @@ -3,10 +3,11 @@ parser_definition() { setup REST help:usage -- \ - "usage: ${0##*/} [-c] pkg..." \ + "usage: ${0##*/} [-cq] pkg..." \ "or: ${0##*/} -C pkg true-statement false-statement" msg -- '' 'Options:' flag CURRENT -c --current -- "Use the current directory as a package" + flag quiet -q --quiet -- "Make the operation quiet" param PKG -C --check label:" -C,--check PKG TRUE FALSE" -- \ "Check if PKG exists and return the string of TRUE if"\ "it exists, and the string of FALSE if it doesn't." \ @@ -23,7 +24,7 @@ if [ "$PKG" ]; then printf %s "$2" fi else -[ "$CURRENT" ] && set -- "${PWD##*/}" - -pkg_list "$@" + [ "$CURRENT" ] && set -- "${PWD##*/}" + [ "$quiet" ] && exec >/dev/null 2>&1 + pkg_list "$@" fi diff --git a/tools/mkdist.sh b/tools/mkdist.sh index c21e964..bcf1caf 100755 --- a/tools/mkdist.sh +++ b/tools/mkdist.sh @@ -25,6 +25,8 @@ fossil ls | while read -r file; do cp "$file" "$basedir/$file" done +cp docs/cpt.info "$basedir/docs/cpt.info" + tar cf "$basedir.tar" "$basedir" xz -z "$basedir.tar" rm -rf -- "$basedir" diff --git a/tools/tool2man.sh b/tools/tool2man.sh index 38cdbf4..c4bbfb8 100755 --- a/tools/tool2man.sh +++ b/tools/tool2man.sh @@ -69,8 +69,8 @@ while read -r line; do esac done < "$file" -out ".Sh AUTHOR" ".An Cem Keylan Aq Mt cem@ckyln.com" -out ".Sh LICENSE" "See LICENSE for copyright information." +out ".Sh AUTHOR" ".An Cem Keylan Aq Mt cem@carbslinux.org" +out ".Sh COPYING" "See LICENSE for copyright information." out ".Sh SEE ALSO" ".Xr cpt 1" [ "$see" ] && for man in $see; do @@ -79,6 +79,6 @@ out ".Sh SEE ALSO" ".Xr cpt 1" out ".Pp" out "The full documentation of cpt is available as an info page." out "If either" ".Ic info" or ".Ic texinfo" -out "package is installed on your system, you can run" -out ".Bd -literal -offset indent" "info cpt" ".Ed" -out .Pp "to learn more about the package manager." +out "package is installed on your system, you can learn more about the package" +out "manager by running" +out ".Sq Sy info cpt ." diff --git a/www/index.md b/www/index.md index 0c55e80..99ad599 100644 --- a/www/index.md +++ b/www/index.md @@ -32,7 +32,7 @@ complements the tools that come with it. It has the following features: <hr> -### Latest Release: 6.0.4 ([2021-05-12](/timeline?c=6.0.4)) +### Latest Release: 6.1.0 ([2021-07-22](/timeline?c=6.1.0)) - [Download](/uvlist?byage=1) - [Changelog](/doc/trunk/CHANGELOG.md) |