meson_post_install.py 837 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/usr/bin/env python3

import glob
import os
import re
import subprocess
import sys

destdir = os.environ.get('DESTDIR', '')

if destdir:
    datadir = os.path.normpath(destdir + os.sep + sys.argv[1])
else:
    datadir = sys.argv[1]

icondir = os.path.join(datadir, 'icons', 'hicolor')

18
name_pattern = re.compile('hicolor_(?:apps)_(?:scalable|symbolic)_(.*)')
19 20 21 22 23 24 25 26 27 28 29 30
search_pattern = '/**/hicolor_*'

for file in glob.glob(icondir + search_pattern, recursive=True):
    os.rename(file, os.path.join(os.path.dirname(file), name_pattern.search(file).group(1)))

if not destdir:
    print('Updating icon cache...')
    subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])

    schemadir = os.path.join(datadir, 'glib-2.0', 'schemas')
    print('Compiling gsettings schemas...')
    subprocess.call(['glib-compile-schemas', schemadir])