OSDN Git Service

nativebridge: update short URLs
[android-x86/device-generic-common.git] / nativebridge / bin / enable_nativebridge
index ef00891..609ecdb 100644 (file)
@@ -6,47 +6,55 @@ houdini_bin=0
 dest_dir=/system/lib$1/arm$1
 binfmt_misc_dir=/proc/sys/fs/binfmt_misc
 
-cd $dest_dir
+urls[0]=http://t.cn/RBJ7mfG
+urls[1]=http://t.cn/RBJ7eml
+urls[2]=http://t.cn/RBJzLwu
+urls[3]=http://goo.gl/96BPKe
+urls[4]=http://goo.gl/v6c4Co
+urls[5]=http://goo.gl/CtKjxx
 
-if [ ! -s libhoudini.so ]; then
-       if touch .dl_houdini; then
-               rm -f .dl_houdini
-       else
-               cd .. && cp -a arm$1 /data/local/tmp
-               mount -t tmpfs tmpfs arm$1 && cd arm$1 &&
-                       cp -a /data/local/tmp/arm$1/* . && rm -rf /data/local/tmp/arm$1
-       fi
+if [ -z "$1" ]; then
+       v=8_y
+       u=1
+else
+       v=8_z
+       u=2
 fi
 
-cd /data/local/tmp
-while [ ! -s $dest_dir/libhoudini.so ]; do
-       while [ "$(getprop net.dns1)" = "" ]; do
-               sleep 10
-       done
-       if [ -z "$1" ]; then
-               [ "`uname -m`" = "x86_64" ] && url=http://goo.gl/Xl1str || url=http://goo.gl/PA2qZ7
-       else
-               url=http://goo.gl/L00S7l
+if [ -s /system/lib$1/libhoudini.so ]; then
+       log -pi -thoudini "found /system/lib$1/libhoudini.so"
+elif [ -e /system/etc/houdini$v.sfs ]; then
+       mount /system/etc/houdini$v.sfs $dest_dir
+else
+       if mountpoint -q $dest_dir; then
+               kill -9 `fuser -m $dest_dir`
+               umount -f $dest_dir
        fi
-       wget $url -cO houdini.tgz &&
-               bzcat houdini.tgz | tar xvf - -C $dest_dir && rm -f houdini.tgz && break
-       rm -f houdini.tgz
-       sleep 30
-done
-
+       mkdir -p /data/arm
+       cd /data/arm
+       while ! mount houdini$v.sfs $dest_dir; do
+               while [ "$(getprop net.dns1)" = "" ]; do
+                       sleep 10
+               done
+               wget ${urls[$u%6]} -cO houdini$v.sfs && continue
+               rm -f houdini$v.sfs
+               sleep 30
+               let u+=3
+       done
+fi
 
-# if you don't see the files 'register' and 'status' in /proc/sys/fs/binfmt_misc
-# then run the following command:
-# mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
+[ -s /system/lib$1/libhoudini.so ] || mount --bind $dest_dir/libhoudini.so /system/lib$1/libhoudini.so
 
 # this is to add the supported binary formats via binfmt_misc
 
 if [ ! -e $binfmt_misc_dir/register ]; then
+       modprobe binfmt_misc
        mount -t binfmt_misc none $binfmt_misc_dir
 fi
 
 cd $binfmt_misc_dir
 if [ -e register ]; then
+       [ -e /system/bin/houdini$1 ] && dest_dir=/system/bin
        # register Houdini for arm binaries
        if [ -z "$1" ]; then
                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
@@ -68,6 +76,4 @@ else
        log -pi -thoudini "houdini$1 enabled"
 fi
 
-[ "$(getprop ro.zygote)" = "zygote64_32" -a -z "$1" ] && exec $0 64
-
 exit 0