Skip to content

Commit 84c47f8

Browse files
Document the Docserv config migration process (#250)
Add a new section into the Developer Guide about how to migrate the old Docserv config (version 6) into new Portal config (version 7). --------- Co-authored-by: Sushant Gaurav <[email protected]>
1 parent f2a61bd commit 84c47f8

3 files changed

Lines changed: 216 additions & 0 deletions

File tree

changelog.d/250.doc.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add a new topic into the Developer Guide about how to migrate the
2+
old Docserv config (version 6) into new Portal config (version 7).

docs/source/developer/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ This guide provides all the necessary information for contributing to the projec
2929
create-release
3030
trigger-actions
3131

32+
migrate-config
3233
build-docs
3334
howto
3435

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
.. _migrate-config:
2+
3+
Migrating old Docserv Config to new Portal Config
4+
=================================================
5+
6+
.. note::
7+
8+
This section is used to document the migration process from the old Docserv config to the new Portal Schema. It has to be done only once and is not
9+
relevant for the regular users of the new Portal Schema or users starting
10+
from scratch.
11+
12+
With the introduction of the new Portal Schema in version 7, the schema got
13+
a massive overhaul.
14+
15+
Therefore, the old Docserv config is not compatible with the new Portal Schema
16+
anymore and needs to be migrated. The migration process can be done by a
17+
migration XSLT stylesheet.
18+
19+
You have two options how the result can look like:
20+
21+
* A directory with multiple files.
22+
23+
This is the recommended approach if you want to organize your configuration
24+
in a modular way and split the configuration into multiple files.
25+
It allows for better tracking of changes and easier collaboration.
26+
Files are referenced by XInclude elements and resolved during the validation
27+
process.
28+
29+
* A single configuration file.
30+
31+
This is useful if you want to debug the whole file, want to search for
32+
specific entries or values, or just prefer a single file.
33+
34+
35+
.. _migration-prerequisites:
36+
37+
Pre-requisites
38+
--------------
39+
40+
Before starting the migration process, ensure you have the following tools installed:
41+
42+
* :command:`xmllint`
43+
* :command:`xsltproc`
44+
* :command:`jing`
45+
46+
Furthermore, you need a Docserv stitchfile:
47+
48+
* Copy it with :command:`scp` from the Docserv server to your local machine.
49+
50+
The Docserv stitchfile, typically located at
51+
:file:`/tmp/docserv-stitch-${{DATE}}.xml` (whereas ``${DATE}`` is the
52+
ISO date of the stitchfile creation in the YYYY-MM-DD format).
53+
54+
* Create it locally by following the instructions in :ref:`prepare-stitchfile`.
55+
56+
57+
58+
.. _prepare-stitchfile:
59+
60+
Preparing the Docserv Stitchfile
61+
--------------------------------
62+
63+
.. note::
64+
65+
The steps below is what the command :command:`docserv-stitch` does on
66+
the Docserv server to create the stitchfile. Of course, the script is
67+
more complex and takes care of validation and other checks, but the above steps are the core of the stitchfile creation process.
68+
69+
As such, make sure your Docserv configs are valid.
70+
71+
72+
If you don't have access to the Docserv server or prefer to create the stitchfile locally, follow these steps to prepare it:
73+
74+
#. Clone the Docserv config repo if you haven't already:
75+
76+
.. code-block:: console
77+
78+
git clone https://gitlab.suse.de/susedoc/docserv-config.git
79+
cd docserv-config/config.d
80+
81+
#. Set the result file name and path:
82+
83+
.. code-block:: console
84+
85+
stitchfile="/tmp/docserv-stitch-$(date --iso-8601).xml"
86+
87+
#. Prepare the header of the stitchfile:
88+
89+
.. code-block:: console
90+
91+
cat << EOF > "$stitchfile"
92+
<?xml version="1.0" encoding="UTF-8"?>
93+
<docservconfig>
94+
<!-- <hashes>...</hashes> -->
95+
96+
EOF
97+
98+
#. Copy content from all categories into result:
99+
100+
.. code-block:: console
101+
102+
xmllint --xpath "/*" _categories.xml >> "$stitchfile"
103+
104+
#. Append all config files to the result:
105+
106+
.. code-block:: console
107+
108+
xmllint --xpath "/*" [a-z]*.xml >> "$stitchfile"
109+
110+
#. Close the root element:
111+
112+
.. code-block:: console
113+
114+
printf "</docservconfig>\n" >> "$stitchfile"
115+
116+
117+
.. _convert-stitchfile:
118+
119+
Converting the Stitchfile
120+
-------------------------
121+
122+
To convert the stitchfile to the new Portal Schema format, use:
123+
124+
* the command :command:`xsltproc` to run the XSLT transformation,
125+
* some of the available XSLT parameters to customize the output as needed (see :ref:`available-xslt-parameters`),
126+
* the migration XSLT stylesheet located at :file:`src/docbuild/config/xml/data/convert-v6-to-v7.xsl`, and
127+
* the stitchfile you prepared in the :ref:`previous section <prepare-stitchfile>`.
128+
129+
130+
.. _available-xslt-parameters:
131+
132+
Available XSLT Parameters
133+
~~~~~~~~~~~~~~~~~~~~~~~~~
134+
135+
The migration XSLT stylesheet accepts the following XSLT parameters:
136+
137+
* ``cat.prefix`` (default ``cat.``)
138+
139+
The prefix for category IDs.
140+
141+
* ``schemafile`` (default empty)
142+
143+
The path to the new Portal Schema file (e.g., :file:`portal-config.rnc`).
144+
The stylesheet recognize the format (RNC or RNG) and changes the ``<?xml-model?>`` PI accordingly.
145+
146+
* ``outputfile`` (default :file:`portal.xml`)
147+
148+
The name of the main configuration file.
149+
150+
* ``outputdir`` (default :file:`output/`)
151+
152+
The base directory where the output file(s) will be saved.
153+
If you want to use the current directory, use ``./``.
154+
155+
* ``use.xincludes`` (default ``false``)
156+
157+
A boolean parameter that determines whether to use XInclude elements in the output.
158+
Set it to ``true`` to create a directory with multiple files, or use the
159+
default to create a single configuration file.
160+
161+
* ``schemaversion`` (default latest)
162+
163+
The version of the new Portal Schema to target. This is used to determine the necessary transformations to apply during the migration process.
164+
165+
166+
.. _create-config-file-with-multiple-files:
167+
168+
Creating Multiple Files
169+
~~~~~~~~~~~~~~~~~~~~~~~
170+
171+
To create a directory with multiple files, do the following:
172+
173+
#. Run the XSLT transformation with the following command:
174+
175+
.. code-block:: console
176+
177+
xsltproc --stringparam outputfile portal.xml \
178+
--stringparam outputdir "./output/" \
179+
--param use.xincludes 'true()' \
180+
src/docbuild/config/xml/data/convert-v6-to-v7.xsl $stitchfile
181+
182+
This will create all files in the :file:`output/` directory, with the main
183+
configuration file named :file:`portal.xml` and additional files for
184+
each category as needed.
185+
186+
#. Copy the generated files to the desired location.
187+
188+
#. Adjust the env configuration to point to the main configuration file,
189+
use the variable :literal:`paths.config_dir` and :literal:`paths.main_portal_config`.
190+
191+
192+
.. _create-single-config-file:
193+
194+
Creating a Single File
195+
~~~~~~~~~~~~~~~~~~~~~~
196+
197+
To create a single configuration file, , do the following:
198+
199+
#. Run the XSLT transformation with the following command:
200+
201+
.. code-block:: console
202+
203+
xsltproc --stringparam schemafile "portal-config.rnc" \
204+
--stringparam outputfile portal-$(date --iso-8601).xml \
205+
--stringparam outputdir "./" \
206+
src/docbuild/config/xml/data/convert-v6-to-v7.xsl $stitchfile
207+
208+
This will create a file named :file:`portal-<DATE>.xml` in the current directory.
209+
210+
#. Copy the generated output file to the desired location.
211+
212+
#. Adjust the env configuration to point to the main configuration file,
213+
use the variable :literal:`paths.config_dir` and :literal:`paths.main_portal_config`.

0 commit comments

Comments
 (0)