From 866670e30907eb534895da26626709ed5f2e419d Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 7 Apr 2021 19:09:25 +0100 Subject: build: Port post-install script to Python Avoid the whole shell/batch file shenanigans. --- build-aux/post-install.bat | 24 ------------------------ build-aux/post-install.py | 26 ++++++++++++++++++++++++++ build-aux/post-install.sh | 18 ------------------ 3 files changed, 26 insertions(+), 42 deletions(-) delete mode 100644 build-aux/post-install.bat create mode 100644 build-aux/post-install.py delete mode 100644 build-aux/post-install.sh (limited to 'build-aux') diff --git a/build-aux/post-install.bat b/build-aux/post-install.bat deleted file mode 100644 index 6994d49e1..000000000 --- a/build-aux/post-install.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off - -set bindir=%1 -set libdir=%2 -set binary_version=%3 - -set libdir_windows=%libdir:/=\% - -if not "%DESTDIR%" == "" goto warn_msg -if not exist %libdir_windows%\gdk-pixbuf-2.0\%binary_version%\ mkdir %libdir_windows%\gdk-pixbuf-2.0\%binary_version% -%bindir%\gdk-pixbuf-query-loaders > %libdir_windows%\gdk-pixbuf-2.0\%binary_version%\loaders.cache - -goto end - -:warn_msg -echo *** -echo *** Warning: loaders.cache not built -echo *** -echo *** You should generate this file manually on the host system -echo *** using: -echo *** gdk-pixbuf-query-loaders ^> %libdir_windows%\gdk-pixbuf-2.0\%binary_version%\loaders.cache -echo *** - -:end diff --git a/build-aux/post-install.py b/build-aux/post-install.py new file mode 100644 index 000000000..d532ddf73 --- /dev/null +++ b/build-aux/post-install.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import os +import sys +import subprocess + +if 'DESTDIR' not in os.environ: + bindir = sys.argv[1] + libdir = sys.argv[2] + binary_version = sys.argv[3] + + query_loaders = os.path.join(bindir, "gdk-pixbuf-query-loaders") + loaders_dir = os.path.join(libdir, "gdk-pixbuf-2.0", binary_version) + loaders_cache = os.path.join(loaders_dir, "loaders.cache") + + os.makedirs(loaders_dir, exist_ok=True) + + cmd = [query_loaders] + with subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True) as p: + data = p.stdout.read() + + with open(loaders_cache, "wb") as f: + f.write(data) +else: + print("*** Warning: loaders.cache not built because DESTDIR is set") + print("*** You will need to manually call gdk-pixbuf-query-loaders") diff --git a/build-aux/post-install.sh b/build-aux/post-install.sh deleted file mode 100644 index 661bceeef..000000000 --- a/build-aux/post-install.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -bindir="$1" -libdir="$2" -binary_version="$3" - -if [ -z "$DESTDIR" ]; then - mkdir -p "$libdir/gdk-pixbuf-2.0/$binary_version" - $bindir/gdk-pixbuf-query-loaders > "$libdir/gdk-pixbuf-2.0/$binary_version/loaders.cache" -else - echo "***" - echo "*** Warning: loaders.cache not built" - echo "***" - echo "*** You should generate this file manually on the host system" - echo "*** using:" - echo "*** gdk-pixbuf-query-loaders > $libdir/gdk-pixbuf-2.0/$binary_version/loaders.cache" - echo "***" -fi -- cgit v1.2.1