diff options
author | Volker Krause <vkrause@kde.org> | 2021-05-22 12:11:16 +0200 |
---|---|---|
committer | Volker Krause <vkrause@kde.org> | 2021-05-23 10:11:55 +0200 |
commit | a0deb0358d07de8b68a41a8270b3386482fa7525 (patch) | |
tree | f2ce449611f91c4002e90dbe4261091b3aaf0028 /toolchain | |
parent | 08faec5d95ef50a1dd6f3e97dc2b73690668ed9d (diff) | |
download | extra-cmake-modules-a0deb0358d07de8b68a41a8270b3386482fa7525.tar.gz extra-cmake-modules-a0deb0358d07de8b68a41a8270b3386482fa7525.tar.bz2 |
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.
Diffstat (limited to 'toolchain')
-rwxr-xr-x | toolchain/generate-fastlane-metadata.py | 26 |
1 files changed, 24 insertions, 2 deletions
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 <id>.appdata.xml or <id>.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 |