From: sev Date: Wed, 3 Jan 2024 00:50:10 +0000 (-0600) Subject: initial commit X-Git-Url: https://git.sev.monster/abchr.git/commitdiff_plain/9efefcc4d79e5b98b2e8beab1309406a66a215e2?ds=inline initial commit --- 9efefcc4d79e5b98b2e8beab1309406a66a215e2 diff --git a/abchr b/abchr new file mode 100755 index 0000000..ab7a8df --- /dev/null +++ b/abchr @@ -0,0 +1,64 @@ +#!/bin/sh +[ "$(id | awk '{print $1}')" != 'uid=0(root)' ] && exec sudo "$0" "$@" + +dir="$(realpath "$(dirname "$0")/../alpine")" +aports="$(realpath "$dir/../aports")" +if [ $# -gt 0 ]; then + cmd="$@" +else + cmd='/bin/ash -i' +fi + +um=0 +uma() { + : $((++um)) + eval "um$um='$1'" +} +m() { + src="$1"; shift + dst="$1"; shift + mkdir -p "$dst" + mount $@ "$src" "$dst" + uma "$dst" +} +mb() { + src="$1"; shift + if [ $# -gt 0 -a "x$(echo "$1" | cut -c 1)" = x/ ]; then + dst="$dir$1"; shift + else + dst="$dir$src" + fi + src="$(realpath $src)" + [ ! -e "$src" ] && return + m "$src" "$dst" --bind --slave $@ +} + +mb /dev -oro +mb /dev/pts +mb /dev/shm +mb /dev/mqueue +m none "$dir/proc" -t proc +mb /sys +ln -f /etc/resolv.conf "$dir/etc/resolv.conf" +mb "$aports" /home/abuild/aports +mb /srv/alpine/edge /home/abuild/packages +mb /var/cache/distfiles +mb /etc/apk/cache + +f="$(chroot "$dir" mktemp -p/tmp/)" + +chrdir="$PWD/" +chrdir="${chrdir%/aports/*}" +if [ "$chrdir" != "$PWD/" ]; then + cmd="cd \"/home/abuild${PWD#$chrdir}\" && $cmd" +fi + +echo "$cmd" | tee "$dir/$f" +chmod ugo+r "$dir/$f" +chroot "$dir" /bin/su abuild -l "$f" + +rm -f "$dir/$f" + +for x in $(seq $um -1 1); do + eval "umount \$um$x" +done diff --git a/abchr-buildall b/abchr-buildall new file mode 100755 index 0000000..9030e4c --- /dev/null +++ b/abchr-buildall @@ -0,0 +1,2 @@ +#!/bin/sh +abchr buildrepo -ps testing diff --git a/abchr-newchroot b/abchr-newchroot new file mode 100755 index 0000000..2879594 --- /dev/null +++ b/abchr-newchroot @@ -0,0 +1,26 @@ +#!/bin/sh +set -e +[ "$(id | awk '{print $1}')" != 'uid=0(root)' ] && + exec sudo "$0" "$(id -u $(whoami))" "$@" +[ "z$1" = z ] && return 1 +mirror=https://dl-cdn.alpinelinux.org/alpine/edge +arch="${ABCHR_ARCH:-x86_64}" +apk="apk-tools-static-$(apk info apk-tools-static | + awk '{if (NR==1) {print substr($1,18)}}').apk" +dir="$(dirname "$0")/../alpine" +tmp="$(dirname "$0")/../tmp" +mkdir -p "$tmp" +wget -P "$tmp" "$mirror/main/$arch/$apk" +tar -xvzf "$tmp/$apk" -C "$tmp" +"$tmp/sbin/apk.static" -UX "$mirror/main" -X "$mirror/community" \ + --allow-untrusted -p "$dir" --initdb \ + add busybox busybox-suid libc-utils sudo \ + alpine-baselayout alpine-conf alpine-release apk-tools \ + alpine-sdk alpine-repo-tools atools lua-aports +rm -rf "$tmp" +cp -Ln /etc/apk/keys/* "$dir/etc/apk/keys" +cp -f /etc/apk/repositories "$dir/etc/apk/repositories" +printf -- > "$dir/etc/sudoers.d/abuild" 'abuild ALL=(ALL) NOPASSWD: ALL' +printf -- >> "$dir/etc/apk/repositories" \ + '/home/abuild/packages/%s\n' main community testing +chroot "$dir" /bin/sh -c "adduser -DGabuild -u$1 abuild" diff --git a/apkgvers b/apkgvers new file mode 100755 index 0000000..135f0a6 --- /dev/null +++ b/apkgvers @@ -0,0 +1,3 @@ +#!/bin/sh +if ! which column >/dev/null 2>&1; then echo need column command >&2; exit 1; fi +grep pkgver= */APKBUILD | sort | sed -e 's_/APKBUILD:pkgver=_ _' | column -tNname,version -R1