aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-07-17 22:29:25 +0000
committermerakor <cem@ckyln.com>2021-07-17 22:29:25 +0000
commit13056c4341239128a9423f50090dd78259b6c23c (patch)
tree9499ef70512c254b8f2cb55927400dccbe2b1080
parent3d09fea9629b478cb50f799a2e9f27e9f5a8a52f (diff)
downloadcpt-13056c4341239128a9423f50090dd78259b6c23c.tar.gz
silence the package manager a bit
FossilOrigin-Name: 0a695c5090671468ce8ddcf2f1138d3c510f8ad1b689dc3f19a3e39d8d30dc38
-rw-r--r--src/cpt-lib.in48
1 files changed, 35 insertions, 13 deletions
diff --git a/src/cpt-lib.in b/src/cpt-lib.in
index ea00bb9..a2466af 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" -eq 1 ] || return 0
+ out "$@"
+}
+
+logv() {
+ # Call `log()` when CPT_VERBOSE is set.
+ [ "$CPT_VERBOSE" -eq 1 ] || return 0
+ log "$@"
+}
+
+warnv() {
+ # Call `warn()` when CPT_VERBOSE is set.
+ [ "$CPT_VERBOSE" -eq 1 ] || return 0
+ warn "$@"
+}
+
die() {
# Print a message and exit with '1' (error).
log "$1" "$2" "!>"
@@ -383,11 +406,6 @@ global_options() {
disp :version -v --version -- "Print version information"
}
-warn() {
- # Print a warning message
- log "$1" "$2" "${3:-WARNING}"
-}
-
contains() {
# Check if a "string list" contains a word.
case " $1 " in *" $2 "*) return 0; esac; return 1
@@ -472,7 +490,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 +556,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"
@@ -1386,17 +1408,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 +1428,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=
;;