[polari] build: Move appstream version check into distscript



commit ce2cd46b9aeea665fbc0579d7dd25abfcbee36a4
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Aug 31 00:49:33 2021 +0200

    build: Move appstream version check into distscript
    
    The time we really care about current release information in appdata is
    when preparing a release, not during regular builds.
    
    Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/220>

 data/appdata/meson.build | 10 ----------
 meson.build              |  7 +++++++
 meson/check-version.py   | 22 ++++++++++++++++++++++
 3 files changed, 29 insertions(+), 10 deletions(-)
---
diff --git a/data/appdata/meson.build b/data/appdata/meson.build
index 52a97767..88b4a0be 100644
--- a/data/appdata/meson.build
+++ b/data/appdata/meson.build
@@ -14,14 +14,4 @@ if (appstream_util.found())
     workdir: meson.current_build_dir(),
     depends: [appdata]
   )
-
-  r = run_command(appstream_util, '--help')
-  if (r.stdout().contains('validate-version'))
-    test('Checking release entry for @0@'.format(meson.project_version()),
-      appstream_util,
-      args: ['validate-version', appdata.full_path(), meson.project_version()],
-      workdir: meson.current_build_dir(),
-      depends: [appdata]
-    )
-  endif
 endif
diff --git a/meson.build b/meson.build
index c886c4a9..83cf8101 100644
--- a/meson.build
+++ b/meson.build
@@ -32,6 +32,7 @@ js_shell = find_program('js78', required: false)
 desktop_file_validate = find_program('desktop-file-validate', required: false)
 json_glib_validate = find_program('json-glib-validate', required: false)
 appstream_util = find_program('appstream-util', required: false)
+check_version = find_program('meson/check-version.py')
 
 gio = dependency('gio-2.0', version: '>= 2.43.4')
 gtk3 = dependency('gtk+-3.0', version: '>= 3.21.6')
@@ -62,6 +63,12 @@ subdir('help')
 
 meson.add_install_script('meson/meson-postinstall.sh')
 
+if (appstream_util.found())
+  meson.add_dist_script(check_version,
+    meson.project_version(),
+    'data/appdata/org.gnome.Polari.appdata.xml.in')
+endif
+
 summary('prefix', get_option('prefix'))
 summary('bindir', get_option('bindir'))
 summary('libdir', get_option('libdir'))
diff --git a/meson/check-version.py b/meson/check-version.py
new file mode 100755
index 00000000..d8c1ed81
--- /dev/null
+++ b/meson/check-version.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+
+import os, sys
+from pathlib import Path
+import argparse, subprocess
+
+def check_version(version, file):
+    subprocess.run(['appstream-util', 'validate-version', file, version],
+                   check=True)
+
+parser = argparse.ArgumentParser(description='Check release version information.')
+parser.add_argument('version', help='the version to check for')
+parser.add_argument('files', nargs='+', help='files to check')
+args = parser.parse_args()
+
+distroot = os.environ.get('MESON_DIST_ROOT', './')
+
+try:
+    for file in args.files:
+        check_version(args.version, Path(distroot, file))
+except:
+    sys.exit(1)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]