-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_common.sh
72 lines (60 loc) · 1.7 KB
/
build_common.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash -ex
VERSION=$1
if [[ -z "$VERSION" ]]; then
VERSION="sid"
else
echo $VERSION
fi
function cleanup() {
rm -Rf $TMPDIR
}
function build_multistrap() {
mkdir -p ${TMPDIR}/conf
cat << EOF > ${TMPDIR}/conf/multistrap.conf
[General]
noauth=true
unpack=true
debootstrap=Debian
aptsources=Debian
[Debian]
packages=apt
source=http://ftp.debian.org/debian
suite=${VERSION}
EOF
}
function build_configure_guest() {
mkdir -p ${TMPDIR}/scripts
cat << EOF > ${TMPDIR}/scripts/configure_guest.sh
#!/bin/bash -ex
export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true
export LC_ALL=C LANGUAGE=C LANG=C
/var/lib/dpkg/info/dash.preinst install
dpkg --configure -a
EOF
chmod +x ${TMPDIR}/scripts/configure_guest.sh
}
#get script location
SCRIPTDIR=`dirname $0`
SCRIPTDIR=`(cd $SCRIPTDIR ; pwd)`
#create tmp dir
TMPDIR=`mktemp -d -t arm64_debian_docker_XXXXXXXX`
trap cleanup EXIT
cd ${TMPDIR}
#get umeq
mkdir -p ${TMPDIR}/tools
wget https://raw.githubusercontent.com/mickael-guene/umeq-static-build/master/bin/umeq-arm64 -O ${TMPDIR}/tools/umeq-arm64
chmod +x ${TMPDIR}/tools/umeq-arm64
#get arm64
build_multistrap
/usr/sbin/multistrap -a arm64 -d rootfs -f ${TMPDIR}/conf/multistrap.conf
#configure it
build_configure_guest
cp ${TMPDIR}/tools/umeq-arm64 ${TMPDIR}/rootfs/usr/bin/umeq-arm64
ln -rsf ${TMPDIR}/rootfs/usr/bin/umeq-arm64 ${TMPDIR}/rootfs/usr/bin/qemu-aarch64-static
tar --owner=root --group=root -c -C rootfs . | docker import - tmp_before_configuration
ID=`docker run -d -v ${TMPDIR}/scripts:/tmp/scripts tmp_before_configuration /tmp/scripts/configure_guest.sh`
docker wait $ID
docker commit $ID mickaelguene/arm64-debian:${VERSION}
docker rm $ID
docker rmi tmp_before_configuration