Commit 9e52a367 authored by Eli Schwartz's avatar Eli Schwartz Committed by Allan McRae
Browse files

makepkg: use the `declare` builtin when backing up variables to eval



Rather than manually crafting foo_backup in a loop and eval'ing them
with a complicated escape pattern, store every splitpkg_overrides
element into a single variable via the eval-friendly `declare` builtin.

An alternative to eval would be using `printf -v` but this does not work
for arrays.

This has the additional benefit of reducing the number of
variables/arrays floating around in the environment.
Signed-off-by: Eli Schwartz's avatarEli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae's avatarAllan McRae <allan@archlinux.org>
parent f054351e
......@@ -1115,34 +1115,22 @@ check_build_status() {
backup_package_variables() {
local var
for var in ${splitpkg_overrides[@]}; do
local indirect="${var}_backup"
eval "${indirect}=(\"\${$var[@]}\")"
done
}
restore_package_variables() {
local var
for var in ${splitpkg_overrides[@]}; do
local indirect="${var}_backup"
if [[ -n ${!indirect} ]]; then
eval "${var}=(\"\${$indirect[@]}\")"
else
unset ${var}
fi
declare -p $var 2>/dev/null || printf '%s\n' "unset $var"
done
}
run_split_packaging() {
local pkgname_backup=("${pkgname[@]}")
local restore_package_variables
for pkgname in ${pkgname_backup[@]}; do
pkgdir="$pkgdirbase/$pkgname"
mkdir "$pkgdir"
backup_package_variables
restore_package_variables="$(backup_package_variables)"
run_package $pkgname
tidy_install
lint_package || exit $E_PACKAGE_FAILED
create_package
restore_package_variables
eval "$restore_package_variables"
done
pkgname=("${pkgname_backup[@]}")
create_debug_package
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment