1 | #!/usr/bin/env kmk_ash
|
---|
2 | # $Id: docbook-changelog-to-manual-dita.sh 99514 2023-04-22 01:59:25Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # Helper script for converting the changelog into a ditamap and a topic
|
---|
5 | # file per version.
|
---|
6 | #
|
---|
7 |
|
---|
8 | #
|
---|
9 | # Copyright (C) 2023 Oracle and/or its affiliates.
|
---|
10 | #
|
---|
11 | # This file is part of VirtualBox base platform packages, as
|
---|
12 | # available from https://www.virtualbox.org.
|
---|
13 | #
|
---|
14 | # This program is free software; you can redistribute it and/or
|
---|
15 | # modify it under the terms of the GNU General Public License
|
---|
16 | # as published by the Free Software Foundation, in version 3 of the
|
---|
17 | # License.
|
---|
18 | #
|
---|
19 | # This program is distributed in the hope that it will be useful, but
|
---|
20 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
22 | # General Public License for more details.
|
---|
23 | #
|
---|
24 | # You should have received a copy of the GNU General Public License
|
---|
25 | # along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
26 | #
|
---|
27 | # SPDX-License-Identifier: GPL-3.0-only
|
---|
28 | #
|
---|
29 |
|
---|
30 | #
|
---|
31 | # Globals.
|
---|
32 | #
|
---|
33 | MY_SED=kmk_sed
|
---|
34 |
|
---|
35 | #
|
---|
36 | # This script is very internal, so we got the following fixed position parameters:
|
---|
37 | # 1: user_ChangeLogImpl.xml to use as input.
|
---|
38 | # 2: docbook-changelog-to-manual-dita.xsl
|
---|
39 | # 3: The out directory.
|
---|
40 | # 4: '--'
|
---|
41 | # 5+: xsltproc invocation (sans output, input and xslt file).
|
---|
42 | #
|
---|
43 | if test $# -lt 6; then
|
---|
44 | echo "syntax error: too few arguments" 1>&2;
|
---|
45 | exit 2;
|
---|
46 | fi
|
---|
47 | MY_INPUT_FILE="$1"
|
---|
48 | MY_XSLT="$2"
|
---|
49 | MY_OUTPUT_DIR="$3"
|
---|
50 | if test "$4" != "--"; then
|
---|
51 | echo "syntax error: Expected '--' as the 4th parameter, got: $4" 1>&2;
|
---|
52 | exit 2;
|
---|
53 | fi
|
---|
54 | shift 4
|
---|
55 |
|
---|
56 | if ! test -f "${MY_INPUT_FILE}"; then
|
---|
57 | echo "error: Input file does not exists or is not a regular file: ${MY_INPUT_FILE}" 1>&2;
|
---|
58 | exit 1;
|
---|
59 | fi
|
---|
60 | if ! test -f "${MY_XSLT}"; then
|
---|
61 | echo "error: The given dita-refentry-flat-topic-ids.xsl file does not exists or is not a regular file: ${MY_XSLT_TOPIC_IDS}" 1>&2;
|
---|
62 | exit 1;
|
---|
63 | fi
|
---|
64 | if ! test -d "${MY_OUTPUT_DIR}"; then
|
---|
65 | echo "error: Destination directory does not exists or not a directory: ${MY_OUTPUT_DIR}" 1>&2;
|
---|
66 | exit 1;
|
---|
67 | fi
|
---|
68 |
|
---|
69 | # Exit on failure.
|
---|
70 | set -e
|
---|
71 |
|
---|
72 | #
|
---|
73 | # First get the ID list from it.
|
---|
74 | # We drop the first line with the <?xml ... ?> stuff.
|
---|
75 | #
|
---|
76 | MY_TOPIC_IDS=$($* --stringparam g_sMode ids "${MY_XSLT}" "${MY_INPUT_FILE}" | ${MY_SED} -e 1d)
|
---|
77 |
|
---|
78 | #
|
---|
79 | # Extract each topic.
|
---|
80 | #
|
---|
81 | for MY_ID in ${MY_TOPIC_IDS};
|
---|
82 | do
|
---|
83 | $* \
|
---|
84 | --stringparam g_sMode topic \
|
---|
85 | --stringparam g_idTopic "${MY_ID}" \
|
---|
86 | --output "${MY_OUTPUT_DIR}/${MY_ID}.dita" "${MY_XSLT}" "${MY_INPUT_FILE}"
|
---|
87 | done
|
---|
88 |
|
---|
89 | #
|
---|
90 | # Now for the ditamap file.
|
---|
91 | #
|
---|
92 | $* --stringparam g_sMode map --output "${MY_OUTPUT_DIR}/changelog-versions.ditamap" "${MY_XSLT}" "${MY_INPUT_FILE}"
|
---|
93 | exit 0
|
---|