Merge branch 'some-compatibility-fixes' of https://gitlab.com/eighthave/fdroidserver

This commit is contained in:
Daniel Martí 2015-07-27 10:41:23 -07:00
commit b4d768b225
5 changed files with 35 additions and 9 deletions

View file

@ -1090,9 +1090,7 @@ def main():
logging.info("...retrieving " + url) logging.info("...retrieving " + url)
of = "{0}_{1}.apk.binary".format(app['id'], thisbuild['vercode']) of = "{0}_{1}.apk.binary".format(app['id'], thisbuild['vercode'])
of = os.path.join(output_dir, of) of = os.path.join(output_dir, of)
p = FDroidPopen(['wget', '-nv', '-O', of, url]) common.download_file(url, local_filename=of)
if p.returncode != 0 or not os.path.exists(of):
raise BuildException("...failed to retrieve " + url)
build_succeeded.append(app) build_succeeded.append(app)
wikilog = "Build succeeded" wikilog = "Build succeeded"

View file

@ -22,6 +22,7 @@ import sys
import re import re
import shutil import shutil
import glob import glob
import requests
import stat import stat
import subprocess import subprocess
import time import time
@ -70,8 +71,8 @@ default_config = {
'keystore': 'keystore.jks', 'keystore': 'keystore.jks',
'smartcardoptions': [], 'smartcardoptions': [],
'char_limits': { 'char_limits': {
'Summary': 50, 'Summary': 80,
'Description': 1500 'Description': 4000
}, },
'keyaliases': {}, 'keyaliases': {},
'repo_url': "https://MyFirstFDroidRepo.org/fdroid/repo", 'repo_url': "https://MyFirstFDroidRepo.org/fdroid/repo",
@ -2072,3 +2073,17 @@ def string_is_integer(string):
return True return True
except ValueError: except ValueError:
return False return False
def download_file(url, local_filename=None, dldir='tmp'):
filename = url.split('/')[-1]
if local_filename is None:
local_filename = os.path.join(dldir, filename)
# the stream=True parameter keeps memory usage low
r = requests.get(url, stream=True)
with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
f.flush()
return local_filename

View file

@ -27,6 +27,7 @@ import socket
import zipfile import zipfile
import hashlib import hashlib
import pickle import pickle
from datetime import datetime, timedelta
from xml.dom.minidom import Document from xml.dom.minidom import Document
from optparse import OptionParser from optparse import OptionParser
import time import time
@ -542,6 +543,19 @@ def scan_apks(apps, apkcache, repodir, knownapks):
apk = zipfile.ZipFile(apkfile, 'r') apk = zipfile.ZipFile(apkfile, 'r')
# if an APK has files newer than the system time, suggest updating
# the system clock. This is useful for offline systems, used for
# signing, which do not have another source of clock sync info. It
# has to be more than 24 hours newer because ZIP/APK files do not
# store timezone info
info = apk.getinfo('AndroidManifest.xml')
dt_obj = datetime(*info.date_time)
checkdt = dt_obj - timedelta(1)
if datetime.today() < checkdt:
logging.warn('System clock is older than manifest in: '
+ apkfilename + '\nSet clock to that time using:\n'
+ 'sudo date -s "' + str(dt_obj) + '"')
iconfilename = "%s.%s.png" % ( iconfilename = "%s.%s.png" % (
thisinfo['id'], thisinfo['id'],
thisinfo['versioncode']) thisinfo['versioncode'])

View file

@ -24,7 +24,7 @@ from optparse import OptionParser
import logging import logging
import common import common
from common import FDroidPopen, FDroidException from common import FDroidException
options = None options = None
config = None config = None
@ -78,9 +78,7 @@ def main():
os.remove(remoteapk) os.remove(remoteapk)
url = 'https://f-droid.org/repo/' + apkfilename url = 'https://f-droid.org/repo/' + apkfilename
logging.info("...retrieving " + url) logging.info("...retrieving " + url)
p = FDroidPopen(['wget', '-nv', url], cwd=tmp_dir) common.download_file(url, dldir=tmp_dir)
if p.returncode != 0:
raise FDroidException("Failed to get " + apkfilename)
compare_result = common.compare_apks( compare_result = common.compare_apks(
os.path.join(unsigned_dir, apkfilename), os.path.join(unsigned_dir, apkfilename),

View file

@ -28,6 +28,7 @@ setup(name='fdroidserver',
'apache-libcloud >= 0.14.1', 'apache-libcloud >= 0.14.1',
'pyasn1', 'pyasn1',
'pyasn1-modules', 'pyasn1-modules',
'requests',
], ],
classifiers=[ classifiers=[
'Development Status :: 3 - Alpha', 'Development Status :: 3 - Alpha',