]> git.sev.monster Git - abchr.git/blob - abchr-newchroot
apkgvers: replace grep/sed with awk
[abchr.git] / abchr-newchroot
1 #!/bin/sh
2 set -e
3 [ "$(id | awk '{print $1}')" != 'uid=0(root)' ] &&
4   exec sudo "$0" "$(id -u $(whoami))" "$@"
5 [ "z$1" = z ] && return 1
6 mirror=https://dl-cdn.alpinelinux.org/alpine/edge
7 arch="${ABCHR_ARCH:-x86_64}"
8 apk update
9 apk="apk-tools-static-$(apk info apk-tools-static |
10   awk '{if (NR==1) {print substr($1,18)}}').apk"
11 dir="$(dirname "$0")/../alpine"
12 tmp="$(dirname "$0")/../tmp"
13 mkdir -p "$tmp"
14 wget -P "$tmp" "$mirror/main/$arch/$apk"
15 tar -xvzf "$tmp/$apk" -C "$tmp"
16 "$tmp/sbin/apk.static" -UX "$mirror/main" -X "$mirror/community" \
17   --allow-untrusted -p "$dir" --initdb \
18   add busybox busybox-suid libc-utils sudo \
19       alpine-baselayout alpine-conf alpine-release apk-tools \
20       alpine-sdk alpine-repo-tools atools lua-aports
21 rm -rf "$tmp"
22 cp -Ln /etc/apk/keys/* "$dir/etc/apk/keys"
23 cp -f /etc/apk/repositories "$dir/etc/apk/repositories"
24 printf -- > "$dir/etc/sudoers.d/abuild" 'abuild ALL=(ALL) NOPASSWD: ALL'
25 printf -- >> "$dir/etc/apk/repositories" \
26   '/home/abuild/packages/%s\n' main community testing
27 chroot "$dir" /bin/sh -c "adduser -DGabuild -u$1 abuild"
This page took 0.029998 seconds and 4 git commands to generate.