mirror of
				https://github.com/f-droid/fdroidserver.git
				synced 2025-11-03 22:20:28 +03:00 
			
		
		
		
	update: handle APKs with a blank versionName
Instead of just crashing, first try to use the versionName as written in the build metadata, otherwise just let it be blank. A blank versionName will cause fdroidclient < 1.3 to crash. Blank versionNames are not allowed in the .txt metadata format, only .yml. closes #477 closes #478 closes fdroidclient#1416 closes fdroidclient#1417 closes fdroidclient#1418 fdroiddata!3061
This commit is contained in:
		
							parent
							
								
									9bf9159a77
								
							
						
					
					
						commit
						de35f1b05b
					
				
					 5 changed files with 36 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -213,6 +213,16 @@ def make_v1(apps, packages, repodir, repodict, requestsdict, fdroid_signing_key_
 | 
			
		|||
        if packageName not in apps:
 | 
			
		||||
            logging.info(_('Ignoring package without metadata: ') + package['apkName'])
 | 
			
		||||
            continue
 | 
			
		||||
        if not package.get('versionName'):
 | 
			
		||||
            app = apps[packageName]
 | 
			
		||||
            versionCodeStr = str(package['versionCode'])  # TODO build.versionCode should be int!
 | 
			
		||||
            for build in app['builds']:
 | 
			
		||||
                if build['versionCode'] == versionCodeStr:
 | 
			
		||||
                    versionName = build.get('versionName')
 | 
			
		||||
                    logging.info(_('Overriding blank versionName in {apkfilename} from metadata: {version}')
 | 
			
		||||
                                 .format(apkfilename=package['apkName'], version=versionName))
 | 
			
		||||
                    package['versionName'] = versionName
 | 
			
		||||
                    break
 | 
			
		||||
        if packageName in output_packages:
 | 
			
		||||
            packagelist = output_packages[packageName]
 | 
			
		||||
        else:
 | 
			
		||||
| 
						 | 
				
			
			@ -479,7 +489,17 @@ def make_v0(apps, apks, repodir, repodict, requestsdict, fdroid_signing_key_fing
 | 
			
		|||
 | 
			
		||||
            apkel = doc.createElement("package")
 | 
			
		||||
            apel.appendChild(apkel)
 | 
			
		||||
            addElement('version', apk['versionName'], doc, apkel)
 | 
			
		||||
 | 
			
		||||
            versionName = apk.get('versionName')
 | 
			
		||||
            if not versionName:
 | 
			
		||||
                versionCodeStr = str(apk['versionCode'])  # TODO build.versionCode should be int!
 | 
			
		||||
                for build in app.builds:
 | 
			
		||||
                    if build['versionCode'] == versionCodeStr and 'versionName' in build:
 | 
			
		||||
                        versionName = build['versionName']
 | 
			
		||||
                        break
 | 
			
		||||
            if versionName:
 | 
			
		||||
                addElement('version', versionName, doc, apkel)
 | 
			
		||||
 | 
			
		||||
            addElement('versioncode', str(apk['versionCode']), doc, apkel)
 | 
			
		||||
            addElement('apkname', apk['apkName'], doc, apkel)
 | 
			
		||||
            addElementIfInApk('srcname', apk, 'srcname', doc, apkel)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1208,13 +1208,18 @@ def scan_apk_androguard(apk, apkfile):
 | 
			
		|||
 | 
			
		||||
    apk['packageName'] = apkobject.get_package()
 | 
			
		||||
    apk['versionCode'] = int(apkobject.get_androidversion_code())
 | 
			
		||||
    apk['versionName'] = apkobject.get_androidversion_name()
 | 
			
		||||
    if apk['versionName'][0] == "@":
 | 
			
		||||
        version_id = int(apk['versionName'].replace("@", "0x"), 16)
 | 
			
		||||
        version_id = arsc.get_id(apk['packageName'], version_id)[1]
 | 
			
		||||
        apk['versionName'] = arsc.get_string(apk['packageName'], version_id)[1]
 | 
			
		||||
    apk['name'] = apkobject.get_app_name()
 | 
			
		||||
 | 
			
		||||
    versionName = apkobject.get_androidversion_name()
 | 
			
		||||
    if versionName:
 | 
			
		||||
        apk['versionName'] = versionName
 | 
			
		||||
        try:  # can be a literal value or a resId
 | 
			
		||||
            res_id = int(versionName.replace("@", "0x"), 16)
 | 
			
		||||
            res_id = arsc.get_id(apk['packageName'], res_id)[1]
 | 
			
		||||
            apk['versionName'] = arsc.get_string(apk['packageName'], res_id)[1]
 | 
			
		||||
        except ValueError:
 | 
			
		||||
            pass
 | 
			
		||||
 | 
			
		||||
    if apkobject.get_max_sdk_version() is not None:
 | 
			
		||||
        apk['maxSdkVersion'] = apkobject.get_max_sdk_version()
 | 
			
		||||
    if apkobject.get_min_sdk_version() is not None:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -288,13 +288,13 @@
 | 
			
		|||
      {
 | 
			
		||||
        "added": 1513900800000,
 | 
			
		||||
        "apkName": "duplicate.permisssions_9999999.apk",
 | 
			
		||||
        "hash": "3d5db5f1ee6fd1d5d9e3c97cc9139b447f538bacd9907f648ba96cfd0848321d",
 | 
			
		||||
        "hash": "8367857fe75f85321ce2c344b34804d0bc193707f6ba03710d025d9030803434",
 | 
			
		||||
        "hashType": "sha256",
 | 
			
		||||
        "minSdkVersion": "18",
 | 
			
		||||
        "packageName": "duplicate.permisssions",
 | 
			
		||||
        "sig": "056c9f1554c40ba59a2103009c82b420",
 | 
			
		||||
        "signer": "659e1fd284549f70d13fb02c620100e27eeea3420558cce62b0f5d4cf2b77d84",
 | 
			
		||||
        "size": 27507,
 | 
			
		||||
        "size": 27446,
 | 
			
		||||
        "targetSdkVersion": "27",
 | 
			
		||||
        "uses-permission": [
 | 
			
		||||
          [
 | 
			
		||||
| 
						 | 
				
			
			@ -336,8 +336,7 @@
 | 
			
		|||
            null
 | 
			
		||||
          ]
 | 
			
		||||
        ],
 | 
			
		||||
        "versionCode": 9999999,
 | 
			
		||||
        "versionName": "0.3-7-gb817ac8"
 | 
			
		||||
        "versionCode": 9999999
 | 
			
		||||
      }
 | 
			
		||||
    ],
 | 
			
		||||
    "fake.ota.update": [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,11 +25,10 @@
 | 
			
		|||
		<marketversion></marketversion>
 | 
			
		||||
		<marketvercode>9999999</marketvercode>
 | 
			
		||||
		<package>
 | 
			
		||||
			<version>0.3-7-gb817ac8</version>
 | 
			
		||||
			<versioncode>9999999</versioncode>
 | 
			
		||||
			<apkname>duplicate.permisssions_9999999.apk</apkname>
 | 
			
		||||
			<hash type="sha256">3d5db5f1ee6fd1d5d9e3c97cc9139b447f538bacd9907f648ba96cfd0848321d</hash>
 | 
			
		||||
			<size>27507</size>
 | 
			
		||||
			<hash type="sha256">8367857fe75f85321ce2c344b34804d0bc193707f6ba03710d025d9030803434</hash>
 | 
			
		||||
			<size>27446</size>
 | 
			
		||||
			<sdkver>18</sdkver>
 | 
			
		||||
			<targetSdkVersion>27</targetSdkVersion>
 | 
			
		||||
			<added>2017-12-22</added>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue