1allow systemd path to be defined by configure option.
2
3The configure probes the host for systemd path information.
4
5Upstream Status: Inappropriate [Embedded]
6
7Signed-off-By: Armin Kuster <akuster@mvista.com>
8
9Index: ipmiutil-3.0.5/configure.ac
10===================================================================
11--- ipmiutil-3.0.5.orig/configure.ac
12+++ ipmiutil-3.0.5/configure.ac
13@@ -149,7 +149,6 @@ CROSS_LFLAGS=""
14 CROSS_CFLAGS=""
15 LIBSENSORS=""
16 SAM2OBJ="isensor2.o ievents2.o"
17-SYSTEMD_DIR=/usr/share/ipmiutil
18
19 AC_ARG_ENABLE([useflags],
20     [  --enable-useflags    include environment CFLAGS and LDFLAGS.],
21@@ -200,29 +199,42 @@ AC_ARG_ENABLE([gpl],
22
23 dnl Does this Linux have systemd enabled?  Otherwise use sysv init.
24 AC_ARG_ENABLE([systemd],
25-    [  --enable-systemd       enable systemd service type=notify support and %_unitdir [[default=disabled]]],)
26-if test "x$enable_systemd" = "xyes"; then
27-   GPL_CFLAGS="$GPL_CFLAGS -DENABLE_SYSTEMD"
28-   # if systemd enabled, install service scripts in unitdir
29-   which rpm >/dev/null 2>&1
30-   if test  $? -eq 0 ; then
31-	SYSTEMD_DIR=`rpm --eval "%{_unitdir}"`
32-   else
33-    SYSTEMD_DIR=/usr/share/ipmiutil
34-   fi
35+    [  --enable-systemd[=systemddir]      install systemd unit file.  If 'yes'
36+        probe the system for unit directory.
37+        If a path is specified, assume that
38+        is a valid install path. [[default=disabled]]],)
39+# Check whether --enable-systemd was given.
40+if test "${enable_systemd+set}" = set; then :
41+	withval=$enable_systemd; if test "$withval" = yes; then
42+	GPL_CFLAGS="$GPL_CFLAGS -DENABLE_SYSTEMD"
43+	if test -z "$systemddir"; then
44+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking location of the systemd unit files directory" >&5
45+		$as_echo_n "checking location of the systemd unit files directory... " >&6; }
46+		_rpmdir = ""
47+		which rpm >/dev/null 2>&1
48+		if test  $? -eq 0 ; then
49+			_rpmdir = `rpm --eval "%{_unitdir}"`
50+		fi
51+		for systemd_d in ${datadir}/usr/share/ipmiutil ${_rpmdir} /usr/share/ipmiutil; do
52+			if test -z "$systemddir"; then
53+				if test -d "$systemd_d"; then
54+					systemddir="$systemd_d"
55+				fi
56+			fi
57+		done
58+	fi
59+	if test -n "$systemddir"; then
60+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $systemddir" >&5
61+		$as_echo "$systemddir" >&6; }
62+	else
63+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
64+		$as_echo "not found" >&6; }
65+	fi
66 else
67-   # otherwise install the systemd service scripts in the data dir
68-  SYSTEMD_DIR=/usr/share/ipmiutil
69-  if test "x$sysname" != "xDarwin" ; then
70-    if test  "x$os" != "xhpux" ; then
71-      # MacOS and HP-UX: 'which' command returns 0 always
72-      which rpm >/dev/null 2>&1
73-      if test  $? -eq 0 ; then
74-         datad=`rpm --eval "%{_datadir}"`
75-         SYSTEMD_DIR=${datad}/ipmiutil
76-      fi
77-    fi
78-  fi
79+	if test "$withval" != no; then
80+		systemddir=$withval
81+	fi
82+fi
83 fi
84
85 dnl start main logic
86@@ -528,7 +540,7 @@ AC_SUBST(INS_LIB)
87 AC_SUBST(SUBDIR_S)
88 AC_SUBST(CROSS_CFLAGS)
89 AC_SUBST(CROSS_LFLAGS)
90-AC_SUBST(SYSTEMD_DIR)
91+AC_SUBST(systemddir)
92 AC_SUBST(SHR_LINK)
93 AC_SUBST(pkgconfigdir)
94
95Index: ipmiutil-3.0.5/scripts/Makefile.am
96===================================================================
97--- ipmiutil-3.0.5.orig/scripts/Makefile.am
98+++ ipmiutil-3.0.5/scripts/Makefile.am
99@@ -17,7 +17,8 @@ cronto = ${DESTDIR}${etcdir}/cron.daily
100 sbinto = ${DESTDIR}${sbindir}
101 varto  = ${DESTDIR}/var/lib/ipmiutil
102 initto = ${DESTDIR}@INIT_DIR@
103-sysdto = ${DESTDIR}@SYSTEMD_DIR@
104+sysdto = ${DESTDIR}@systemddir@
105+systemddir = @systemddir@
106 sysvinit = ${datato}
107 sbinfls = ialarms ihealth ifru igetevent ireset icmd isol ilan isensor isel iserial iwdt iconfig ipicmg ifirewall ifwum ihpm iuser
108
109@@ -47,10 +48,14 @@ install:
110 	${INSTALL_SCRIPT_SH} ipmi_port.sh ${sysvinit}/ipmi_port
111 	${INSTALL_SCRIPT_SH} ipmi_info    ${sysvinit}/ipmi_info
112 	${INSTALL_SCRIPT_SH} checksel     ${datato}
113-	${INSTALL_DATA_SH} ipmiutil_wdt.service ${sysdto}
114-	${INSTALL_DATA_SH} ipmiutil_asy.service ${sysdto}
115-	${INSTALL_DATA_SH} ipmiutil_evt.service ${sysdto}
116-	${INSTALL_DATA_SH} ipmi_port.service    ${sysdto}
117+
118+	if [ ! -z "${systemddir}" ]; then \
119+		$(MKDIR) ${sysdto}; \
120+		${INSTALL_DATA_SH} ipmiutil_wdt.service ${sysdto}; \
121+		${INSTALL_DATA_SH} ipmiutil_asy.service ${sysdto}; \
122+		${INSTALL_DATA_SH} ipmiutil_evt.service ${sysdto}; \
123+		${INSTALL_DATA_SH} ipmi_port.service    ${sysdto}; \
124+	fi
125 	${INSTALL_SCRIPT_SH} ipmiutil.env     ${datato}
126 	${INSTALL_SCRIPT_SH} ipmiutil.pre     ${datato}
127 	${INSTALL_SCRIPT_SH} ipmiutil.setup   ${datato}
128