2011-02-17 21:16:26 +01:00
|
|
|
#!/usr/bin/env python2
|
2011-01-26 17:26:51 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2010-10-22 00:26:38 +02:00
|
|
|
#
|
|
|
|
# update.py - part of the FDroid server tools
|
2011-05-11 23:22:46 +02:00
|
|
|
# Copyright (C) 2010-11, Ciaran Gultnieks, ciaran@ciarang.com
|
2010-10-22 00:26:38 +02:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import glob
|
|
|
|
import subprocess
|
|
|
|
import re
|
|
|
|
import zipfile
|
2011-03-17 00:27:42 +01:00
|
|
|
import hashlib
|
2010-10-22 00:26:38 +02:00
|
|
|
from xml.dom.minidom import Document
|
|
|
|
from optparse import OptionParser
|
|
|
|
|
|
|
|
#Read configuration...
|
2010-12-17 13:31:04 +01:00
|
|
|
repo_name = None
|
|
|
|
repo_description = None
|
|
|
|
repo_icon = None
|
|
|
|
repo_url = None
|
2010-10-22 00:26:38 +02:00
|
|
|
execfile('config.py')
|
|
|
|
|
2011-02-17 21:16:26 +01:00
|
|
|
import common
|
2010-11-11 23:34:39 +01:00
|
|
|
|
2010-10-22 00:26:38 +02:00
|
|
|
# Parse command line...
|
|
|
|
parser = OptionParser()
|
|
|
|
parser.add_option("-c", "--createmeta", action="store_true", default=False,
|
|
|
|
help="Create skeleton metadata files that are missing")
|
2010-10-25 22:27:21 +02:00
|
|
|
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
|
|
|
help="Spew out even more information than normal")
|
2011-06-27 23:47:56 +02:00
|
|
|
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
2011-01-26 17:02:30 +01:00
|
|
|
help="No output, except for warnings and errors")
|
2010-12-31 22:03:01 +01:00
|
|
|
parser.add_option("-b", "--buildreport", action="store_true", default=False,
|
|
|
|
help="Report on build data status")
|
2011-06-27 23:47:56 +02:00
|
|
|
parser.add_option("-i", "--interactive", default=False, action="store_true",
|
|
|
|
help="Interactively ask about things that need updating.")
|
|
|
|
parser.add_option("-e", "--editor", default="/etc/alternatives/editor",
|
|
|
|
help="Specify editor to use in interactive mode. Default "+
|
|
|
|
"is /etc/alternatives/editor")
|
2010-10-22 00:26:38 +02:00
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
icon_dir=os.path.join('repo','icons')
|
|
|
|
|
|
|
|
# Delete and re-create the icon directory...
|
|
|
|
if os.path.exists(icon_dir):
|
|
|
|
shutil.rmtree(icon_dir)
|
|
|
|
os.mkdir(icon_dir)
|
|
|
|
|
2011-01-02 16:15:55 +01:00
|
|
|
warnings = 0
|
|
|
|
|
2010-12-17 13:31:04 +01:00
|
|
|
#Make sure we have the repository description...
|
|
|
|
if (repo_url is None or repo_name is None or
|
|
|
|
repo_icon is None or repo_description is None):
|
|
|
|
print "Repository description fields are required in config.py"
|
|
|
|
print "See config.sample.py for details"
|
|
|
|
sys.exit(1)
|
|
|
|
|
2011-01-05 23:20:57 +01:00
|
|
|
# Get all apps...
|
2011-02-17 21:16:26 +01:00
|
|
|
apps = common.read_metadata(verbose=options.verbose)
|
2011-01-05 23:20:57 +01:00
|
|
|
|
|
|
|
# Copy apks and source tarballs for stuff we've built from source that
|
|
|
|
# is flagged to be included in the repo...
|
|
|
|
for app in apps:
|
|
|
|
if app['usebuilt']:
|
2011-01-26 17:02:30 +01:00
|
|
|
if not options.quiet:
|
|
|
|
print "Copying built files for " + app['id']
|
2011-01-05 23:20:57 +01:00
|
|
|
src = os.path.join('built', app['id'] + "_*")
|
|
|
|
for file in glob.glob(src):
|
|
|
|
shutil.copy(file, 'repo/')
|
|
|
|
|
2010-10-22 00:26:38 +02:00
|
|
|
# Gather information about all the apk files in the repo directory...
|
|
|
|
apks = []
|
|
|
|
for apkfile in glob.glob(os.path.join('repo','*.apk')):
|
|
|
|
|
|
|
|
apkfilename = apkfile[5:]
|
2011-01-26 19:05:35 +01:00
|
|
|
srcfilename = apkfilename[:-4] + "_src.tar.gz"
|
2010-10-22 00:26:38 +02:00
|
|
|
|
2011-01-26 17:02:30 +01:00
|
|
|
if not options.quiet:
|
|
|
|
print "Processing " + apkfilename
|
2010-10-22 00:26:38 +02:00
|
|
|
thisinfo = {}
|
|
|
|
thisinfo['apkname'] = apkfilename
|
2011-01-26 19:05:35 +01:00
|
|
|
if os.path.exists(os.path.join('repo', srcfilename)):
|
|
|
|
thisinfo['srcname'] = srcfilename
|
2010-10-25 22:27:21 +02:00
|
|
|
thisinfo['size'] = os.path.getsize(apkfile)
|
|
|
|
thisinfo['permissions'] = []
|
|
|
|
thisinfo['features'] = []
|
2011-04-06 20:55:27 +02:00
|
|
|
p = subprocess.Popen([os.path.join(sdk_path, 'platform-tools', 'aapt'),
|
|
|
|
'dump', 'badging', apkfile],
|
|
|
|
stdout=subprocess.PIPE)
|
2010-10-22 00:26:38 +02:00
|
|
|
output = p.communicate()[0]
|
2010-10-25 22:27:21 +02:00
|
|
|
if options.verbose:
|
2010-10-22 00:26:38 +02:00
|
|
|
print output
|
2010-10-25 22:27:21 +02:00
|
|
|
if p.returncode != 0:
|
|
|
|
print "ERROR: Failed to get apk information"
|
2010-10-22 00:26:38 +02:00
|
|
|
sys.exit(1)
|
|
|
|
for line in output.splitlines():
|
|
|
|
if line.startswith("package:"):
|
2010-11-19 00:23:40 +01:00
|
|
|
pat = re.compile(".*name='([a-zA-Z0-9.]*)'.*")
|
2010-10-22 00:26:38 +02:00
|
|
|
thisinfo['id'] = re.match(pat, line).group(1)
|
|
|
|
pat = re.compile(".*versionCode='([0-9]*)'.*")
|
2011-01-22 13:29:22 +01:00
|
|
|
thisinfo['versioncode'] = int(re.match(pat, line).group(1))
|
2010-10-22 00:26:38 +02:00
|
|
|
pat = re.compile(".*versionName='([^']*)'.*")
|
|
|
|
thisinfo['version'] = re.match(pat, line).group(1)
|
|
|
|
if line.startswith("application:"):
|
|
|
|
pat = re.compile(".*label='([^']*)'.*")
|
|
|
|
thisinfo['name'] = re.match(pat, line).group(1)
|
|
|
|
pat = re.compile(".*icon='([^']*)'.*")
|
|
|
|
thisinfo['iconsrc'] = re.match(pat, line).group(1)
|
2010-10-25 22:27:21 +02:00
|
|
|
if line.startswith("sdkVersion:"):
|
|
|
|
pat = re.compile(".*'([0-9]*)'.*")
|
|
|
|
thisinfo['sdkversion'] = re.match(pat, line).group(1)
|
|
|
|
if line.startswith("native-code:"):
|
|
|
|
pat = re.compile(".*'([^']*)'.*")
|
|
|
|
thisinfo['nativecode'] = re.match(pat, line).group(1)
|
|
|
|
if line.startswith("uses-permission:"):
|
|
|
|
pat = re.compile(".*'([^']*)'.*")
|
|
|
|
perm = re.match(pat, line).group(1)
|
|
|
|
if perm.startswith("android.permission."):
|
|
|
|
perm = perm[19:]
|
|
|
|
thisinfo['permissions'].append(perm)
|
|
|
|
if line.startswith("uses-feature:"):
|
|
|
|
pat = re.compile(".*'([^']*)'.*")
|
|
|
|
perm = re.match(pat, line).group(1)
|
|
|
|
if perm.startswith("android.feature."):
|
|
|
|
perm = perm[16:]
|
|
|
|
thisinfo['features'].append(perm)
|
|
|
|
|
|
|
|
if not thisinfo.has_key('sdkversion'):
|
|
|
|
print " WARNING: no SDK version information found"
|
|
|
|
thisinfo['sdkversion'] = 0
|
2010-10-22 00:26:38 +02:00
|
|
|
|
2011-03-17 00:27:42 +01:00
|
|
|
# Calculate the md5 and sha256...
|
|
|
|
m = hashlib.md5()
|
|
|
|
sha = hashlib.sha256()
|
2010-10-22 00:26:38 +02:00
|
|
|
f = open(apkfile, 'rb')
|
|
|
|
while True:
|
|
|
|
t = f.read(1024)
|
|
|
|
if len(t) == 0:
|
|
|
|
break
|
|
|
|
m.update(t)
|
2011-03-17 00:27:42 +01:00
|
|
|
sha.update(t)
|
2010-10-22 00:26:38 +02:00
|
|
|
thisinfo['md5'] = m.hexdigest()
|
2011-03-17 00:27:42 +01:00
|
|
|
thisinfo['sha256'] = sha.hexdigest()
|
2010-10-22 00:26:38 +02:00
|
|
|
f.close()
|
|
|
|
|
2011-01-16 12:33:57 +01:00
|
|
|
# Get the signature (or md5 of, to be precise)...
|
2011-02-17 22:19:36 +01:00
|
|
|
p = subprocess.Popen(['java', 'getsig',
|
|
|
|
os.path.join(os.getcwd(), apkfile)],
|
|
|
|
cwd=os.path.join(sys.path[0], 'getsig'),
|
|
|
|
stdout=subprocess.PIPE)
|
2011-01-16 12:33:57 +01:00
|
|
|
output = p.communicate()[0]
|
|
|
|
if options.verbose:
|
|
|
|
print output
|
|
|
|
if p.returncode != 0 or not output.startswith('Result:'):
|
|
|
|
print "ERROR: Failed to get apk signature"
|
|
|
|
sys.exit(1)
|
|
|
|
thisinfo['sig'] = output[7:].strip()
|
|
|
|
|
2010-10-22 00:26:38 +02:00
|
|
|
# Extract the icon file...
|
|
|
|
apk = zipfile.ZipFile(apkfile, 'r')
|
|
|
|
thisinfo['icon'] = (thisinfo['id'] + '.' +
|
2011-01-22 13:29:22 +01:00
|
|
|
str(thisinfo['versioncode']) + '.png')
|
2010-10-22 00:26:38 +02:00
|
|
|
iconfilename = os.path.join(icon_dir, thisinfo['icon'])
|
2011-01-02 16:15:55 +01:00
|
|
|
try:
|
|
|
|
iconfile = open(iconfilename, 'wb')
|
|
|
|
iconfile.write(apk.read(thisinfo['iconsrc']))
|
|
|
|
iconfile.close()
|
|
|
|
except:
|
|
|
|
print "WARNING: Error retrieving icon file"
|
|
|
|
warnings += 1
|
2010-10-22 00:26:38 +02:00
|
|
|
apk.close()
|
|
|
|
|
|
|
|
apks.append(thisinfo)
|
|
|
|
|
|
|
|
# Some information from the apks needs to be applied up to the application
|
|
|
|
# level. When doing this, we use the info from the most recent version's apk.
|
|
|
|
for app in apps:
|
|
|
|
bestver = 0
|
|
|
|
for apk in apks:
|
|
|
|
if apk['id'] == app['id']:
|
|
|
|
if apk['versioncode'] > bestver:
|
|
|
|
bestver = apk['versioncode']
|
|
|
|
bestapk = apk
|
|
|
|
|
|
|
|
if bestver == 0:
|
2010-12-29 17:43:04 +01:00
|
|
|
if app['name'] is None:
|
|
|
|
app['name'] = app['id']
|
2010-10-22 00:26:38 +02:00
|
|
|
app['icon'] = ''
|
2011-01-23 23:43:01 +01:00
|
|
|
if app['disabled'] is None:
|
|
|
|
print "WARNING: Application " + app['id'] + " has no packages"
|
2010-10-22 00:26:38 +02:00
|
|
|
else:
|
2010-12-29 17:43:04 +01:00
|
|
|
if app['name'] is None:
|
|
|
|
app['name'] = bestapk['name']
|
2010-10-22 00:26:38 +02:00
|
|
|
app['icon'] = bestapk['icon']
|
|
|
|
|
|
|
|
# Generate warnings for apk's with no metadata (or create skeleton
|
|
|
|
# metadata files, if requested on the command line)
|
|
|
|
for apk in apks:
|
|
|
|
found = False
|
|
|
|
for app in apps:
|
|
|
|
if app['id'] == apk['id']:
|
|
|
|
found = True
|
|
|
|
break
|
|
|
|
if not found:
|
|
|
|
if options.createmeta:
|
|
|
|
f = open(os.path.join('metadata', apk['id'] + '.txt'), 'w')
|
|
|
|
f.write("License:Unknown\n")
|
|
|
|
f.write("Web Site:\n")
|
|
|
|
f.write("Source Code:\n")
|
|
|
|
f.write("Issue Tracker:\n")
|
|
|
|
f.write("Summary:" + apk['name'] + "\n")
|
|
|
|
f.write("Description:\n")
|
|
|
|
f.write(apk['name'] + "\n")
|
|
|
|
f.write(".\n")
|
|
|
|
f.close()
|
|
|
|
print "Generated skeleton metadata for " + apk['id']
|
|
|
|
else:
|
|
|
|
print "WARNING: " + apk['apkname'] + " (" + apk['id'] + ") has no metadata"
|
|
|
|
print " " + apk['name'] + " - " + apk['version']
|
|
|
|
|
2010-12-06 22:29:41 +01:00
|
|
|
#Sort the app list by name, then the web site doesn't have to by default:
|
2011-01-17 08:51:30 +01:00
|
|
|
apps = sorted(apps, key=lambda app: app['name'].upper())
|
2010-12-06 22:29:41 +01:00
|
|
|
|
2010-10-22 00:26:38 +02:00
|
|
|
# Create the index
|
|
|
|
doc = Document()
|
|
|
|
|
|
|
|
def addElement(name, value, doc, parent):
|
|
|
|
el = doc.createElement(name)
|
|
|
|
el.appendChild(doc.createTextNode(value))
|
|
|
|
parent.appendChild(el)
|
|
|
|
|
|
|
|
root = doc.createElement("fdroid")
|
|
|
|
doc.appendChild(root)
|
|
|
|
|
2010-12-17 13:31:04 +01:00
|
|
|
repoel = doc.createElement("repo")
|
|
|
|
repoel.setAttribute("name", repo_name)
|
2011-02-25 23:11:39 +01:00
|
|
|
repoel.setAttribute("icon", os.path.basename(repo_icon))
|
2010-12-17 13:31:04 +01:00
|
|
|
repoel.setAttribute("url", repo_url)
|
2011-03-28 19:06:38 +02:00
|
|
|
|
2011-01-29 10:32:21 +01:00
|
|
|
if repo_keyalias != None:
|
2011-03-28 19:06:38 +02:00
|
|
|
|
|
|
|
# Generate a certificate fingerprint the same way keytool does it
|
|
|
|
# (but with slightly different formatting)
|
|
|
|
def cert_fingerprint(data):
|
|
|
|
digest = hashlib.sha1(data).digest()
|
|
|
|
ret = []
|
|
|
|
for i in range(4):
|
|
|
|
ret.append(":".join("%02X" % ord(b) for b in digest[i*5:i*5+5]))
|
|
|
|
return " ".join(ret)
|
|
|
|
|
2011-03-27 05:14:06 +02:00
|
|
|
def extract_pubkey():
|
|
|
|
p = subprocess.Popen(['keytool', '-exportcert',
|
|
|
|
'-alias', repo_keyalias,
|
|
|
|
'-keystore', keystore,
|
|
|
|
'-storepass', keystorepass],
|
|
|
|
stdout=subprocess.PIPE)
|
|
|
|
cert = p.communicate()[0]
|
|
|
|
if p.returncode != 0:
|
|
|
|
print "ERROR: Failed to get repo pubkey"
|
|
|
|
sys.exit(1)
|
2011-03-28 19:06:38 +02:00
|
|
|
global repo_pubkey_fingerprint
|
|
|
|
repo_pubkey_fingerprint = cert_fingerprint(cert)
|
2011-03-27 05:14:06 +02:00
|
|
|
return "".join("%02x" % ord(b) for b in cert)
|
2011-03-28 19:06:38 +02:00
|
|
|
|
2011-03-27 05:14:06 +02:00
|
|
|
repoel.setAttribute("pubkey", extract_pubkey())
|
2011-03-28 19:06:38 +02:00
|
|
|
|
2010-12-17 13:31:04 +01:00
|
|
|
addElement('description', repo_description, doc, repoel)
|
|
|
|
root.appendChild(repoel)
|
|
|
|
|
2010-10-22 21:38:54 +02:00
|
|
|
apps_inrepo = 0
|
|
|
|
apps_disabled = 0
|
2011-01-23 22:54:49 +01:00
|
|
|
apps_nopkg = 0
|
2010-10-22 21:38:54 +02:00
|
|
|
|
2010-10-22 00:26:38 +02:00
|
|
|
for app in apps:
|
|
|
|
|
2010-10-22 21:38:54 +02:00
|
|
|
if app['disabled'] is None:
|
|
|
|
|
2011-01-22 13:29:22 +01:00
|
|
|
# Get a list of the apks for this app...
|
2011-01-23 23:03:46 +01:00
|
|
|
gotmarketver = False
|
2011-01-22 13:29:22 +01:00
|
|
|
apklist = []
|
2010-10-22 21:38:54 +02:00
|
|
|
for apk in apks:
|
|
|
|
if apk['id'] == app['id']:
|
2011-01-22 13:29:22 +01:00
|
|
|
if str(apk['versioncode']) == app['marketvercode']:
|
2010-10-29 23:06:39 +02:00
|
|
|
gotmarketver = True
|
2011-01-22 13:29:22 +01:00
|
|
|
apklist.append(apk)
|
|
|
|
|
2011-01-23 22:54:49 +01:00
|
|
|
if len(apklist) == 0:
|
|
|
|
apps_nopkg += 1
|
|
|
|
else:
|
|
|
|
apps_inrepo += 1
|
|
|
|
apel = doc.createElement("application")
|
|
|
|
apel.setAttribute("id", app['id'])
|
|
|
|
root.appendChild(apel)
|
|
|
|
|
|
|
|
addElement('id', app['id'], doc, apel)
|
|
|
|
addElement('name', app['name'], doc, apel)
|
|
|
|
addElement('summary', app['summary'], doc, apel)
|
|
|
|
addElement('icon', app['icon'], doc, apel)
|
|
|
|
addElement('description', app['description'], doc, apel)
|
|
|
|
addElement('license', app['license'], doc, apel)
|
|
|
|
addElement('web', app['web'], doc, apel)
|
|
|
|
addElement('source', app['source'], doc, apel)
|
|
|
|
addElement('tracker', app['tracker'], doc, apel)
|
|
|
|
if app['donate'] != None:
|
|
|
|
addElement('donate', app['donate'], doc, apel)
|
|
|
|
addElement('marketversion', app['marketversion'], doc, apel)
|
|
|
|
addElement('marketvercode', app['marketvercode'], doc, apel)
|
|
|
|
if not (app['antifeatures'] is None):
|
|
|
|
addElement('antifeatures', app['antifeatures'], doc, apel)
|
2011-03-08 16:13:46 +01:00
|
|
|
if app['requiresroot']:
|
|
|
|
addElement('requirements', 'root', doc, apel)
|
2011-01-23 22:54:49 +01:00
|
|
|
|
|
|
|
# Sort the apk list into version order, just so the web site
|
|
|
|
# doesn't have to do any work by default...
|
|
|
|
apklist = sorted(apklist, key=lambda apk: apk['versioncode'], reverse=True)
|
|
|
|
|
2011-05-11 23:22:46 +02:00
|
|
|
# Check for duplicates - they will make the client unhappy...
|
|
|
|
for i in range(len(apklist) - 1):
|
|
|
|
if apklist[i]['versioncode'] == apklist[i+1]['versioncode']:
|
|
|
|
print "ERROR - duplicate versions"
|
|
|
|
print apklist[i]['apkname']
|
|
|
|
print apklist[i+1]['apkname']
|
|
|
|
sys.exit(1)
|
|
|
|
|
2011-01-23 22:54:49 +01:00
|
|
|
for apk in apklist:
|
|
|
|
apkel = doc.createElement("package")
|
|
|
|
apel.appendChild(apkel)
|
|
|
|
addElement('version', apk['version'], doc, apkel)
|
|
|
|
addElement('versioncode', str(apk['versioncode']), doc, apkel)
|
|
|
|
addElement('apkname', apk['apkname'], doc, apkel)
|
2011-01-26 19:05:35 +01:00
|
|
|
if apk.has_key('srcname'):
|
|
|
|
addElement('srcname', apk['srcname'], doc, apkel)
|
2011-03-17 00:27:42 +01:00
|
|
|
for hash_type in ('sha256', 'md5'):
|
|
|
|
if not hash_type in apk:
|
|
|
|
continue
|
|
|
|
hashel = doc.createElement("hash")
|
|
|
|
hashel.setAttribute("type", hash_type)
|
|
|
|
hashel.appendChild(doc.createTextNode(apk[hash_type]))
|
|
|
|
apkel.appendChild(hashel)
|
2011-01-23 22:54:49 +01:00
|
|
|
addElement('sig', apk['sig'], doc, apkel)
|
|
|
|
addElement('size', str(apk['size']), doc, apkel)
|
|
|
|
addElement('sdkver', str(apk['sdkversion']), doc, apkel)
|
|
|
|
perms = ""
|
|
|
|
for p in apk['permissions']:
|
|
|
|
if len(perms) > 0:
|
|
|
|
perms += ","
|
|
|
|
perms += p
|
2010-10-25 22:27:21 +02:00
|
|
|
if len(perms) > 0:
|
2011-01-23 22:54:49 +01:00
|
|
|
addElement('permissions', perms, doc, apkel)
|
|
|
|
features = ""
|
|
|
|
for f in apk['features']:
|
|
|
|
if len(features) > 0:
|
|
|
|
features += ","
|
|
|
|
features += f
|
2010-10-25 22:27:21 +02:00
|
|
|
if len(features) > 0:
|
2011-01-23 22:54:49 +01:00
|
|
|
addElement('features', features, doc, apkel)
|
2010-10-25 22:27:21 +02:00
|
|
|
|
2010-12-31 22:03:01 +01:00
|
|
|
if options.buildreport:
|
|
|
|
if len(app['builds']) == 0:
|
|
|
|
print ("WARNING: No builds defined for " + app['id'] +
|
|
|
|
" Source: " + app['source'])
|
|
|
|
warnings += 1
|
|
|
|
else:
|
|
|
|
if app['marketvercode'] != '0':
|
|
|
|
gotbuild = False
|
|
|
|
for build in app['builds']:
|
|
|
|
if build['vercode'] == app['marketvercode']:
|
|
|
|
gotbuild = True
|
|
|
|
if not gotbuild:
|
|
|
|
print ("WARNING: No build data for market version of "
|
|
|
|
+ app['id'] + " (" + app['marketversion']
|
|
|
|
+ ") " + app['source'])
|
|
|
|
warnings += 1
|
|
|
|
|
2011-03-02 22:47:48 +01:00
|
|
|
# If we don't have the market version, check if there is a build
|
|
|
|
# with a commit ID starting with '!' - this means we can't build it
|
|
|
|
# for some reason, and don't want hassling about it...
|
|
|
|
if not gotmarketver and app['marketvercode'] != '0':
|
|
|
|
for build in app['builds']:
|
|
|
|
if build['vercode'] == app['marketvercode']:
|
|
|
|
gotmarketver = True
|
|
|
|
|
|
|
|
# Output a message of harassment if we don't have the market version:
|
2010-10-29 23:06:39 +02:00
|
|
|
if not gotmarketver and app['marketvercode'] != '0':
|
2011-01-27 22:22:19 +01:00
|
|
|
if app['usebuilt']:
|
|
|
|
addr = app['source']
|
|
|
|
else:
|
|
|
|
addr = app['web']
|
2010-10-29 23:06:39 +02:00
|
|
|
print "WARNING: Don't have market version (" + app['marketversion'] + ") of " + app['name']
|
2011-01-27 22:22:19 +01:00
|
|
|
print " (" + app['id'] + ") " + addr
|
2010-12-31 22:03:01 +01:00
|
|
|
warnings += 1
|
2010-12-04 23:56:13 +01:00
|
|
|
if options.verbose:
|
|
|
|
# A bit of extra debug info, basically for diagnosing
|
|
|
|
# app developer mistakes:
|
|
|
|
print " Market vercode:" + app['marketvercode']
|
|
|
|
print " Got:"
|
|
|
|
for apk in apks:
|
|
|
|
if apk['id'] == app['id']:
|
2011-01-22 13:29:22 +01:00
|
|
|
print " " + str(apk['versioncode']) + " - " + apk['version']
|
2011-06-27 23:47:56 +02:00
|
|
|
if options.interactive:
|
|
|
|
print "Build data out of date for " + app['id']
|
|
|
|
while True:
|
|
|
|
answer = raw_input("[I]gnore, [E]dit or [Q]uit?").lower()
|
|
|
|
if answer == 'i':
|
|
|
|
break
|
|
|
|
elif answer == 'e':
|
|
|
|
subprocess.call([options.editor,
|
|
|
|
os.path.join('metadata',
|
|
|
|
app['id'] + '.txt')])
|
|
|
|
break
|
|
|
|
elif answer == 'q':
|
|
|
|
sys.exit(0)
|
2010-10-22 21:38:54 +02:00
|
|
|
else:
|
|
|
|
apps_disabled += 1
|
2010-10-22 00:26:38 +02:00
|
|
|
|
|
|
|
of = open(os.path.join('repo','index.xml'), 'wb')
|
2011-01-17 10:13:55 +01:00
|
|
|
output = doc.toxml()
|
2010-10-22 00:26:38 +02:00
|
|
|
of.write(output)
|
|
|
|
of.close()
|
|
|
|
|
2011-01-29 10:32:21 +01:00
|
|
|
if repo_keyalias != None:
|
|
|
|
|
|
|
|
if not options.quiet:
|
|
|
|
print "Creating signed index."
|
2011-03-28 19:06:38 +02:00
|
|
|
print "Key fingerprint:", repo_pubkey_fingerprint
|
2011-01-29 10:32:21 +01:00
|
|
|
|
|
|
|
#Create a jar of the index...
|
|
|
|
p = subprocess.Popen(['jar', 'cf', 'index.jar', 'index.xml'],
|
|
|
|
cwd='repo', stdout=subprocess.PIPE)
|
|
|
|
output = p.communicate()[0]
|
|
|
|
if options.verbose:
|
|
|
|
print output
|
|
|
|
if p.returncode != 0:
|
|
|
|
print "ERROR: Failed to create jar file"
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# Sign the index...
|
|
|
|
p = subprocess.Popen(['jarsigner', '-keystore', keystore,
|
|
|
|
'-storepass', keystorepass, '-keypass', keypass,
|
|
|
|
os.path.join('repo', 'index.jar') , repo_keyalias], stdout=subprocess.PIPE)
|
|
|
|
output = p.communicate()[0]
|
|
|
|
if p.returncode != 0:
|
|
|
|
print "Failed to sign index"
|
|
|
|
print output
|
|
|
|
sys.exit(1)
|
|
|
|
if options.verbose:
|
|
|
|
print output
|
|
|
|
|
2010-12-17 13:31:04 +01:00
|
|
|
#Copy the repo icon into the repo directory...
|
2011-02-25 23:11:39 +01:00
|
|
|
iconfilename = os.path.join(icon_dir, os.path.basename(repo_icon))
|
2010-12-17 13:31:04 +01:00
|
|
|
shutil.copyfile(repo_icon, iconfilename)
|
|
|
|
|
2010-10-22 00:26:38 +02:00
|
|
|
print "Finished."
|
2010-10-22 21:38:54 +02:00
|
|
|
print str(apps_inrepo) + " apps in repo"
|
|
|
|
print str(apps_disabled) + " disabled"
|
2011-01-23 22:54:49 +01:00
|
|
|
print str(apps_nopkg) + " with no packages"
|
2010-12-31 22:03:01 +01:00
|
|
|
print str(warnings) + " warnings"
|
2010-10-22 00:26:38 +02:00
|
|
|
|