abuild: get rid of 'sudo' and other root-related stuff
Termux doesn't require things like 'sudo', 'chroot', 'adduser/addgroup' for installing or building packages. Furthermore, Termux is single-user environment.
This commit is contained in:
parent
6fb3feaf24
commit
58fa8e3192
|
@ -0,0 +1,30 @@
|
||||||
|
--- abuild-3.2.0/abuild-keygen.in 2018-06-22 10:24:10.000000000 +0300
|
||||||
|
+++ abuild-3.2.0.mod/abuild-keygen.in 2018-11-18 20:02:12.017576128 +0200
|
||||||
|
@@ -56,14 +56,14 @@
|
||||||
|
|
||||||
|
|
||||||
|
if [ -n "$install_pubkey" ]; then
|
||||||
|
- msg "Installing $pubkey to /etc/apk/keys..."
|
||||||
|
- sudo mkdir -p /etc/apk/keys
|
||||||
|
- sudo cp -i "$pubkey" /etc/apk/keys/
|
||||||
|
+ msg "Installing $pubkey to \$PREFIX/etc/apk/keys..."
|
||||||
|
+ mkdir -p @TERMUX_PREFIX@/etc/apk/keys
|
||||||
|
+ cp -i "$pubkey" @TERMUX_PREFIX@/etc/apk/keys/
|
||||||
|
else
|
||||||
|
|
||||||
|
msg ""
|
||||||
|
msg "You'll need to install $pubkey into "
|
||||||
|
- msg "/etc/apk/keys to be able to install packages and repositories signed with"
|
||||||
|
+ msg "\$PREFIX/etc/apk/keys to be able to install packages and repositories signed with"
|
||||||
|
msg "$privkey"
|
||||||
|
fi
|
||||||
|
|
||||||
|
@@ -94,7 +94,7 @@
|
||||||
|
Options:
|
||||||
|
-a, --append Set PACKAGER_PRIVKEY=<generated key> in
|
||||||
|
$ABUILD_USERCONF
|
||||||
|
- -i, --install Install public key into /etc/apk/keys using sudo
|
||||||
|
+ -i, --install Install public key into \$PREFIX/etc/apk/keys
|
||||||
|
-n Non-interactive. Use defaults
|
||||||
|
-q, --quiet
|
||||||
|
-h, --help Show this help
|
|
@ -0,0 +1,37 @@
|
||||||
|
--- abuild-3.2.0/abuild-rmtemp.c 2018-06-22 10:24:10.000000000 +0300
|
||||||
|
+++ abuild-3.2.0.mod/abuild-rmtemp.c 2018-11-18 19:54:49.254290401 +0200
|
||||||
|
@@ -16,7 +16,7 @@
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
-#define PREFIX "/var/tmp/abuild."
|
||||||
|
+#define PREFIX "@TERMUX_PREFIX@/var/tmp/abuild."
|
||||||
|
|
||||||
|
static void fail() {
|
||||||
|
errx(1, "%s", strerror(errno));
|
||||||
|
@@ -29,10 +29,12 @@
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
if (argc < 2) return 0;
|
||||||
|
|
||||||
|
+#ifndef __ANDROID__
|
||||||
|
if (getuid()) {
|
||||||
|
argv[0] = "-abuild-rmtemp";
|
||||||
|
execv("/usr/bin/abuild-sudo", argv);
|
||||||
|
}
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
if (strncmp(argv[1], PREFIX, strlen(PREFIX)) || \
|
||||||
|
strchr(argv[1] + strlen(PREFIX), '/'))
|
||||||
|
@@ -40,9 +42,12 @@
|
||||||
|
|
||||||
|
struct stat s;
|
||||||
|
if (lstat(argv[1], &s)) fail();
|
||||||
|
+
|
||||||
|
+#ifndef __ANDROID__
|
||||||
|
struct passwd *p = getpwnam(getenv("USER"));
|
||||||
|
if (!p) errx(1, "Incorrect user");
|
||||||
|
if (s.st_uid != p->pw_uid) errx(1, "Permission denied");
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
if (nftw(argv[1], handler, 512, FTW_DEPTH)) fail();
|
||||||
|
|
|
@ -1,23 +1,52 @@
|
||||||
diff -uNr abuild-3.2.0/abuild.in abuild-3.2.0.mod/abuild.in
|
diff -uNr abuild-3.2.0/abuild.in abuild-3.2.0.mod/abuild.in
|
||||||
--- abuild-3.2.0/abuild.in 2018-06-22 10:24:10.000000000 +0300
|
--- abuild-3.2.0/abuild.in 2018-06-22 10:24:10.000000000 +0300
|
||||||
+++ abuild-3.2.0.mod/abuild.in 2018-11-18 15:32:09.638859377 +0200
|
+++ abuild-3.2.0.mod/abuild.in 2018-11-18 15:51:27.863075393 +0200
|
||||||
@@ -1,4 +1,4 @@
|
@@ -1,4 +1,4 @@
|
||||||
-#!/bin/ash -e
|
-#!/bin/ash -e
|
||||||
+#!/bin/bash -e
|
+#!/bin/bash -e
|
||||||
|
|
||||||
# abuild - build apk packages (light version of makepkg)
|
# abuild - build apk packages (light version of makepkg)
|
||||||
# Copyright (c) 2008-2015 Natanael Copa <ncopa@alpinelinux.org>
|
# Copyright (c) 2008-2015 Natanael Copa <ncopa@alpinelinux.org>
|
||||||
@@ -21,8 +21,7 @@
|
@@ -21,11 +21,7 @@
|
||||||
. "$datadir/functions.sh"
|
. "$datadir/functions.sh"
|
||||||
|
|
||||||
# defaults
|
# defaults
|
||||||
-: ${FAKEROOT:="fakeroot"}
|
-: ${FAKEROOT:="fakeroot"}
|
||||||
-: ${SUDO_APK:="abuild-apk"}
|
-: ${SUDO_APK:="abuild-apk"}
|
||||||
+: ${SUDO_APK:="apk"}
|
|
||||||
: ${APK:="apk"}
|
: ${APK:="apk"}
|
||||||
: ${ADDUSER:="abuild-adduser"}
|
-: ${ADDUSER:="abuild-adduser"}
|
||||||
: ${ADDGROUP:="abuild-addgroup"}
|
-: ${ADDGROUP:="abuild-addgroup"}
|
||||||
@@ -933,7 +932,7 @@
|
|
||||||
|
apk_opt_wait="--wait 30"
|
||||||
|
|
||||||
|
@@ -544,26 +540,6 @@
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
-mkusers() {
|
||||||
|
- local i
|
||||||
|
- for i in $pkggroups; do
|
||||||
|
- if ! getent group $i >/dev/null; then
|
||||||
|
- msg "Creating group $i"
|
||||||
|
- $ADDGROUP -S $i || return 1
|
||||||
|
- fi
|
||||||
|
- done
|
||||||
|
- for i in $pkgusers; do
|
||||||
|
- if ! getent passwd $i >/dev/null; then
|
||||||
|
- local gopt=
|
||||||
|
- msg "Creating user $i"
|
||||||
|
- if getent group $i >/dev/null; then
|
||||||
|
- gopt="-G $i"
|
||||||
|
- fi
|
||||||
|
- $ADDUSER -S -D -H $gopt $i || return 1
|
||||||
|
- fi
|
||||||
|
- done
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
# helper to update config.sub to a recent version
|
||||||
|
update_config_sub() {
|
||||||
|
find . -name config.sub | (local changed=false; while read f; do
|
||||||
|
@@ -933,7 +909,7 @@
|
||||||
|
|
||||||
echo "# Generated by $(basename $0) $program_version" >"$pkginfo"
|
echo "# Generated by $(basename $0) $program_version" >"$pkginfo"
|
||||||
if [ -n "$FAKEROOTKEY" ]; then
|
if [ -n "$FAKEROOTKEY" ]; then
|
||||||
|
@ -26,7 +55,7 @@ diff -uNr abuild-3.2.0/abuild.in abuild-3.2.0.mod/abuild.in
|
||||||
fi
|
fi
|
||||||
echo "# $(date -u)" >> "$pkginfo"
|
echo "# $(date -u)" >> "$pkginfo"
|
||||||
cat >> "$pkginfo" <<-EOF
|
cat >> "$pkginfo" <<-EOF
|
||||||
@@ -1502,14 +1501,11 @@
|
@@ -1502,14 +1478,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
build_abuildrepo() {
|
build_abuildrepo() {
|
||||||
|
@ -42,7 +71,15 @@ diff -uNr abuild-3.2.0/abuild.in abuild-3.2.0.mod/abuild.in
|
||||||
if ! want_check; then
|
if ! want_check; then
|
||||||
_check=true
|
_check=true
|
||||||
fi
|
fi
|
||||||
@@ -1747,33 +1743,17 @@
|
@@ -1524,7 +1497,6 @@
|
||||||
|
fetch
|
||||||
|
unpack
|
||||||
|
prepare
|
||||||
|
- mkusers
|
||||||
|
$_build
|
||||||
|
$_check
|
||||||
|
rootpkg
|
||||||
|
@@ -1747,33 +1719,17 @@
|
||||||
type "$1" 2>&1 | head -n 1 | egrep -q "is a (shell )?function"
|
type "$1" 2>&1 | head -n 1 | egrep -q "is a (shell )?function"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +116,16 @@ diff -uNr abuild-3.2.0/abuild.in abuild-3.2.0.mod/abuild.in
|
||||||
$_package \
|
$_package \
|
||||||
prepare_subpackages \
|
prepare_subpackages \
|
||||||
prepare_language_packs \
|
prepare_language_packs \
|
||||||
@@ -2125,14 +2105,11 @@
|
@@ -2096,7 +2052,7 @@
|
||||||
|
$install_deps $recursive $upgrade $color_opt \
|
||||||
|
abuildindex || return 1
|
||||||
|
done
|
||||||
|
- $SUDO_APK add --upgrade --repository "$REPODEST/$repo" \
|
||||||
|
+ $APK add --upgrade --repository "$REPODEST/$repo" \
|
||||||
|
$apk_opt_wait \
|
||||||
|
--virtual .makedepends-$pkgname $builddeps \
|
||||||
|
|| return 1
|
||||||
|
@@ -2125,14 +2081,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
rootbld_actions() {
|
rootbld_actions() {
|
||||||
|
@ -95,7 +141,52 @@ diff -uNr abuild-3.2.0/abuild.in abuild-3.2.0.mod/abuild.in
|
||||||
if ! want_check; then
|
if ! want_check; then
|
||||||
_check=true
|
_check=true
|
||||||
fi
|
fi
|
||||||
@@ -2481,7 +2458,7 @@
|
@@ -2163,8 +2116,6 @@
|
||||||
|
|
||||||
|
msg "Preparing build chroot..."
|
||||||
|
|
||||||
|
- mkusers
|
||||||
|
-
|
||||||
|
BUILD_ROOT=$(mktemp -d /var/tmp/abuild.XXXXXXXXXX)
|
||||||
|
local aportsgit=${APORTSDIR:-${startdir}}
|
||||||
|
|
||||||
|
@@ -2205,7 +2156,7 @@
|
||||||
|
) < "$repo_template" > "$BUILD_ROOT/etc/apk/repositories"
|
||||||
|
|
||||||
|
calcdeps
|
||||||
|
- $SUDO_APK add --initdb --root "$BUILD_ROOT" --update \
|
||||||
|
+ $APK add --initdb --root "$BUILD_ROOT" --update \
|
||||||
|
abuild alpine-base build-base git $hostdeps $builddeps
|
||||||
|
|
||||||
|
local bwrap_opts=""
|
||||||
|
@@ -2346,22 +2297,22 @@
|
||||||
|
|
||||||
|
local _quiet="$1"
|
||||||
|
[ -z "$_quiet" ] && msg "Installing for build:$builddeps"
|
||||||
|
- $SUDO_APK add $_quiet $apk_opt_wait --repository "$REPODEST/$repo" \
|
||||||
|
+ $APK add $_quiet $apk_opt_wait --repository "$REPODEST/$repo" \
|
||||||
|
--virtual .makedepends-$pkgname \
|
||||||
|
$builddeps \
|
||||||
|
|| return 1
|
||||||
|
if [ -n "$CBUILDROOT" ]; then
|
||||||
|
[ -z "$_quiet" ] && msg "Installing for host:$hostdeps"
|
||||||
|
- $SUDO_APK add $_quiet --root "$CBUILDROOT" --arch "$CTARGET_ARCH" --repository "$REPODEST/$repo" $apk_opt_wait \
|
||||||
|
+ $APK add $_quiet --root "$CBUILDROOT" --arch "$CTARGET_ARCH" --repository "$REPODEST/$repo" $apk_opt_wait \
|
||||||
|
--no-scripts --virtual .makedepends-$pkgname $hostdeps || return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
undeps() {
|
||||||
|
local _quiet="$@"
|
||||||
|
- $SUDO_APK del $_quiet $apk_opt_wait .makedepends-$pkgname || :
|
||||||
|
+ $APK del $_quiet $apk_opt_wait .makedepends-$pkgname || :
|
||||||
|
if [ -n "$CBUILDROOT" ]; then
|
||||||
|
- $SUDO_APK del $_quiet --root "$CBUILDROOT" --arch "$CTARGET_ARCH" $apk_opt_wait \
|
||||||
|
+ $APK del $_quiet --root "$CBUILDROOT" --arch "$CTARGET_ARCH" $apk_opt_wait \
|
||||||
|
--no-scripts .makedepends-$pkgname || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
@@ -2481,7 +2432,7 @@
|
||||||
package Install project into $pkgdir
|
package Install project into $pkgdir
|
||||||
prepare Apply patches
|
prepare Apply patches
|
||||||
rootbld Build package in clean chroot
|
rootbld Build package in clean chroot
|
||||||
|
@ -104,7 +195,7 @@ diff -uNr abuild-3.2.0/abuild.in abuild-3.2.0.mod/abuild.in
|
||||||
sanitycheck Basic sanity check of APKBUILD
|
sanitycheck Basic sanity check of APKBUILD
|
||||||
snapshot Create a \$giturl or \$svnurl snapshot and upload to \$disturl
|
snapshot Create a \$giturl or \$svnurl snapshot and upload to \$disturl
|
||||||
sourcecheck Check if remote source package exists upstream
|
sourcecheck Check if remote source package exists upstream
|
||||||
@@ -2563,7 +2540,7 @@
|
@@ -2563,7 +2514,7 @@
|
||||||
if [ -z "$REPODEST" ]; then
|
if [ -z "$REPODEST" ]; then
|
||||||
warning "REPODEST is not set and is now required. Defaulting to ~/packages"
|
warning "REPODEST is not set and is now required. Defaulting to ~/packages"
|
||||||
[ -n "$PKGDEST" ] && die "PKGDEST is no longer supported."
|
[ -n "$PKGDEST" ] && die "PKGDEST is no longer supported."
|
||||||
|
|
|
@ -6,3 +6,11 @@ TERMUX_PKG_SRCURL=https://github.com/alpinelinux/abuild/archive/v$TERMUX_PKG_VER
|
||||||
TERMUX_PKG_DEPENDS="openssl"
|
TERMUX_PKG_DEPENDS="openssl"
|
||||||
TERMUX_PKG_BUILD_IN_SRC=yes
|
TERMUX_PKG_BUILD_IN_SRC=yes
|
||||||
TERMUX_PKG_EXTRA_MAKE_ARGS="sysconfdir=$TERMUX_PREFIX/etc"
|
TERMUX_PKG_EXTRA_MAKE_ARGS="sysconfdir=$TERMUX_PREFIX/etc"
|
||||||
|
|
||||||
|
TERMUX_PKG_RM_AFTER_INSTALL="
|
||||||
|
bin/abuild-adduser
|
||||||
|
bin/abuild-addgroup
|
||||||
|
bin/abuild-apk
|
||||||
|
bin/abuild-sudo
|
||||||
|
bin/buildlab
|
||||||
|
"
|
||||||
|
|
Loading…
Reference in New Issue