OSDN Git Service

nativebridge: disable 32k32u and 64k64u support temporarily
[android-x86/device-generic-common.git] / nativebridge / bin / enable_nativebridge
1 #!/system/bin/sh
2
3 PATH=/system/bin:/system/xbin
4
5 houdini_bin=0
6 dest_dir=/system/lib$1/arm$1
7 binfmt_misc_dir=/proc/sys/fs/binfmt_misc
8
9 if [ -z "$1" ]; then
10         v=8_y
11         url=http://goo.gl/v6c4Co
12 else
13         v=8_z
14         url=http://goo.gl/CtKjxx
15 fi
16
17 if [ -s /system/lib$1/libhoudini.so ]; then
18         log -pi -thoudini "found /system/lib$1/libhoudini.so"
19 elif [ -e /system/etc/houdini$v.sfs ]; then
20         mount /system/etc/houdini$v.sfs $dest_dir
21 else
22         if mountpoint -q $dest_dir; then
23                 kill -9 `fuser -m $dest_dir`
24                 umount -f $dest_dir
25         fi
26         mkdir -p /data/arm
27         cd /data/arm
28         while ! mount houdini$v.sfs $dest_dir; do
29                 while [ "$(getprop net.dns1)" = "" ]; do
30                         sleep 10
31                 done
32                 wget $url -cO houdini$v.sfs && continue
33                 rm -f houdini$v.sfs
34                 sleep 30
35         done
36 fi
37
38 [ -s /system/lib$1/libhoudini.so ] || mount --bind $dest_dir/libhoudini.so /system/lib$1/libhoudini.so
39
40 # this is to add the supported binary formats via binfmt_misc
41
42 if [ ! -e $binfmt_misc_dir/register ]; then
43         modprobe binfmt_misc
44         mount -t binfmt_misc none $binfmt_misc_dir
45 fi
46
47 cd $binfmt_misc_dir
48 if [ -e register ]; then
49         [ -e /system/bin/houdini$1 ] && dest_dir=/system/bin
50         # register Houdini for arm binaries
51         if [ -z "$1" ]; then
52                 echo ':arm_exe:M::\\x7f\\x45\\x4c\\x46\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x28::'"$dest_dir/houdini:P" > register
53                 echo ':arm_dyn:M::\\x7f\\x45\\x4c\\x46\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x03\\x00\\x28::'"$dest_dir/houdini:P" > register
54         else
55                 echo ':arm64_exe:M::\\x7f\\x45\\x4c\\x46\\x02\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\xb7::'"$dest_dir/houdini64:P" > register
56                 echo ':arm64_dyn:M::\\x7f\\x45\\x4c\\x46\\x02\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x03\\x00\\xb7::'"$dest_dir/houdini64:P" > register
57         fi
58         if [ -e arm${1}_exe ]; then
59                 houdini_bin=1
60         fi
61 else
62         log -pe -thoudini "No binfmt_misc support"
63 fi
64
65 if [ $houdini_bin -eq 0 ]; then
66         log -pe -thoudini "houdini$1 enabling failed!"
67 else
68         log -pi -thoudini "houdini$1 enabled"
69 fi
70
71 exit 0