]> git.sev.monster Git - abchr.git/blame - abchr
initial commit
[abchr.git] / abchr
CommitLineData
9efefcc4 1#!/bin/sh
2[ "$(id | awk '{print $1}')" != 'uid=0(root)' ] && exec sudo "$0" "$@"
3
4dir="$(realpath "$(dirname "$0")/../alpine")"
5aports="$(realpath "$dir/../aports")"
6if [ $# -gt 0 ]; then
7 cmd="$@"
8else
9 cmd='/bin/ash -i'
10fi
11
12um=0
13uma() {
14 : $((++um))
15 eval "um$um='$1'"
16}
17m() {
18 src="$1"; shift
19 dst="$1"; shift
20 mkdir -p "$dst"
21 mount $@ "$src" "$dst"
22 uma "$dst"
23}
24mb() {
25 src="$1"; shift
26 if [ $# -gt 0 -a "x$(echo "$1" | cut -c 1)" = x/ ]; then
27 dst="$dir$1"; shift
28 else
29 dst="$dir$src"
30 fi
31 src="$(realpath $src)"
32 [ ! -e "$src" ] && return
33 m "$src" "$dst" --bind --slave $@
34}
35
36mb /dev -oro
37mb /dev/pts
38mb /dev/shm
39mb /dev/mqueue
40m none "$dir/proc" -t proc
41mb /sys
42ln -f /etc/resolv.conf "$dir/etc/resolv.conf"
43mb "$aports" /home/abuild/aports
44mb /srv/alpine/edge /home/abuild/packages
45mb /var/cache/distfiles
46mb /etc/apk/cache
47
48f="$(chroot "$dir" mktemp -p/tmp/)"
49
50chrdir="$PWD/"
51chrdir="${chrdir%/aports/*}"
52if [ "$chrdir" != "$PWD/" ]; then
53 cmd="cd \"/home/abuild${PWD#$chrdir}\" && $cmd"
54fi
55
56echo "$cmd" | tee "$dir/$f"
57chmod ugo+r "$dir/$f"
58chroot "$dir" /bin/su abuild -l "$f"
59
60rm -f "$dir/$f"
61
62for x in $(seq $um -1 1); do
63 eval "umount \$um$x"
64done
This page took 0.050732 seconds and 4 git commands to generate.