Skip to content

Commit

Permalink
fix({srcinfo,package-base}.sh): add missing overrides and append arra…
Browse files Browse the repository at this point in the history
…ys (pacstall#1176)

Co-authored-by: ook37 <[email protected]>
  • Loading branch information
oklopfer and ook37 authored Jul 7, 2024
1 parent 54706c4 commit ea75e9d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion misc/scripts/package-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function package_override() {
{ ignore_stack=false; set -o pipefail; trap stacktrace ERR RETURN; }
# shellcheck disable=SC2031
local o all_ovars opac="${pacname}" obase="${pkgbase}" ovars=("gives" "pkgdesc" "url" "priority")
all_ovars=("${ovars[@]}" "arch" "license" "checkdepends" "optdepends" "pacdeps" "provides" "conflicts" "breaks" "replaces" "enhances" "recommends" "backup" "repology")
all_ovars=("${ovars[@]}" "arch" "license" "depends" "checkdepends" "optdepends" "pacdeps" "provides" "checkconflicts" "conflicts" "breaks" "replaces" "enhances" "recommends" "backup" "repology")
for o in "${all_ovars[@]}"; do
local look lbase
# shellcheck disable=SC2034
Expand Down
27 changes: 17 additions & 10 deletions misc/scripts/srcinfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function srcinfo.array_build() {
}

function srcinfo.extr_globvar() {
{ ignore_stack=false; set -eo pipefail; trap stacktrace ERR RETURN; }
{ ignore_stack=false; set -o pipefail; trap stacktrace ERR RETURN; }
local attr="${1}" isarray="${2}" outputvar="${3}" ref
if ((isarray==1)); then
srcinfo.array_build ref "${attr}"
Expand Down Expand Up @@ -87,10 +87,15 @@ function srcinfo.extr_fnvar() {
function srcinfo.get_attr() {
{ ignore_stack=false; set -o pipefail; trap stacktrace ERR RETURN; }
local pkgname="${1}" attrname="${2}" isarray="${3}" outputvar="${4}"
if ((isarray==1)); then
eval "${outputvar}=()"
else
printf -v "${outputvar}" %s ''
fi
if [[ -n ${pkgname} ]]; then
srcinfo.extr_globvar "${attrname}" "${isarray}" "${outputvar}"
if is_function "package_${pkgname}"; then
srcinfo.extr_fnvar "package_${pkgname}" "${attrname}" "${isarray}" "${outputvar}"
srcinfo.extr_fnvar "package_${pkgname}" "${attrname}" "${isarray}" "${outputvar}" || { ignore_stack=true; return 1; }
fi
else
srcinfo.extr_globvar "${attrname}" "${isarray}" "${outputvar}"
Expand All @@ -103,7 +108,9 @@ function srcinfo.write_attr() {
attrvalues=("${attrvalues[@]//+([[:space:]])/ }")
attrvalues=("${attrvalues[@]#[[:space:]]}")
attrvalues=("${attrvalues[@]%[[:space:]]}")
printf "\t${attrname} = %s\n" "${attrvalues[@]}"
if [[ -n "${attrvalues[*]}" ]]; then
printf "\t${attrname} = %s\n" "${attrvalues[@]}"
fi
}

function srcinfo.extract() {
Expand All @@ -118,13 +125,11 @@ function srcinfo.write_details() {
{ ignore_stack=false; set -o pipefail; trap stacktrace ERR RETURN; }
local attr package_arch a
for attr in "${singlevalued[@]}"; do
local -n at="${attr}"
[[ -n ${at} ]] && srcinfo.extract "$1" "${attr}" 0
srcinfo.extract "$1" "${attr}" 0
done

for attr in "${multivalued[@]}"; do
local -n at="${attr}"
[[ -n ${at[*]} ]] && srcinfo.extract "$1" "${attr}" 1
srcinfo.extract "$1" "${attr}" 1
done

srcinfo.get_attr "$1" 'arch' 1 'package_arch' || package_arch=("all")
Expand Down Expand Up @@ -227,8 +232,8 @@ function srcinfo.write_global() {
function srcinfo.write_package() {
{ ignore_stack=false; set -o pipefail; trap stacktrace ERR RETURN; }
local singlevalued=(gives pkgdesc url priority)
local multivalued=(arch license checkdepends optdepends pacdeps
provides conflicts breaks replaces enhances recommends backup repology)
local multivalued=(arch license depends checkdepends optdepends pacdeps
provides checkconflicts conflicts breaks replaces enhances recommends backup repology)
printf '%s = %s\n' 'pkgname' "$1"
srcinfo.write_details "$1"
}
Expand Down Expand Up @@ -567,7 +572,9 @@ function srcinfo.match_pkg() {
continue
fi
fi
[[ ${b} == "${match}" ]] && printf '%s\n' "${!guy}"
if [[ ${b} == "${match}" ]]; then
printf '%s\n' "${!guy}"
fi
done
}

Expand Down
10 changes: 5 additions & 5 deletions pacstall
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ function download() {
# This will then output the options given by the user to ${PACDIR}-selectopts-${varname}-${pacname}, which you can then turn into another array
function select_options() {
{ ignore_stack=false; set -o pipefail; trap stacktrace ERR RETURN; }
local message="${1}" length="${2}" varname="${3}"
rm -f "${PACDIR}-selectopts-${varname}-${pacname}"
local message="${1}" length="${2}" varname="${3}" optname="${pkgbase:-${pacname}}"
rm -f "${PACDIR}-selectopts-${varname}-${optname}"
if ((length >= 6)); then
echo -ne "${message} [${BOLD}1-$length${NC} or ${BIGreen}Y${NC}] "
else
Expand All @@ -480,9 +480,9 @@ function select_options() {
input="Y"
fi
if [[ -z $input ]] || [[ $input =~ ^[Yy]$ ]]; then
seq -s ' ' 1 "$length" | tee "${PACDIR}-selectopts-${varname}-${pacname}" > /dev/null
seq -s ' ' 1 "$length" | tee "${PACDIR}-selectopts-${varname}-${optname}" > /dev/null
elif ((input == 0)) || [[ $input =~ ^[Nn]$ ]]; then
echo "n" | tee "${PACDIR}-selectopts-${varname}-${pacname}" > /dev/null
echo "n" | tee "${PACDIR}-selectopts-${varname}-${optname}" > /dev/null
elif ! [[ $input =~ [a-zA-Z]+ ]] || [[ $input =~ ^[0-9]+$ ]]; then
for i in "${input[@]}"; do
unset split_arr
Expand Down Expand Up @@ -511,7 +511,7 @@ function select_options() {
out+=("$i")
fi
done
echo "${out[@]}" | tee "${PACDIR}-selectopts-${varname}-${pacname}" > /dev/null
echo "${out[@]}" | tee "${PACDIR}-selectopts-${varname}-${optname}" > /dev/null
else
select_options "$message" "$length" "$varname"
fi
Expand Down

0 comments on commit ea75e9d

Please sign in to comment.