summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jobs/alpine-amd64.conf2
-rwxr-xr-xjobs/alpine-amd64.run38
-rwxr-xr-xscripts/uchroot33
-rw-r--r--scripts/utils1
4 files changed, 74 insertions, 0 deletions
diff --git a/jobs/alpine-amd64.conf b/jobs/alpine-amd64.conf
new file mode 100644
index 0000000..04e6713
--- /dev/null
+++ b/jobs/alpine-amd64.conf
@@ -0,0 +1,2 @@
+TAGS=heavy
+TIMEOUT=14400
diff --git a/jobs/alpine-amd64.run b/jobs/alpine-amd64.run
new file mode 100755
index 0000000..83c6717
--- /dev/null
+++ b/jobs/alpine-amd64.run
@@ -0,0 +1,38 @@
+#!/bin/sh
+# vim: ft=sh
+set -e
+. common
+
+if [ -n "$CLEAN" ]; then
+ echo_stage "Remove root"
+ flock --exclusive "$WORKSPACE/root.lock" uroot rm -rf "$WORKSPACE/root"
+ exit 0
+fi
+
+# TODO get latest uri from latest-releases.yml file
+flock --exclusive "$WORKSPACE/root.lock" /bin/sh -se <<EOF
+ . utils
+ if [ ! -d "$WORKSPACE/root" ]; then
+ echo_stage "Setting up new root"
+ wget "http://dl-cdn.alpinelinux.org/alpine/edge/releases/x86_64/alpine-minirootfs-3.8.0-x86_64.tar.gz" -O alpine.tar.gz
+ gunzip alpine.tar.gz
+ tar -f alpine.tar --delete ./dev/null
+ mkdir "$WORKSPACE/root"
+ uroot tar -xf alpine.tar -C "$WORKSPACE/root"
+ uchroot "$WORKSPACE/root" /bin/sh -sxe <<EEOF
+ apk update
+ apk add alpine-sdk
+ adduser -D -h /build build
+ addgroup build abuild
+ # TODO more setup
+EEOF
+ fi
+
+ echo_stage "Update system"
+ uchroot "$WORKSPACE/root" /bin/sh -ce 'apk update && apk upgrade'
+
+ echo_stage "Update package sources"
+ # TODO
+EOF
+
+# TODO
diff --git a/scripts/uchroot b/scripts/uchroot
new file mode 100755
index 0000000..77f3f10
--- /dev/null
+++ b/scripts/uchroot
@@ -0,0 +1,33 @@
+#!/bin/sh
+set -e
+[ $# -ge 1 ] || {
+ echo "Usage: uchroot ROOT [CMD] [ARG].." >&2
+ exit 1
+}
+
+if [ "$(id -u)" != "0" ]; then
+ exec uroot "$0" "$@"
+fi
+###############################################################
+
+ROOT="$1"
+shift
+[ -d "$ROOT" ] || {
+ echo "There is no such directory: $ROOT" >&2
+ exit 1
+}
+[ -d "$ROOT/proc" -a -d "$ROOT/dev" -a -d "$ROOT/sys" ] || {
+ echo "Root seems to not contain valid rootfs: $ROOT" >&2
+ exit 1
+}
+
+
+mount -t proc none "$ROOT/proc"
+mount --rbind /dev "$ROOT/dev"
+mount --rbind /sys "$ROOT/sys"
+cp -f /etc/resolv.conf "$ROOT/etc/resolv.conf"
+
+if [ $# -lt 1 ]; then
+ set "/bin/sh"
+fi
+exec chroot "$ROOT" "$@"
diff --git a/scripts/utils b/scripts/utils
index 8781882..103d471 100644
--- a/scripts/utils
+++ b/scripts/utils
@@ -1,6 +1,7 @@
# vim: ft=sh
[ -n "$LAMINAR_COMMON" ] # variables definition guard
+V="${V:-0}"
if [ "$V" -ge 3 ]; then
set -x
fi