Commit 82fb2ae 1 parent 7a70fb4 commit 82fb2ae Copy full SHA for 82fb2ae
File tree 1 file changed +59
-0
lines changed
1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Wait until the adb shell is unavailable, meaning the device is rebooting
4
+ wait_for_reboot () {
5
+ while test -n " $( adb shell echo ' 1' 2> /dev/null) "
6
+ do
7
+ echo -n " ." ;
8
+ sleep 3;
9
+ done
10
+ echo
11
+ }
12
+
13
+ # wait until we get a working adb shell, meaning the device is in normal or recovery mode
14
+ wait_for_device () {
15
+ while test -z " $( adb shell echo ' 1' 2> /dev/null) "
16
+ do
17
+ echo -n " ." ;
18
+ sleep 3;
19
+ done
20
+ echo
21
+ }
22
+
23
+ SYSTEM_IMAGE=$1
24
+
25
+ if [ ! -f " $SYSTEM_IMAGE " ]; then
26
+ echo " Usage: $0 system.img"
27
+ exit
28
+ fi
29
+
30
+ wait_for_device
31
+
32
+ adb shell " ls /data"
33
+
34
+ if file $SYSTEM_IMAGE | grep -v " : Linux rev 1.0 ext4" > /dev/null; then
35
+ echo " Converting from sparse ext4 image to mountable ext4 image"
36
+ simg2img $SYSTEM_IMAGE tmp.img > /dev/null
37
+ resize2fs -M tmp.img > /dev/null 2>&1
38
+ mv tmp.img $SYSTEM_IMAGE
39
+ fi
40
+
41
+ echo Pushing android system image...
42
+ adb push $SYSTEM_IMAGE /data/system.img > /dev/null 2>&1 &
43
+
44
+ SIZE=$( stat -t $SYSTEM_IMAGE | awk ' {print $2}' )
45
+ S=0
46
+ while test $S -lt $SIZE
47
+ do
48
+ sleep 1
49
+ S=$( adb shell stat -t /data/system.img | awk ' {print $2}' )
50
+ printf " %0.2d%%\r" $[100* $S /$SIZE ]
51
+ done
52
+
53
+ echo " Done, rebooting to Halium"
54
+
55
+ adb shell " ls /data"
56
+
57
+ # adb reboot
58
+
59
+ # vim: expandtab: ts=4: sw=4
You can’t perform that action at this time.
0 commit comments