update: include "What's New" texts when they are available

This uses the "What's New" entry for the CurrentVersionCode and includes it
as the current WhatsNew metadata for the App class.

Things like fastlane supply and Google Play support a "What's New" entry
per-APK, but fdroidclient does not current use anything but the current
version of this data.  Right now, it seems we probably only want to have
the latest WhatsNew in the index to save space.

In theory, we could make the WhatsNew data structure follow the structure
of fastlane/Play, but that would quite a bit of complexity for something
that might never be used.

fdroidclient#910
This commit is contained in:
Hans-Christoph Steiner 2017-04-13 23:36:46 +02:00
parent 822c2d3992
commit 9589d13ef2
7 changed files with 66 additions and 2 deletions

View File

@ -619,6 +619,10 @@ def copy_triple_t_store_metadata(apps):
_set_localized_text_entry(app, locale, 'Video',
os.path.join(root, f))
continue
elif f == 'whatsnew':
_set_localized_text_entry(app, segments[-1], 'WhatsNew',
os.path.join(root, f))
continue
base, extension = common.get_extension(f)
dirname = os.path.basename(root)
@ -648,6 +652,18 @@ def insert_localized_app_metadata(apps):
repo/packageName/locale/phoneScreenshots/1.png
repo/packageName/locale/phoneScreenshots/2.png
The changelog files must be text files named with the versionCode
ending with ".txt" and must be in the following layout:
https://github.com/fastlane/fastlane/blob/1.109.0/supply/README.md#changelogs-whats-new
repo/packageName/locale/changelogs/12345.txt
This will scan the each app's source repo then the metadata/ dir
for these standard locations of changelog files. If it finds
them, they will be added to the dict of all packages, with the
versions in the metadata/ folder taking precendence over the what
is in the app's source repo.
Where "packageName" is the app's packageName and "locale" is the locale
of the graphics, e.g. what language they are in, using the IETF RFC5646
format (en-US, fr-CA, es-MX, etc).
@ -657,6 +673,7 @@ def insert_localized_app_metadata(apps):
of graphic and screenshot files. If it finds them, it will copy
them into the repo. The fastlane files follow this pattern:
https://github.com/fastlane/fastlane/blob/1.109.0/supply/README.md#images-and-screenshots
"""
sourcedirs = glob.glob(os.path.join('build', '[A-Za-z]*', 'fastlane', 'metadata', 'android', '[a-z][a-z][A-Z-.@]*'))
@ -690,6 +707,10 @@ def insert_localized_app_metadata(apps):
_set_localized_text_entry(apps[packageName], locale, 'Video',
os.path.join(root, f))
continue
elif f == str(apps[packageName]['CurrentVersionCode']) + '.txt':
_set_localized_text_entry(apps[packageName], segments[-2], 'WhatsNew',
os.path.join(root, f))
continue
base, extension = common.get_extension(f)
if base in GRAPHIC_NAMES and extension in ALLOWED_EXTENSIONS:

View File

@ -0,0 +1 @@
100

View File

@ -0,0 +1 @@
full description

View File

@ -0,0 +1 @@
short description

View File

@ -0,0 +1 @@
title

View File

@ -0,0 +1 @@
video

View File

@ -24,6 +24,44 @@ from fdroidserver.common import FDroidPopen
class UpdateTest(unittest.TestCase):
'''fdroid update'''
def testInsertStoreMetadata(self):
config = dict()
fdroidserver.common.fill_config_defaults(config)
config['accepted_formats'] = ('txt', 'yml')
fdroidserver.update.config = config
fdroidserver.update.options = fdroidserver.common.options
os.chdir(os.path.join(localmodule, 'tests'))
apps = dict()
for packageName in ('info.guardianproject.urzip', 'org.videolan.vlc', 'obb.mainpatch.current'):
apps[packageName] = dict()
apps[packageName]['id'] = packageName
apps[packageName]['CurrentVersionCode'] = 0xcafebeef
apps['info.guardianproject.urzip']['CurrentVersionCode'] = 100
fdroidserver.update.insert_localized_app_metadata(apps)
self.assertEqual(3, len(apps))
for packageName, app in apps.items():
self.assertTrue('localized' in app)
self.assertTrue('en-US' in app['localized'])
self.assertEqual(1, len(app['localized']))
if packageName == 'info.guardianproject.urzip':
self.assertEqual(5, len(app['localized']['en-US']))
self.assertEqual('full description\n', app['localized']['en-US']['Description'])
self.assertEqual('title\n', app['localized']['en-US']['Name'])
self.assertEqual('short description\n', app['localized']['en-US']['Summary'])
self.assertEqual('video\n', app['localized']['en-US']['Video'])
self.assertEqual('100\n', app['localized']['en-US']['WhatsNew'])
elif packageName == 'org.videolan.vlc':
self.assertEqual('icon.png', app['localized']['en-US']['icon'])
self.assertEqual(9, len(app['localized']['en-US']['phoneScreenshots']))
self.assertEqual(15, len(app['localized']['en-US']['sevenInchScreenshots']))
elif packageName == 'obb.mainpatch.current':
self.assertEqual('icon.png', app['localized']['en-US']['icon'])
self.assertEqual('featureGraphic.png', app['localized']['en-US']['featureGraphic'])
self.assertEqual(1, len(app['localized']['en-US']['phoneScreenshots']))
self.assertEqual(1, len(app['localized']['en-US']['sevenInchScreenshots']))
def javagetsig(self, apkfile):
getsig_dir = os.path.join(os.path.dirname(__file__), 'getsig')
if not os.path.exists(getsig_dir + "/getsig.class"):
@ -84,7 +122,7 @@ class UpdateTest(unittest.TestCase):
self.assertIsNone(pysig, "python sig should be None: " + str(sig))
def testScanApksAndObbs(self):
os.chdir(os.path.dirname(__file__))
os.chdir(os.path.join(localmodule, 'tests'))
if os.path.basename(os.getcwd()) != 'tests':
raise Exception('This test must be run in the "tests/" subdir')
@ -131,7 +169,7 @@ class UpdateTest(unittest.TestCase):
self.assertIsNone(apk.get('obbPatchFile'))
def test_scan_invalid_apk(self):
os.chdir(os.path.dirname(__file__))
os.chdir(os.path.join(localmodule, 'tests'))
if os.path.basename(os.getcwd()) != 'tests':
raise Exception('This test must be run in the "tests/" subdir')