cpt

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

commit 6bb6cf67528eb9d24f1b9e0a3842abc3ea32ece8
parent bf78f794963ab349389940d5268bc33ff2ece40f
Author: Dylan Araps <dylan.araps@gmail.com>
Date:   Thu,  6 Feb 2020 13:22:19 +0200

kiss: Add function to pop list itemS

Diffstat:
Mkiss | 37++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 deletions(-)

diff --git 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