initial import
This commit is contained in:
853
libretools/doas.patch
Normal file
853
libretools/doas.patch
Normal file
@@ -0,0 +1,853 @@
|
||||
diff --git a/HACKING/testing.md b/HACKING/testing.md
|
||||
index 8dee4853..3946f0ef 100644
|
||||
--- a/HACKING/testing.md
|
||||
+++ b/HACKING/testing.md
|
||||
@@ -5,7 +5,7 @@ Please write unit tests for new things. Tests can be run with `make
|
||||
check`, which just runs `./testenv roundup` in the `test/` directory.
|
||||
Relatedly, you need the `roundup` (the `sh-roundup` package on
|
||||
Parabola) tool to run the tests. `./testenv` can be given
|
||||
-`--no-network` and/or `--no-sudo` to dissable tests that require those
|
||||
+`--no-network` and/or `--no-doas` to dissable tests that require those
|
||||
things. Make can be made to pass those things in by setting
|
||||
`TESTENVFLAGS`. If you don't dissable either, I *strongly* recommend
|
||||
setting TMPDIR to somewhere on a btrfs partition before running the
|
||||
diff --git a/src/abslibre-tools/libredbdiff b/src/abslibre-tools/libredbdiff
|
||||
index a01c32fb..22d27a77 100755
|
||||
--- a/src/abslibre-tools/libredbdiff
|
||||
+++ b/src/abslibre-tools/libredbdiff
|
||||
@@ -3,6 +3,8 @@
|
||||
#
|
||||
# Copyright (C) 2014 Esteban Carnevale <alfplayer@mailoo.org>
|
||||
# Copyright (C) 2014, 2017 Luke Shumaker <lukeshu@sbcglobal.net>
|
||||
+# Copyright (C) 2020 André Silva <emulatorman@hyperbola.info>
|
||||
+# Copyright (C) 2020 Márcio Silva <coadde@hyperbola.info>
|
||||
#
|
||||
# License: GNU GPLv3+
|
||||
#
|
||||
@@ -131,7 +133,7 @@ print_cmp() {
|
||||
}
|
||||
|
||||
usage() {
|
||||
- print "Usage: sudo %q" "$cmd"
|
||||
+ print "Usage: doas %q" "$cmd"
|
||||
print " or: %q -n [REPO]" "$cmd"
|
||||
print " or: %q -h" "$cmd"
|
||||
print 'Show packages that need to be updated from Arch repositories.'
|
||||
diff --git a/src/chroot-tools/hooks-check.sh b/src/chroot-tools/hooks-check.sh
|
||||
index 2bf3fff4..de18c452 100644
|
||||
--- a/src/chroot-tools/hooks-check.sh
|
||||
+++ b/src/chroot-tools/hooks-check.sh
|
||||
@@ -1,5 +1,7 @@
|
||||
#!/hint/bash -euE -o pipefail
|
||||
# Copyright (C) 2013, 2017 Luke Shumaker <lukeshu@sbcglobal.net>
|
||||
+# Copyright (C) 2020 André Silva <emulatorman@hyperbola.info>
|
||||
+# Copyright (C) 2020 Márcio Silva <coadde@hyperbola.info>
|
||||
#
|
||||
# License: GNU GPLv2+
|
||||
#
|
||||
@@ -19,13 +21,21 @@
|
||||
hook_check_pkgbuild+=("check_pkgbuild_nonfree")
|
||||
check_pkgbuild_nonfree() {
|
||||
local s=0
|
||||
- sudo -EH -u "$LIBREUSER" pkgbuild-check-nonfree -f || s=$?
|
||||
+ if [ $(doas grep -qs 'permit nopass keepenv setenv { HOME='$LIBREHOME' } '$LIBREUSER /etc/doas.conf; echo $?) != 0 ]; then
|
||||
+ echo 'permit nopass keepenv setenv { HOME='$LIBREHOME' } '$LIBREUSER >> "$copydir/etc/doas.conf"
|
||||
+ fi
|
||||
+ doas -u "$LIBREUSER" bash -c "DOAS_USER="$DOAS_USER" pkgbuild-check-nonfree -f || s=$?"
|
||||
+ sed -i '\|permit nopass keepenv setenv { HOME='$LIBREHOME' } '$LIBREUSER'|d' "$copydir/etc/doas.conf"
|
||||
pkgbuild-summarize-nonfree $s
|
||||
}
|
||||
|
||||
#hook_check_pkgbuild+=("check_pkgbuild_namcap")
|
||||
check_pkgbuild_namcap() {
|
||||
- sudo -EH -u "$LIBREUSER" namcap PKGBUILD
|
||||
+ if [ $(doas grep -qs 'permit nopass keepenv setenv { HOME='$LIBREHOME' } '$LIBREUSER /etc/doas.conf; echo $?) != 0 ]; then
|
||||
+ echo 'permit nopass keepenv setenv { HOME='$LIBREHOME' } '$LIBREUSER >> "$copydir/etc/doas.conf"
|
||||
+ fi
|
||||
+ doas -u "$LIBREUSER" bash -c "DOAS_USER="$DOAS_USER" namcap PKGBUILD"
|
||||
+ sed -i '\|permit nopass keepenv setenv { HOME='$LIBREHOME' } '$LIBREUSER'|d' "$copydir/etc/doas.conf"
|
||||
}
|
||||
|
||||
#hook_check_pkg+=("check_pkg")
|
||||
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
|
||||
index 7b1c8c2c..f9bbc463 100755
|
||||
--- a/src/chroot-tools/librechroot
|
||||
+++ b/src/chroot-tools/librechroot
|
||||
@@ -206,7 +206,7 @@ usage() {
|
||||
echo
|
||||
prose 'Each named chroot has a master clean copy (named `root`), and any
|
||||
number of other named copies; the copy used by default is the
|
||||
- current username (or $SUDO_USER, or `copy` if root).'
|
||||
+ current username (or $DOAS_USER, or `copy` if root).'
|
||||
echo
|
||||
prose 'The full path to the chroot copy is "$CHROOTDIR/$CHROOT/$COPY",
|
||||
unless the copy name is manually specified as an absolute path,
|
||||
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
|
||||
index d4e5b8a0..b6e7ff92 100755
|
||||
--- a/src/chroot-tools/libremakepkg
|
||||
+++ b/src/chroot-tools/libremakepkg
|
||||
@@ -6,6 +6,8 @@ set -euE
|
||||
# Copyright (C) 2010-2012 Joshua Ismael Haase Hernández (xihh) <hahj87@gmail.com>
|
||||
# Copyright (C) 2012 Michał Masłowski <mtjm@mtjm.eu>
|
||||
# Copyright (C) 2012-2015, 2017 Luke Shumaker <lukeshu@sbcglobal.net>
|
||||
+# Copyright (C) 2020 André Silva <emulatorman@hyperbola.info>
|
||||
+# Copyright (C) 2020 Márcio Silva <coadde@hyperbola.info>
|
||||
#
|
||||
# License: GNU GPLv2+
|
||||
#
|
||||
@@ -144,8 +146,8 @@ usage() {
|
||||
bullet 'set `MAKEFLAGS` and `PACKAGER` in `/etc/makepkg.conf` to reflect
|
||||
the value outside of the chroot.'
|
||||
bullet 'create a `builduser` with the same numeric UID as the
|
||||
- invoking $SUDO_USER.'
|
||||
- bullet 'lets this `builduser` call `sudo pacman` without a password.'
|
||||
+ invoking $DOAS_USER.'
|
||||
+ bullet 'lets this `builduser` call `doas pacman` without a password.'
|
||||
bullet 'adds a pacman repositoriy of locally built packages'
|
||||
echo
|
||||
prose 'This command is configured both with `chroot.conf` (either in
|
||||
diff --git a/src/chroot-tools/makechrootpkg.in b/src/chroot-tools/makechrootpkg.in
|
||||
index f97b329b..370d672f 100644
|
||||
--- a/src/chroot-tools/makechrootpkg.in
|
||||
+++ b/src/chroot-tools/makechrootpkg.in
|
||||
@@ -33,9 +33,9 @@ init_variables() {
|
||||
bindmounts_rw=()
|
||||
|
||||
copy=$USER
|
||||
- [[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER
|
||||
+ [[ -n ${DOAS_USER:-} ]] && copy=$DOAS_USER
|
||||
[[ -z "$copy" || $copy = root ]] && copy=copy
|
||||
- src_owner=${SUDO_USER:-$USER}
|
||||
+ src_owner=${DOAS_USER:-$USER}
|
||||
}
|
||||
|
||||
usage() {
|
||||
@@ -191,7 +191,7 @@ prepare_chroot() {
|
||||
$repack || rm -rf "$copydir/build"
|
||||
|
||||
local builduser_uid builduser_gid
|
||||
- builduser_uid="${SUDO_UID:-$UID}"
|
||||
+ builduser_uid="$(id -u ${DOAS_USER:-$USER})"
|
||||
builduser_gid="$(id -g "$builduser_uid")"
|
||||
local install="install -o $builduser_uid -g $builduser_gid"
|
||||
local x
|
||||
@@ -222,10 +222,12 @@ prepare_chroot() {
|
||||
echo "$x" >>"$copydir/etc/makepkg.conf"
|
||||
done
|
||||
|
||||
- cat > "$copydir/etc/sudoers.d/builduser-pacman" <<EOF
|
||||
-builduser ALL = NOPASSWD: /usr/bin/pacman
|
||||
+ if [ $(doas grep -qs 'permit nopass builduser as root cmd /usr/bin/pacman' "$copydir/etc/doas.conf"; echo $?) != 0 ]; then
|
||||
+ cat > "$copydir/etc/doas.conf" <<EOF
|
||||
+permit nopass :wheel
|
||||
+permit nopass builduser as root cmd /usr/bin/pacman
|
||||
EOF
|
||||
- chmod 440 "$copydir/etc/sudoers.d/builduser-pacman"
|
||||
+ fi
|
||||
|
||||
if ! grep -q '^\[repo\]' "$copydir/etc/pacman.conf"; then
|
||||
local line
|
||||
@@ -266,29 +268,33 @@ Server = file:///repo
|
||||
_chrootprepare() {
|
||||
# shellcheck source=/dev/null
|
||||
. /etc/profile
|
||||
- # Beware, there are some stupid arbitrary rules on how you can
|
||||
- # use "$" in arguments to commands with "sudo -i". ${foo} or
|
||||
- # ${1} is OK, but $foo or $1 isn't.
|
||||
- # https://bugzilla.sudo.ws/show_bug.cgi?id=765
|
||||
- sudo -iu builduser bash -c 'cd /startdir; makepkg "$@" --nobuild' -bash "$@"
|
||||
+ if [ $(doas grep -qs 'permit nopass setenv { HOME="/build" PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" _="/bin/bash" } builduser' /etc/doas.conf; echo $?) != 0 ]; then
|
||||
+ echo 'permit nopass setenv { HOME="/build" PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" _="/bin/bash" } builduser' >> "$copydir/etc/doas.conf"
|
||||
+ fi
|
||||
+ doas -u builduser bash -c 'cd $HOME; cd /startdir; DOAS_USER='$DOAS_USER' makepkg "$@" --nobuild' -bash "$@"
|
||||
+ sed -i '\|permit nopass setenv { HOME="/build" PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" _="/bin/bash" } builduser|d' "$copydir/etc/doas.conf"
|
||||
}
|
||||
|
||||
_chrootbuild() {
|
||||
# shellcheck source=/dev/null
|
||||
. /etc/profile
|
||||
- # Beware, there are some stupid arbitrary rules on how you can
|
||||
- # use "$" in arguments to commands with "sudo -i". ${foo} or
|
||||
- # ${1} is OK, but $foo or $1 isn't.
|
||||
- # https://bugzilla.sudo.ws/show_bug.cgi?id=765
|
||||
- sudo -iu builduser bash -c 'cd /startdir; makepkg "${@:2}" --allsource' -bash ".src.tar.gz" "$@" || return
|
||||
- sudo -iu builduser bash -c 'cd /startdir; makepkg "$@" --noextract --noprepare' -bash "$@"
|
||||
+ if [ $(doas grep -qs 'permit nopass setenv { HOME="/build" PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin" _="/bin/bash" } builduser' /etc/doas.conf; echo $?) != 0 ]; then
|
||||
+ echo 'permit nopass setenv { HOME="/build" PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin" _="/bin/bash" } builduser' >> "$copydir/etc/doas.conf"
|
||||
+ fi
|
||||
+ doas -u builduser bash -c 'cd $HOME; cd /startdir; DOAS_USER='$DOAS_USER' makepkg "${@:2}" --allsource' -bash ".src.tar.gz" "$@" || return
|
||||
+ sed -i '\|permit nopass setenv { HOME="/build" PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin:" _="/bin/bash" } builduser|d' "$copydir/etc/doas.conf"
|
||||
+ if [ $(doas grep -qs 'permit nopass setenv { HOME="/build" PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin" _="/bin/bash" } builduser' /etc/doas.conf; echo $?) != 0 ]; then
|
||||
+ echo 'permit nopass setenv { HOME="/build" PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin" _="/bin/bash" } builduser' >> "$copydir/etc/doas.conf"
|
||||
+ fi
|
||||
+ doas -u builduser bash -c 'cd $HOME; cd /startdir; DOAS_USER='$DOAS_USER' makepkg "$@" --noextract --noprepare' -bash "$@"
|
||||
+ sed -i '\|permit nopass setenv { HOME="/build" PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin" _="/bin/bash" } builduser|d' "$copydir/etc/doas.conf"
|
||||
}
|
||||
|
||||
_chrootnamcap() {
|
||||
pacman -S --needed --noconfirm namcap
|
||||
for pkgfile in /startdir/PKGBUILD /pkgdest/*; do
|
||||
echo "Checking ${pkgfile##*/}"
|
||||
- sudo -u builduser namcap "$pkgfile" 2>&1 | tee "/logdest/${pkgfile##*/}-namcap.log"
|
||||
+ doas -u builduser namcap "$pkgfile" 2>&1 | tee "/logdest/${pkgfile##*/}-namcap.log"
|
||||
done
|
||||
}
|
||||
|
||||
@@ -306,7 +312,7 @@ download_sources() {
|
||||
|
||||
# Ensure sources are downloaded
|
||||
if [[ "$(id -u "$makepkg_user")" != 0 ]]; then
|
||||
- sudo -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \
|
||||
+ doas -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \
|
||||
makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o ||
|
||||
die "Could not download sources."
|
||||
else
|
||||
@@ -372,7 +378,7 @@ main() {
|
||||
|
||||
[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
|
||||
[[ -n $makepkg_user && -z $(id -u "$makepkg_user") ]] && die 'Invalid makepkg user.'
|
||||
- makepkg_user=${makepkg_user:-${SUDO_USER:-$USER}}
|
||||
+ makepkg_user=${makepkg_user:-${DOAS_USER:-$USER}}
|
||||
|
||||
check_root
|
||||
|
||||
@@ -400,8 +406,8 @@ main() {
|
||||
esac
|
||||
done
|
||||
|
||||
- if [[ -n $SUDO_USER ]]; then
|
||||
- eval "USER_HOME=~$SUDO_USER"
|
||||
+ if [[ -n $DOAS_USER ]]; then
|
||||
+ eval "USER_HOME=~$DOAS_USER"
|
||||
else
|
||||
USER_HOME=$HOME
|
||||
fi
|
||||
diff --git a/src/dagpkg b/src/dagpkg
|
||||
index d6f7ccaa..38c6844d 100755
|
||||
--- a/src/dagpkg
|
||||
+++ b/src/dagpkg
|
||||
@@ -1,11 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
-#
|
||||
+#
|
||||
# dagpkg - create a directed graph of package dependencies and build
|
||||
# them in topological order
|
||||
|
||||
# Copyright (C) 2014 Nicolás Reynolds <fauno@parabola.nu>
|
||||
# Copyright (C) 2014 Michał Masłowski <mtjm@mtjm.eu>
|
||||
# Copyright (C) 2017 Luke Shumaker <lukeshu@sbcglobal.net>
|
||||
+# Copyright (C) 2020 André Silva <emulatorman@hyperbola.info>
|
||||
+# Copyright (C) 2020 Márcio Silva <coadde@hyperbola.info>
|
||||
#
|
||||
# License: GNU GPLv3+
|
||||
#
|
||||
@@ -196,7 +198,11 @@ main() {
|
||||
# upgrade the system
|
||||
# this would probably have to go on HOOKPREBUILD if you're working
|
||||
# outside chroots
|
||||
- sudo -E pacman -Syu --noconfirm
|
||||
+ if [ $(doas grep -qs 'permit nopass keepenv '$LIBREUSER /etc/doas.conf; echo $?) != 0 ]; then
|
||||
+ echo 'permit nopass keepenv '$LIBREUSER >> "$copydir/etc/doas.conf"
|
||||
+ fi
|
||||
+ doas pacman -Syu --noconfirm
|
||||
+ sed -i '\|permit nopass keepenv '$LIBREUSER'|d' "$copydir/etc/doas.conf"
|
||||
|
||||
# run the pre build command from libretools.conf
|
||||
if [[ -n "$HOOKPREBUILD" ]]; then
|
||||
diff --git a/src/lib/archroot.sh.in b/src/lib/archroot.sh.in
|
||||
index 98fd2cfb..e449499d 100644
|
||||
--- a/src/lib/archroot.sh.in
|
||||
+++ b/src/lib/archroot.sh.in
|
||||
@@ -11,8 +11,8 @@ CHROOT_VERSION='v4'
|
||||
orig_argv=("$0" "$@")
|
||||
check_root() {
|
||||
(( EUID == 0 )) && return
|
||||
- if type -P sudo >/dev/null; then
|
||||
- exec sudo -- "${orig_argv[@]}"
|
||||
+ if type -P doas >/dev/null; then
|
||||
+ exec doas -- "${orig_argv[@]}"
|
||||
else
|
||||
exec su root -c "$(printf ' %q' "${orig_argv[@]}")"
|
||||
fi
|
||||
diff --git a/src/lib/conf.sh.3.ronn b/src/lib/conf.sh.3.ronn
|
||||
index 949ce3e9..93bf3d08 100644
|
||||
--- a/src/lib/conf.sh.3.ronn
|
||||
+++ b/src/lib/conf.sh.3.ronn
|
||||
@@ -12,15 +12,15 @@ files related to Arch/Hyperbola(7) and libretools(7).
|
||||
|
||||
### VARIABLES
|
||||
|
||||
-When loading configuration files in a program run with `sudo`(8), it
|
||||
+When loading configuration files in a program run with `doas`(1), it
|
||||
is often desirable to load the configuration files from the home
|
||||
-directory of the user who called `sudo`, instead of from /root.
|
||||
+directory of the user who called `doas`, instead of from /root.
|
||||
|
||||
To accommodate this, instead of using the usual $<USER> and $<HOME>,
|
||||
`conf.sh` sets $<LIBREUSER> and $<LIBREHOME>, which it then uses.
|
||||
|
||||
* <LIBREUSER>:
|
||||
- If $<SUDO_USER> is set, then $<LIBREUSER> is set to
|
||||
+ If $<DOAS_USER> is set, then $<LIBREUSER> is set to
|
||||
that. Otherwise, $<LIBREUSER> is set to the value of $<USER>.
|
||||
* <LIBREHOME>:
|
||||
If $<LIBREUSER> == $<USER>, then $<LIBREHOME> is set to the value
|
||||
diff --git a/src/lib/conf.sh.in b/src/lib/conf.sh.in
|
||||
index 942484ef..e28febf6 100644
|
||||
--- a/src/lib/conf.sh.in
|
||||
+++ b/src/lib/conf.sh.in
|
||||
@@ -19,8 +19,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
SNAPSHOT=2020-05-08
|
||||
-
|
||||
-LIBREUSER="${SUDO_USER:-$USER}"
|
||||
+LIBREUSER="${DOAS_USER:-$USER}"
|
||||
if [[ $LIBREUSER == "$USER" ]]; then
|
||||
LIBREHOME=$HOME
|
||||
else
|
||||
diff --git a/src/librefetch/librefetch.conf.5.ronn b/src/librefetch/librefetch.conf.5.ronn
|
||||
index 29df4d2d..9325b0bc 100644
|
||||
--- a/src/librefetch/librefetch.conf.5.ronn
|
||||
+++ b/src/librefetch/librefetch.conf.5.ronn
|
||||
@@ -19,7 +19,7 @@ to override.
|
||||
|
||||
If `$XDG_CONFIG_HOME` is not set, a default value is set:
|
||||
|
||||
- * if `$SUDO_USER` is set: `$(eval echo ~$SUDO_USER)/.config`
|
||||
+ * if `$DOAS_USER` is set: `$(eval echo ~$DOAS_USER)/.config`
|
||||
* else: `$HOME/.config`
|
||||
|
||||
## OPTIONS
|
||||
diff --git a/src/libretools.conf b/src/libretools.conf
|
||||
index 7ecad428..ab7e3c95 100644
|
||||
--- a/src/libretools.conf
|
||||
+++ b/src/libretools.conf
|
||||
@@ -35,7 +35,7 @@ REPODEST=staging@dusseldorf.hyperbola.info:$LIBREUSER
|
||||
|
||||
## These are run before and after uploading packages
|
||||
HOOKPRERELEASE="ssh -p 51011 -fN ${REPODEST%%:*}"
|
||||
-HOOKPOSTRELEASE="sudo librechroot clean-repo" # && sudo librechroot -n i686 clean-repo"
|
||||
+HOOKPOSTRELEASE="doas librechroot clean-repo" # && doas librechroot -n i686 clean-repo"
|
||||
|
||||
################################################################################
|
||||
# dagpkg #
|
||||
@@ -48,9 +48,9 @@ HOOKPREBUILD=""
|
||||
|
||||
## Uncomment one of those or make one of your choice
|
||||
# Normal
|
||||
-FULLBUILDCMD="sudo libremakepkg"
|
||||
+FULLBUILDCMD="doas libremakepkg"
|
||||
# Cross compiling
|
||||
-#FULLBUILDCMD="sudo libremakepkg -n cross-compile-chroot"
|
||||
+#FULLBUILDCMD="doas libremakepkg -n cross-compile-chroot"
|
||||
# Don't use a chroot
|
||||
#FULLBUILDCMD="makepkg -sL --noconfirm"
|
||||
|
||||
diff --git a/src/workflows.md b/src/workflows.md
|
||||
index 03dca4f6..c7c85052 100644
|
||||
--- a/src/workflows.md
|
||||
+++ b/src/workflows.md
|
||||
@@ -22,7 +22,7 @@ This is how the chroot is configured:
|
||||
* Create the same user (with same uid) on the chroot that the one I use
|
||||
regularly.
|
||||
|
||||
-* Give it password-less sudo on the chroot.
|
||||
+* Give it password-less doas on the chroot.
|
||||
|
||||
* Bind mount `/home` to `/chroot/home`, where I have the abslibre-mips64el
|
||||
clone.
|
||||
diff --git a/src/xbs-abs/helper-abs b/src/xbs-abs/helper-abs
|
||||
index e8f41de9..0d2e6cdc 100755
|
||||
--- a/src/xbs-abs/helper-abs
|
||||
+++ b/src/xbs-abs/helper-abs
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (C) 2013-2014, 2017 Luke Shumaker <lukeshu@sbcglobal.net>
|
||||
+# Copyright (C) 2020 André Silva <emulatorman@hyperbola.info>
|
||||
+# Copyright (C) 2020 Márcio Silva <coadde@hyperbola.info>
|
||||
#
|
||||
# For code from db-functions (arch_svn):
|
||||
# Copyright (C) 2012 Pierre Schmitz <pierre@archlinux.de>
|
||||
@@ -43,7 +45,7 @@ arch_svn() {
|
||||
if [[ -z "${SVNUSER}" ]]; then
|
||||
/usr/bin/svn "${@}"
|
||||
else
|
||||
- sudo -u "${SVNUSER}" -- /usr/bin/svn --username "${USER}" "${@}"
|
||||
+ doas -u "${SVNUSER}" -- /usr/bin/svn --username "${USER}" "${@}"
|
||||
fi
|
||||
}
|
||||
|
||||
diff --git a/test/lib-conf-test.sh b/test/lib-conf-test.sh
|
||||
index d79c5f2a..1cf5d6f1 100644
|
||||
--- a/test/lib-conf-test.sh
|
||||
+++ b/test/lib-conf-test.sh
|
||||
@@ -13,13 +13,13 @@ it_sets_makepkg_vars_in_custom_file() {
|
||||
}
|
||||
|
||||
it_figures_out_HOME_when_root() {
|
||||
- require sudo || return 0
|
||||
+ require doas || return 0
|
||||
# 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 ]]
|
||||
cd "$tmpdir"
|
||||
echo '. $(librelib conf.sh); echo "$LIBREHOME"' > test.sh
|
||||
- LIBREHOME=$(testsudo bash ./test.sh)
|
||||
+ LIBREHOME=$(testdoas bash ./test.sh)
|
||||
[[ $LIBREHOME != /root ]]
|
||||
}
|
||||
|
||||
diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh
|
||||
index 2aad0c60..172b9462 100644
|
||||
--- a/test/librechroot-test.sh
|
||||
+++ b/test/librechroot-test.sh
|
||||
@@ -6,56 +6,56 @@ describe librechroot
|
||||
setup_chrootdir
|
||||
|
||||
it_creates_repo_for_new_chroots() {
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
- testsudo librechroot -l "$roundup_test_name" run test -r /repo/repo.db
|
||||
+ testdoas librechroot -l "$roundup_test_name" run test -r /repo/repo.db
|
||||
}
|
||||
|
||||
it_cleans_the_local_repo_correctly() {
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
- testsudo librechroot -l "$roundup_test_name" make
|
||||
- testsudo librechroot -l "$roundup_test_name" clean-repo
|
||||
- testsudo librechroot -l "$roundup_test_name" run test -r /repo/repo.db
|
||||
+ testdoas librechroot -l "$roundup_test_name" make
|
||||
+ testdoas librechroot -l "$roundup_test_name" clean-repo
|
||||
+ testdoas librechroot -l "$roundup_test_name" run test -r /repo/repo.db
|
||||
# TODO: inspect /repo/* more
|
||||
}
|
||||
|
||||
it_respects_exit_status_if_out_isnt_a_tty() (
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
set -o pipefail
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
r=0
|
||||
- { testsudo librechroot -l "$roundup_test_name" run bash -c 'exit 3' | cat; } || r=$?
|
||||
+ { testdoas librechroot -l "$roundup_test_name" run bash -c 'exit 3' | cat; } || r=$?
|
||||
|
||||
[[ $r == 3 ]]
|
||||
)
|
||||
|
||||
it_creates_ca_certificates() {
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
- testsudo librechroot -l "$roundup_test_name" run test -r /etc/ssl/certs/ca-certificates.crt
|
||||
+ testdoas librechroot -l "$roundup_test_name" run test -r /etc/ssl/certs/ca-certificates.crt
|
||||
}
|
||||
|
||||
it_disables_networking_when_requested() {
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
|
||||
- testsudo librechroot -l "$roundup_test_name" run curl https://repo.hyperbola.info:50011/ >/dev/null
|
||||
- not testsudo librechroot -l "$roundup_test_name" -N run curl https://repo.hyperbola.info:50011/ >/dev/null
|
||||
+ testdoas librechroot -l "$roundup_test_name" run curl https://repo.hyperbola.info:50011/ >/dev/null
|
||||
+ not testdoas librechroot -l "$roundup_test_name" -N run curl https://repo.hyperbola.info:50011/ >/dev/null
|
||||
}
|
||||
|
||||
it_handles_CHROOTEXTRAPKG_correctly() {
|
||||
- requuire network sudo || return 0
|
||||
+ requuire network doas || return 0
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
|
||||
- not testsudo librechroot -l "$roundup_test_name" run lsof
|
||||
+ not testdoas librechroot -l "$roundup_test_name" run lsof
|
||||
echo "CHROOTEXTRAPKG=(lsof)" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf
|
||||
- testsudo librechroot -l "$roundup_test_name" install-name lsof
|
||||
- testsudo librechroot -l "$roundup_test_name" clean-pkgs
|
||||
- testsudo librechroot -l "$roundup_test_name" run lsof
|
||||
+ testdoas librechroot -l "$roundup_test_name" install-name lsof
|
||||
+ testdoas librechroot -l "$roundup_test_name" clean-pkgs
|
||||
+ testdoas librechroot -l "$roundup_test_name" run lsof
|
||||
echo "CHROOTEXTRAPKG=()" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf
|
||||
- testsudo librechroot -l "$roundup_test_name" clean-pkgs
|
||||
- not testsudo librechroot -l "$roundup_test_name" run lsof
|
||||
+ testdoas librechroot -l "$roundup_test_name" clean-pkgs
|
||||
+ not testdoas librechroot -l "$roundup_test_name" run lsof
|
||||
}
|
||||
|
||||
it_displays_help_as_normal_user() {
|
||||
@@ -82,20 +82,20 @@ it_displays_help_and_fails_with_0_args() {
|
||||
[[ "$(sed -n 2p $tmpdir/stderr)" =~ Usage:.* ]]
|
||||
}
|
||||
|
||||
-# requires sudo so we know it's not failing because it needs root
|
||||
+# requires doas so we know it's not failing because it needs root
|
||||
it_fails_for_unknown_commands() {
|
||||
- require sudo || return 0
|
||||
- testsudo librechroot phony >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
|
||||
+ require doas || return 0
|
||||
+ testdoas librechroot phony >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
|
||||
|
||||
[[ $stat != 0 ]]
|
||||
empty $tmpdir/stdout
|
||||
not empty $tmpdir/stderr
|
||||
}
|
||||
|
||||
-# requires sudo so we know it's not failing because it needs root
|
||||
+# requires doas so we know it's not failing because it needs root
|
||||
it_fails_for_unknown_flags() {
|
||||
- require sudo || return 0
|
||||
- testsudo librechroot -q >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
|
||||
+ require doas || return 0
|
||||
+ testdoas librechroot -q >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
|
||||
|
||||
[[ $stat != 0 ]]
|
||||
empty $tmpdir/stdout
|
||||
@@ -103,8 +103,8 @@ it_fails_for_unknown_flags() {
|
||||
}
|
||||
|
||||
it_fails_when_syncing_a_copy_with_itself() {
|
||||
- require sudo || return 0
|
||||
- testsudo timeout 5 librechroot -l root sync || stat=$?
|
||||
+ require doas || return 0
|
||||
+ testdoas timeout 5 librechroot -l root sync || stat=$?
|
||||
case $stat in
|
||||
0|124|137) # success|timeout+TERM|timeout+KILL
|
||||
false;;
|
||||
@@ -114,23 +114,23 @@ it_fails_when_syncing_a_copy_with_itself() {
|
||||
}
|
||||
|
||||
it_deletes_copies() {
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
- testsudo librechroot -l "$roundup_test_name" make
|
||||
+ testdoas librechroot -l "$roundup_test_name" make
|
||||
test -d "$chrootdir/default/$roundup_test_name"
|
||||
- testsudo librechroot -l "$roundup_test_name" delete
|
||||
+ testdoas librechroot -l "$roundup_test_name" delete
|
||||
not test -e "$chrootdir/default/$roundup_test_name"
|
||||
}
|
||||
|
||||
it_deletes_subvolumes_recursively() {
|
||||
- require network sudo btrfs || return 0
|
||||
+ require network doas btrfs || return 0
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
- testsudo librechroot -l "$roundup_test_name" make
|
||||
- testsudo librechroot -l "$roundup_test_name" run pacman -S --noconfirm btrfs-progs
|
||||
+ testdoas librechroot -l "$roundup_test_name" make
|
||||
+ testdoas librechroot -l "$roundup_test_name" run pacman -S --noconfirm btrfs-progs
|
||||
test -d "$chrootdir/default/$roundup_test_name"
|
||||
not test -e "$chrootdir/default/$roundup_test_name/var/subvolume"
|
||||
- testsudo librechroot -l "$roundup_test_name" run btrfs subvolume create /var/subvolume
|
||||
+ testdoas librechroot -l "$roundup_test_name" run btrfs subvolume create /var/subvolume
|
||||
test -d "$chrootdir/default/$roundup_test_name/var/subvolume"
|
||||
- testsudo librechroot -l "$roundup_test_name" delete
|
||||
+ testdoas librechroot -l "$roundup_test_name" delete
|
||||
not test -e "$chrootdir/default/$roundup_test_name"
|
||||
}
|
||||
diff --git a/test/libremakepkg-test.sh b/test/libremakepkg-test.sh
|
||||
index 3609cb63..b0f0d977 100644
|
||||
--- a/test/libremakepkg-test.sh
|
||||
+++ b/test/libremakepkg-test.sh
|
||||
@@ -6,52 +6,52 @@ describe libremakepkg
|
||||
setup_chrootdir
|
||||
|
||||
it_builds_a_trivial_package() {
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD"
|
||||
cd "$tmpdir"
|
||||
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
- testsudo libremakepkg -l "$roundup_test_name"
|
||||
+ testdoas libremakepkg -l "$roundup_test_name"
|
||||
|
||||
[[ -f $(echo libretools-hello-1.0-1-any.pkg.tar.?z) ]]
|
||||
}
|
||||
|
||||
it_enables_networking_during_prepare() {
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
cp libremakepkg.d/PKGBUILD-netprepare "$tmpdir/PKGBUILD"
|
||||
cd "$tmpdir"
|
||||
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
- testsudo libremakepkg -l "$roundup_test_name"
|
||||
+ testdoas libremakepkg -l "$roundup_test_name"
|
||||
[[ -f $(echo libretools-netprepare-1.0-1-any.pkg.tar.?z) ]]
|
||||
}
|
||||
|
||||
it_disables_networking_during_build() {
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
cp libremakepkg.d/PKGBUILD-netbuild "$tmpdir/PKGBUILD"
|
||||
cd "$tmpdir"
|
||||
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
- not testsudo libremakepkg -l "$roundup_test_name"
|
||||
+ not testdoas libremakepkg -l "$roundup_test_name"
|
||||
not [[ -f $(echo libretools-netbuild-1.0-1-any.pkg.tar.?z) ]]
|
||||
- testsudo libremakepkg -l "$roundup_test_name" -N
|
||||
+ testdoas libremakepkg -l "$roundup_test_name" -N
|
||||
[[ -f $(echo libretools-netbuild-1.0-1-any.pkg.tar.?z) ]]
|
||||
}
|
||||
|
||||
it_disables_networking_during_package() {
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
cp libremakepkg.d/PKGBUILD-netpackage "$tmpdir/PKGBUILD"
|
||||
cd "$tmpdir"
|
||||
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
- not testsudo libremakepkg -l "$roundup_test_name"
|
||||
+ not testdoas libremakepkg -l "$roundup_test_name"
|
||||
not [[ -f $(echo libretools-netpackage-1.0-1-any.pkg.tar.?z) ]]
|
||||
- testsudo libremakepkg -l "$roundup_test_name" -N
|
||||
+ testdoas libremakepkg -l "$roundup_test_name" -N
|
||||
[[ -f $(echo libretools-netpackage-1.0-1-any.pkg.tar.?z) ]]
|
||||
}
|
||||
|
||||
it_cleans_the_chroot_before_building() {
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
# 1. First, we build testpkg1
|
||||
# 2. Then, we build testpkg2, which depends on testpkg1
|
||||
# Therefore, testpkg1 will be installed after testpkg2 is built, we
|
||||
@@ -70,28 +70,28 @@ it_cleans_the_chroot_before_building() {
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
|
||||
cd "$tmpdir/1"
|
||||
- testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; }
|
||||
+ testdoas libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; }
|
||||
|
||||
cd "$tmpdir/2"
|
||||
- testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; }
|
||||
- testsudo librechroot -l "$roundup_test_name" run libretools-testpkg1 'first time, pass'
|
||||
+ testdoas libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; }
|
||||
+ testdoas librechroot -l "$roundup_test_name" run libretools-testpkg1 'first time, pass'
|
||||
|
||||
# This next line is actually a separate test, but it fits in well with this test, and chroot tests are slow..
|
||||
# it_doesnt_cache_local_packages() {
|
||||
- not testsudo librechroot -l "$roundup_test_name" run test -e /var/cache/pacman/pkg/libretools-testpkg1-1.0-1-any.pkg.tar.?z
|
||||
+ not testdoas librechroot -l "$roundup_test_name" run test -e /var/cache/pacman/pkg/libretools-testpkg1-1.0-1-any.pkg.tar.?z
|
||||
|
||||
cd "$tmpdir/3"
|
||||
- testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; }
|
||||
- not testsudo librechroot -l "$roundup_test_name" run libretools-testpkg1 'second time, fail'
|
||||
+ testdoas libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; }
|
||||
+ not testdoas librechroot -l "$roundup_test_name" run libretools-testpkg1 'second time, fail'
|
||||
}
|
||||
|
||||
it_handles_PKGDEST_not_existing() {
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD"
|
||||
cd "$tmpdir"
|
||||
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
- testsudo env PKGDEST="$tmpdir/dest/pkgdest" libremakepkg -l "$roundup_test_name"
|
||||
+ testdoas env PKGDEST="$tmpdir/dest/pkgdest" libremakepkg -l "$roundup_test_name"
|
||||
|
||||
[[ -f $(echo dest/pkgdest/libretools-hello-1.0-1-any.pkg.tar.?z) ]]
|
||||
}
|
||||
@@ -118,7 +118,7 @@ it_otherwise_fails_as_normal_user() {
|
||||
}
|
||||
|
||||
it_fails_if_a_hook_fails() {
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD"
|
||||
cd "$tmpdir"
|
||||
local stat=0
|
||||
@@ -127,30 +127,30 @@ it_fails_if_a_hook_fails() {
|
||||
trap 'sed -i s/-bogus// "$XDG_CONFIG_HOME"/libretools/libretools.conf' RETURN
|
||||
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
- testsudo libremakepkg -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
|
||||
+ testdoas libremakepkg -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
|
||||
|
||||
[[ $stat != 0 ]]
|
||||
tail -n1 $tmpdir/stderr | grep -qF '==> ERROR: Failure(s) in check_pkgbuild: check_pkgbuild_nonfree'
|
||||
}
|
||||
|
||||
it_detects_distcc_files() {
|
||||
- require network sudo || return 0
|
||||
+ require network doas || return 0
|
||||
cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD"
|
||||
cd "$tmpdir"
|
||||
|
||||
echo "CHROOTEXTRAPKG+=(distcc-nozeroconf socat)" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf
|
||||
trap 'sed -i /CHROOTEXTRAPKGs+=/d "$XDG_CONFIG_HOME"/libretools/chroot.conf' RETURN
|
||||
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
|
||||
- testsudo librechroot -l "$roundup_test_name" run pacman -S --noconfirm distcc-nozeroconf socat
|
||||
+ testdoas librechroot -l "$roundup_test_name" run pacman -S --noconfirm distcc-nozeroconf socat
|
||||
|
||||
# first make sure that the engine works
|
||||
- testsudo libremakepkg -l "$roundup_test_name"
|
||||
+ testdoas libremakepkg -l "$roundup_test_name"
|
||||
[[ -f $(echo libretools-hello-1.0-1-any.pkg.tar.?z) ]]
|
||||
rm -f -- libretools-hello-1.0-1-any.pkg.tar.?z
|
||||
# now throw a wrench in it
|
||||
- testsudo librechroot -l "$roundup_test_name" run touch /bin/distcc-tool
|
||||
+ testdoas librechroot -l "$roundup_test_name" run touch /bin/distcc-tool
|
||||
# and make sure that the engine broke
|
||||
- testsudo libremakepkg -l "$roundup_test_name" || stat=$?
|
||||
+ testdoas libremakepkg -l "$roundup_test_name" || stat=$?
|
||||
[[ $stat != 0 ]]
|
||||
not [[ -f $(echo libretools-hello-1.0-1-any.pkg.tar.?z) ]]
|
||||
}
|
||||
diff --git a/test/librestage-test.sh b/test/librestage-test.sh
|
||||
index 75450aec..7169df0d 100644
|
||||
--- a/test/librestage-test.sh
|
||||
+++ b/test/librestage-test.sh
|
||||
@@ -45,7 +45,7 @@ it_fails_with_invalid_args() {
|
||||
}
|
||||
|
||||
it_guesses_the_repo() {
|
||||
- nochroot=false; require network sudo || nochroot=true
|
||||
+ nochroot=false; require network doas || nochroot=true
|
||||
mkdir -p -- "$tmpdir/reponame/libretools-hello"
|
||||
cp librestage.d/PKGBUILD-hello "$tmpdir/reponame/libretools-hello/PKGBUILD"
|
||||
cd "$tmpdir/reponame/libretools-hello"
|
||||
@@ -53,7 +53,7 @@ it_guesses_the_repo() {
|
||||
if $nochroot; then
|
||||
makepkg
|
||||
else
|
||||
- testsudo libremakepkg -l "$roundup_test_name"
|
||||
+ testdoas libremakepkg -l "$roundup_test_name"
|
||||
fi
|
||||
librestage
|
||||
|
||||
@@ -63,7 +63,7 @@ it_guesses_the_repo() {
|
||||
}
|
||||
|
||||
it_stages_packages_without_PKGDEST() {
|
||||
- nochroot=false; require network sudo || nochroot=true
|
||||
+ nochroot=false; require network doas || nochroot=true
|
||||
|
||||
echo "PKGDEST=''" >> $XDG_CONFIG_HOME/pacman/makepkg.conf
|
||||
echo "SRCPKGDEST=''" >> $XDG_CONFIG_HOME/pacman/makepkg.conf
|
||||
@@ -74,7 +74,7 @@ it_stages_packages_without_PKGDEST() {
|
||||
if $nochroot; then
|
||||
makepkg
|
||||
else
|
||||
- testsudo libremakepkg -l "$roundup_test_name"
|
||||
+ testdoas libremakepkg -l "$roundup_test_name"
|
||||
fi
|
||||
librestage repo1
|
||||
|
||||
diff --git a/test/test-common.sh b/test/test-common.sh
|
||||
index 3f3763cb..e46872fd 100644
|
||||
--- a/test/test-common.sh
|
||||
+++ b/test/test-common.sh
|
||||
@@ -36,8 +36,8 @@ before() {
|
||||
after() {
|
||||
common_after
|
||||
killall gpg-agent &>/dev/null || true
|
||||
- if [[ -f "$tmpdir/.used-sudo" ]]; then
|
||||
- sudo rm -rf -- "$tmpdir" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"
|
||||
+ if [[ -f "$tmpdir/.used-doas" ]]; then
|
||||
+ doas rm -rf -- "$tmpdir" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"
|
||||
else
|
||||
rm -rf -- "$tmpdir" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"
|
||||
fi
|
||||
@@ -62,12 +62,12 @@ setup_chrootdir() {
|
||||
_cleanup_chrootdir() (
|
||||
chrootdir=$1
|
||||
shopt -s nullglob
|
||||
- if [[ $SUDO ]]; then
|
||||
+ if [[ $DOAS ]]; then
|
||||
if [[ "$(stat -f -c %T "$chrootdir")" == btrfs ]]; then
|
||||
- sudo find "$chrootdir" -depth -inum 256 -exec \
|
||||
+ doas find "$chrootdir" -depth -inum 256 -exec \
|
||||
btrfs subvolume delete {} \; &>/dev/null
|
||||
fi
|
||||
- sudo rm -rf -- "$chrootdir"
|
||||
+ doas rm -rf -- "$chrootdir"
|
||||
else
|
||||
rm -rf -- "$chrootdir"
|
||||
fi
|
||||
@@ -79,8 +79,8 @@ require() (
|
||||
if libremessages in_array "network" "$@" && ! [[ $NETWORK ]]; then
|
||||
missing+=('networking')
|
||||
fi
|
||||
- if libremessages in_array "sudo" "$@" && ! [[ $SUDO ]]; then
|
||||
- missing+=('sudo')
|
||||
+ if libremessages in_array "doas" "$@" && ! [[ $DOAS ]]; then
|
||||
+ missing+=('doas')
|
||||
fi
|
||||
if libremessages in_array "btrfs" "$@" && ! [[ "$(stat -f -c %T "$chrootdir" 2>/dev/null || true)" == 'btrfs' ]]; then
|
||||
missing+=('btrfs')
|
||||
@@ -89,8 +89,8 @@ require() (
|
||||
libremessages warning "Next test requires %s; Skipping (passing)..." "$(echo "${missing[*]}"|sed 's/ /, /g')" &>/dev/tty
|
||||
return 1
|
||||
fi
|
||||
- if libremessages in_array "sudo" "$@"; then
|
||||
- touch "$tmpdir/.used-sudo"
|
||||
+ if libremessages in_array "doas" "$@"; then
|
||||
+ touch "$tmpdir/.used-doas"
|
||||
fi
|
||||
return 0
|
||||
)
|
||||
diff --git a/test/testenv b/test/testenv
|
||||
index 7072326b..6c8860a2 100755
|
||||
--- a/test/testenv
|
||||
+++ b/test/testenv
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
# Parse the arguments
|
||||
NETWORK=true
|
||||
-SUDO=true
|
||||
+DOAS=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;;
|
||||
+ --no-doas) shift; unset DOAS;;
|
||||
+ --doas) shift; DOAS=true;;
|
||||
--) shift; break;;
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
-export NETWORK SUDO
|
||||
+export NETWORK DOAS
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
echo 'You need to run testenv with arguments!' >&2
|
||||
@@ -48,22 +48,22 @@ export XDG_CONFIG_HOME="$HOME/.config"
|
||||
export _librelib_conf_sh_sysconfdir="$destdir/etc"
|
||||
export _librelib_conf_sh_pkgconfdir="$destdir/etc/libretools.d"
|
||||
|
||||
-# Hack to respect our variables in sudo
|
||||
-_sudo() {
|
||||
+# Hack to respect our variables in doas
|
||||
+_doas() {
|
||||
local vars=(TMPDIR PATH LIBRETOOLS_LIBDIR XDG_CACHE_HOME XDG_CONFIG_HOME _librelib_conf_sh_sysconfdir)
|
||||
local args=()
|
||||
local var
|
||||
for var in "${vars[@]}"; do
|
||||
args+=("$var=${!var}")
|
||||
done
|
||||
- sudo env "${args[@]}" "$@"
|
||||
+ doas env "${args[@]}" "$@"
|
||||
}
|
||||
printf '%s\n' \
|
||||
'#!/bin/bash' \
|
||||
- "$(declare -f _sudo)" \
|
||||
- '_sudo "$@"' \
|
||||
- > "$destdir/usr/bin/testsudo"
|
||||
-chmod 755 "$destdir/usr/bin/testsudo"
|
||||
+ "$(declare -f _doas)" \
|
||||
+ '_doas "$@"' \
|
||||
+ > "$destdir/usr/bin/testdoas"
|
||||
+chmod 755 "$destdir/usr/bin/testdoas"
|
||||
|
||||
# Run the tests
|
||||
eval "$@"
|
||||
Reference in New Issue
Block a user