chiark / gitweb /
Merge branch 'scanner-repos' into 'master'
authorDaniel Martí <mvdan@mvdan.cc>
Sat, 20 Feb 2016 07:29:12 +0000 (07:29 +0000)
committerDaniel Martí <mvdan@mvdan.cc>
Sat, 20 Feb 2016 07:29:12 +0000 (07:29 +0000)
Allow commonsware and gradle plugin repos

This is in a MR because I'm uneasy about adding a semi-random AWS url to the list. But seems like the commonsware guy only publishes jars there, which doesn't make any sense to me.

Any idea @eighthave?

See merge request !102

completion/bash-completion
examples/config.py
fdroidserver/metadata.py
fdroidserver/update.py
setup.cfg
setup.py
tests/metadata/info.guardianproject.urzip.txt [new file with mode: 0644]
tests/run-tests

index f0ce84a355305a84b1a83c7f1b6b889cd4d7deed..f2632d676baf797e55bd082f87a54d5667a00b86 100644 (file)
@@ -136,7 +136,7 @@ __complete_update() {
        opts="-c -v -q -b -i -I -e -w"
        lopts="--create-metadata --verbose --quiet --buildreport
  --interactive --icons --editor --wiki --pretty --clean --delete-unknown
- --nosign"
+ --nosign --use-date-from-apk"
        case "${prev}" in
                -e|--editor)
                        _filedir
index 2aaaed1091988af457219d24c581c7fcf667a9f8..54c326fe584736f3d0731f40dfc49e58222e5aa3 100644 (file)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python2
+# -*- coding: utf-8 -*-
 
 # Copy this file to config.py, then amend the settings below according to
 # your system configuration.
@@ -148,6 +149,18 @@ The repository of older versions of applications from the main demo repository.
 #     'bar.info:/var/www/fdroid',
 #     }
 
+# Any mirrors of this repo, for example all of the servers declared in
+# serverwebroot, will automatically be used by the client.  If one
+# mirror is not working, then the client will try another.  If the
+# client has Tor enabled, then the client will prefer mirrors with
+# .onion addresses. This base URL will be used for both the main repo
+# and the archive, if it is enabled.  So these URLs should end in the
+# 'fdroid' base of the F-Droid part of the web server like serverwebroot.
+#
+# mirrors = {
+#     'https://foo.bar/fdroid',
+#     'http://foobarfoobarfoobar.onion/fdroid',
+# }
 
 # optionally specific which identity file to use when using rsync over SSH
 #
index dc0055f21deb310176c3e1cbfd1d02b050227c71..bc8708df4377c7889e8dbe164fe6ce1fce2fb7c3 100644 (file)
@@ -132,7 +132,7 @@ class App():
         self.UpdateCheckName = None
         self.UpdateCheckData = None
         self.CurrentVersion = ''
-        self.CurrentVersionCode = '0'
+        self.CurrentVersionCode = None
         self.NoSourceSince = ''
 
         self.id = None
index 6bbf0fae9686d2f3fd30b719b59e3400a3faaaea..67de608daab9fbc9e07aa826b6490faff8195f38 100644 (file)
@@ -27,6 +27,7 @@ import socket
 import zipfile
 import hashlib
 import pickle
+import urlparse
 from datetime import datetime, timedelta
 from xml.dom.minidom import Document
 from argparse import ArgumentParser
@@ -207,7 +208,7 @@ def update_wiki(apps, sortedids, apks):
         if validapks == 0 and not app.Disabled:
             wikidata += '\n[[Category:Apps with no packages]]\n'
         if cantupdate and not app.Disabled:
-            wikidata += "\n[[Category:Apps we can't update]]\n"
+            wikidata += "\n[[Category:Apps we cannot update]]\n"
         if buildfails and not app.Disabled:
             wikidata += "\n[[Category:Apps with failing builds]]\n"
         elif not gotcurrentver and not cantupdate and not app.Disabled and app.UpdateCheckMode != "Static":
@@ -404,7 +405,7 @@ def getsig(apkpath):
     return md5(cert_encoded.encode('hex')).hexdigest()
 
 
-def scan_apks(apps, apkcache, repodir, knownapks):
+def scan_apks(apps, apkcache, repodir, knownapks, use_date_from_apk=False):
     """Scan the apks in the given repo directory.
 
     This also extracts the icons.
@@ -413,6 +414,8 @@ def scan_apks(apps, apkcache, repodir, knownapks):
     :param apkcache: current apk cache information
     :param repodir: repo directory to scan
     :param knownapks: known apks info
+    :param use_date_from_apk: use date from APK (instead of current date)
+                              for newly added APKs
     :returns: (apks, cachechanged) where apks is a list of apk information,
               and cachechanged is True if the apkcache got changed.
     """
@@ -567,12 +570,16 @@ def scan_apks(apps, apkcache, repodir, knownapks):
             # has to be more than 24 hours newer because ZIP/APK files do not
             # store timezone info
             manifest = apkzip.getinfo('AndroidManifest.xml')
-            dt_obj = datetime(*manifest.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) + '"')
+            if manifest.date_time[1] == 0:  # month can't be zero
+                logging.debug('AndroidManifest.xml has no date')
+            else:
+                dt_obj = datetime(*manifest.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" % (
                 apk['id'],
@@ -684,6 +691,10 @@ def scan_apks(apps, apkcache, repodir, knownapks):
             # Record in known apks, getting the added date at the same time..
             added = knownapks.recordapk(apk['apkname'], apk['id'])
             if added:
+                if use_date_from_apk and manifest.date_time[1] != 0:
+                    added = datetime(*manifest.date_time).timetuple()
+                    logging.debug("Using date from APK")
+
                 apk['added'] = added
 
             apkcache[apkfilename] = apk
@@ -760,6 +771,15 @@ def make_index(apps, sortedids, apks, repodir, archive, categories):
 
     repoel = doc.createElement("repo")
 
+    mirrorcheckfailed = False
+    for mirror in config.get('mirrors', []):
+        base = os.path.basename(urlparse.urlparse(mirror).path.rstrip('/'))
+        if config.get('nonstandardwebroot') is not True and base != 'fdroid':
+            logging.error("mirror '" + mirror + "' does not end with 'fdroid'!")
+            mirrorcheckfailed = True
+    if mirrorcheckfailed:
+        sys.exit(1)
+
     if archive:
         repoel.setAttribute("name", config['archive_name'])
         if config['repo_maxage'] != 0:
@@ -767,6 +787,9 @@ def make_index(apps, sortedids, apks, repodir, archive, categories):
         repoel.setAttribute("icon", os.path.basename(config['archive_icon']))
         repoel.setAttribute("url", config['archive_url'])
         addElement('description', config['archive_description'], doc, repoel)
+        urlbasepath = os.path.basename(urlparse.urlparse(config['archive_url']).path)
+        for mirror in config.get('mirrors', []):
+            addElement('mirror', urlparse.urljoin(mirror, urlbasepath), doc, repoel)
 
     else:
         repoel.setAttribute("name", config['repo_name'])
@@ -775,8 +798,11 @@ def make_index(apps, sortedids, apks, repodir, archive, categories):
         repoel.setAttribute("icon", os.path.basename(config['repo_icon']))
         repoel.setAttribute("url", config['repo_url'])
         addElement('description', config['repo_description'], doc, repoel)
+        urlbasepath = os.path.basename(urlparse.urlparse(config['repo_url']).path)
+        for mirror in config.get('mirrors', []):
+            addElement('mirror', urlparse.urljoin(mirror, urlbasepath), doc, repoel)
 
-    repoel.setAttribute("version", "14")
+    repoel.setAttribute("version", "15")
     repoel.setAttribute("timestamp", str(int(time.time())))
 
     nosigningkey = False
@@ -1114,6 +1140,8 @@ def main():
                         help="Clean update - don't uses caches, reprocess all apks")
     parser.add_argument("--nosign", action="store_true", default=False,
                         help="When configured for signed indexes, create only unsigned indexes at this stage")
+    parser.add_argument("--use-date-from-apk", action="store_true", default=False,
+                        help="Use date from apk instead of current time for newly added apks")
     options = parser.parse_args()
 
     config = common.read_config(options)
@@ -1188,7 +1216,7 @@ def main():
     delete_disabled_builds(apps, apkcache, repodirs)
 
     # Scan all apks in the main repo
-    apks, cachechanged = scan_apks(apps, apkcache, repodirs[0], knownapks)
+    apks, cachechanged = scan_apks(apps, apkcache, repodirs[0], knownapks, options.use_date_from_apk)
 
     # Generate warnings for apk's with no metadata (or create skeleton
     # metadata files, if requested on the command line)
@@ -1230,7 +1258,7 @@ def main():
 
     # Scan the archive repo for apks as well
     if len(repodirs) > 1:
-        archapks, cc = scan_apks(apps, apkcache, repodirs[1], knownapks)
+        archapks, cc = scan_apks(apps, apkcache, repodirs[1], knownapks, options.use_date_from_apk)
         if cc:
             cachechanged = True
     else:
@@ -1268,6 +1296,8 @@ def main():
             if app.Name is None:
                 app.Name = bestapk['name']
             app.icon = bestapk['icon'] if 'icon' in bestapk else None
+            if app.CurrentVersionCode is None:
+                app.CurrentVersionCode = str(bestver)
 
     # Sort the app list by name, then the web site doesn't have to by default.
     # (we had to wait until we'd scanned the apks to do this, because mostly the
index b88034e414bc7b80d686e3c94d516305348053ea..bbd3a2abec669c49ce66de5f5cfd27f13e006459 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,2 +1,6 @@
 [metadata]
 description-file = README.md
+
+[aliases]
+release = register sdist --sign upload
+
index 4a266e7cb6d661bc44f4b009f290f6217a5555b9..947112f9a4e961af407bb4ffdc2e1b12660824ea 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ else:
     data_prefix = sys.prefix
 
 setup(name='fdroidserver',
-      version='0.5.0',
+      version='0.6.0',
       description='F-Droid Server Tools',
       long_description=open('README.md').read(),
       author='The F-Droid Project',
@@ -39,7 +39,7 @@ setup(name='fdroidserver',
       classifiers=[
           'Development Status :: 3 - Alpha',
           'Intended Audience :: Developers',
-          'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)'
+          'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
           'Operating System :: POSIX',
           'Topic :: Utilities',
       ],
diff --git a/tests/metadata/info.guardianproject.urzip.txt b/tests/metadata/info.guardianproject.urzip.txt
new file mode 100644 (file)
index 0000000..c734895
--- /dev/null
@@ -0,0 +1,25 @@
+Categories:Development,GuardianProject
+License:GPLv3
+Web Site:https://dev.guardianproject.info/projects/urzip
+Source Code:https://github.com/guardianproject/urzip
+Issue Tracker:https://dev.guardianproject.info/projects/urzip/issues
+Bitcoin:1Fi5xUHiAPRKxHvyUGVFGt9extBe8Srdbk
+
+Auto Name:Urzip:本地应用的信息
+Summary:一个实用工具,获取已安装在您的设备上的应用的有关信息
+Description:
+It’s Urzip 是一个获得已安装 APK 相关信息的实用工具。它从您的设备上已安装的所有应用开始,一键触摸即可显示 APK 的指纹,并且提供到达 virustotal.com 和 androidobservatory.org 的快捷链接,让您方便地了解特定 APK 的档案。它还可以让您导出签名证书和生成 ApkSignaturePin Pin 文件供 TrustedIntents 库使用。
+
+★ Urzip 支持下列语言: Deutsch, English, español, suomi, 日本語, 한국어, Norsk, português (Portugal), Русский, Slovenščina, Türkçe
+没看到您的语言?帮忙翻译本应用吧:
+https://www.transifex.com/projects/p/urzip
+
+★ 致用户:我们还缺少你喜欢的功能?发现了一个 bug?请告诉我们!我们乐于听取您的意见。请发送电子邮件至: support@guardianproject.info 或者加入我们的聊天室 https://guardianproject.info/contact
+.
+
+Repo Type:git
+Repo:https://github.com/guardianproject/urzip.git
+
+
+
+Current Version Code:9999999
index 243fbf4ca23b3e89e62225e692005c73b5a29484..de9c9a1532247bf017210027da4075898b75f24b 100755 (executable)
@@ -121,6 +121,23 @@ if [ `uname -s` == "Linux" ]; then
 fi
 
 
+#------------------------------------------------------------------------------#
+echo_header "test UTF-8 metadata"
+
+REPOROOT=`create_test_dir`
+cd $REPOROOT
+
+$fdroid init
+sed -i.tmp 's,^ *repo_description.*,repo_description = """获取已安装在您的设备上的应用的,' config.py
+echo "mirrors = {'https://foo.bar/fdroid', 'http://secret.onion/fdroid'}" >> config.py
+mkdir metadata
+cp $WORKSPACE/tests/urzip.apk repo/
+cp $WORKSPACE/tests/metadata/info.guardianproject.urzip.txt metadata/
+
+$fdroid readmeta
+$fdroid update
+
+
 #------------------------------------------------------------------------------#
 echo_header "test metadata checks"