From 26c7e094cec7a7e8a6db4f8059267a6f28e2ec7b Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Mon, 24 Sep 2007 12:03:14 +0000
Subject: [PATCH] Replace paths in ganeti-watcher.sgml.

Reviewed-by: iustinp
---
 man/Makefile.am         | 31 ++++++++++++++++++++++++++-----
 man/ganeti-watcher.sgml |  4 ++--
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/man/Makefile.am b/man/Makefile.am
index 4b6a410b9..accd08905 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -3,12 +3,33 @@
 man_MANS = ganeti.7 ganeti-os-interface.7 gnt-cluster.8 gnt-node.8 gnt-os.8 \
 	   gnt-instance.8 ganeti-noded.8 ganeti-watcher.8 gnt-backup.8
 
+maninput = $(patsubst %.7,%.in,$(patsubst %.8,%.in,$(man_MANS)))
+
 EXTRA_DIST = ganeti-os-interface.sgml gnt-cluster.sgml gnt-node.sgml \
 	     ganeti-watcher.sgml ganeti.sgml gnt-instance.sgml gnt-os.sgml \
 	     gnt-backup.sgml ganeti-noded.sgml \
-	     footer.sgml $(man_MANS)
-MAINTAINERCLEANFILES = *.[78]
+	     footer.sgml $(maninput)
+CLEANFILES = *.[78]
+MAINTAINERCLEANFILES = *.in
+
+# Wrapper around docbook2man to control the output's filename
+%.in: %.sgml footer.sgml
+	tmpdir=`mktemp -d "./manbuildXXXXXX"` && \
+	mkdir "$$tmpdir" && \
+	docbook2man -o "$$tmpdir" $< && \
+	ok= && \
+	for check in `basename $< .sgml`.{7,8}; do \
+		if test -f "$$tmpdir/$$check"; then \
+			mv "$$tmpdir/$$check" $@ && \
+			ok=1 && \
+			break; \
+		fi; \
+	done; \
+	if test -z "$$ok"; then \
+		echo "Building $@ failed."; \
+		exit 1; \
+	fi; \
+	rm -rf "$$tmpdir"
 
-%.7 %.8: %.sgml footer.sgml
-	docbook2man $<
-	rm -f manpage.links manpage.refs
+%.7 %.8: %.in Makefile
+	sed -e 's#@LOCALSTATEDIR@#$(localstatedir)#g' < $< > $@
diff --git a/man/ganeti-watcher.sgml b/man/ganeti-watcher.sgml
index e5973e7e7..8c630d0cc 100644
--- a/man/ganeti-watcher.sgml
+++ b/man/ganeti-watcher.sgml
@@ -62,9 +62,9 @@
 
     <para>
       The command has a state file located at
-      <filename>/var/lib/ganeti/restart_state</filename> and a log
+      <filename>@LOCALSTATEDIR@/lib/ganeti/restart_state</filename> and a log
       file at
-      <filename>/var/log/ganeti/watcher.log</filename>. Removal of
+      <filename>@LOCALSTATEDIR@/log/ganeti/watcher.log</filename>. Removal of
       either file will not affect correct operation; the removal of
       the state file will just cause the restart counters for the
       instances to reset to zero.
-- 
GitLab