Skip to content
Snippets Groups Projects
Commit c6263bae authored by Natanael Copa's avatar Natanael Copa
Browse files

abuild: remove dependency of sudo

use the abuild-sudo tool instead

fixes #951
parent 442e8042
No related branches found
No related tags found
No related merge requests found
...@@ -18,9 +18,12 @@ abuild_path=$(readlink -f $0) ...@@ -18,9 +18,12 @@ abuild_path=$(readlink -f $0)
# defaults # defaults
BUILD_BASE="build-base" BUILD_BASE="build-base"
SUDO=${SUDO:-"sudo"}
FAKEROOT=${FAKEROOT:-"fakeroot"} FAKEROOT=${FAKEROOT:-"fakeroot"}
APK=${APK:-apk}
: ${APK:=abuild-apk}
: ${ADDUSER:=abuild-adduser}
: ${ADDGROUP:=abuild-addgroup}
apk_opt_wait="--wait 30" apk_opt_wait="--wait 30"
# read config # read config
...@@ -100,7 +103,7 @@ cleanup() { ...@@ -100,7 +103,7 @@ cleanup() {
set_xterm_title "" set_xterm_title ""
if [ -z "$install_after" ] && [ -n "$uninstall_after" ]; then if [ -z "$install_after" ] && [ -n "$uninstall_after" ]; then
msg "Uninstalling dependencies..." msg "Uninstalling dependencies..."
$SUDO $APK del --quiet $apk_opt_wait $uninstall_after $APK del --quiet $apk_opt_wait $uninstall_after
fi fi
if [ -n "$CLEANUP_FILES" ]; then if [ -n "$CLEANUP_FILES" ]; then
rm -f $CLEANUP_FILES rm -f $CLEANUP_FILES
...@@ -485,13 +488,13 @@ mkusers() { ...@@ -485,13 +488,13 @@ mkusers() {
if getent group $i >/dev/null; then if getent group $i >/dev/null; then
gopt="-G $i" gopt="-G $i"
fi fi
$SUDO adduser -S -D -H $gopt $i || return 1 $ADDUSER -S -D -H $gopt $i || return 1
fi fi
done done
for i in $pkggroups; do for i in $pkggroups; do
if ! getent group $i >/dev/null; then if ! getent group $i >/dev/null; then
msg "Creating group $i" msg "Creating group $i"
$SUDO addgroup -S $i || return 1 $ADDGROUP -S $i || return 1
fi fi
done done
} }
...@@ -1289,10 +1292,10 @@ builddeps() { ...@@ -1289,10 +1292,10 @@ builddeps() {
if [ -n "$install_deps" ] && [ -z "$recursive" ] && [ -n "$deps" ]; then if [ -n "$install_deps" ] && [ -z "$recursive" ] && [ -n "$deps" ]; then
# make a --simluate run first to detect missing deps # make a --simluate run first to detect missing deps
# apk-tools --virtual is no goot at reporting those. # apk-tools --virtual is no goot at reporting those.
$SUDO $APK add --repository "$abuildrepo" \ $APK add --repository "$abuildrepo" \
$apk_opt_wait \ $apk_opt_wait \
--simulate --quiet $deps || return 1 --simulate --quiet $deps || return 1
$SUDO $APK add --repository "$abuildrepo" \ $APK add --repository "$abuildrepo" \
$apk_opt_wait \ $apk_opt_wait \
--virtual .makedepends-$pkgname $deps \ --virtual .makedepends-$pkgname $deps \
&& return 0 && return 0
...@@ -1324,7 +1327,7 @@ builddeps() { ...@@ -1324,7 +1327,7 @@ builddeps() {
cd "$dir" && $0 $forceroot $keep $quiet $install_deps \ cd "$dir" && $0 $forceroot $keep $quiet $install_deps \
$recursive $upgrade $color_opt abuildindex || return 1 $recursive $upgrade $color_opt abuildindex || return 1
done done
$SUDO $APK add -u --repository "$abuildrepo" \ $APK add -u --repository "$abuildrepo" \
$apk_opt_wait \ $apk_opt_wait \
--virtual .makedepends-$pkgname $deps --virtual .makedepends-$pkgname $deps
} }
...@@ -1439,18 +1442,18 @@ post_add() { ...@@ -1439,18 +1442,18 @@ post_add() {
post_add $i || return 1 post_add $i || return 1
fi fi
done done
$SUDO $APK add $apk_opt_wait -u "$pkgf" || die "Failed to install $1" $APK add $apk_opt_wait -u "$pkgf" || die "Failed to install $1"
} }
installdeps() { installdeps() {
local deps i local deps i
$SUDO $APK add $apk_opt_wait --repository "$abuildrepo" \ $APK add $apk_opt_wait --repository "$abuildrepo" \
--virtual .makedepends-$pkgname \ --virtual .makedepends-$pkgname \
$makedepends $makedepends
} }
uninstalldeps (){ uninstalldeps (){
$SUDO $APK del $apk_opt_wait .makedepends-$pkgname $APK del $apk_opt_wait .makedepends-$pkgname
} }
all() { all() {
...@@ -1540,7 +1543,6 @@ shift $(( $OPTIND - 1 )) ...@@ -1540,7 +1543,6 @@ shift $(( $OPTIND - 1 ))
# check so we are not root # check so we are not root
if [ "$(whoami)" = "root" ] && [ -z "$FAKEROOTKEY" ]; then if [ "$(whoami)" = "root" ] && [ -z "$FAKEROOTKEY" ]; then
[ -z "$forceroot" ] && die "Do not run abuild as root" [ -z "$forceroot" ] && die "Do not run abuild as root"
SUDO=
FAKEROOT= FAKEROOT=
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment