only use AutoName: in checkupdates

AutoName: is only needed for the commit messages generated by checkupdates,
and it makes the logic for localized names confusing.

closes #654
refs #304
This commit is contained in:
Hans-Christoph Steiner 2020-01-13 15:43:42 +01:00
parent 0f6b638986
commit fff59e5197
11 changed files with 289 additions and 49 deletions

View file

@ -247,7 +247,7 @@ class IndexTest(unittest.TestCase):
self.maxDiff = None
self.assertEqual(json.dumps(i, indent=2), json.dumps(o, indent=2))
def test_make_v0(self):
def test_make_v0_repo_only(self):
tmptestsdir = tempfile.mkdtemp(prefix=inspect.currentframe().f_code.co_name,
dir=self.tmpdir)
os.chdir(tmptestsdir)
@ -264,7 +264,71 @@ class IndexTest(unittest.TestCase):
}
requestsdict = {'install': [], 'uninstall': []}
fdroidserver.common.config['repo_pubkey'] = 'ffffffffffffffffffffffffffffffffff'
fdroidserver.index.make_v0({}, [], 'repo', repodict, requestsdict, [])
fdroidserver.index.make_v0({}, [], 'repo', repodict, requestsdict, {})
self.assertTrue(os.path.isdir(repo_icons_dir))
self.assertTrue(os.path.exists(os.path.join(repo_icons_dir,
fdroidserver.common.default_config['repo_icon'])))
self.assertTrue(os.path.exists(os.path.join('repo', 'index.xml')))
def test_make_v0(self):
tmptestsdir = tempfile.mkdtemp(prefix=inspect.currentframe().f_code.co_name,
dir=self.tmpdir)
os.chdir(tmptestsdir)
os.mkdir('metadata')
os.mkdir('repo')
metadatafile = 'metadata/info.zwanenburg.caffeinetile.yml'
shutil.copy(os.path.join(self.basedir, metadatafile),
metadatafile)
repo_icons_dir = os.path.join('repo', 'icons')
self.assertFalse(os.path.isdir(repo_icons_dir))
repodict = {
'address': 'https://example.com/fdroid/repo',
'description': 'This is just a test',
'icon': 'blahblah',
'name': 'test',
'timestamp': datetime.datetime.now(),
'version': 12,
}
app = fdroidserver.metadata.parse_metadata(metadatafile, False, False)
app['icon'] = 'info.zwanenburg.caffeinetile.4.xml'
app['CurrentVersionCode'] = '4'
apps = {app.id: app}
apk = {
'hash': 'dbbdd7deadb038862f426b71efe4a64df8c3edf25d669e935f349510e16f65db',
'hashType': 'sha256',
'uses-permission': [
[
'android.permission.WAKE_LOCK',
None
]
],
'uses-permission-sdk-23': [],
'features': [],
'icons_src': {
'160': 'res/drawable/ic_coffee_on.xml',
'-1': 'res/drawable/ic_coffee_on.xml'
},
'icons': {
'160': 'info.zwanenburg.caffeinetile.4.xml'
},
'antiFeatures': [],
'packageName': 'info.zwanenburg.caffeinetile',
'versionCode': 4,
'name': 'Caffeine Tile',
'versionName': '1.3',
'minSdkVersion': 24,
'targetSdkVersion': 25,
'sig': '03f9b2f848d22fd1d8d1331e8b1b486d',
'signer': '51cfa5c8a743833ad89acf81cb755936876a5c8b8eca54d1ffdcec0cdca25d0e',
'size': 11740,
'apkName': 'info.zwanenburg.caffeinetile_4.apk',
'icon': 'info.zwanenburg.caffeinetile.4.xml',
'added': datetime.datetime.fromtimestamp(1539122400),
}
requestsdict = {'install': [], 'uninstall': []}
fdroidserver.common.config['repo_pubkey'] = 'ffffffffffffffffffffffffffffffffff'
fdroidserver.common.config['make_current_version_link'] = True
fdroidserver.index.make_v0(apps, [apk], 'repo', repodict, requestsdict, {})
self.assertTrue(os.path.isdir(repo_icons_dir))
self.assertTrue(os.path.exists(os.path.join(repo_icons_dir,
fdroidserver.common.default_config['repo_icon'])))

View file

@ -9,6 +9,7 @@ Translation: https://www.transifex.com/otf/checkey
Bitcoin: 1Fi5xUHiAPRKxHvyUGVFGt9extBe8Srdbk
Liberapay: GuardianProject
Name: Checkey the app!
AutoName: Checkey
AutoUpdateMode: None

View file

@ -0,0 +1 @@
Checkey: info on local apps

View file

@ -0,0 +1 @@
Checkey: ローカルアプリの情報

View file

@ -32,14 +32,18 @@
"flattrID": "cad90e036b975ed129a3ce80a0750466",
"issueTracker": "https://gitlab.com/souch/SMSbypass/issues",
"license": "GPL-3.0-only",
"name": "Battery level",
"sourceCode": "https://gitlab.com/souch/SMSbypass/tree/HEAD",
"summary": "Filter SMS and show them in a fake app",
"webSite": "https://gitlab.com/souch/SMSbypass",
"added": 1524700800000,
"icon": "souch.smsbypass.9.png",
"packageName": "souch.smsbypass",
"lastUpdated": 1524700800000
"lastUpdated": 1524700800000,
"localized": {
"en-US": {
"name": "Battery level"
}
}
},
{
"categories": [
@ -77,13 +81,17 @@
"donate": "https://f-droid.org/about",
"issueTracker": "https://gitlab.com/fdroid/privileged-extension/issues",
"license": "Apache-2.0",
"name": "fake.ota.update_1234",
"sourceCode": "https://gitlab.com/fdroid/privileged-extension",
"summary": "Tests whether OTA ZIP files are being include",
"webSite": "https://f-droid.org",
"added": 1457568000000,
"packageName": "fake.ota.update",
"lastUpdated": 1457568000000
"lastUpdated": 1457568000000,
"localized": {
"en-US": {
"name": "fake.ota.update_1234"
}
}
},
{
"categories": [
@ -106,12 +114,16 @@
"suggestedVersionCode": "99999999",
"liberapay": "12334",
"license": "GPL-3.0-only",
"name": "OBB Main Old Version",
"sourceCode": "https://github.com/eighthave/urzip",
"added": 1388448000000,
"icon": "obb.main.oldversion.1444412523.png",
"packageName": "obb.main.oldversion",
"lastUpdated": 1388448000000
"lastUpdated": 1388448000000,
"localized": {
"en-US": {
"name": "OBB Main Old Version"
}
}
},
{
"bitcoin": "1Fi5xUHiAPRKxHvyUGVFGt9extBe8Srdbk",
@ -120,12 +132,16 @@
],
"suggestedVersionCode": "99999999",
"license": "GPL-3.0-only",
"name": "OBB Main Two Versions",
"sourceCode": "https://github.com/eighthave/urzip",
"added": 1444608000000,
"icon": "obb.main.twoversions.1101617.png",
"packageName": "obb.main.twoversions",
"lastUpdated": 1466380800000
"lastUpdated": 1466380800000,
"localized": {
"en-US": {
"name": "OBB Main Two Versions"
}
}
},
{
"bitcoin": "1Fi5xUHiAPRKxHvyUGVFGt9extBe8Srdbk",
@ -134,7 +150,6 @@
],
"suggestedVersionCode": "99999999",
"license": "GPL-3.0-only",
"name": "OBB Main/Patch Current",
"sourceCode": "https://github.com/eighthave/urzip",
"added": 1461369600000,
"icon": "obb.mainpatch.current.1619.png",
@ -144,6 +159,7 @@
"en-US": {
"featureGraphic": "featureGraphic_ffhLaojxbGAfu9ROe1MJgK5ux8d0OVc6b65nmvOBaTk=.png",
"icon": "icon_WI0pkO3LsklrsTAnRr-OQSxkkoMY41lYe2-fAvXLiLg=.png",
"name": "OBB Main/Patch Current",
"phoneScreenshots": [
"screenshot-main.png"
],
@ -165,13 +181,17 @@
"description": "Activates silent mode during calendar events.",
"issueTracker": "https://github.com/miguelvps/PoliteDroid/issues",
"license": "GPL-3.0-only",
"name": "Polite Droid",
"sourceCode": "https://github.com/miguelvps/PoliteDroid",
"summary": "Calendar tool",
"added": 1498176000000,
"icon": "com.politedroid.6.png",
"packageName": "com.politedroid",
"lastUpdated": 1498176000000
"lastUpdated": 1498176000000,
"localized": {
"en-US": {
"name": "Polite Droid"
}
}
},
{
"authorWebSite": "https://guardianproject.info",
@ -187,7 +207,6 @@
"issueTracker": "https://dev.guardianproject.info/projects/urzip/issues",
"liberapayID": "9999999",
"license": "GPL-3.0-only",
"name": "urzip-\u03c0\u00c7\u00c7\u03c0\u00c7\u00c7\u73b0\u4ee3\u6c49\u8bed\u901a\u7528\u5b57-\u0431\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438-\u0639\u0631\u0628\u064a1234",
"openCollective": "f-droid-just-testing",
"sourceCode": "https://github.com/guardianproject/urzip",
"summary": "\u4e00\u4e2a\u5b9e\u7528\u5de5\u5177\uff0c\u83b7\u53d6\u5df2\u5b89\u88c5\u5728\u60a8\u7684\u8bbe\u5907\u4e0a\u7684\u5e94\u7528\u7684\u6709\u5173\u4fe1\u606f",

View file

@ -371,7 +371,7 @@ APK is called F-Droid Privileged Extension.</desc>
<id>info.guardianproject.urzip</id>
<added>2016-06-23</added>
<lastupdated>2016-06-23</lastupdated>
<name>urzip-πÇÇπÇÇ现代汉语通用字-български-عربي1234</name>
<name>title</name>
<summary>一个实用工具,获取已安装在您的设备上的应用的有关信息</summary>
<icon>info.guardianproject.urzip.100.png</icon>
<desc>Its Urzip 是一个获得已安装 APK 相关信息的实用工具。它从您的设备上已安装的所有应用开始,一键触摸即可显示 APK 的指纹,并且提供到达 virustotal.com 和 androidobservatory.org 的快捷链接,让您方便地了解特定 APK 的档案。它还可以让您导出签名证书和生成 ApkSignaturePin Pin 文件供 TrustedIntents 库使用。

View file

@ -2,6 +2,7 @@
# http://www.drdobbs.com/testing/unit-testing-with-python/240165163
import copy
import git
import glob
import inspect
@ -69,6 +70,10 @@ class UpdateTest(unittest.TestCase):
def setUp(self):
logging.basicConfig(level=logging.INFO)
logging.getLogger('androguard.axml').setLevel(logging.INFO)
logging.getLogger('androguard.core.api_specific_resources').setLevel(logging.INFO)
from PIL import PngImagePlugin
logging.getLogger(PngImagePlugin.__name__).setLevel(logging.INFO)
self.basedir = os.path.join(localmodule, 'tests')
self.tmpdir = os.path.abspath(os.path.join(self.basedir, '..', '.testfiles'))
if not os.path.exists(self.tmpdir):
@ -174,6 +179,140 @@ class UpdateTest(unittest.TestCase):
elif packageName == 'eu.siacs.conversations':
self.assertEqual('Conversations', app['localized']['en-US']['name'])
def test_name_title_scraping(self):
"""metadata file --> fdroiddata localized files --> fastlane/triple-t in app source --> APK"""
config = dict()
fdroidserver.common.fill_config_defaults(config)
fdroidserver.common.config = config
fdroidserver.update.config = config
os.chdir(os.path.join(localmodule, 'tests'))
fdroidserver.update.options = type('', (), {})()
fdroidserver.update.options.clean = True
fdroidserver.update.options.delete_unknown = True
fdroidserver.update.options.rename_apks = False
fdroidserver.update.options.allow_disabled_algorithms = False
apps = fdroidserver.metadata.read_metadata()
knownapks = fdroidserver.common.KnownApks()
apks, cachechanged = fdroidserver.update.process_apks({}, 'repo', knownapks, False)
fdroidserver.update.insert_localized_app_metadata(apps)
fdroidserver.update.apply_info_from_latest_apk(apps, apks)
app = apps['info.guardianproject.urzip']
self.assertIsNone(app.Name)
self.assertTrue('localized' in app)
self.assertEqual('title', app['localized']['en-US']['name'])
app = apps['org.videolan.vlc']
self.assertIsNone(app.Name)
self.assertTrue('localized' in app)
self.assertFalse('name' in app['localized']['en-US'])
app = apps['info.guardianproject.checkey']
self.assertEqual('Checkey the app!', app.Name)
self.assertTrue('localized' in app)
self.assertEqual('Checkey: info on local apps', app['localized']['en-US']['name'])
self.assertEqual('Checkey: ローカルアプリの情報', app['localized']['ja-JP']['name'])
app = apps['org.adaway']
self.assertIsNone(app.Name)
self.assertFalse('localized' in app)
app = apps['obb.main.twoversions']
self.assertIsNone(app.Name)
self.assertFalse('localized' in app)
def test_insert_missing_app_names_from_apks(self):
"""en-US serves as the final, default, fallback value with index-v1"""
testvalue = 'TESTVALUE!'
apps = {
'none': {},
'name': {'Name': testvalue},
'onlyapk': {'Name': None},
'autoname': {'AutoName': 'autoname', 'Name': None},
'onlylocalized': {'localized': {'en-US': {'name': testvalue}}},
'non_en_us_localized': {'localized': {'de-AT': {'name': 'leiwand'}}},
'apks': {},
}
apks = [
{'packageName': 'none', 'name': '', 'versionCode': 1},
{'packageName': 'name', 'name': 'fromapk', 'versionCode': 1},
{'packageName': 'onlyapk', 'name': testvalue, 'versionCode': 1},
{'packageName': 'autoname', 'name': testvalue, 'versionCode': 1},
{'packageName': 'onlylocalized', 'name': 'fromapk', 'versionCode': 1},
{'packageName': 'non_en_us_localized', 'name': testvalue, 'versionCode': 0xcafe},
{'packageName': 'apks', 'name': 'fromapk1', 'versionCode': 1},
{'packageName': 'apks', 'name': 'fromapk2', 'versionCode': 2},
{'packageName': 'apks', 'name': testvalue, 'versionCode': 3},
]
fdroidserver.update.insert_missing_app_names_from_apks(apps, apks)
for appid, app in apps.items():
if appid == 'none':
self.assertIsNone(app.get('Name'))
self.assertIsNone(app.get('localized'))
elif appid == 'onlyapk':
self.assertIsNone(app.get('Name'))
self.assertEqual(testvalue, app['localized']['en-US']['name'])
elif appid == 'autoname':
self.assertIsNone(app.get('Name'))
self.assertEqual(testvalue, app['localized']['en-US']['name'])
elif appid == 'onlylocalized':
self.assertIsNone(app.get('Name'))
self.assertEqual(testvalue, app['localized']['en-US']['name'])
elif appid == 'non_en_us_localized':
self.assertIsNone(app.get('Name'))
self.assertEqual(testvalue, app['localized']['en-US']['name'])
elif appid == 'name':
self.assertEqual(testvalue, app['Name'])
self.assertIsNone(app.get('localized'))
elif appid == 'apks':
self.assertIsNone(app.get('Name'))
self.assertEqual(testvalue, app['localized']['en-US']['name'])
def test_insert_missing_app_names_from_apks_from_repo(self):
config = dict()
fdroidserver.common.fill_config_defaults(config)
fdroidserver.common.config = config
fdroidserver.update.config = config
fdroidserver.update.options = type('', (), {})()
fdroidserver.update.options.clean = True
fdroidserver.update.options.delete_unknown = True
fdroidserver.update.options.rename_apks = False
fdroidserver.update.options.allow_disabled_algorithms = False
apps = fdroidserver.metadata.read_metadata()
knownapks = fdroidserver.common.KnownApks()
apks, cachechanged = fdroidserver.update.process_apks({}, 'repo', knownapks, False)
appid = 'info.guardianproject.checkey'
testapps = {appid: copy.copy(apps[appid])}
self.assertEqual('Checkey the app!', testapps[appid]['Name'])
del(testapps[appid]['Name'])
fdroidserver.update.insert_missing_app_names_from_apks(testapps, apks)
self.assertIsNone(testapps[appid].get('Name'))
repoapps = fdroidserver.update.prepare_apps(apps, apks, 'repo')
fdroidserver.update.insert_missing_app_names_from_apks(repoapps, apks)
self.assertIsNone(repoapps['com.politedroid']['Name'])
self.assertEqual('Polite Droid',
repoapps['com.politedroid']['localized']['en-US']['name'])
self.assertEqual('Duplicate Permisssions', repoapps['duplicate.permisssions']['Name'])
self.assertEqual('Caffeine Tile', repoapps['info.zwanenburg.caffeinetile']['Name'])
self.assertEqual('No minSdkVersion or targetSdkVersion', repoapps['no.min.target.sdk']['Name'])
self.assertIsNone(repoapps['obb.main.oldversion'].get('Name'))
self.assertEqual('OBB Main Old Version',
repoapps['obb.main.oldversion']['localized']['en-US']['name'])
self.assertIsNone(repoapps['obb.main.twoversions'].get('Name'))
self.assertEqual('OBB Main Two Versions',
repoapps['obb.main.twoversions']['localized']['en-US']['name'])
self.assertIsNone(repoapps['souch.smsbypass'].get('Name'))
self.assertEqual('Battery level',
repoapps['souch.smsbypass']['localized']['en-US']['name'])
self.assertIsNone(repoapps['info.guardianproject.urzip'].get('Name'))
self.assertEqual('title',
repoapps['info.guardianproject.urzip']['localized']['en-US']['name'])
self.assertIsNone(repoapps['obb.mainpatch.current'].get('Name'))
del(repoapps['info.guardianproject.urzip']['localized'])
fdroidserver.update.insert_missing_app_names_from_apks(repoapps, apks)
self.assertEqual('urzip-πÇÇπÇÇ现代汉语通用字-български-عربي1234',
repoapps['info.guardianproject.urzip']['localized']['en-US']['name'])
def test_insert_triple_t_metadata(self):
importer = os.path.join(self.basedir, 'tmp', 'importer')
packageName = 'org.fdroid.ci.test.app'