[PATCH 07/21] build: fix usage of sed and drop build-aux/genman

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx>

"sed -i" is a GNU specific extention.

Replace with more portable version and drop completely genman
in favour of a make rule.

Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx>
---
:100644 100644 e73a80d... 97e6b7d... M	Makefile.am
:100755 000000 94ae715... 0000000... D	build-aux/genman
:100644 100644 8e4d4c7... 21d1e22... M	init/Makefile.am
:100644 100644 946a9b3... 0bf600f... M	man/Makefile.am
 Makefile.am      |    1 -
 build-aux/genman |   52 ----------------------------------------------------
 init/Makefile.am |    5 ++---
 man/Makefile.am  |   17 +++++++++++------
 4 files changed, 13 insertions(+), 62 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index e73a80d..97e6b7d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -37,7 +37,6 @@ EXTRA_DIST		= autogen.sh $(SPEC).in \
 			  build-aux/git-version-gen \
 			  build-aux/gitlog-to-changelog \
 			  build-aux/release.mk \
-			  build-aux/genman \
 			  .version
 
 AUTOMAKE_OPTIONS	= foreign
diff --git a/build-aux/genman b/build-aux/genman
deleted file mode 100755
index 94ae715..0000000
--- a/build-aux/genman
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/bash
-
-set -e
-
-# Set variables
-# in - input man page (something_foo.3.in)
-# out - output file (something_foo.3)
-# common - common ipc error file
-
-in="$1"
-out="$2"
-common="$3"
-
-# make sure to trap on error and ctrl+c
-# so we can cleanup our temporary files
-# and provide error back to Makefile
-cleanup() {
-	rm -f "$out"-t "$out"
-}
-
-trap "cleanup" ABRT
-trap "cleanup" QUIT
-trap "cleanup" TERM
-trap "cleanup" INT
-trap "cleanup" ERR
-
-# Determine build date in man page format YYYY-MM-DD
-date="$(LC_ALL=C date "+%F")"
-
-# do the hack.. it looks ugly but it works fine
-
-# remove temporary file
-rm -f "$out"-t
-
-# insert the $common ipc error file in the man page
-if grep -q @COMMONIPCERRORS@ "$in"; then
-	awk "{print}(\$1 ~ /@COMMONIPCERRORS@/){exit 0}" "$in" > "$out"-t
-	cat "$common" >> "$out"-t
-	awk -v p=0 "(\$1 ~ /@COMMONIPCERRORS@/){p = 1} {if(p==1)print}" "$in" >> "$out"-t
-else
-	cp "$in" "$out"-t
-fi
-
-# substitute BUILDDATE with precalculated date
-# and remove COMMONIPCERRORS tag from above
-sed -i \
-	-e 's#@BUILDDATE@#'$date'#g' \
-	-e 's#@COMMONIPCERRORS@##g' \
-	"$out"-t
-
-# move in place as requested
-mv "$out"-t "$out"
diff --git a/init/Makefile.am b/init/Makefile.am
index 8e4d4c7..21d1e22 100644
--- a/init/Makefile.am
+++ b/init/Makefile.am
@@ -47,14 +47,13 @@ initscript_SCRIPTS  = corosync corosync-notifyd
 
 %: %.in Makefile
 	rm -f $@-t $@
-	cp $< $@-t
-	sed -i \
+	cat $< | sed \
 		-e 's#@''SBINDIR@#$(sbindir)#g' \
 		-e 's#@''SYSCONFDIR@#$(sysconfdir)#g' \
 		-e 's#@''INITDDIR@#$(INITDDIR)#g' \
 		-e 's#@''INITWRAPPERSDIR@#$(INITWRAPPERSDIR)#g' \
 		-e 's#@''LOCALSTATEDIR@#$(localstatedir)#g' \
-	    $@-t
+	    > $@-t
 	mv $@-t $@
 
 all-local: $(initscript_SCRIPTS) $(systemdconf_DATA)
diff --git a/man/Makefile.am b/man/Makefile.am
index 946a9b3..0bf600f 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -140,13 +140,18 @@ endif
 HTML_DOCS 		= $(dist_man_MANS:%=%.html) $(man_MANS:%=%.html)
 
 # developer man page generation
-%.3: %.3.in $(autogen_common) $(top_srcdir)/build-aux/genman
+%.3: %.3.in $(autogen_common)
 	@echo Generating $@ man page && \
-	rm -f $@-t $@ && \
-	$(top_srcdir)/build-aux/genman \
-		$(srcdir)/$@.in \
-		$(builddir)/$@-t \
-		$(srcdir)/$(autogen_common) && \
+	rm -f $@-t-t $@-t $@ && \
+	date="$$(LC_ALL=C date "+%F")" && \
+	awk "{print}(\$$1 ~ /@COMMONIPCERRORS@/){exit 0}" $@.in > $@-t-t && \
+	cat $(autogen_common) >> $@-t-t && \
+	awk -v p=0 "(\$$1 ~ /@COMMONIPCERRORS@/){p = 1} {if(p==1)print}" $@.in >> $@-t-t && \
+	cat $@-t-t | \
+		sed -e 's#@BUILDDATE@#'$$date'#g' \
+		    -e 's#@COMMONIPCERRORS@##g' \
+		    > $@-t && \
+	rm -f $@-t-t && \
 	mv $@-t $@
 
 clean-local:
-- 
1.7.7.6

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux