-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare-os-image.sh
executable file
·42 lines (34 loc) · 1006 Bytes
/
prepare-os-image.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
#!/usr/bin/env bash
source init-env.sh
DISTRO=${DISTRO:-"bionic"}
VERSION=$version
SYSTEM_SIZE=${SYSTEM_SIZE:-'1536'} # 1.5G
echo "Building image" $SYSTEM_SIZE
dd if=/dev/zero of=$bb2/rootfs.img bs=1M count=$SYSTEM_SIZE conv=sparse
mkfs.ext4 -L rootfs $bb2/rootfs.img
if [[ ! -d $bb2/loop ]]; then
mkdir $bb2/loop
mount -t ext4 -o loop $bb2/rootfs.img $bb2/loop
else
echo "Loop Exsist"
mount -t ext4 -o loop $bb2/rootfs.img $bb2/loop
fi
echo "Copying root"
echo "$gt"
cp -ar $bb3/* $bb2/loop/
echo "Umount $nl"
umount $bb2/loop
echo "Building sparse"
export SPARSE_IMG="ubuntu_$DISTRO.hikey970.$VERSION.sparse.img"
img2simg $bb2/rootfs.img $bb2/$SPARSE_IMG
echo "Cleaning Up"
rm -rf $bb2/rootfs.img
cp -rf $bb2/$SPARSE_IMG $bb1/artifacts
cd $bb1/artifacts
tar -czvf $SPARSE_IMG.tar.gz $SPARSE_IMG
rm -rf $bb2/$SPARSE_IMG
echo "ALL COMPLETE"
ls -lha $bb1/artifacts/$SPARSE_IMG
ls -lha $bb1/artifacts/SPARSE_IMG.tar.gz
sha1sum $bb1/artifacts/$SPARSE_IMG
sha1sum $bb1/artifacts/$SPARSE_IMG.tar.gz