summaryrefslogtreecommitdiff
path: root/META-INF/com/google/android/update-binary
blob: 9d087060a5cefc5d7c279f134555ffffde7816c6 (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/sbin/sh
# AnyKernel2 Backend
# osm0sis @ xda-developers

OUTFD=/proc/self/fd/$2;
ZIP="$3";
DIR=`dirname "$ZIP"`;

ui_print() {
  until [ ! "$1" ]; do
    echo -e "ui_print $1\nui_print" > $OUTFD;
    shift;
  done;
}
show_progress() { echo "progress $1 $2" > $OUTFD; }
set_perm_recursive() {
  dirs=$(echo $* | $bb awk '{ print substr($0, index($0,$5)) }');
  for i in $dirs; do
    chown -R $1.$2 $i; chown -R $1:$2 $i;
    find "$i" -type d -exec chmod $3 {} +;
    find "$i" -type f -exec chmod $4 {} +;
  done;
}
file_getprop() { grep "^$2" "$1" | cut -d= -f2; }
getprop() { test -e /sbin/getprop && /sbin/getprop $1 || file_getprop /default.prop $1; }
abort() { ui_print "$*"; umount /system; umount /data; exit 1; }

show_progress 1.34 4;
ui_print " ";
mkdir -p /tmp/anykernel/bin;
cd /tmp/anykernel;
unzip -o "$ZIP";
if [ $? != 0 -o -z "$(ls /tmp/anykernel/tools)" ]; then
  abort "Unzip failed. Aborting...";
fi;
chmod -R 755 /tmp/anykernel/tools /tmp/anykernel/bin;
bb=/tmp/anykernel/tools/busybox;

ui_print "$(file_getprop /tmp/anykernel/anykernel.sh kernel.string)";
ui_print " ";
ui_print "AnyKernel2 by osm0sis @ xda-developers";
ui_print " ";
umount /system;
mount -o ro -t auto /system;
mount /data;
test -f /system/system/build.prop && root=/system;

if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.devicecheck)" == 1 ]; then
  ui_print "Checking device...";
  for i in 1 2 3 4 5; do
    testname="$(file_getprop /tmp/anykernel/anykernel.sh device.name$i)";
    if [ "$(getprop ro.product.device)" == "$testname" -o "$(getprop ro.build.product)" == "$testname" ]; then
      ui_print "$testname";
      match=1;
    fi;
  done;
  ui_print " ";
  if [ "$match" != 1 ]; then
    abort "Unsupported device. Aborting...";
  fi;
fi;

if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.initd)" == 1 ]; then
  ui_print "Creating init.d...";
  ui_print " ";
  mount -o rw,remount -t auto /system;
  mkdir $root/system/etc/init.d;
  set_perm_recursive 0 0 0755 0755 $root/system/etc/init.d;
  mount -o ro,remount -t auto /system;
fi;

ui_print "Installing kernel...";
for i in $($bb --list); do
  $bb ln -s $bb /tmp/anykernel/bin/$i;
done;
if [ $? != 0 -o -z "$(ls /tmp/anykernel/bin)" ]; then
  abort "Recovery busybox setup failed. Aborting...";
fi;
PATH="/tmp/anykernel/bin:$PATH" $bb ash /tmp/anykernel/anykernel.sh $2;
if [ $? != "0" ]; then
  abort;
fi;

if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.modules)" == 1 ]; then
  ui_print " ";
  ui_print "Pushing modules...";
  mount -o rw,remount -t auto /system;
  cp -rf /tmp/anykernel/modules/* $root/system/lib/modules/;
  set_perm_recursive 0 0 0755 0644 $root/system/lib/modules;
  mount -o ro,remount -t auto /system;
fi;

if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.cleanup)" == 1 ]; then
  rm -rf /tmp/anykernel;
fi;

umount /system;
umount /data;
ui_print " ";
ui_print "Done!";