aboutsummaryrefslogtreecommitdiff
path: root/kiss
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2020-02-06 11:22:18 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2020-02-06 11:22:18 +0000
commit04ced018883e09cb712e4bf45aacecea38f87b0f (patch)
tree8963916e71af1d9d1f805624f5c9219bc7eabc2f /kiss
parent09a9a8dfdf57969c7d938d4d8b8d3c6806fd01a9 (diff)
downloadcpt-04ced018883e09cb712e4bf45aacecea38f87b0f.tar.gz
kiss: Add function to pop list itemS
FossilOrigin-Name: fa152731f4ed750890a1e9e540473774b0549d7d03ecff0c76ca4f70e017eb02
Diffstat (limited to 'kiss')
-rwxr-xr-xkiss37
1 files changed, 16 insertions, 21 deletions
diff --git a/kiss b/kiss
index edb9ecc..47a17e4 100755
--- a/kiss
+++ b/kiss
@@ -69,6 +69,15 @@ esc() {
"$(printf %s "$2" | sed 's/[\/&]/\\&/g')"
}
+pop() {
+ # Remove an item from a "string list". This allows us
+ # to remove a 'sed' call and reuse this code throughout.
+ del=$1
+ shift "$(($# ? 1 : 0))"
+
+ for i; do [ "$i" = "$del" ] || printf %s " $i "; done
+}
+
pkg_lint() {
# Check that each mandatory file in the package entry exists.
log "$1" "Checking repository files"
@@ -495,11 +504,9 @@ pkg_build() {
# If an explicit package is a dependency of another explicit
# package, remove it from the explicit list as it needs to be
# installed as a dependency.
+ # shellcheck disable=2086
for pkg; do
- # There's no better way to remove a word from a string in
- # POSIX 'sh' sadly.
- contains "$deps" "$pkg" &&
- explicit=$(printf %s "$explicit" | sed "s/ $pkg / /g")
+ contains "$deps" "$pkg" && explicit=$(pop "$pkg" $explicit)
done
# See [1] at top of script.
@@ -534,7 +541,7 @@ pkg_build() {
# list. No better way than using 'sed' in POSIX 'sh'.
# See [1] at top of script.
# shellcheck disable=2046,2086
- set -- $(printf %s " $* " | sed "s/ $pkg / /")
+ set -- $(pop "$pkg" "$@")
}
}
done
@@ -706,22 +713,10 @@ pkg_conflicts() {
p_name=$2
- # Generate a list of all installed package manifests.
- set +f
- set -f -- "$sys_db"/*/manifest
-
- # Filter the manifest list and remove the previously
- # installed version of the package if it exists.
- for pkg; do
- i_name=${pkg%/*}
- i_name=${i_name##*/}
-
- shift "$(($# ? 1 : 0))"
-
- [ "$p_name" = "$i_name" ] && continue
-
- set -- "$@" "$pkg"
- done
+ # Generate a list of all installed package manifests
+ # and remove the current package from the list.
+ # shellcheck disable=2046,2086
+ set -- $(set +f; pop "$sys_db/$p_name/manifest" "$sys_db"/*/manifest)
[ -s "$cac_dir/$pid-m" ] || return 0