chiark / gitweb /
Merge branch 'rational-jarsigner-logging' into 'master'
authorHans-Christoph Steiner <hans@guardianproject.info>
Mon, 11 Dec 2017 20:27:06 +0000 (20:27 +0000)
committerHans-Christoph Steiner <hans@guardianproject.info>
Mon, 11 Dec 2017 20:27:06 +0000 (20:27 +0000)
handle jarsigner/apksigner output cleanly for rational logging

Closes #405

See merge request fdroid/fdroidserver!404

completion/bash-completion
fd-commit [deleted file]
fdroidserver/metadata.py
fdroidserver/nightly.py
fdroidserver/update.py
hooks/pre-commit
makebuildserver
setup.py

index d18edd3501d8e17f815f0aee899cd115a6a2f4e1..3627ae460fd48c74bae1ca1b283c689013fcf281 100644 (file)
@@ -35,7 +35,7 @@ __by_ext() {
 }
 
 __package() {
-       files="$(__by_ext txt) $(__by_ext yaml) $(__by_ext json) $(__by_ext xml)"
+       files="$(__by_ext txt) $(__by_ext yml) $(__by_ext json) $(__by_ext xml)"
        COMPREPLY=( $( compgen -W "$files" -- $cur ) )
 }
 
@@ -352,11 +352,6 @@ _fdroid() {
        }
 }
 
-_fd-commit() {
-       __package
-}
-
 complete -F _fdroid fdroid
-complete -F _fd-commit fd-commit
 
 return 0
diff --git a/fd-commit b/fd-commit
deleted file mode 100755 (executable)
index 4f6e969..0000000
--- a/fd-commit
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/bin/bash
-#
-# fd-commit - part of the F-Droid server tools
-# Commits updates to apps, allowing you to edit the commit messages
-#
-# Copyright (C) 2013-2014 Daniel Marti <mvdan@mvdan.cc>
-#
-# 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/>.
-
-commands=()
-
-if [ ! -d metadata ]; then
-       if [ -d ../metadata ]; then
-               cd ..
-       else
-               echo "No metadata files found!"
-               exit 2
-       fi
-fi
-
-while read line; do
-
-       case "$line" in
-               *'??'*'metadata/'*'.txt') new=true ;;
-               *'M'*'metadata/'*'.txt') new=false ;;
-               *) continue ;;
-       esac
-
-       file=${line##* }
-       id=${file##*/}
-       id=${id%.txt*}
-
-       if [ $# -gt 0 ]; then
-               case "$@" in
-                       *" $id "*) ;;  # Middle
-                       "$id "*) ;;    # Start
-                       *" $id") ;;    # End
-                       "$id") ;;      # Alone
-                       *) continue ;; # Missing
-               esac
-       fi
-
-       [ -d metadata/$id ] && extra=metadata/$id || extra=
-
-       name= autoname=
-       while read l; do
-               case "$l" in
-                       'Auto Name:'*) autoname=${l#*:} ;;
-                       'Name:'*) name=${l#*:} ;;
-                       'Summary:'*) break ;;
-               esac
-       done < "$file"
-
-       if [ -n "$name" ]; then
-               fullname="$name"
-       elif [ -n "$autoname" ]; then
-               fullname="$autoname"
-       else
-               fullname="$id"
-       fi
-
-       if $new; then
-               message="New app: $fullname"
-       else
-               onlybuild=true
-               newbuild=false
-               disable=false
-               while read line; do
-                       case "$line" in
-                               '-Build:'*) onlybuild=false ;;
-                               '+Build:'*)
-                                       $newbuild && onlybuild=false
-                                       newbuild=true
-                                       build=${line#*:}
-                                       version=${build%%,*}
-                                       build=${build#*,}
-                                       vercode=${build%%,*}
-                                       ;;
-                               '+'*'disable='*)
-                                       $newbuild && $onlybuild && disable=true
-                                       ;;
-                       esac
-               done < <(git diff HEAD -- "$file")
-
-               if $newbuild && $onlybuild; then
-                       if $disable; then
-                               message="Don't update $fullname to $version ($vercode)"
-                       else
-                               message="Update $fullname to $version ($vercode)"
-                       fi
-               else
-                       message="$fullname:"
-               fi
-       fi
-
-       message=${message//\"/\\\"}
-       commands+=("git add -- $file $extra && git commit -m \"$message\" -e -v")
-
-done < <(git status --porcelain metadata)
-
-[ -z "$commands" ] && exit 0
-
-git reset >/dev/null
-for cmd in "${commands[@]}"; do
-       eval "$cmd"
-       git reset >/dev/null
-done
index c29c1e4c29a079e545f60d678df0d5c11b7c6c5f..d2bae63feff270216120ee1d7bfc89989fcec2d6 100644 (file)
@@ -1545,5 +1545,5 @@ def write_metadata(metadatapath, app):
 
 def add_metadata_arguments(parser):
     '''add common command line flags related to metadata processing'''
-    parser.add_argument("-W", default='error',
-                        help=_("force errors to be warnings, or ignore"))
+    parser.add_argument("-W", choices=['error', 'warn', 'ignore'], default='error',
+                        help=_("force metadata errors (default) to be warnings, or to be ignored."))
index 50c859f4fe9758a4ee18fa8659818cbe195520c4..249cd2e4f2e49803ab26fcd8f8bf2bc93ab057fa 100644 (file)
@@ -28,6 +28,7 @@ import shutil
 import subprocess
 import sys
 import tempfile
+import yaml
 from urllib.parse import urlparse
 from argparse import ArgumentParser
 
@@ -69,7 +70,8 @@ def _ssh_key_from_debug_keystore():
 
     rsakey = paramiko.RSAKey.from_private_key_file(privkey)
     fingerprint = base64.b64encode(hashlib.sha256(rsakey.asbytes()).digest()).decode('ascii').rstrip('=')
-    ssh_private_key_file = os.path.join(tmp_dir, 'debug_keystore_' + fingerprint + '_id_rsa')
+    ssh_private_key_file = os.path.join(tmp_dir, 'debug_keystore_'
+                                        + fingerprint.replace('/', '_') + '_id_rsa')
     shutil.move(privkey, ssh_private_key_file)
 
     pub = rsakey.get_name() + ' ' + rsakey.get_base64() + ' ' + ssh_private_key_file
@@ -191,9 +193,7 @@ Last updated: {date}'''.format(repo_git_base=repo_git_base,
         icon_path = os.path.join(git_mirror_path, 'icon.png')
         try:
             import qrcode
-            img = qrcode.make(repo_url)
-            with open(icon_path, 'wb') as fp:
-                fp.write(img)
+            qrcode.make(repo_url).save(icon_path)
         except Exception:
             exampleicon = os.path.join(common.get_examples_dir(), 'fdroid-icon.png')
             shutil.copy(exampleicon, icon_path)
@@ -264,6 +264,18 @@ Last updated: {date}'''.format(repo_git_base=repo_git_base,
             except subprocess.CalledProcessError:
                 pass
 
+        app_url = clone_url[:-len(NIGHTLY)]
+        template = dict()
+        template['AuthorName'] = clone_url.split('/')[4]
+        template['AuthorWebSite'] = '/'.join(clone_url.split('/')[:4])
+        template['Categories'] = ['nightly']
+        template['SourceCode'] = app_url
+        template['IssueTracker'] = app_url + '/issues'
+        template['Summary'] = 'Nightly build of ' + urlparse(app_url).path[1:]
+        template['Description'] = template['Summary']
+        with open('template.yml', 'w') as fp:
+            yaml.dump(template, fp)
+
         subprocess.check_call(['fdroid', 'update', '--rename-apks', '--create-metadata', '--verbose'],
                               cwd=repo_basedir)
         common.local_rsync(options, repo_basedir + '/metadata/', git_mirror_metadatadir + '/')
@@ -279,6 +291,16 @@ Last updated: {date}'''.format(repo_git_base=repo_git_base,
             shutil.rmtree(os.path.dirname(ssh_private_key_file))
 
     else:
+        if not os.path.isfile(KEYSTORE_FILE):
+            androiddir = os.path.dirname(KEYSTORE_FILE)
+            if not os.path.exists(androiddir):
+                os.mkdir(androiddir)
+                logging.info(_('created {path}').format(path=androiddir))
+            logging.error(_('{path} does not exist!  Create it by running:').format(path=KEYSTORE_FILE)
+                          + '\n    keytool -genkey -v -keystore ' + KEYSTORE_FILE + ' -storepass android \\'
+                          + '\n     -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 \\'
+                          + '\n     -dname "CN=Android Debug,O=Android,C=US"')
+            sys.exit(1)
         ssh_dir = os.path.join(os.getenv('HOME'), '.ssh')
         os.makedirs(os.path.dirname(ssh_dir), exist_ok=True)
         privkey = _ssh_key_from_debug_keystore()
index 71c4e430d4edee755dcae42f10ed0f09a81e4a2c..097513bf40e2dbb1d7d5937131495557d355fbe3 100644 (file)
@@ -1670,7 +1670,7 @@ def create_metadata_from_template(apk):
         with open('template.yml') as f:
             metatxt = f.read()
         if 'name' in apk and apk['name'] != '':
-            metatxt = re.sub(r'^(((Auto)?Name|Summary):).*$',
+            metatxt = re.sub(r'''^(((Auto)?Name|Summary):)[ '"\.]*$''',
                              r'\1 ' + apk['name'],
                              metatxt,
                              flags=re.IGNORECASE | re.MULTILINE)
index 2bbfe39c3a5b0df483cc03fa349ece3bd5d700b9..1dcc1d5aeee269568467658c3234a32b876e3e2f 100755 (executable)
@@ -11,7 +11,7 @@ if [ -z "$files" ]; then
     PY_FILES="fdroid makebuildserver setup.py examples/*.py buildserver/*.py fdroidserver/*.py"
     PY_TEST_FILES="tests/*.TestCase"
     SH_FILES="hooks/pre-commit"
-    BASH_FILES="fd-commit jenkins-build-all jenkins-setup-build-environment jenkins-test completion/bash-completion buildserver/provision-*"
+    BASH_FILES="jenkins-build-all jenkins-setup-build-environment jenkins-test completion/bash-completion buildserver/provision-*"
     RB_FILES="buildserver/Vagrantfile"
 else
     # if actually committing right now, then only run on the files
index 831eede3dc198c42e9d3ff75dddc579092b8fed8..306c2845777ebc13a873e2fc500c50ca95262fed 100755 (executable)
@@ -179,7 +179,7 @@ cachefiles = [
     ('https://dl.google.com/android/repository/platform-26_r02.zip',
      '2aafa7d19c5e9c4b643ee6ade3d85ef89dc2f79e8383efdb9baf7fddad74b52a'),
     ('https://dl.google.com/android/repository/platform-27_r01.zip',
-     '96ddff1a5034fcc4340f2d482635eeaccaa6707b6b0f82d26d1435476a2f52e5'),
+     'cbba6f8fcf025e1b533326746763aa1d6e2cf4001b1b441602bb44d253bc49ac'),
     ('https://dl.google.com/android/repository/build-tools_r17-linux.zip',
      '4c8444972343a19045236f6924bd7f12046287c70dace96ab88b2159c8ec0e74'),
     ('https://dl.google.com/android/repository/build-tools_r18.0.1-linux.zip',
index b7ab51e74ce2c9998196efb5e4f0a13913b4c354..f68ba1b5e43052277467ba38de5ed31550d2e3f2 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -74,7 +74,7 @@ setup(name='fdroidserver',
       url='https://f-droid.org',
       license='AGPL-3.0',
       packages=['fdroidserver', 'fdroidserver.asynchronousfilereader'],
-      scripts=['fdroid', 'fd-commit', 'makebuildserver'],
+      scripts=['fdroid', 'makebuildserver'],
       data_files=get_data_files(),
       python_requires='>=3.4',
       cmdclass={'versioncheck': VersionCheckCommand},