import common
import metadata
-from common import FDroidPopen
+from common import FDroidPopen, SilentPopen
from metadata import MetaDataException
apklist.append(apk)
# Include ones we can't build, as a special case...
for thisbuild in app['builds']:
- if 'disable' in thisbuild:
+ if thisbuild['disable']:
if thisbuild['vercode'] == app['Current Version Code']:
cantupdate = True
# TODO: Nasty: vercode is a string in the build, and an int elsewhere
"""
for app in apps:
for build in app['builds']:
- if 'disable' in build:
+ if build['disable']:
apkfilename = app['id'] + '_' + str(build['vercode']) + '.apk'
for repodir in repodirs:
apkpath = os.path.join(repodir, apkfilename)
iconpath, oldsize, im.size))
im.save(iconpath, "PNG")
- else:
- logging.info("%s is small enough: %s" % im.size)
-
except Exception, e:
logging.error("Failed resizing {0} - {1}".format(iconpath, e))
apkfilename = apkfile[len(repodir) + 1:]
if ' ' in apkfilename:
- logging.error("No spaces in APK filenames!")
+ logging.critical("Spaces in filenames are not allowed.")
sys.exit(1)
if apkfilename in apkcache:
thisinfo = apkcache[apkfilename]
else:
-
- logging.info("Processing " + apkfilename)
+ logging.debug("Processing " + apkfilename)
thisinfo = {}
thisinfo['apkname'] = apkfilename
srcfilename = apkfilename[:-4] + "_src.tar.gz"
thisinfo['features'] = []
thisinfo['icons_src'] = {}
thisinfo['icons'] = {}
- p = FDroidPopen([os.path.join(config['sdk_path'], 'build-tools',
- config['build_tools'], 'aapt'),
- 'dump', 'badging', apkfile])
+ p = SilentPopen([config['aapt'], 'dump', 'badging', apkfile])
if p.returncode != 0:
- logging.critical("Failed to get apk information")
- sys.exit(1)
- for line in p.stdout.splitlines():
+ if options.delete_unknown:
+ if os.path.exists(apkfile):
+ logging.error("Failed to get apk information, deleting " + apkfile)
+ os.remove(apkfile)
+ else:
+ logging.error("Could not find {0} to remove it".format(apkfile))
+ else:
+ logging.error("Failed to get apk information, skipping " + apkfile)
+ continue
+ for line in p.output.splitlines():
if line.startswith("package:"):
try:
thisinfo['id'] = re.match(name_pat, line).group(1)
thisinfo['versioncode'] = int(re.match(vercode_pat, line).group(1))
thisinfo['version'] = re.match(vername_pat, line).group(1)
except Exception, e:
- logging.info("Package matching failed: " + str(e))
+ logging.error("Package matching failed: " + str(e))
logging.info("Line was: " + line)
sys.exit(1)
elif line.startswith("application:"):
path = match.group(2)
thisinfo['icons_src'][density] = path
elif line.startswith("sdkVersion:"):
- thisinfo['sdkversion'] = re.match(sdkversion_pat, line).group(1)
+ m = re.match(sdkversion_pat, line)
+ if m is None:
+ logging.error(line.replace('sdkVersion:', '')
+ + ' is not a valid minSdkVersion!')
+ else:
+ thisinfo['sdkversion'] = m.group(1)
elif line.startswith("maxSdkVersion:"):
thisinfo['maxsdkversion'] = re.match(sdkversion_pat, line).group(1)
elif line.startswith("native-code:"):
# Check for debuggable apks...
if common.isApkDebuggable(apkfile, config):
- logging.warn("{0} is debuggable... {1}".format(apkfile, line))
+ logging.warn('{0} is set to android:debuggable="true"!'.format(apkfile))
# Calculate the sha256...
sha = hashlib.sha256()
sys.exit(1)
p = FDroidPopen(['java', '-cp', os.path.join(os.path.dirname(__file__), 'getsig'),
'getsig', os.path.join(os.getcwd(), apkfile)])
- if p.returncode != 0 or not p.stdout.startswith('Result:'):
+ if p.returncode != 0 or not p.output.startswith('Result:'):
logging.critical("Failed to get apk signature")
sys.exit(1)
- thisinfo['sig'] = p.stdout[7:].strip()
+ thisinfo['sig'] = p.output[7:].strip()
apk = zipfile.ZipFile(apkfile, 'r')
continue
if last_density is None:
continue
- logging.info("Density %s not available, resizing down from %s"
- % (density, last_density))
+ logging.debug("Density %s not available, resizing down from %s"
+ % (density, last_density))
last_iconpath = os.path.join(
get_icon_dir(repodir, last_density), iconfilename)
continue
if last_density is None:
continue
- logging.info("Density %s not available, copying from lower density %s"
- % (density, last_density))
+ logging.debug("Density %s not available, copying from lower density %s"
+ % (density, last_density))
shutil.copyfile(
os.path.join(get_icon_dir(repodir, last_density), iconfilename),
'-alias', config['repo_keyalias'],
'-keystore', config['keystore'],
'-storepass:file', config['keystorepassfile']]
- + config['smartcardoptions'])
+ + config['smartcardoptions'], output=False)
if p.returncode != 0:
msg = "Failed to get repo pubkey!"
if config['keystore'] == 'NONE':
logging.critical(msg)
sys.exit(1)
global repo_pubkey_fingerprint
- repo_pubkey_fingerprint = cert_fingerprint(p.stdout)
- return "".join("%02x" % ord(b) for b in p.stdout)
+ repo_pubkey_fingerprint = cert_fingerprint(p.output)
+ return "".join("%02x" % ord(b) for b in p.output)
repoel.setAttribute("pubkey", extract_pubkey())
if 'repo_keyalias' in config:
- logging.info("Creating signed index with this key:")
- logging.info("SHA256: %s" % repo_pubkey_fingerprint)
+ logging.info("Creating signed index with this key (SHA256):")
+ logging.info("%s" % repo_pubkey_fingerprint)
# Create a jar of the index...
p = FDroidPopen(['jar', 'cf', 'index.jar', 'index.xml'], cwd=repodir)
p = FDroidPopen(args)
# TODO keypass should be sent via stdin
if p.returncode != 0:
- logging.info("Failed to sign index")
+ logging.critical("Failed to sign index")
sys.exit(1)
# Copy the repo icon into the repo directory...
if 'srcname' in apk:
shutil.move(os.path.join(repodir, apk['srcname']),
os.path.join(archivedir, apk['srcname']))
+ # Move GPG signature too...
+ sigfile = apk['srcname'] + '.asc'
+ sigsrc = os.path.join(repodir, sigfile)
+ if os.path.exists(sigsrc):
+ shutil.move(sigsrc, os.path.join(archivedir, sigfile))
+
archapks.append(apk)
apks.remove(apk)
# Parse command line...
parser = OptionParser()
- parser.add_option("-c", "--createmeta", action="store_true", default=False,
+ parser.add_option("-c", "--create-metadata", action="store_true", default=False,
help="Create skeleton metadata files that are missing")
parser.add_option("--delete-unknown", action="store_true", default=False,
help="Delete APKs without metadata from the repo")
resize_all_icons(repodirs)
sys.exit(0)
+ # check that icons exist now, rather than fail at the end of `fdroid update`
+ for k in ['repo_icon', 'archive_icon']:
+ if k in config:
+ if not os.path.exists(config[k]):
+ logging.critical(k + ' "' + config[k] + '" does not exist! Correct it in config.py.')
+ sys.exit(1)
+
# Get all apps...
apps = metadata.read_metadata()
found = True
break
if not found:
- if options.createmeta:
+ if options.create_metadata:
+ if 'name' not in apk:
+ logging.error(apk['id'] + ' does not have a name! Skipping...')
+ continue
f = open(os.path.join('metadata', apk['id'] + '.txt'), 'w')
f.write("License:Unknown\n")
f.write("Web Site:\n")