OSDN Git Service

Refine download function to support ftp, ssh with <machine>:<path> and file://<path>
authorDavid 'Digit' Turner <digit@google.com>
Tue, 6 Apr 2010 00:39:35 +0000 (17:39 -0700)
committerDavid 'Digit' Turner <digit@google.com>
Tue, 6 Apr 2010 00:39:35 +0000 (17:39 -0700)
This is a preliminary change to further toolchain build scripts modifications

Change-Id: I47758a23d916bc59f4b60eca83bcc6d6c2332203

build/core/ndk-common.sh
build/tools/build-toolchain.sh

index 1a0161f..c036826 100644 (file)
@@ -501,13 +501,13 @@ find_program ()
 # $2: target file
 download_file ()
 {
-    # is this HTTP, HTTPS or FTP ?
-    echo $1 | grep -q -e "^\(http\|https\):.*"
+    # Is this HTTP, HTTPS or FTP ?
+    echo $1 | grep -q -E -e "^(http|https|ftp):.*"
     if [ $? = 0 ] ; then
-        if [ -n "$WGET" ] ; then
-            run $WGET -O $2 $1 
-        elif [ -n "$CURL" ] ; then
-            run $CURL -o $2 $1
+        if [ -n "$CMD_WGET" ] ; then
+            run $CMD_WGET -O $2 $1 
+        elif [ -n "$CMD_CURL" ] ; then
+            run $CMD_CURL -o $2 $1
         else
             echo "Please install wget or curl on this machine"
             exit 1
@@ -515,12 +515,14 @@ download_file ()
         return
     fi
 
-    # is this SSH ?
-    echo $1 | grep -q -e "^ssh:.*"
+    # Is this SSH ?
+    # Accept both ssh://<path> or <machine>:<path>
+    #
+    echo $1 | grep -q -E -e "^(ssh|[^:]+):.*"
     if [ $? = 0 ] ; then
-        if [ -n "$SCP" ] ; then
+        if [ -n "$CMD_SCP" ] ; then
             scp_src=`echo $1 | sed -e s%ssh://%%g`
-            run $SCP $scp_src $2
+            run $CMD_SCP $scp_src $2
         else
             echo "Please install scp on this machine"
             exit 1
@@ -528,9 +530,13 @@ download_file ()
         return
     fi
 
-    echo $1 | grep -q -e "^/.*"
+    # Is this a file copy ?
+    # Accept both file://<path> or /<path>
+    #
+    echo $1 | grep -q -E -e "^(file://|/).*"
     if [ $? = 0 ] ; then
-        run cp -f $1 $2
+        cp_src=`echo $1 | sed -e s%^file://%%g`
+        run cp -f $cp_src $2
+        return
     fi
 }
-
index bdb210f..6826a78 100755 (executable)
@@ -213,9 +213,9 @@ ANDROID_SYSROOT=$ANDROID_NDK_ROOT/build/platforms/$PLATFORM/arch-$ARCH
 check_md5sum
 
 # Do we have anything to download stuff
-find_program WGET wget
-find_program CURL curl
-find_program SCP scp
+find_program CMD_WGET wget
+find_program CMD_CURL curl
+find_program CMD_SCP scp
 
 timestamp_check ()
 {