da8cd10e67
Change-Id: I4f2b8b4c798ea446699e181d570c2a72b1388657
62 lines
2.4 KiB
Python
Executable file
62 lines
2.4 KiB
Python
Executable file
#!/usr/bin/env python
|
|
import sys, random, urllib2, zipfile, StringIO, os
|
|
from optparse import OptionParser
|
|
|
|
FILENAME=["gapps-gb-20110120-signed.zip","gapps-gb-tegra-20110118-signed.zip","gapps-hdpi-20101114-signed.zip","gapps-mdpi-20101020-signed.zip","gapps-mdpi-tiny-20101020-signed.zip","gapps-mdpi-tegra-20101020-signed.zip","gapps-passion-EPE54B-signed.zip","gapps-ds-ERE36B-signed.zip","DRC83_base_defanged.zip"]
|
|
VERSIONS=["gb","gb-tegra","hdpi","mdpi","mdpi-tiny","tegra","cm5hdpi","cm5mdpi","cm4"]
|
|
MIRRORS=["http://goo-inside.me/gapps/","http://android.d3xt3r01.tk/cyanogen/gapps/","http://android.local.host.name/gapps/"]
|
|
|
|
def device():
|
|
print "usage: get-google-files -m [method] -v [version]"
|
|
print "Note: Device method is currently not implemented, please use download"
|
|
sys.exit(1)
|
|
|
|
def download(version):
|
|
try:
|
|
os.makedirs(os.path.join(os.path.dirname(__file__), "proprietary"))
|
|
except:
|
|
pass
|
|
if len(MIRRORS) > 1:
|
|
i = random.randrange(0, len(MIRRORS)-1)
|
|
else:
|
|
i = 0
|
|
|
|
try:
|
|
j = VERSIONS.index(version.lower())
|
|
except ValueError:
|
|
print "GApps version not found, defaulting to HDPI"
|
|
j = 0
|
|
|
|
url = MIRRORS[i] + FILENAME[j]
|
|
|
|
print "Fetching %s GApps from %s" % (version.upper(),url)
|
|
|
|
data = urllib2.urlopen(url).read()
|
|
zip = zipfile.ZipFile(StringIO.StringIO(data),'r')
|
|
|
|
for filename in zip.namelist():
|
|
if filename.split("/")[0] == "system" and filename[-1] != "/":
|
|
print "Extracting %s" % filename
|
|
try:
|
|
bytes = zip.read(filename)
|
|
fd = open(os.path.join(os.path.dirname(__file__), "proprietary", os.path.basename(filename)),"wb")
|
|
fd.write(bytes)
|
|
fd.close()
|
|
except Exception, e:
|
|
print e
|
|
pass
|
|
|
|
def main():
|
|
parser = OptionParser(usage="usage: %prog [options]")
|
|
parser.add_option("-m", "--method", dest='method', default="download", help="Extraction Method: download")
|
|
parser.add_option("-v", "--version", dest='version', default="gb", help="GApps Version: gb, gb-tegra, hdpi, mdpi, mdpi-tiny, tegra, cm5hdpi, cm5mdpi, cm4 [default: gb]")
|
|
(options, args) = parser.parse_args()
|
|
|
|
if options.method == "device":
|
|
return device()
|
|
|
|
if options.method == "download":
|
|
return download(options.version)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|