blob: 2bec1cb1bbf66682b8907eac0b4ece5e25e5a889 (
plain)
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
|
#!/bin/bash -x
name=ubuntu-arm64-chroot
d=$(mktemp -d --tmpdir XXXXXX-${name})
: ${DEST:=${d}/$name}
clean_up() { sudo rm -rf "$d"; }
trap clean_up EXIT INT
# On trusty you will need to install an update of the qemu package -
# or one that has qemu-aarch64-static(1). You can search for an update
# using:
#
# http://packages.ubuntu.com/search?suite=trusty-updates&keywords=qemu
#
# Last time I tried this the following .deb worked OK on trusty:
#
# qemu-user-static_2.0.0+dfsg-2ubuntu1.7_amd64.deb
xchroot="DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot"
packages="wget,qemu-utils,cloud-guest-utils,eatmydata"
if [ -f extra-packages ]; then
extra_packages="$(cat extra-packages | tr '\n' ',')"
packages="$(echo ${packages},${extra_packages} | sed -s 's/,$//')"
fi
: ${SERIES:=$(lsb_release -c | awk '{print $2}')}
sudo apt-get install -y debootstrap qemu-user-static binfmt-support
sudo debootstrap --include=$packages --foreign --arch arm64 $SERIES $DEST
#sudo cp /usr/bin/qemu-aarch64-static $DEST/usr/bin
sudo $xchroot $DEST /debootstrap/debootstrap --second-stage
sudo $xchroot $DEST dpkg-reconfigure -a
sudo cp post-debootstrap $DEST/post-debootstrap
sudo $xchroot $DEST /post-debootstrap
sudo rm $DEST/post-debootstrap
echo localhost | sudo tee $DEST/etc/hostname
sudo tar -C $d -acf $name.tar $name
sudo rm -rf $d
|