diff --git a/desktop/meson.build b/desktop/meson.build index 5351b08e14..4203695a58 100644 --- a/desktop/meson.build +++ b/desktop/meson.build @@ -46,7 +46,7 @@ endif if appstreamcli.found() test('appdata_file', - find_program('test-appdata.sh', required: true, dirs: [meson.current_source_dir()]), + find_program('test-appdata.py', required: true, dirs: [meson.current_source_dir()]), env: [ 'GIMP_TESTING_BUILDDIR=' + meson.current_build_dir(), 'GIMP_RELEASE=' + (release and not gimp_rc_git ? '1' : '0'), diff --git a/desktop/test-appdata.py b/desktop/test-appdata.py new file mode 100644 index 0000000000..ec04eecacf --- /dev/null +++ b/desktop/test-appdata.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +import os +import sys +import subprocess +import tempfile +from datetime import date + +os.chdir(os.environ['GIMP_TESTING_BUILDDIR']) +if int(os.environ.get('GIMP_RELEASE', '0')) == 1: + result = subprocess.run(['appstreamcli', 'validate', 'org.gimp.GIMP.appdata.xml']) + sys.exit(result.returncode) +else: + temp_fd, APPDATA = tempfile.mkstemp(prefix='org.gimp.GIMP.appdata.',suffix='.xml',dir='.') + with open('org.gimp.GIMP.appdata.xml', 'r', encoding='utf-8') as f: + content = f.read() + new_content = content.replace( + 'date="TODO"', + f'date="{date.today().isoformat()}"' + ) + with os.fdopen(temp_fd, 'w', encoding='utf-8') as f: + f.write(new_content) + result = subprocess.run(['appstreamcli', 'validate', APPDATA]) + os.remove(APPDATA) + sys.exit(result.returncode) diff --git a/desktop/test-appdata.sh b/desktop/test-appdata.sh deleted file mode 100755 index 6a77a10f92..0000000000 --- a/desktop/test-appdata.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -cd $GIMP_TESTING_BUILDDIR -if [ $GIMP_RELEASE -eq 1 ]; then - appstreamcli validate org.gimp.GIMP.appdata.xml - exit $? -else - APPDATA=`mktemp org.gimp.GIMP.appdata.XXX.xml` - sed "s/date=\"TODO\"/date=\"`date --iso-8601`\"/" org.gimp.GIMP.appdata.xml > $APPDATA - appstreamcli validate $APPDATA - success=$? - rm $APPDATA - exit $success -fi