Skip to content

Commit 0856b50

Browse files
JillTyrellrofl0r
authored andcommitted
Default to super_chroot if not running as root and USER_NS is supported.
1 parent e811b05 commit 0856b50

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

KEEP/config.stage0

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ export HOSTCC=gcc
2222
## stage0 builds in less than 2minutes using -j9 on an AMD 8core
2323
export MAKE_THREADS=1
2424

25-
# in case you have linux kernel 3.8+ with CONFIG_USER_NS enabled,
26-
# you can use super_chroot in place of chroot, so you don't need
27-
# root perms to build.
28-
# if SUPER is set, the enter-chroot script will use super_chroot.
29-
#export SUPER=1
30-
3125
# SCP_MIRRORS is a newline-separated list where the default download template
3226
# tries to download source tarballs from if set (before doing regular download).
3327
# first %s passed is the tarball filename, second %s the local destination.

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ Set the `SABOTAGE_BUILDDIR`, `A`, and `MAKE_THREADS` variables.
6363
You may usually ignore the other values.
6464
Both the config file and the COOKBOOK cover the meaning of these variables.
6565

66-
Enable `SUPER` to use the following `./enter-chroot` script without root.
67-
6866
NOTE: It is possible to build an i386 Sabotage from within an existing 32-bit
6967
chroot on a 64-bit system.
7068
The `enter-chroot` script automatically handles this scenario.
@@ -80,10 +78,6 @@ ATTENTION: if you're using void or arch linux, building gcc630 in stage1 might
8078
fail due to a buggy ld. there's a workaround though:
8179
https://github.com/sabotage-linux/sabotage/issues/505
8280

83-
Older pre-3.8 Linux systems will not support the rootless chroot approach used
84-
by `./enter-chroot`.
85-
Disable `SUPER` and run `./enter-chroot` as root if you encounter an issue.
86-
8781
At this point, stage1 is complete and your Sabotage chroot is set up. There are
8882
two optional steps to consider at this time:
8983

enter-chroot

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,18 @@ case "$A" in i?86)
2626
esac
2727
fi
2828

29-
if [ ! -z "$SUPER" ] ; then
29+
uid="$(id -u)"
30+
if [ -d /proc/self/ns ] && [ "$uid" != "0" ] ; then
3031
CHROOT=./super_chroot
3132
if [ ! -x "$CHROOT" ] ; then
3233
if ! "$CC" "$K"/super_chroot.c -static -s -Os -o "$CHROOT" 2>/dev/null ; then
3334
echo "error: failed to build super_chroot!"
3435
echo "try: musl-gcc KEEP/super_chroot.c -o super_chroot"
35-
echo "or: unset SUPER and re-run ./enter-chroot as root."
36+
echo "or: re-run ./enter-chroot as root."
3637
exit 1
3738
fi
3839
fi
3940
else
40-
41-
uid="$(id -u)"
4241
if [ "$uid" != "0" ]; then
4342
printf -- "need to be root. please enter password.\n"
4443
su -c "$0"
@@ -93,7 +92,7 @@ tryumount() {
9392
fi
9493
}
9594

96-
if [ -z "$SUPER" ] && [ -d "$R"/dev/pts ] ; then
95+
if [ "$CHROOT" = "chroot" ] && [ -d "$R"/dev/pts ] ; then
9796
tryumount "$R"/src/tarballs
9897
tryumount "$R"/dev/pts
9998
tryumount "$R"/dev/shm

0 commit comments

Comments
 (0)