Change in osmo-gsm-manuals[master]: vty_reference_combine.sh: print the final result to stdout

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Mon Nov 2 18:54:00 UTC 2020


fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/20952 )

Change subject: vty_reference_combine.sh: print the final result to stdout
......................................................................

vty_reference_combine.sh: print the final result to stdout

This is a follow-up change for [1], making this script more
flexible.  It's now a task of the caller to store the merge
results to a file.  This approach allows to merge several
*.xml files and store all the results in a single directory.

Unfortunately, it's impossible to pass the same file as both
input and output to xsltproc, because it would immediately
overwrite its input.  To work this around, create two
temporary files and remove them at the end of the script.

[1] Iabe729af22c235cf9c4b252acda99b43ebcae20c

Change-Id: I6aac73d998c5937894233631e654a160d5623198
Related: SYS#4937
---
M build/Makefile.vty-reference.inc
M build/vty_reference_combine.sh
2 files changed, 18 insertions(+), 17 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Hoernchen: Looks good to me, approved
  laforge: Looks good to me, but someone else must approve



diff --git a/build/Makefile.vty-reference.inc b/build/Makefile.vty-reference.inc
index 9e22925..878c841 100644
--- a/build/Makefile.vty-reference.inc
+++ b/build/Makefile.vty-reference.inc
@@ -79,7 +79,7 @@
 	$(OSMO_GSM_MANUALS_DIR)/build/vty_reference_combine.sh "$(MERGE_DOC)" \
 		$$($(OSMO_GSM_MANUALS_DIR)/build/find_existing_path.sh "vty/*reference.xml" $(builddir) $(srcdir)) \
 		$(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
-		$(srcdir)/vty/*additions*.xml
+		$(srcdir)/vty/*additions*.xml > $(GEN_DIR)/combined.xml
 	xsltproc $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl $(GEN_DIR)/combined.xml \
 		> $(GEN_DIR)/docbook_vty.xml
 
@@ -98,5 +98,5 @@
 	$(OSMO_GSM_MANUALS_DIR)/build/vty_reference_combine.sh "$(MERGE_DOC)" \
 		$$($(OSMO_GSM_MANUALS_DIR)/build/find_existing_path.sh "*reference.xml" $$VTYDIR_BUILD $$VTYDIR_SRC) \
 		$(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
-		$$VTYDIR_SRC/*additions*.xml && \
+		$$VTYDIR_SRC/*additions*.xml > $$VTYGEN/combined.xml && \
 	xsltproc $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl $$VTYGEN/combined.xml > "$@"
diff --git a/build/vty_reference_combine.sh b/build/vty_reference_combine.sh
index 11e84c0..7b19758 100755
--- a/build/vty_reference_combine.sh
+++ b/build/vty_reference_combine.sh
@@ -1,12 +1,9 @@
 #!/bin/sh
 # usage: vty_reference_combine.sh path/to/merge_doc.xsl path/to/*reference.xml [paths to additional xmls]
+# the result of combination is printed to stdout
 # see Makefile.vty-reference.inc
 set -e
 
-# Allow overriding the "generated" output dir, so we don't have collisions when building multiple VTY references in one
-# Osmocom project (OS#4292)
-VTYGEN=${VTYGEN:-generated}
-
 # first argument: merge_doc.xsl
 MERGE_DOC="$1"
 shift
@@ -16,25 +13,29 @@
 test "$(ls -1 $reference | wc -l)" = "1"
 shift
 
-combined="$VTYGEN/combined.xml"
-combine_src="$VTYGEN/combine_src.xml"
-
 set -x
-cp $reference "$combined"
+
+# we cannot use the same file as input and output, because
+# xsltproc would override the input immediately :/
+combined=$(mktemp)
+combine_src=$(mktemp)
+cp $reference $combined
 
 while [ -n "$1" ]; do
 	addition="$(realpath "$1")"
 	shift
 
-	# Fix permissions: xsltproc sets the output permissions the same as the
-	# input file, which means during "make distcheck" our output file will
-	# become read-only.
-	if [ -f "$combine_src" ]; then
-		chmod 644 "$combine_src"
-	fi
+	# sync both input and output files
+	cp $combined $combine_src
 
-	mv "$combined" "$combine_src"
 	xsltproc -o "$combined" \
 		--stringparam with "$addition" \
 		"$MERGE_DOC" "$combine_src"
 done
+
+# print the results to stdout
+cat $combined >&1
+
+# clean up temporary files
+rm -f $combine_src
+rm -f $combined

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/20952
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Change-Id: I6aac73d998c5937894233631e654a160d5623198
Gerrit-Change-Number: 20952
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Hoernchen <ewild at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201102/0a58a2d4/attachment.htm>


More information about the gerrit-log mailing list