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 @@ $(GEN_DIR)/docbook_vty.xml: \ $(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 @@ $(GEN_DIR)/docbook_%-vty-reference.xml: \ $(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 @@ reference="$1" 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