chiark / gitweb /
strip file extension from generated name for non-APKs
authorHans-Christoph Steiner <hans@eds.org>
Thu, 1 Jun 2017 08:29:30 +0000 (10:29 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Thu, 1 Jun 2017 14:01:05 +0000 (16:01 +0200)
With a generic file, the file name is the only guaranteed name metadata
field.  So if the name is not specified in the metadata, then the name
is set to the filename.  This changes that so that the file extension is
stripped from that generated name.

fdroidserver/index.py
fdroidserver/update.py
tests/repo/index.xml

index 32727115593331c12c2d52bcfd06575f33789579..942c58612ff1b2db90f4e649812f2927cb490440 100644 (file)
@@ -448,7 +448,7 @@ def make_v0(apps, apks, repodir, repodict, requestsdict):
                 and repodir == 'repo':  # only create these
             namefield = common.config['current_version_name_source']
             sanitized_name = re.sub(b'''[ '"&%?+=/]''', b'', app.get(namefield).encode('utf-8'))
-            apklinkname = sanitized_name + b'.apk'
+            apklinkname = sanitized_name + os.path.splitext(current_version_file)[1].encode('utf-8')
             current_version_path = os.path.join(repodir, current_version_file).encode('utf-8', 'surrogateescape')
             if os.path.islink(apklinkname):
                 os.remove(apklinkname)
index c36fd86e3ca3e69b9080045d91a72b3807d6ac27..614ae07f5a51bf9245370547d6b3ca7105f66f27 100644 (file)
@@ -843,8 +843,8 @@ def scan_repo_files(apkcache, repodir, knownapks, use_date_from_file=False):
         if not usecache:
             logging.debug("Processing " + name_utf8)
             repo_file = collections.OrderedDict()
+            repo_file['name'] = os.path.splitext(name_utf8)[0]
             # TODO rename apkname globally to something more generic
-            repo_file['name'] = name_utf8
             repo_file['apkName'] = name_utf8
             repo_file['hash'] = shasum
             repo_file['hashType'] = 'sha256'
index ff958b7bc9d2e0cfb7e3d5a15af0c9ae42a08279..4b85a960b4b1e84e7e63b347e30c8c2ff8c59537 100644 (file)
@@ -12,7 +12,7 @@
                <id>fake.ota.update</id>
                <added>2016-03-10</added>
                <lastupdated>2016-03-10</lastupdated>
-               <name>fake.ota.update_1234.zip</name>
+               <name>fake.ota.update_1234</name>
                <summary>Tests whether OTA ZIP files are being include</summary>
                <desc>&lt;p&gt;F-Droid can make use of system privileges or permissions to install, update and remove applications on its own. The only way to obtain those privileges is to become a system app.&lt;/p&gt;&lt;p&gt;This is where the Privileged Extension comes in - being a separate app and much smaller, it can be installed as a system app and communicate with the main app via AIDL IPC.&lt;/p&gt;&lt;p&gt;This has several advantages:&lt;/p&gt;&lt;ul&gt;&lt;li&gt; Reduced disk usage in the system partition&lt;/li&gt;&lt;li&gt; System updates don't remove F-Droid&lt;/li&gt;&lt;li&gt; The process of installing into system via root is safer&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;This is packaged as an OTA (Over-The-Air) update ZIP file.  It must be installed using TWRP or other Android recovery that can flash updates to the system from the /data/data/org.fdroid.fdroid folder on the /data partition. The standalone APK is called F-Droid Privileged Extension.&lt;/p&gt;</desc>
                <license>Apache-2.0</license>