mirror of
https://codeberg.org/kiss-community/kiss
synced 2024-09-28 04:12:40 -06:00
kiss: Add function to pop list itemS
This commit is contained in:
parent
bf78f79496
commit
6bb6cf6752
37
kiss
37
kiss
@ -69,6 +69,15 @@ esc() {
|
|||||||
"$(printf %s "$2" | sed 's/[\/&]/\\&/g')"
|
"$(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() {
|
pkg_lint() {
|
||||||
# Check that each mandatory file in the package entry exists.
|
# Check that each mandatory file in the package entry exists.
|
||||||
log "$1" "Checking repository files"
|
log "$1" "Checking repository files"
|
||||||
@ -495,11 +504,9 @@ pkg_build() {
|
|||||||
# If an explicit package is a dependency of another explicit
|
# If an explicit package is a dependency of another explicit
|
||||||
# package, remove it from the explicit list as it needs to be
|
# package, remove it from the explicit list as it needs to be
|
||||||
# installed as a dependency.
|
# installed as a dependency.
|
||||||
|
# shellcheck disable=2086
|
||||||
for pkg; do
|
for pkg; do
|
||||||
# There's no better way to remove a word from a string in
|
contains "$deps" "$pkg" && explicit=$(pop "$pkg" $explicit)
|
||||||
# POSIX 'sh' sadly.
|
|
||||||
contains "$deps" "$pkg" &&
|
|
||||||
explicit=$(printf %s "$explicit" | sed "s/ $pkg / /g")
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# See [1] at top of script.
|
# See [1] at top of script.
|
||||||
@ -534,7 +541,7 @@ pkg_build() {
|
|||||||
# list. No better way than using 'sed' in POSIX 'sh'.
|
# list. No better way than using 'sed' in POSIX 'sh'.
|
||||||
# See [1] at top of script.
|
# See [1] at top of script.
|
||||||
# shellcheck disable=2046,2086
|
# shellcheck disable=2046,2086
|
||||||
set -- $(printf %s " $* " | sed "s/ $pkg / /")
|
set -- $(pop "$pkg" "$@")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
@ -706,22 +713,10 @@ pkg_conflicts() {
|
|||||||
|
|
||||||
p_name=$2
|
p_name=$2
|
||||||
|
|
||||||
# Generate a list of all installed package manifests.
|
# Generate a list of all installed package manifests
|
||||||
set +f
|
# and remove the current package from the list.
|
||||||
set -f -- "$sys_db"/*/manifest
|
# shellcheck disable=2046,2086
|
||||||
|
set -- $(set +f; pop "$sys_db/$p_name/manifest" "$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
|
|
||||||
|
|
||||||
[ -s "$cac_dir/$pid-m" ] || return 0
|
[ -s "$cac_dir/$pid-m" ] || return 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user