Skip to content

Commit

Permalink
Simplify rootless-test
Browse files Browse the repository at this point in the history
  • Loading branch information
BtbN committed Sep 4, 2024
1 parent c8a8660 commit e7b51ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
12 changes: 5 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ for addin in ${ADDINS[*]}; do
source "addins/${addin}.sh"
done

TESTFILE="uidtestfile"
rm -f "$TESTFILE"
docker run --rm -v "$PWD:/uidtestdir" "$IMAGE" touch "/uidtestdir/$TESTFILE"
DOCKERUID="$(stat -c "%u" "$TESTFILE")"
rm -f "$TESTFILE"
[[ "$DOCKERUID" != "$(id -u)" ]] && UIDARGS=( -u "$(id -u):$(id -g)" ) || UIDARGS=()
unset TESTFILE
if docker info -f "{{println .SecurityOptions}}" | grep rootless >/dev/null 2>&1; then
UIDARGS=()
else
UIDARGS=( -u "$(id -u):$(id -g)" )
fi

rm -rf ffbuild
mkdir ffbuild
Expand Down
12 changes: 5 additions & 7 deletions download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ set -xe
cd "$(dirname "$0")"
source util/vars.sh dl only

TESTFILE="uidtestfile"
rm -f "$TESTFILE"
docker run --rm -v "$PWD:/uidtestdir" "${REGISTRY}/${REPO}/base:latest" touch "/uidtestdir/$TESTFILE"
DOCKERUID="$(stat -c "%u" "$TESTFILE")"
rm -f "$TESTFILE"
[[ "$DOCKERUID" != "$(id -u)" ]] && UIDARGS=( -u "$(id -u):$(id -g)" ) || UIDARGS=()
unset TESTFILE
if docker info -f "{{println .SecurityOptions}}" | grep rootless >/dev/null 2>&1; then
UIDARGS=()
else
UIDARGS=( -u "$(id -u):$(id -g)" )
fi

[[ -t 1 ]] && TTY_ARG="-t" || TTY_ARG=""

Expand Down

0 comments on commit e7b51ec

Please sign in to comment.