From a0deb0358d07de8b68a41a8270b3386482fa7525 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Sat, 22 May 2021 12:11:16 +0200 Subject: Attempt to find the Play store icon if it's not explicitly set This relies on the apparently predominant naming pattern for those files, those of our apps not using this often do not seem to have an appropriate file (512x512 png) to begin with. Explicit override is also possible, by the already existing mechanism of putting a file with the right name into the fastlane/ source directory. Having the icon included here will allow it to be automatically synced to the Play store. --- toolchain/generate-fastlane-metadata.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'toolchain') diff --git a/toolchain/generate-fastlane-metadata.py b/toolchain/generate-fastlane-metadata.py index 034a8699..ef59a278 100755 --- a/toolchain/generate-fastlane-metadata.py +++ b/toolchain/generate-fastlane-metadata.py @@ -218,6 +218,22 @@ def processLocalImages(applicationName, data): os.chdir(oldcwd) +# Attempt to find the application icon if we haven't gotten that explicitly from processLocalImages +def findIcon(applicationName, iconBaseName): + iconPath = os.path.join(arguments.output, 'metadata', applicationName, 'en-US', 'images', 'icon.png') + if os.path.exists(iconPath): + return + + oldcwd = os.getcwd() + os.chdir(arguments.source) + + iconFiles = glob.glob(f"**/{iconBaseName}-playstore.png", recursive=True) + for icon in iconFiles: + shutil.copy(icon, iconPath) + break + + os.chdir(oldcwd) + # Download screenshots referenced in the appstream data # see https://f-droid.org/en/docs/All_About_Descriptions_Graphics_and_Screenshots/ def downloadScreenshots(applicationName, data): @@ -254,7 +270,7 @@ def createMetadataArchive(applicationName): os.chdir(oldcwd) # Generate metadata for the given appstream and desktop files -def processAppstreamFile(appstreamFileName, desktopFileName): +def processAppstreamFile(appstreamFileName, desktopFileName, iconBaseName): # appstreamFileName has the form .appdata.xml or .metainfo.xml, so we # have to strip off two extensions applicationName = os.path.splitext(os.path.splitext(os.path.basename(appstreamFileName))[0])[0] @@ -335,6 +351,7 @@ def processAppstreamFile(appstreamFileName, desktopFileName): shutil.rmtree(imagePath, ignore_errors=True) processLocalImages(applicationName, data) downloadScreenshots(applicationName, data) + findIcon(applicationName, iconBaseName) # put the result in an archive file for easier use by Jenkins createMetadataArchive(applicationName) @@ -359,6 +376,11 @@ def scanSourceDir(): if not appname or not is_app: continue + iconBaseName = None + for elem in root.findall('application'): + if prefix + 'icon' in elem.attrib: + iconBaseName = elem.attrib[prefix + 'icon'].split('/')[-1] + # now that we have the app id, look for matching appdata/desktop files appdataFiles = glob.glob(arguments.source + "/**/" + appname + ".metainfo.xml", recursive=True) appdataFiles.extend(glob.glob(arguments.source + "/**/" + appname + ".appdata.xml", recursive=True)) @@ -375,7 +397,7 @@ def scanSourceDir(): desktopFile = f break - processAppstreamFile(appdataFile, desktopFile) + processAppstreamFile(appdataFile, desktopFile, iconBaseName) ### Script Commences -- cgit v1.2.1