]> git.saurik.com Git - cydia.git/commitdiff
Separate out extract() in syroot.sh.
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 12 Mar 2011 23:07:51 +0000 (15:07 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 14 Mar 2011 12:09:08 +0000 (05:09 -0700)
sysroot.sh

index 4815b242f375d9f9ce777286b5fcc64c73e96e18..26ecbadf741e2af347d470d5ea0e6bfa6b2df3cd 100755 (executable)
@@ -36,6 +36,30 @@ declare -A dpkgz
 dpkgz[gz]=gunzip
 dpkgz[lzma]=unlzma
 
+function extract() {
+    package=$1
+    url=$2
+
+    wget -O "${package}.deb" "${url}"
+    for z in lzma gz; do
+        compressed=data.tar.${z}
+
+        if ar -x "${package}.deb" "${compressed}" 2>/dev/null; then
+            ${dpkgz[${z}]} "${compressed}"
+            break
+        fi
+    done
+
+    if ! [[ -e data.tar ]]; then
+        echo "unable to extract package" 1>&2
+        exit 1
+    fi
+
+    ls -la data.tar
+    tar -xf ./data.tar
+    rm -f data.tar
+}
+
 wget -qO- "${repository}dists/${distribution}/${component}/binary-${architecture}/Packages.bz2" | bzcat | {
     regex='^([^ \t]*): *(.*)'
     declare -A fields
@@ -45,25 +69,7 @@ wget -qO- "${repository}dists/${distribution}/${component}/binary-${architecture
             package=${fields[package]}
             if [[ ${package} == *(apr|apr-lib|apt7|apt7-lib|coreutils|mobilesubstrate|pcre) ]]; then
                 filename=${fields[filename]}
-
-                wget -O "${package}.deb" "${repository}${filename}"
-                for z in lzma gz; do
-                    compressed=data.tar.${z}
-
-                    if ar -x "${package}.deb" "${compressed}" 2>/dev/null; then
-                        ${dpkgz[${z}]} "${compressed}"
-                        break
-                    fi
-                done
-
-                if ! [[ -e data.tar ]]; then
-                    echo "unable to extract package" 1>&2
-                    exit 1
-                fi
-
-                ls -la data.tar
-                tar -xf ./data.tar
-                rm -f data.tar
+                extract "${package}" "${repository}${filename}"
             fi
 
             unset fields