Merge branch 'nail-down-btlog-and-bugfix' into 'master'

Nail down btlog and key bugfix

See merge request !248
This commit is contained in:
Torsten Grote 2017-04-10 21:21:52 +00:00
commit cb942168d5
7 changed files with 35 additions and 38 deletions

View file

@ -223,7 +223,7 @@ The repository of older versions of applications from the main demo repository.
# If you want to upload the release apk file to androidobservatory.org # If you want to upload the release apk file to androidobservatory.org
# #
# uploadto_androidobservatory = False # androidobservatory = False
# If you want to upload the release apk file to virustotal.com # If you want to upload the release apk file to virustotal.com

View file

@ -42,6 +42,7 @@ import zipfile
from argparse import ArgumentParser from argparse import ArgumentParser
from . import common from . import common
from . import server
options = None options = None
@ -49,8 +50,7 @@ options = None
def make_binary_transparency_log(repodirs, btrepo='binary_transparency', def make_binary_transparency_log(repodirs, btrepo='binary_transparency',
url=None, url=None,
commit_title='fdroid update', commit_title='fdroid update'):
git_remote=None):
'''Log the indexes in a standalone git repo to serve as a "binary '''Log the indexes in a standalone git repo to serve as a "binary
transparency" log. transparency" log.
@ -142,17 +142,6 @@ For more info on this idea:
gitrepo.index.add([os.path.join(repodir, os.path.basename(f)), ]) gitrepo.index.add([os.path.join(repodir, os.path.basename(f)), ])
gitrepo.index.commit(commit_title) gitrepo.index.commit(commit_title)
if git_remote:
logging.info('Pushing binary transparency log to ' + git_remote)
origin = git.remote.Remote(gitrepo, 'origin')
if origin in gitrepo.remotes:
origin = gitrepo.remote('origin')
if 'set_url' in dir(origin): # added in GitPython 2.x
origin.set_url(git_remote)
else:
origin = gitrepo.create_remote('origin', git_remote)
origin.fetch()
origin.push('master')
def main(): def main():
@ -199,6 +188,7 @@ def main():
headers = { headers = {
'User-Agent': 'F-Droid 0.102.3' 'User-Agent': 'F-Droid 0.102.3'
} }
etag = None
if os.path.exists(http_headers_file): if os.path.exists(http_headers_file):
with open(http_headers_file) as fp: with open(http_headers_file) as fp:
etag = json.load(fp)['ETag'] etag = json.load(fp)['ETag']
@ -226,8 +216,9 @@ def main():
if new_files: if new_files:
os.chdir(tempdirbase) os.chdir(tempdirbase)
make_binary_transparency_log(repodirs, options.git_repo, options.url, 'fdroid btlog', make_binary_transparency_log(repodirs, options.git_repo, options.url, 'fdroid btlog')
git_remote=options.git_remote) if options.git_remote:
server.push_binary_transparency(options.git_repo, options.git_remote)
shutil.rmtree(tempdirbase, ignore_errors=True) shutil.rmtree(tempdirbase, ignore_errors=True)
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -281,20 +281,20 @@ def upload_to_virustotal(repo_section, vt_apikey):
logging.info(response['verbose_msg'] + " " + response['permalink']) logging.info(response['verbose_msg'] + " " + response['permalink'])
def push_binary_transparency(binary_transparency_remote): def push_binary_transparency(git_repo_path, git_remote):
'''push the binary transparency git repo to the specifed remote''' '''push the binary transparency git repo to the specifed remote'''
import git import git
repo = git.Repo('binary_transparency_log') logging.info('Pushing binary transparency log to ' + git_remote)
pushremote = None gitrepo = git.Repo(git_repo_path)
for remote in repo.remotes: origin = git.remote.Remote(gitrepo, 'origin')
if remote.url == binary_transparency_remote: if origin in gitrepo.remotes:
pushremote = remote origin = gitrepo.remote('origin')
break if 'set_url' in dir(origin): # added in GitPython 2.x
origin.set_url(git_remote)
if not pushremote: else:
pushremote = repo.create_remote('fdroid_server_update', binary_transparency_remote) origin = gitrepo.create_remote('origin', git_remote)
pushremote.push('master') origin.push('master')
def main(): def main():
@ -376,11 +376,12 @@ def main():
if not config.get('awsbucket') \ if not config.get('awsbucket') \
and not config.get('serverwebroot') \ and not config.get('serverwebroot') \
and not config.get('servergitmirrors') \ and not config.get('servergitmirrors') \
and not config.get('uploadto_androidobservatory') \ and not config.get('androidobservatory') \
and not config.get('binary_transparency_remote') \
and not config.get('virustotal_apikey') \ and not config.get('virustotal_apikey') \
and local_copy_dir is None: and local_copy_dir is None:
logging.warn('No option set! Edit your config.py to set at least one among:\n' logging.warn('No option set! Edit your config.py to set at least one among:\n'
+ 'serverwebroot, servergitmirrors, local_copy_dir, awsbucket, virustotal_apikey or uploadto_androidobservatory') + 'serverwebroot, servergitmirrors, local_copy_dir, awsbucket, virustotal_apikey, androidobservatory, or binary_transparency_remote')
sys.exit(1) sys.exit(1)
repo_sections = ['repo'] repo_sections = ['repo']
@ -428,14 +429,14 @@ def main():
update_servergitmirrors(servergitmirrors, repo_section) update_servergitmirrors(servergitmirrors, repo_section)
if config.get('awsbucket'): if config.get('awsbucket'):
update_awsbucket(repo_section) update_awsbucket(repo_section)
if config.get('uploadto_androidobservatory'): if config.get('androidobservatory'):
upload_to_android_observatory(repo_section) upload_to_android_observatory(repo_section)
if config.get('virustotal_apikey'): if config.get('virustotal_apikey'):
upload_to_virustotal(repo_section, config.get('virustotal_apikey')) upload_to_virustotal(repo_section, config.get('virustotal_apikey'))
binary_transparency_remote = config.get('binary_transparency_remote') binary_transparency_remote = config.get('binary_transparency_remote')
if binary_transparency_remote: if binary_transparency_remote:
push_binary_transparency(binary_transparency_remote) push_binary_transparency('binary_transparency', binary_transparency_remote)
sys.exit(0) sys.exit(0)

View file

@ -857,7 +857,7 @@ def scan_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk):
perm_match['maxSdkVersion'] perm_match['maxSdkVersion']
) )
apk['uses-permission'].add(permission) apk['uses-permission'].append(permission)
elif line.startswith('uses-permission-sdk-23:'): elif line.startswith('uses-permission-sdk-23:'):
perm_match = re.match(APK_PERMISSION_PAT, line).groupdict() perm_match = re.match(APK_PERMISSION_PAT, line).groupdict()
if perm_match['maxSdkVersion']: if perm_match['maxSdkVersion']:
@ -867,7 +867,7 @@ def scan_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk):
perm_match['maxSdkVersion'] perm_match['maxSdkVersion']
) )
apk['uses-permission-sdk-23'].add(permission_sdk_23) apk['uses-permission-sdk-23'].append(permission_sdk_23)
elif line.startswith('uses-feature:'): elif line.startswith('uses-feature:'):
feature = re.match(APK_FEATURE_PAT, line).group(1) feature = re.match(APK_FEATURE_PAT, line).group(1)
@ -1410,7 +1410,7 @@ def main():
git_remote = config.get('binary_transparency_remote') git_remote = config.get('binary_transparency_remote')
if git_remote or os.path.isdir(os.path.join('binary_transparency', '.git')): if git_remote or os.path.isdir(os.path.join('binary_transparency', '.git')):
btlog.make_binary_transparency_log(repodirs, git_remote=git_remote) btlog.make_binary_transparency_log(repodirs)
if config['update_stats']: if config['update_stats']:
# Update known apks info... # Update known apks info...

View file

@ -54,14 +54,18 @@
<version>0.1</version> <version>0.1</version>
<versioncode>1444412523</versioncode> <versioncode>1444412523</versioncode>
<apkname>obb.main.oldversion_1444412523.apk</apkname> <apkname>obb.main.oldversion_1444412523.apk</apkname>
<hash type="sha256">7562a36c9e2b38013b96663cf41f0f290dc7a248a81befa8d89e14f390c94c7f</hash> <hash type="sha256">c5f149e526f89c05c62923bdb7bb1e2be5673c46ec85143f41e514340631449c</hash>
<size>11470</size> <size>14323</size>
<sdkver>4</sdkver> <sdkver>4</sdkver>
<targetSdkVersion>18</targetSdkVersion> <targetSdkVersion>18</targetSdkVersion>
<obbMainFile>main.1434483388.obb.main.oldversion.obb</obbMainFile> <obbMainFile>main.1434483388.obb.main.oldversion.obb</obbMainFile>
<obbMainFileSha256>d3eb539a556352f3f47881d71fb0e5777b2f3e9a4251d283c18c67ce996774b7</obbMainFileSha256> <obbMainFileSha256>d3eb539a556352f3f47881d71fb0e5777b2f3e9a4251d283c18c67ce996774b7</obbMainFileSha256>
<added>2013-12-31</added> <added>2013-12-31</added>
<sig>b4964fd759edaa54e65bb476d0276880</sig> <sig>eb41d4d6082bb3e81c3d58dbf7fc7332</sig>
<permissions>ACCESS_NETWORK_STATE,ACCESS_WIFI_STATE,BLUETOOTH,BLUETOOTH_ADMIN,CHANGE_NETWORK_STATE,CHANGE_WIFI_MULTICAST_STATE,CHANGE_WIFI_STATE,INTERNET,NFC,RECEIVE_BOOT_COMPLETED</permissions>
<uses-permission maxSdkVersion="22" name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission maxSdkVersion="18" name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission-sdk-23 maxSdkVersion="25" name="android.permission.WRITE_SETTINGS"/>
</package> </package>
</application> </application>
<application id="obb.main.twoversions"> <application id="obb.main.twoversions">

View file

@ -602,7 +602,8 @@ echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.p
echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
echo "binary_transparency_remote = '$REPOROOT/git_remote'" >> config.py echo "binary_transparency_remote = '$REPOROOT/git_remote'" >> config.py
echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
$fdroid update --verbose --pretty $fdroid update --verbose
$fdroid server update --verbose
test -e repo/index.xml test -e repo/index.xml
test -e repo/index.jar test -e repo/index.jar
test -e repo/index-v1.jar test -e repo/index-v1.jar