summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2018-09-13 17:24:58 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2018-09-19 16:03:32 +0200
commit98b4a19a536ddb9f75611deaa272ae5661c5df4d (patch)
treedccf8de03536282b57aa0cfab770764578767be5
parente732789bbfad6f4824d66a6ed76e40f8d907e846 (diff)
downloadNetworkManager-98b4a19a536ddb9f75611deaa272ae5661c5df4d.tar.gz
build: meson: support $DESTDIR in installation script
Adapt the meson post-installation script to handle the $DESTDIR variable supplied by user to specify the installation target directory. While at it, convert the script to shell because it seems simpler to me.
-rw-r--r--Makefile.am2
-rw-r--r--meson.build2
-rw-r--r--meson_post_install.py46
-rwxr-xr-xtools/meson-post-install.sh44
4 files changed, 46 insertions, 48 deletions
diff --git a/Makefile.am b/Makefile.am
index 3f81c38925..13c07612fc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5040,7 +5040,6 @@ EXTRA_DIST += \
valgrind.suppressions \
meson.build \
meson_options.txt \
- meson_post_install.py \
config.h.meson \
config-extra.h.meson \
docs/meson.build \
@@ -5081,6 +5080,7 @@ EXTRA_DIST += \
tools/check-exports.sh \
tools/create-exports-NetworkManager.sh \
tools/debug-helper.py \
+ tools/meson-post-install.sh \
tools/run-nm-test.sh \
tools/test-networkmanager-service.py \
tools/test-sudo-wrapper.sh \
diff --git a/meson.build b/meson.build
index 7c7ef7ecc5..239e6744b6 100644
--- a/meson.build
+++ b/meson.build
@@ -895,7 +895,7 @@ configure_file(
)
meson.add_install_script(
- 'meson_post_install.py',
+ join_paths('tools', 'meson-post-install.sh'),
nm_datadir,
nm_bindir,
nm_pkgconfdir,
diff --git a/meson_post_install.py b/meson_post_install.py
deleted file mode 100644
index 16dbc42b95..0000000000
--- a/meson_post_install.py
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/env python3
-
-import os
-import sys
-
-if not os.environ.get('DESTDIR'):
- datadir = sys.argv[1]
- bindir = sys.argv[2]
- pkgconfdir = sys.argv[3]
- pkglibdir = sys.argv[4]
- localstatedir = sys.argv[5]
-
- completions_dir = os.path.join(datadir, 'bash-completion', 'completions')
- os.rename(os.path.join(completions_dir, 'nmcli-completion'), os.path.join(completions_dir, 'nmcli'))
-
- nmtui_alias = ['nmtui-connect', 'nmtui-edit', 'nmtui-hostname']
- src = os.path.join(bindir, 'nmtui')
- [os.symlink(src, os.path.join(bindir, dst))
- for dst in nmtui_alias]
-
- dst_dirs = [
- os.path.join(pkgconfdir, 'conf.d'),
- os.path.join(pkgconfdir, 'system-connections'),
- os.path.join(pkgconfdir, 'dispatcher.d', 'no-wait.d'),
- os.path.join(pkgconfdir, 'dispatcher.d', 'pre-down.d'),
- os.path.join(pkgconfdir, 'dispatcher.d', 'pre-up.d'),
- os.path.join(pkgconfdir, 'dnsmasq.d'),
- os.path.join(pkgconfdir, 'dnsmasq-shared.d'),
- os.path.join(pkglibdir, 'conf.d'),
- os.path.join(pkglibdir, 'VPN'),
- os.path.join(localstatedir, 'lib', 'NetworkManager')
- ]
- [os.makedirs(dst_dir)
- for dst_dir in dst_dirs
- if not os.path.exists(dst_dir)]
-
- if sys.argv[6] == 'install_docs':
- mandir = sys.argv[7]
-
- src = os.path.join(mandir, 'man1', 'nmtui.1')
- [os.symlink(src, os.path.join(mandir, 'man1', dst + '.1'))
- for dst in nmtui_alias]
-
- src = os.path.join(mandir, 'man5', 'NetworkManager.conf.5')
- dst = os.path.join(mandir, 'man5', 'nm-system-settings.conf.5')
- os.symlink(src, dst)
diff --git a/tools/meson-post-install.sh b/tools/meson-post-install.sh
new file mode 100755
index 0000000000..fd21941bbd
--- /dev/null
+++ b/tools/meson-post-install.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+datadir=$1
+bindir=$2
+pkgconfdir=$3
+pkglibdir=$4
+localstatedir=$5
+
+[ -n "$DESTDIR" ] && DESTDIR=${DESTDIR%%/}/
+
+if [ -f "${DESTDIR}${datadir}/bash-completion/completions/nmcli-completion" ]; then
+ mv "${DESTDIR}${datadir}/bash-completion/completions/nmcli-completion" \
+ "${DESTDIR}${datadir}/bash-completion/completions/nmcli"
+fi
+
+if [ -x "${DESTDIR}${bindir}/nmtui" ]; then
+ for alias in nmtui-connect nmtui-edit nmtui-hostname; do
+ ln -sf nmtui "${DESTDIR}${bindir}/$alias"
+ done
+fi
+
+for dir in "${pkgconfdir}/conf.d" \
+ "${pkgconfdir}/system-connections" \
+ "${pkgconfdir}/dispatcher.d/no-wait.d" \
+ "${pkgconfdir}/dispatcher.d/pre-down.d" \
+ "${pkgconfdir}/dispatcher.d/pre-up.d" \
+ "${pkgconfdir}/dnsmasq.d" \
+ "${pkgconfdir}/dnsmasq-shared.d" \
+ "${pkgconfdir}/conf.d" \
+ "${pkgconfdir}/VPN" \
+ "${localstatedir}/lib/NetworkManager"; do
+ mkdir -p "${DESTDIR}${dir}"
+done
+
+if [ "$6" = install_docs ]; then
+ mandir=$7
+
+ for alias in nmtui-connect nmtui-edit nmtui-hostname; do
+ ln -f "${DESTDIR}${mandir}/man1/nmtui.1" "${DESTDIR}${mandir}/man1/${alias}.1"
+ done
+
+ ln -f "${DESTDIR}${mandir}/man5/NetworkManager.conf.5" "${DESTDIR}${mandir}/man5/nm-system-settings.conf"
+fi
+