-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathremote-remaster
82 lines (62 loc) · 2.15 KB
/
remote-remaster
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
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
#
# Remote (ARM server) remaster script to be run on the remote. This is
# essentially the remote harness.
#
# Copyright Harald Sitter 2015, may be copied under GNU GPL v2 or
set -ex
__dir__=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CACHEDIR=$__dir__/cache
OUTDIR=$__dir__/output
EXTRACTDIR=$__dir__/ubuntu-touch-remaster/extract
TAR="tar --numeric-owner --atime-preserve --preserve-permissions"
function chroot_teardown {
if [ -z "$REMASTER_CHROOT_SETUP" ]; then
return
fi
echo "=== Un-Binding /proc, /sys and /dev"
umount $EXTRACTDIR/sys
umount $EXTRACTDIR/dev
umount $EXTRACTDIR/proc
echo "=== removing resolve.conf in chroot `date`"
rm $EXTRACTDIR/etc/resolv.conf
trap - EXIT SIGHUP SIGINT SIGTERM
unset REMASTER_CHROOT_SETUP
}
function chroot_setup {
if [ ! -z "$REMASTER_CHROOT_SETUP" ]; then
return
fi
export REMASTER_CHROOT_SETUP=1
trap chroot_teardown EXIT SIGHUP SIGINT SIGTERM
echo "=== setting up resolve.conf in chroot `date`"
cp /etc/resolv.conf $EXTRACTDIR/etc/
echo "=== Binding /proc, /sys and /dev"
mount --bind /dev $EXTRACTDIR/dev
mount --bind /proc $EXTRACTDIR/proc
mount --bind /sys $EXTRACTDIR/sys
}
[[ -d "$CACHEDIR" ]] || mkdir -p $CACHEDIR
rm -rf $OUTDIR
mkdir -p $OUTDIR
rm -rf $EXTRACTDIR
mkdir -p $EXTRACTDIR
echo "=== syncing reference image `date`"
pushd $CACHEDIR
zsync http://cdimage.ubuntu.com/ubuntu-touch/vivid/daily-preinstalled/current/vivid-preinstalled-touch-armhf.tar.gz.zsync
img=$CACHEDIR/vivid-preinstalled-touch-armhf.tar.gz
popd
echo "=== extracting reference image `date`"
$TAR --preserve-order -xpf $img -C $EXTRACTDIR
chroot_setup
echo "=== Entering chroot `date`"
cp $__dir__/chroot-remaster $EXTRACTDIR/remaster
chroot $EXTRACTDIR /bin/bash /remaster
chroot_teardown
echo "=== making a new tar - this takes an age `date`"
# gzip rsyncable as the gz is being extracted and meddled with as part of the
# image import, so the gzip we output here will not be the one used for
# devices anyway. might as well improve for transfer here. all things considered
pushd $EXTRACTDIR
$TAR -cp * | gzip --rsyncable -1 >$OUTDIR/vivid-preinstalled-touch-armhf.tar.gz
popd