The attached patch removes our depencence on a hardcoded path to
pm/functions.  It modifies Makefile.am in the src and pm/sleep.d
directories to have make install rewrite the installed scripts to
source the final installation location of pm/functions, not the
hardcoded path.

One interesting thing to note is that the scripts are considered data
by the autotools process, so all that install-exec-(local|hook) stuff
has been incorrect for the lifetime of pm-utils so far.

I would like some review and testing -- it Works For Me, but I am an
autotools n00b and probably missed something.
diff --git a/pm/sleep.d/00clear b/pm/sleep.d/00clear
index b96e0a7..fac3496 100755
--- a/pm/sleep.d/00clear
+++ b/pm/sleep.d/00clear
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-. /usr/lib/pm-utils/functions
+. @PM-UTILS-LIBDIR@/functions
 
 RETVAL=0
 case "$1" in
diff --git a/pm/sleep.d/00logging b/pm/sleep.d/00logging
index 563745a..8ba7b72 100755
--- a/pm/sleep.d/00logging
+++ b/pm/sleep.d/00logging
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-. /usr/lib/pm-utils/functions
+. @PM-UTILS-LIBDIR@/functions
 
 case "$1" in
         hibernate|suspend)
diff --git a/pm/sleep.d/10NetworkManager b/pm/sleep.d/10NetworkManager
index f9eeb91..56c7c2b 100755
--- a/pm/sleep.d/10NetworkManager
+++ b/pm/sleep.d/10NetworkManager
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-. /usr/lib/pm-utils/functions
+. @PM-UTILS-LIBDIR@/functions
 
 suspend_nm() {
     # Tell NetworkManager to shut down networking
diff --git a/pm/sleep.d/20video b/pm/sleep.d/20video
index 41e79ad..d51e741 100755
--- a/pm/sleep.d/20video
+++ b/pm/sleep.d/20video
@@ -7,7 +7,7 @@
 # it under the terms of version 2 of the GNU General Public License as
 # published by the Free Software Foundation.
 
-. /usr/lib/pm-utils/functions
+. @PM-UTILS-LIBDIR@/functions
 
 if type vbetool |grep -q "not found" ; then
 	vbe() { echo "vbetool not found" 1>&2; return 1; }
diff --git a/pm/sleep.d/49bluetooth b/pm/sleep.d/49bluetooth
index 57ed8ee..e3f6fe9 100755
--- a/pm/sleep.d/49bluetooth
+++ b/pm/sleep.d/49bluetooth
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-. /usr/lib/pm-utils/functions
+. @PM-UTILS-LIBDIR@/functions
 
 suspend_bluetooth()
 {
diff --git a/pm/sleep.d/50modules b/pm/sleep.d/50modules
index 19707c1..b406258 100755
--- a/pm/sleep.d/50modules
+++ b/pm/sleep.d/50modules
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-. /usr/lib/pm-utils/functions
+. @PM-UTILS-LIBDIR@/functions
 
 suspend_modules()
 {
diff --git a/pm/sleep.d/55battery b/pm/sleep.d/55battery
index 680cee4..9ff0fe7 100755
--- a/pm/sleep.d/55battery
+++ b/pm/sleep.d/55battery
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-. /usr/lib/pm-utils/functions
+. @PM-UTILS-LIBDIR@/functions
 
 resume_batteries()
 {
diff --git a/pm/sleep.d/65alsa b/pm/sleep.d/65alsa
index 68400db..5df0647 100755
--- a/pm/sleep.d/65alsa
+++ b/pm/sleep.d/65alsa
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-. /usr/lib/pm-utils/functions
+. @PM-UTILS-LIBDIR@/functions
 
 case "$1" in
 	hibernate|suspend)
diff --git a/pm/sleep.d/90clock b/pm/sleep.d/90clock
index 6e73714..2a30beb 100755
--- a/pm/sleep.d/90clock
+++ b/pm/sleep.d/90clock
@@ -1,5 +1,5 @@
 #!/bin/sh
-. /usr/lib/pm-utils/functions
+. @PM-UTILS-LIBDIR@/functions
 
 NTPD_LOCK="/var/run/pm-utils/pm-ntpd.lock"
 
diff --git a/pm/sleep.d/94cpufreq b/pm/sleep.d/94cpufreq
index 0c03400..546b0eb 100755
--- a/pm/sleep.d/94cpufreq
+++ b/pm/sleep.d/94cpufreq
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-. /usr/lib/pm-utils/functions
+. @PM-UTILS-LIBDIR@/functions
 
 hibernate_cpufreq()
 {
diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video
index cbba76f..9070344 100755
--- a/pm/sleep.d/99video
+++ b/pm/sleep.d/99video
@@ -7,7 +7,7 @@
 # it under the terms of version 2 of the GNU General Public License as
 # published by the Free Software Foundation.
 
-. /usr/lib/pm-utils/functions
+. @PM-UTILS-LIBDIR@/functions
 
 
 reset_brightness() {
diff --git a/pm/sleep.d/Makefile.am b/pm/sleep.d/Makefile.am
index 5092a42..5f47601 100644
--- a/pm/sleep.d/Makefile.am
+++ b/pm/sleep.d/Makefile.am
@@ -1,4 +1,5 @@
 sleepdir = $(libdir)/pm-utils/sleep.d
+pm_utils_libdir = $(libdir)/pm-utils
 
 sleep_SCRIPTS =			\
 	00clear			\
@@ -18,7 +19,16 @@ sleep_SCRIPTS =			\
 
 EXTRA_DIST=$(sleep_SCRIPTS)
 
-install-exec-local:
+# If anything sources pm/functions, you MUST:
+# 1: Have it source @PM-UTILS-LIBDIR@/functions
+# 2: Add it to the list of files to be transformed in the for loop below.
+# Doing this will ensure that the scripts will function 
+# no matter where they are installed.
+install-data-hook:
+	for x in $(sleep_SCRIPTS); \
+		do printf ",[EMAIL PROTECTED]@#$(pm_utils_libdir)#g\nwq\n" | \
+		ed "$(sleepdir)/$$x" >/dev/null 2>&1; \
+	done
 	-mkdir -p $(DESTDIR)$(sysconfdir)/pm/sleep.d
 
 clean-local :
diff --git a/pm/sleep.d/zzz b/pm/sleep.d/zzz
index 1d16e78..0853445 100644
--- a/pm/sleep.d/zzz
+++ b/pm/sleep.d/zzz
@@ -1,5 +1,5 @@
 #!/bin/sh
-. /usr/lib/pm-utils/functions
+. @PM-UTILS-LIBDIR@/functions
 [ -e "$INHIBIT" ] && return 1
 sync;sync;sync;
 case $1 in
diff --git a/src/Makefile.am b/src/Makefile.am
index 184c221..9f1ba5b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,5 @@
 pm_utils_bindir = $(libdir)/pm-utils/bin
+pm_utils_libdir = $(libdir)/pm-utils
 
 pm_utils_bin_PROGRAMS =		\
 	pm-pmu			\
@@ -28,8 +29,17 @@ acpowerdir = $(bindir)
 acpower_SCRIPTS =		\
 	on_ac_power
 
-install-exec-hook:
+# If anything sources pm/functions, you MUST:
+# 1: Have it source @PM-UTILS-LIBDIR@/functions
+# 2: Add it to the list of files to be transformed in the for loop below.
+# Doing this will ensure that the scripts will function 
+# no matter where they are installed.
+install-data-hook:
 	-mkdir -p $(DESTDIR)$(sbindir)
+	for x in $(pm_utils_bindir)/pm-action $(extradir)/pm-powersave; do \ 
+		printf ",[EMAIL PROTECTED]@#$(pm_utils_libdir)#g\nwq\n" | \
+			ed "$$x" >/dev/null 2>&1; \
+	done
 	-ln -s $(pm_utils_bindir)/pm-action $(DESTDIR)$(sbindir)/pm-suspend
 	-ln -s $(pm_utils_bindir)/pm-action $(DESTDIR)$(sbindir)/pm-hibernate
 	-ln -s $(pm_utils_bindir)/pm-action $(DESTDIR)$(sbindir)/pm-suspend-hybrid
diff --git a/src/pm-action b/src/pm-action
index 3a1e6a5..dce8eaa 100755
--- a/src/pm-action
+++ b/src/pm-action
@@ -84,7 +84,7 @@ do
 	shift
 done
 
-. /usr/lib/pm-utils/functions
+. @PM-UTILS-LIBDIR@/functions
 
 [ -f /sys/power/state ] || exit 1
 
diff --git a/src/pm-powersave b/src/pm-powersave
index 11ec1b9..4b690ce 100755
--- a/src/pm-powersave
+++ b/src/pm-powersave
@@ -25,8 +25,8 @@
 #
 
 POWERSAVE_LOGFILE="/dev/null"
-[ -f /usr/lib/pm-utils/functions ] || return 1
-. /usr/lib/pm-utils/functions
+[ -f @PM-UTILS-LIBDIR@/functions ] || return 1
+. @PM-UTILS-LIBDIR@/functions
 
 if [ "x$1" = "xtrue" -o "x$1" = "xfalse" ] ; then
     init_logfile "${POWERSAVE_LOGFILE}"
_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to