[iagno] Make post-install work if datadir set.



commit 5665f3ba63ae7b370ebddeaf94902f38b6fa74bc
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon Feb 4 14:04:22 2019 +0100

    Make post-install work if datadir set.
    
    As suggested by Jan Tojnar, done by
    copying commit gnome-2048@84ad3134.
    
    See !4.

 build-aux/meson_post_install.py | 24 +++++++++++++++++++-----
 data/meson.build                |  8 ++++----
 meson.build                     | 18 ++++++++++++------
 3 files changed, 35 insertions(+), 15 deletions(-)
---
diff --git a/build-aux/meson_post_install.py b/build-aux/meson_post_install.py
index 6d18340..ae920fc 100644
--- a/build-aux/meson_post_install.py
+++ b/build-aux/meson_post_install.py
@@ -2,13 +2,27 @@
 
 from os import environ, path
 from subprocess import call
+import sys
+
+if len(sys.argv) < 4:
+    sys.exit("usage: meson_post_install.py <icondir> <schemadir> <appsdir>")
+
+icon_cache_dir  = sys.argv[1]
+schemadir       = sys.argv[2]
+appsdir         = sys.argv[3]
 
 if not environ.get('DESTDIR', ''):
-    PREFIX = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
-    DATA_DIR = path.join(PREFIX, 'share')
     print('Updating icon cache...')
-    call(['gtk-update-icon-cache', '-qtf', path.join(DATA_DIR, 'icons/hicolor')])
+    if not os.path.exists(icon_cache_dir):
+        os.makedirs(icon_cache_dir)
+    call(['gtk-update-icon-cache', '-qtf', icon_cache_dir])
+
     print("Compiling new schemas")
-    call(["glib-compile-schemas", path.join(DATA_DIR, 'glib-2.0/schemas')])
+    if not os.path.exists(schemadir):
+        os.makedirs(schemadir)
+    call(["glib-compile-schemas", schemadir])
+
     print("Updating desktop database")
-    call(["update-desktop-database", path.join(DATA_DIR, 'applications')])
+    if not os.path.exists(appsdir):
+        os.makedirs(appsdir)
+    call(["update-desktop-database", appsdir])
diff --git a/data/meson.build b/data/meson.build
index 7998780..8ea679e 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -3,19 +3,19 @@ icon_sizes = ['16', '22', '24', '32', '48', '256']
 foreach size : icon_sizes
     install_data(
         join_paths('icons', 'hicolor', '@0@x@0@'.format(size), '@0@.png'.format(project_id)),
-        install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', '@0@x@0@'.format(size), 'apps')
+        install_dir: join_paths(icondir, '@0@x@0@'.format(size), 'apps')
     )
 endforeach
 # Install symbolic icon
 install_data(
         join_paths('icons', 'hicolor', 'symbolic', '@0 -symbolic svg'.format(project_id)),
-    install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', 'symbolic', 'apps')
+    install_dir: join_paths(icondir, 'symbolic', 'apps')
 )
 
 # Install gschema
 install_data(
   '@0  gschema xml'.format(project_id),
-  install_dir : join_paths(get_option('datadir'), 'glib-2.0', 'schemas')
+  install_dir : schemadir
 )
 
 # Compiling gresoruce
@@ -31,7 +31,7 @@ desktop_file = i18n.merge_file(
     po_dir: join_paths(meson.source_root(), 'po'),
     type: 'desktop',
     install: true,
-    install_dir: join_paths(get_option('datadir'), 'applications')
+    install_dir: appsdir
 )
 
 # Validate desktop file
diff --git a/meson.build b/meson.build
index 470a90d..113a64f 100644
--- a/meson.build
+++ b/meson.build
@@ -21,9 +21,13 @@ rsvg_dependency = dependency('librsvg-2.0', version: '>= 2.32.0')
 # Set gettext package name
 add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()), language: 'c')
 
-localedir = join_paths(get_option('prefix'), get_option('localedir'))
-pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
-soundsdir = join_paths(pkgdatadir, 'sounds')
+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, meson.project_name())
+soundsdir   = join_paths(pkgdatadir, 'sounds')
+schemadir   = join_paths(datadir, 'glib-2.0', 'schemas')
+appsdir     = join_paths(datadir, 'applications')
 
 conf = configuration_data ()
 conf.set_quoted ('VERSION', meson.project_version())
@@ -40,6 +44,8 @@ subdir('po')
 subdir('help')
 subdir('src')
 
-meson.add_install_script(python3.find_python().path(), join_paths(meson.source_root(),
-                                                                  'build-aux',
-                                                                  'meson_post_install.py'))
+meson.add_install_script(python3.find_python().path(),
+                         join_paths(meson.source_root(), 'build-aux', 'meson_post_install.py'),
+                         icondir,
+                         schemadir,
+                         appsdir)


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