add setup-alpine script

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
This commit is contained in:
Hiltjo Posthuma 2014-07-05 21:09:21 +00:00
parent a52a87fb72
commit 0b6fc88b20

42
misc/setup-alpine Executable file
View File

@ -0,0 +1,42 @@
#!/bin/sh
# Things you might want to do after setup:
# - apk update
# - apk add alpine-sdk
# - use misc/run-chroot to chroot to it.
# - remove gcc, binutils, pkg-config etc packages.
# - remove libraries such as libpng (png-config), these can mess up
# the builds.
# - remove /usr/include or move to /usr/include.old, note that
# python for example uses files from /usr/include/python2.7 at runtime (oh oh).
# - add a separate morpheus user to build stuff.
# - copy static plan9 mk to /bin.
# - copy static git to /bin
set -e -x
mirror="http://nl.alpinelinux.org/alpine/"
installdir="/ns/alpine"
tmpdir="${installdir}/tmp"
# fetch apk package tools.
mkdir -p "${tmpdir}/sbin"
cd "$tmpdir"
apktools="apk-tools-static-2.4.4-r0.apk"
if ! test -f "$apktools"; then
wget "${mirror}/v3.0/main/x86_64/${apktools}"
fi
if ! test -d "sbin"; then
tar -xzf "$apktools"
fi
# install in chroot.
"${installdir}/tmp/sbin/apk.static" -X "${mirror}/v3.0/main" -U --allow-untrusted --root "${installdir}" --initdb add alpine-base
# copy etc/resolv.conf
mkdir -p "${installdir}/etc"
cp /etc/resolv.conf "${installdir}/etc/resolv.conf"
chmod 755 "${installdir}/etc/resolv.conf"
# write used mirror as apk repository.
mkdir -p "${installdir}/etc/apk"
echo "${mirror}/v3.0/main" > ${installdir}/etc/apk/repositories