Although running makepkg in root is frowned upon, there ae
circumstances that one might need to do so. For example, during the
bootstrap process of building my own toy gnu/linux distro, I need to run
makepkg in root. This option is disabled by
default. It can be enabled by setting 'ALLOWROOT' in makepkg to 1.
---
scripts/makepkg.sh.in | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index ca3e7459..b2cd8ee4 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -79,6 +79,7 @@ SIGNPKG=''
SPLITPKG=0
SOURCEONLY=0
VERIFYSOURCE=0
+ALLOWROOT=0
if [[ -n $SOURCE_DATE_EPOCH ]]; then
REPRODUCIBLE=1
@@ -1175,9 +1176,13 @@ fi
if (( ! INFAKEROOT )); then
if (( EUID == 0 )); then
- error "$(gettext "Running %s as root is not allowed as it can
cause permanent,\n\
-catastrophic damage to your system.")" "makepkg"
- exit $E_ROOT
+ if (( ALLOWROOT )); then
+ plain "Running as root is not recommended. Proceed with
caution."
+ else
+ error "$(gettext "Running %s as root is not allowed as
it can cause permanent,\n\
+ catastrophic damage to your system.")" "makepkg"
+ exit $E_ROOT
+ fi
fi
else
if [[ -z $FAKEROOTKEY ]]; then
@@ -1352,6 +1357,10 @@ if (( SOURCEONLY )); then
check_source_integrity all
cd_safe "$startdir"
+ # allow makepkg to run in root
+ if (( ALLOWROOT )); then
+ unset FAKEROOTKEY
+ fi
enter_fakeroot
if [[ $SIGNPKG = 'y' ]]; then
--
2.20.1