forked from CyanogenMod/android_bootable_recovery
-
Notifications
You must be signed in to change notification settings - Fork 8
/
install-system
83 lines (69 loc) · 1.88 KB
/
install-system
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
83
#!/sbin/sh
TARPATH=$(realpath $2)
SYSIMG=$(realpath $3)
prepare_ubuntu_system()
{
mount /data
rm -f /data/system.img
rm -rf /data/ubuntu
for data in system android; do
rm -rf /data/$data-data
done
dd if=/dev/zero of=/data/system.img seek=500K bs=4096 count=0 >/dev/null 2>&1
mkfs.ext2 -F /data/system.img >/dev/null 2>&1
mkdir -p /data/ubuntu
mount -o loop /data/system.img /data/ubuntu/
}
cleanup()
{
umount /data/ubuntu/ 2>/dev/null && rm -rf /data/ubuntu 2>/dev/null
rm -r /data/zip
}
usage()
{
echo "usage: $(basename $0) <method>\n
methods: zip, pre"
exit 1
}
TARBALL=$(basename $TARPATH)
THIS_DIR=$(dirname $0)
if [ $1 == "zip" ]; then
mkdir /data/zip
unzip $TARPATH -d /data/zip
TARBALL = /data/zip/ubuntu.tar.gz
SYSIMG = /data/zip/system.img
fi
if [ -z "$TARBALL" ]; then
echo "need valid rootfs tarball path"
usage
fi
echo -n "preparing system-image on device ... "
prepare_ubuntu_system
echo "[done]"
echo -n "unpacking rootfs tarball to system-image ... "
echo "$TARPATH"
zcat $TARPATH | tar xf - -C /data/ubuntu
cd /data/ubuntu
mkdir -p /data/ubuntu/android/firmware
mkdir -p /data/ubuntu/android/persist
mkdir -p /data/ubuntu/userdata
[ -e /data/ubuntu/SWAP.swap ] && mv /data/ubuntu/SWAP.swap /data/SWAP.img
for link in cache data factory firmware persist system; do
cd /data/ubuntu && ln -s /android/$link $link
done
cd /data/ubuntu/lib && ln -s /system/lib/modules modules
cd /data/ubuntu && ln -s /android/system/vendor vendor
[ -e /data/ubuntu/etc/mtab ] && rm /data/ubuntu/etc/mtab
cd /data/ubuntu/etc && ln -s /proc/mounts mtab
echo "[done]"
echo -n "adding android system image to installation ... "
cd "$(dirname "$0")"
ANDROID_DIR="/data/ubuntu/var/lib/lxc/android/"
cp $SYSIMG $ANDROID_DIR
echo "[done]"
echo -n "enabling Mir ... "
touch /data/ubuntu/home/phablet/.display-mir
echo "[done]"
echo -n "cleaning up on device ... "
cleanup
echo "[done]"