[gnome-2048] build: Make post install script more portable



commit 84ad3134b52307874b5c7fac931157024a093243
Author: Jan Tojnar <jtojnar gmail com>
Date:   Thu Jan 17 04:52:29 2019 +0100

    build: Make post install script more portable
    
    When datadir is set to non-defautl value, the post install script will not work
    as intended. Additionally, we no longer rely on shebang, which is not portable
    either. (/usr/bin/env is not used on Nix, for example.)

 data/meson.build      |  4 ++--
 meson.build           | 10 ++++++++--
 meson_post_install.py | 19 +++++++++++--------
 3 files changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 47922ee..e5e0caa 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -10,12 +10,12 @@ icon_sizes = [
 foreach size : icon_sizes
   install_data(
     join_paths('icons', 'hicolor', size, 'gnome-2048.png'),
-    install_dir: join_paths(datadir, 'icons', 'hicolor', size, 'apps'),
+    install_dir: join_paths(icondir, size, 'apps'),
   )
 endforeach
 install_data(
   join_paths('icons', 'hicolor', 'symbolic', 'gnome-2048-symbolic.svg'),
-  install_dir: join_paths(datadir, 'icons', 'hicolor', 'symbolic', 'apps'),
+  install_dir: join_paths(icondir, 'symbolic', 'apps'),
 )
 
 install_data(
diff --git a/meson.build b/meson.build
index 2b2043b..a780c67 100644
--- a/meson.build
+++ b/meson.build
@@ -7,6 +7,9 @@ project(
 
 gnome = import('gnome')
 i18n = import('i18n')
+# the new python module would be better but it does not have path method in meson 0.49
+# https://github.com/mesonbuild/meson/issues/4070
+python3 = import('python3')
 
 cc = meson.get_compiler('c')
 valac = meson.get_compiler('vala')
@@ -14,6 +17,7 @@ valac = meson.get_compiler('vala')
 # Paths
 localedir = join_paths(get_option('prefix'), get_option('localedir'))
 datadir = join_paths(get_option('prefix'), get_option('datadir'))
+icondir = join_paths(datadir, 'icons', 'hicolor')
 pkgdatadir = join_paths(datadir, 'gnome-2048')
 schemadir = join_paths(datadir, 'glib-2.0', 'schemas')
 
@@ -37,6 +41,8 @@ subdir('help')
 subdir('src')
 
 meson.add_install_script(
-  'meson_post_install.py',
-  datadir
+  python3.find_python().path(),
+  join_paths(meson.source_root(), 'meson_post_install.py'),
+  icondir,
+  schemadir,
 )
diff --git a/meson_post_install.py b/meson_post_install.py
index a814cdf..c9ffcaf 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -2,13 +2,17 @@
 
 import os
 import subprocess
+import sys
 
-if not os.environ.get('DESTDIR'):
-  prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr/local')
-  datadir = os.path.join(prefix, 'share')
 
+if len(sys.argv) < 3:
+  sys.exit("usage: meson_post_install.py <icondir> <schemadir>")
+
+icon_cache_dir = sys.argv[1]
+schemadir = sys.argv[2]
+
+if not os.environ.get('DESTDIR'):
   print('Updating icon cache...')
-  icon_cache_dir = os.path.join(datadir, 'icons', 'hicolor')
   if not os.path.exists(icon_cache_dir):
     os.makedirs(icon_cache_dir)
   subprocess.call(['gtk-update-icon-cache',
@@ -16,7 +20,6 @@ if not os.environ.get('DESTDIR'):
                    icon_cache_dir])
 
   print('Compiling GSettings schemas...')
-  schemas_dir = os.path.join(datadir, 'glib-2.0', 'schemas')
-  if not os.path.exists(schemas_dir):
-    os.makedirs(schemas_dir)
-  subprocess.call(['glib-compile-schemas', schemas_dir])
+  if not os.path.exists(schemadir):
+    os.makedirs(schemadir)
+  subprocess.call(['glib-compile-schemas', schemadir])


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