forked from mindboards/ev3dev-rootfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-image
More file actions
executable file
·51 lines (44 loc) · 1.55 KB
/
create-image
File metadata and controls
executable file
·51 lines (44 loc) · 1.55 KB
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
#!/bin/sh -e
if [ $# -gt 0 ]; then
echo "usage: ./create-image"
echo
echo "ENVIRONMENT VARIABLES"
echo "---------------------"
echo "DEBIAN_MIRROR URL for debian package repository"
echo " default: http://ftp.debian.org/debian"
echo "EV3DEV_MIRROR URL for ev3dev package repository"
echo " default: http://ppa.lechnology.com/ev3dev"
echo "IMAGE_SIZE Size(s) of image files to create"
echo " default: 1G 2G 4G 8G"
exit 0
fi
if [ ! -z $DEBIAN_MIRROR ]; then
DEBIAN_MIRROR="-m $DEBIAN_MIRROR"
fi
if [ -z $IMAGE_SIZE ]; then
IMAGE_SIZE="1G 2G 4G 8G"
fi
polystrap -d ev3dev-rootfs $DEBIAN_MIRROR ev3dev
# guestfish does not know how to set label for vfat!
guestfish -N bootroot:vfat:ext3:512M:48M:mbr \
set-label /dev/sda2 EV3_FILESYS : \
mount /dev/sda2 / : \
tar-in ev3dev-rootfs.tar.gz / compress:gzip : \
mkdir-p /media/mmc_p1 : \
mount /dev/sda1 /media/mmc_p1 : \
mv /uImage /media/mmc_p1/ : \
mv /uInitrd /media/mmc_p1/ : \
mv /boot.scr /media/mmc_p1/ : \
mv /ev3dev.rc.local /media/mmc_p1/
# Hack to set the volume label on the vfat partition since guestfish does not know how
# volume name must be null padded to exactly 11 bytes
echo -e "EV3_BOOT\0\0\0" | dd of=test1.img bs=1 seek=32811 count=11 conv=notrunc
for size in $IMAGE_SIZE
do
truncate -r test1.img ev3dev.$size.img
truncate -s $size ev3dev.$size.img
virt-resize --expand /dev/sda2 test1.img ev3dev.$size.img
zip -9 ev3dev.$size.img.zip ev3dev.$size.img
cat ev3dev.$size.img | xz -9 > ev3dev.$size.img.xz
rm -f ev3dev.$size.img
done