[nautilus] postinstall: Use python



commit 53928d7f468e233b569f37d058bd9d4742bb60a5
Author: Carlos Soriano <csoriano gnome org>
Date:   Tue May 2 19:44:41 2017 +0200

    postinstall: Use python
    
    Instead of shell scripts, much better to maintain.
    Also, the new python script has better handling of non existing paths.

 build-aux/meson/postinstall.py |   27 +++++++++++++++++++++++++++
 build-aux/meson/postinstall.sh |   13 -------------
 meson.build                    |    2 +-
 3 files changed, 28 insertions(+), 14 deletions(-)
---
diff --git a/build-aux/meson/postinstall.py b/build-aux/meson/postinstall.py
new file mode 100755
index 0000000..81afb18
--- /dev/null
+++ b/build-aux/meson/postinstall.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+
+prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr/local')
+datadir = os.path.join(prefix, 'share')
+
+# Packaging tools define DESTDIR and this isn't needed for them
+if 'DESTDIR' not in os.environ:
+    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', '-qtf', icon_cache_dir])
+
+    print('Updating desktop database...')
+    desktop_database_dir = os.path.join(datadir, 'applications')
+    if not os.path.exists(desktop_database_dir):
+        os.makedirs(desktop_database_dir)
+    subprocess.call(['update-desktop-database', '-q', desktop_database_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])
diff --git a/meson.build b/meson.build
index 73fcfd8..ef8293a 100644
--- a/meson.build
+++ b/meson.build
@@ -125,4 +125,4 @@ if get_option ('enable-nst-extension')
 endif
 
 # Compile GSettings schemas when installing from source.
-meson.add_install_script ('build-aux/meson/postinstall.sh')
+meson.add_install_script ('build-aux/meson/postinstall.py')


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