summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@parabola.nu>2024-04-03 00:23:29 -0600
committerLuke T. Shumaker <lukeshu@parabola.nu>2024-04-03 23:20:19 -0600
commitcf393aa811580eea7428a4842a50151578343585 (patch)
tree7f41289be5aca18e1a1189ee9eb30ea861283179
parenta4f024464fccd80f3e8ab888e8fe5722fbf6c2a1 (diff)
test: Get rid of the old testenv filtering in favor of native BATS tags
BATS didn't have tags when I ported from Roundup to BATS in 2018. Tags have since been added to BATS in 2022 for inclusion in v1.8.0.
-rw-r--r--HACKING/testing.md16
-rw-r--r--Makefile5
-rw-r--r--config.mk2
-rw-r--r--test/cases/lib-blacklist.bats6
-rw-r--r--test/cases/lib-conf.bats4
-rw-r--r--test/cases/librechroot.bats37
-rw-r--r--test/cases/librefetch.bats3
-rw-r--r--test/cases/libremakepkg.bats36
-rw-r--r--test/cases/librerelease.bats3
-rw-r--r--test/cases/librestage.bats19
-rw-r--r--test/lib/common.bash23
-rwxr-xr-xtest/testenv26
12 files changed, 59 insertions, 121 deletions
diff --git a/HACKING/testing.md b/HACKING/testing.md
index d0b3bed..3b38d40 100644
--- a/HACKING/testing.md
+++ b/HACKING/testing.md
@@ -2,10 +2,12 @@ Testing
=======
Please write unit tests for new things. Tests can be run with `make check`,
-which just runs `./testenv bats cases` in the `test/` directory. You will need
-the `bats` tool (the `bats` Parabola package) in order to run the tests.
-`./testenv` can be given `--no-network` and/or `--no-sudo` to disable tests
-which require those things. You can also pass them to make as `TESTENVFLAGS`.
-If you don't disable either, I *strongly* recommend setting TMPDIR to somewhere
-on a btrfs partition before running the tests; otherwise the chroot tests will
-take forever. I mean, they already take long on btrfs, but without it... _dang_.
+which just runs `./testenv bats cases` in the `test/` directory. You will need
+the `bats` tool (the `bats` Parabola package) in order to run the tests. `bats`
+can be given `--filter-tags !network,!sudo,!btrfs` to disable tests which
+require those things. `make check` can be made to pass those flags in by
+setting `BATS_FLAGS`. If `!btrfs` is not given, then TMPDIR *must* be on btrfs
+partition (or else the tests that need btrfs will fail). If neither `!network`
+nor `!sudo` is given, then I *strongly* recommend setting TMPDIR to somewhere on
+a btrfs partition; otherwise the chroot tests will take forever. I mean, they
+already take long on btrfs, but without it... _dang_.
diff --git a/Makefile b/Makefile
index aff9cbd..87bb868 100644
--- a/Makefile
+++ b/Makefile
@@ -12,8 +12,7 @@ files.src.gen += .srcversion-libretools.mk .srcversion-devtools.mk
nested.subdirs = src po
$(outdir)/check:
- cd $(@D)/test && ./testenv $(TESTENVFLAGS) \
- bats $(if $(findstring --no-network,$(TESTENVFLAGS)),--filter-tags !net,) cases
+ cd $(@D)/test && ./testenv bats $(BATS_FLAGS) cases
$(outdir)/shellcheck: private shellcheck.flags = --exclude=1090,1091,2016,2059,2064,2164,2191
$(outdir)/shellcheck: private shellcheck.prune = -false
@@ -24,6 +23,6 @@ $(outdir)/shellcheck: private shellcheck.prune += -o -type f -name Makefile
$(outdir)/shellcheck: private shellcheck.prune += -o -type f -name makepkg.gen
$(outdir)/shellcheck: private shellcheck.prune += -o -type f -name source.sh.gen
$(outdir)/shellcheck:
- cd $(@D)/test && ./testenv $(TESTENVFLAGS) 'cd "$$TMPDIR/destdir" && find \( $(shellcheck.prune) \) -prune -o -not -type d -exec shellcheck $(shellcheck.flags) {} +'
+ cd $(@D)/test && ./testenv 'cd "$$TMPDIR/destdir" && find \( $(shellcheck.prune) \) -prune -o -not -type d -exec shellcheck $(shellcheck.flags) {} +'
include $(topsrcdir)/build-aux/Makefile.tail.mk
diff --git a/config.mk b/config.mk
index fbd0ec5..92c3039 100644
--- a/config.mk
+++ b/config.mk
@@ -33,7 +33,7 @@ devtoolsdir = $(call abspath,$(topsrcdir)/../devtools-par)
enable_manpages = t
RONNFLAGS = --manual='libretools Manual' --organization='Parabola'
-TESTENVFLAGS ?=
+BATS_FLAGS ?=
.LIBPATTERNS ?=
diff --git a/test/cases/lib-blacklist.bats b/test/cases/lib-blacklist.bats
index ba74d04..4dc30c9 100644
--- a/test/cases/lib-blacklist.bats
+++ b/test/cases/lib-blacklist.bats
@@ -94,17 +94,15 @@ load ../lib/common
not empty $tmpdir/stderr
}
+# bats test_tags=network
@test "libreblacklist downloads the blacklist as needed" {
- require network || skip
-
libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr
not empty $tmpdir/stdout
}
+# bats test_tags=network
@test "libreblacklist downloads the blacklist repeatedly" {
- require network || skip
-
libreblacklist update
libreblacklist update
}
diff --git a/test/cases/lib-conf.bats b/test/cases/lib-conf.bats
index 0925640..6a8fee7 100644
--- a/test/cases/lib-conf.bats
+++ b/test/cases/lib-conf.bats
@@ -8,8 +8,8 @@ load ../lib/common
[[ $PKGDEST == /pkgdest ]]
}
+# bats test_tags=sudo
@test "lib/conf.sh figures out HOME when root" {
- require sudo || skip
# This one is tricky, because it does the job too well, it will find
# the actual HOME, instead of the test environment HOME. Therefore, we
# will just check that [[ $HOME != /root ]]
@@ -19,8 +19,8 @@ load ../lib/common
[[ $LIBREHOME != /root ]]
}
+# bats test_tags=sudo
@test "lib/conf.sh nests LIBREUSER" {
- require sudo || skip
[[ $USER != root ]]
cd "$tmpdir"
echo '. $(librelib conf.sh); echo "$LIBREUSER"' > test.sh
diff --git a/test/cases/librechroot.bats b/test/cases/librechroot.bats
index ca61e1e..5073972 100644
--- a/test/cases/librechroot.bats
+++ b/test/cases/librechroot.bats
@@ -1,41 +1,39 @@
load ../lib/common
+# bats test_tags=network,sudo
@test "librechroot creates repo for new chroots" {
- require network sudo || skip
testsudo librechroot -l "$BATS_TEST_NAME" run test -r /repo/repo.db
}
+# bats test_tags=network,sudo
@test "librechroot cleans the local repo correctly" {
- require network sudo || skip
testsudo librechroot -l "$BATS_TEST_NAME" make
testsudo librechroot -l "$BATS_TEST_NAME" clean-repo
testsudo librechroot -l "$BATS_TEST_NAME" run test -r /repo/repo.db
# TODO: inspect /repo/* more
}
+# bats test_tags=network,sudo
@test "librechroot respects exit status if out isnt a tty" {
- require network sudo || skip
set -o pipefail
{ testsudo librechroot -l "$BATS_TEST_NAME" run bash -c 'exit 3' | cat; } || status=$?
[[ $status == 3 ]]
}
+# bats test_tags=network,sudo
@test "librechroot creates ca certificates" {
- require network sudo || skip
testsudo librechroot -l "$BATS_TEST_NAME" run test -r /etc/ssl/certs/ca-certificates.crt
}
+# bats test_tags=network,sudo
@test "librechroot disables networking when requested" {
- require network sudo || skip
-
testsudo librechroot -l "$BATS_TEST_NAME" run curl https://repo.parabola.nu/ >/dev/null
not testsudo librechroot -l "$BATS_TEST_NAME" -N run curl https://repo.parabola.nu/ >/dev/null
}
+# bats test_tags=network,sudo
@test "librechroot handles CHROOTEXTRAPKG correctly" {
- require network sudo || skip
-
not testsudo librechroot -l "$BATS_TEST_NAME" run lsof
echo "CHROOTEXTRAPKG=(lsof)" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf
testsudo librechroot -l "$BATS_TEST_NAME" install-name lsof
@@ -46,9 +44,8 @@ load ../lib/common
not testsudo librechroot -l "$BATS_TEST_NAME" run lsof
}
+# bats test_tags=network,sudo
@test "librechroot obeys depends in PKGBUILD" {
- require network sudo || skip
-
# NB: We chown `/startdir` because chcleanup runs `makepkg
# --printsrcinfo > .SRCINFO` as the user that owns
# `/startdir/PKGBUILD`, and `makepkg` doesn't like to be run
@@ -78,9 +75,8 @@ load ../lib/common
testsudo librechroot -l "$BATS_TEST_NAME" run lsof
}
+# bats test_tags=network,sudo
@test "librechroot can install libretools with chcleanup" {
- require network sudo || skip
-
# NB: We chown `/startdir` because chcleanup runs `makepkg
# --printsrcinfo > .SRCINFO` as the user that owns
# `/startdir/PKGBUILD`, and `makepkg` doesn't like to be run
@@ -124,9 +120,8 @@ load ../lib/common
[[ "$(sed -n 2p $tmpdir/stderr)" =~ Usage:.* ]]
}
+# bats test_tags=network,sudo
@test "librechroot obeys the n flag" {
- require network sudo || skip
-
not test -f "$chrootdir/$BATS_TEST_NAME/$BATS_TEST_NAME/$BATS_TEST_NAME.stamp"
testsudo librechroot -n "$BATS_TEST_NAME" -l "$BATS_TEST_NAME" run touch /"$BATS_TEST_NAME.stamp"
@@ -135,8 +130,8 @@ load ../lib/common
}
# requires sudo so we know it's not failing because it needs root
+# bats test_tags=sudo
@test "librechroot fails for unknown commands" {
- require sudo || skip
testsudo librechroot phony >$tmpdir/stdout 2>$tmpdir/stderr || status=$?
[[ $status != 0 ]]
@@ -145,8 +140,8 @@ load ../lib/common
}
# requires sudo so we know it's not failing because it needs root
+# bats test_tags=sudo
@test "librechroot fails for unknown flags" {
- require sudo || skip
testsudo librechroot -q >$tmpdir/stdout 2>$tmpdir/stderr || status=$?
[[ $status != 0 ]]
@@ -154,8 +149,8 @@ load ../lib/common
not empty $tmpdir/stderr
}
+# bats test_tags=sudo
@test "librechroot fails when syncing a copy with itself" {
- require sudo || skip
testsudo timeout 5 librechroot -l root sync || status=$?
case $status in
0|124|137) # success|timeout+TERM|timeout+KILL
@@ -165,16 +160,17 @@ load ../lib/common
esac
}
+# bats test_tags=network,sudo
@test "librechroot deletes copies" {
- require network sudo || skip
testsudo librechroot -l "$BATS_TEST_NAME" make
test -d "$chrootdir/default/$BATS_TEST_NAME"
testsudo librechroot -l "$BATS_TEST_NAME" delete
not test -e "$chrootdir/default/$BATS_TEST_NAME"
}
+# bats test_tags=network,sudo,btrfs
@test "librechroot deletes subvolumes recursively" {
- require network sudo btrfs || skip
+ [[ "$(stat -f -c %T "$chrootdir" 2>/dev/null || true)" == 'btrfs' ]]
testsudo librechroot -l "$BATS_TEST_NAME" make
testsudo librechroot -l "$BATS_TEST_NAME" install-name btrfs-progs
test -d "$chrootdir/default/$BATS_TEST_NAME"
@@ -185,9 +181,8 @@ load ../lib/common
not test -e "$chrootdir/default/$BATS_TEST_NAME"
}
+# bats test_tags=network,sudo
@test "librechroot cleans up TMPDIR" {
- require network sudo || skip
-
local dir="$tmpdir/tmp"
mkdir -- "$dir"
diff --git a/test/cases/librefetch.bats b/test/cases/librefetch.bats
index 6f63210..21150bb 100644
--- a/test/cases/librefetch.bats
+++ b/test/cases/librefetch.bats
@@ -1,8 +1,5 @@
load ../lib/common
-# bats file_tags=net
-
-
setup() {
common_setup
diff --git a/test/cases/libremakepkg.bats b/test/cases/libremakepkg.bats
index 34db6e3..985d6f6 100644
--- a/test/cases/libremakepkg.bats
+++ b/test/cases/libremakepkg.bats
@@ -20,8 +20,8 @@ teardown() {
common_teardown
}
+# bats test_tags=network,sudo
@test "libremakepkg builds a trivial package" {
- require network sudo || skip
cp fixtures/libremakepkg/PKGBUILD-hello "$tmpdir/PKGBUILD"
cd "$tmpdir"
@@ -30,8 +30,8 @@ teardown() {
globfile libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*))
}
+# bats test_tags=network,sudo
@test "libremakepkg disables networking during prepare" {
- require network sudo || skip
cp fixtures/libremakepkg/PKGBUILD-netprepare "$tmpdir/PKGBUILD"
cd "$tmpdir"
@@ -41,8 +41,8 @@ teardown() {
globfile libretools-netprepare-1.0-1-any.pkg.tar?(.!(sig|*.*))
}
+# bats test_tags=network,sudo
@test "libremakepkg disables networking during build" {
- require network sudo || skip
cp fixtures/libremakepkg/PKGBUILD-netbuild "$tmpdir/PKGBUILD"
cd "$tmpdir"
@@ -52,8 +52,8 @@ teardown() {
globfile libretools-netbuild-1.0-1-any.pkg.tar?(.!(sig|*.*))
}
+# bats test_tags=network,sudo
@test "libremakepkg disables networking during package" {
- require network sudo || skip
cp fixtures/libremakepkg/PKGBUILD-netpackage "$tmpdir/PKGBUILD"
cd "$tmpdir"
@@ -63,8 +63,8 @@ teardown() {
globfile libretools-netpackage-1.0-1-any.pkg.tar?(.!(sig|*.*))
}
+# bats test_tags=network,sudo
@test "libremakepkg cleans the chroot before building" {
- require network sudo || skip
# 1. First, we build testpkg1
# 2. Then, we build testpkg2, which depends on testpkg1
# Therefore, testpkg1 will be installed after testpkg2 is built, we
@@ -97,8 +97,8 @@ teardown() {
not testsudo librechroot -l "$BATS_TEST_NAME" run libretools-testpkg1 'second time, fail'
}
+# bats test_tags=network,sudo
@test "libremakepkg handles PKGDEST not existing" {
- require network sudo || skip
cp fixtures/libremakepkg/PKGBUILD-hello "$tmpdir/PKGBUILD"
cd "$tmpdir"
@@ -127,8 +127,8 @@ teardown() {
not empty $tmpdir/stderr
}
+# bats test_tags=network,sudo
@test "libremakepkg fails if a hook fails" {
- require network sudo || skip
cp fixtures/libremakepkg/PKGBUILD-hello "$tmpdir/PKGBUILD"
cd "$tmpdir"
@@ -142,8 +142,8 @@ teardown() {
tail -n1 $tmpdir/stderr | grep -qF '==> ERROR: Failure(s) in check_pkgbuild: check_pkgbuild_nonfree'
}
+# bats test_tags=network,sudo
@test "libremakepkg detects distcc files" {
- require network sudo || skip
cp fixtures/libremakepkg/PKGBUILD-hello "$tmpdir/PKGBUILD"
cd "$tmpdir"
@@ -164,9 +164,8 @@ teardown() {
not globfile libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*))
}
+# bats test_tags=network,sudo
@test "libremakepkg forwards distcc ports" {
- require network sudo || skip
-
# The maximum AF_UNIX socket path is 108 bytes; so let's have
# a chroot name that's guaranteed to be >110 characters, to
# make sure we handle that.
@@ -190,9 +189,8 @@ teardown() {
globfile libretools-distcc-1.0-1-any.pkg.tar?(.!(sig|*.*))
}
+# bats test_tags=network,sudo
@test "libremakepkg doesnt symlink outputs" {
- require network sudo || skip
-
sed -i /^unset/d "$XDG_CONFIG_HOME/pacman/makepkg.conf"
cp fixtures/libremakepkg/PKGBUILD-hello "$tmpdir/PKGBUILD"
@@ -206,9 +204,8 @@ teardown() {
globfile "$tmpdir/workdir/srcpkgdest"/libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*))
}
+# bats test_tags=network,sudo
@test "libremakepkg succeeds with good signatures" {
- require network sudo || skip
-
cp fixtures/libremakepkg/PKGBUILD-signed "$tmpdir/PKGBUILD"
cp fixtures/libremakepkg/hello.sh "$tmpdir/hello.sh"
cd "$tmpdir"
@@ -217,9 +214,8 @@ teardown() {
testsudo libremakepkg -l "$BATS_TEST_NAME"
}
+# bats test_tags=network,sudo
@test "libremakepkg fails with bad signatures" {
- require network sudo || skip
-
cp fixtures/libremakepkg/PKGBUILD-signed "$tmpdir/PKGBUILD"
cp fixtures/libremakepkg/hello.sh "$tmpdir/hello.sh"
cd "$tmpdir"
@@ -230,9 +226,8 @@ teardown() {
not testsudo libremakepkg -l "$BATS_TEST_NAME"
}
+# bats test_tags=network,sudo
@test "libremakepkg does not run pkgver" {
- require network sudo || skip
-
cp fixtures/libremakepkg/PKGBUILD-pkgver "$tmpdir/PKGBUILD"
pushd "$tmpdir"
@@ -244,8 +239,8 @@ teardown() {
diff -u fixtures/libremakepkg/PKGBUILD-pkgver "$tmpdir/PKGBUILD"
}
+# bats test_tags=network,sudo
@test "libremakepkg has a flag to make startdir rw" {
- require network sudo || skip
cp fixtures/libremakepkg/PKGBUILD-rwstartdir "$tmpdir/PKGBUILD"
cd "$tmpdir"
@@ -255,9 +250,8 @@ teardown() {
globfile libretools-rwstartdir-1.0-1-any.pkg.tar?(.!(sig|*.*))
}
+# bats test_tags=network,sudo
@test "libremakepkg can re-use source-packages" {
- require network sudo || skip
-
cp fixtures/libremakepkg/PKGBUILD-hello "$tmpdir/PKGBUILD"
cd "$tmpdir"
diff --git a/test/cases/librerelease.bats b/test/cases/librerelease.bats
index cd9455e..ce9692f 100644
--- a/test/cases/librerelease.bats
+++ b/test/cases/librerelease.bats
@@ -1,8 +1,5 @@
load ../lib/common
-# bats file_tags=net
-
-
## helpers ##
# Stub server-side `db-update` for SSH localhost to run
diff --git a/test/cases/librestage.bats b/test/cases/librestage.bats
index 4551d1e..000ea3e 100644
--- a/test/cases/librestage.bats
+++ b/test/cases/librestage.bats
@@ -26,27 +26,22 @@ shopt -s extglob
not empty "$tmpdir/stderr"
}
+# bats test_tags=network,sudo
@test "librestage guesses the repo" {
- nochroot=false; require network sudo || nochroot=true
mkdir -p -- "$tmpdir/reponame/libretools-hello"
cp fixtures/librestage/PKGBUILD-hello "$tmpdir/reponame/libretools-hello/PKGBUILD"
cd "$tmpdir/reponame/libretools-hello"
- if $nochroot; then
- makepkg
- else
- testsudo libremakepkg -l "$BATS_TEST_NAME"
- fi
+ testsudo libremakepkg -l "$BATS_TEST_NAME"
librestage
find "$tmpdir" -not -type d -exec ls -ld -- {} +
globfile $tmpdir/workdir/staging/reponame/libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*))
- $nochroot || globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*))
+ globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*))
}
+# bats test_tags=network,sudo
@test "librestage stages packages without PKGDEST" {
- nochroot=false; require network sudo || nochroot=true
-
cat >> "$XDG_CONFIG_HOME/pacman/makepkg.conf" <<-eot
PKGDEST=''
SRCPKGDEST=''
@@ -55,14 +50,10 @@ shopt -s extglob
cp fixtures/librestage/PKGBUILD-hello "$tmpdir/PKGBUILD"
cd "$tmpdir"
- if $nochroot; then
- makepkg
- else
testsudo libremakepkg -l "$BATS_TEST_NAME"
- fi
librestage repo1
find "$tmpdir" -not -type d -exec ls -ld -- {} +
globfile $tmpdir/workdir/staging/repo1/libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*))
- $nochroot || globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*))
+ globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*))
}
diff --git a/test/lib/common.bash b/test/lib/common.bash
index 90b6f04..db6b33e 100644
--- a/test/lib/common.bash
+++ b/test/lib/common.bash
@@ -66,7 +66,7 @@ common_setup() {
common_teardown() {
gpg-connect-agent KILLAGENT /bye || true
if [[ -n ${tmpdir:-} ]]; then
- if [[ -f "$tmpdir/.used-sudo" ]]; then
+ if libremessages in_array 'sudo' "${BATS_TEST_TAGS[@]}"; then
sudo rm -rf -- "$tmpdir"
else
rm -rf -- "$tmpdir"
@@ -100,27 +100,6 @@ teardown() {
# Utility functions for use in test definitions ######################
-require() (
- set +x
- local missing=()
- if libremessages in_array "network" "$@" && ! [[ $NETWORK ]]; then
- missing+=('networking')
- fi
- if libremessages in_array "sudo" "$@" && ! [[ $SUDO ]]; then
- missing+=('sudo')
- fi
- if libremessages in_array "btrfs" "$@" && ! [[ "$(stat -f -c %T "$chrootdir" 2>/dev/null || true)" == 'btrfs' ]]; then
- missing+=('btrfs')
- fi
- if (( ${#missing[@]} )); then
- return 1
- fi
- if libremessages in_array "sudo" "$@"; then
- touch "$tmpdir/.used-sudo"
- fi
- return 0
-)
-
empty() {
diff -u /dev/null "$1"
}
diff --git a/test/testenv b/test/testenv
index 09fd328..eb34dda 100755
--- a/test/testenv
+++ b/test/testenv
@@ -2,21 +2,6 @@
{
set -e
- # Parse the arguments
- NETWORK=true
- SUDO=true
- while [[ $# -gt 0 ]]; do
- case "$1" in
- --no-network) shift; unset NETWORK;;
- --network) shift; NETWORK=true;;
- --no-sudo) shift; unset SUDO;;
- --sudo) shift; SUDO=true;;
- --) shift; break;;
- *) break;;
- esac
- done
- export NETWORK SUDO
-
if [[ $# == 0 ]]; then
echo 'You need to run testenv with arguments!' >&2
exit 1
@@ -27,7 +12,7 @@
cleanup() {
set +e
# coordinate this with ./lib/common.bash
- if [[ $SUDO ]] && [[ -d "$TMPDIR/chroots" ]]; then
+ if [[ -f "$TMPDIR/.used-sudo" ]] && [[ -d "$TMPDIR/chroots" ]]; then
if [[ "$(stat -f -c %T "$TMPDIR/chroots")" == btrfs ]]; then
sudo find "$TMPDIR/chroots" -depth -inum 256 -exec \
btrfs subvolume delete {} \; &>/dev/null
@@ -61,8 +46,9 @@
"${_librelib_conf_sh_sysconfdir}/makepkg.d/librefetch.conf"
# Hack to respect our variables in sudo
- install -Dm755 /dev/stdin "$destdir/usr/bin/testsudo" <<-'eot'
+ install -Dm755 /dev/stdin "$destdir/usr/bin/testsudo" <<-eot
#!/bin/bash
+ touch ${TMPDIR@Q}/.used-sudo
vars=(
TMPDIR
GNUPGHOME XDG_CACHE_HOME XDG_CONFIG_HOME
@@ -70,10 +56,10 @@
GPGKEY
)
env=()
- for var in "${vars[@]}"; do
- env+=("$var=${!var}")
+ for var in "\${vars[@]}"; do
+ env+=("\$var=\${!var}")
done
- sudo "${env[@]}" "$@"
+ sudo "\${env[@]}" "\$@"
eot
# Hack to work around GnuPG being stupid with locating gpg-agent's socket
install -Dm755 /dev/stdin "$destdir/usr/bin/gpg" <<-'eot'