build: Only update post-install caches when they exist

When building without UI, there are no icon or desktop files so there is no need to run the commands to refresh the caches.

It would be even nicer to move the postinstall script to the malcontent-control subdirectory but it really applies to the installation output of the whole project, not just the malcontent-control part.
This commit is contained in:
Jan Tojnar 2020-03-25 19:13:00 +01:00
parent 697fd56f38
commit 0d60138e0a
No known key found for this signature in database
GPG Key ID: 7FAB2A15F7A607A4
1 changed files with 6 additions and 4 deletions

View File

@ -7,10 +7,12 @@ import subprocess
install_prefix = os.environ['MESON_INSTALL_PREFIX']
if not os.environ.get('DESTDIR'):
print('Updating icon cache…')
icon_cache_dir = os.path.join(install_prefix, 'share', 'icons', 'hicolor')
if os.path.exists(icon_cache_dir):
print('Updating icon cache…')
subprocess.call(['gtk-update-icon-cache', '-qtf', icon_cache_dir])
print('Updating desktop database…')
desktop_database_dir = os.path.join(install_prefix, 'share', 'applications')
if os.path.exists(desktop_database_dir):
print('Updating desktop database…')
subprocess.call(['update-desktop-database', '-q', desktop_database_dir])