Factor out Install Guide for Debian with debconf

Sync install guide translation build tool with the
changes I8df6b3b382137d08d60f85bc41bcd98ac1f4eb47
and Iffced3907ac2fddd42e6adc56b6e4859fde8e987.

Change-Id: Ie3d20ab930738925f2daacd4cd305b4ad8ec1798
This commit is contained in:
KATO Tomoyuki 2016-05-28 14:23:24 +09:00
parent 329e410bfd
commit 8b9a52f570
1 changed files with 37 additions and 52 deletions

View File

@ -102,7 +102,7 @@ function build_rst {
done done
elif [ ${book} = "install-guide" ] ; then elif [ ${book} = "install-guide" ] ; then
# Install Guide has several variations, build all of them # Install Guide has several variations, build all of them
TAGS="obs rdo ubuntu" TAGS="obs rdo ubuntu debian debconf"
INDEX=${DOC_DIR}${book}/source/index.rst INDEX=${DOC_DIR}${book}/source/index.rst
# For translation work, we should have only one index file, # For translation work, we should have only one index file,
@ -116,60 +116,45 @@ function build_rst {
trap "mv -f ${INDEX}.save ${INDEX}" EXIT trap "mv -f ${INDEX}.save ${INDEX}" EXIT
for tag in $TAGS; do for tag in $TAGS; do
## if [[ "$tag" == "debconf" ]]; then
# Because Sphinx uses the first heading as title regardless of # Build the guide with debconf
# only directive, replace title directive with the proper title # To use debian only contents, use "debian" tag.
# for each distribution to set the title explicitly. BUILD_DIR="${DOC_DIR}${book}-${tag}/build-${tag}/html"
title=$(grep -m 1 -A 5 "^.. only:: ${tag}" ${INDEX} | \ DOCTREES="${BUILD_DIR}.doctrees"
sed -n 4p | sed -e 's/^ *//g') tox -evenv "sphinx-build -q -E -t debian \
sed -i -e "s/\.\. title::.*/.. title:: ${title}/" ${INDEX} -D language=${language}
-d ${DOCTREES}
## ${DOC_DIR}${book}-${tag}/source/ \
# Sphinx builds the navigation before processing directives, ${BUILD_DIR}"
# so the conditional toctree does not work. mkdir -p publish-docs/${language}/${book}-${tag}
# We need to prepare toctree depending on distribution rsync -a ${DOC_DIR}${book}-${tag}/build-${tag}/html/ \
# only with one toctree before exectuing sphinx-build. publish-docs/${language}/${book}-${tag}
# Get line number of each tag
lineno_start=$(grep -n "^Contents" ${INDEX} | sed -e 's/:.*//')
lineno_end=$(grep -n "^.. end of contents" ${INDEX} \
| sed -e 's/:.*//')
lineno_debian=$(grep -n "^.. only:: debian" ${INDEX} \
| tail -1 | sed -e 's/:.*//')
lineno_notdebian=$(grep -n "^.. only:: [^d]" ${INDEX} \
| tail -1 | sed -e 's/:.*//')
# Remove indent for pseudo only directive
sed -i "${lineno_start},${lineno_end} \
s/^ *\.\. toctree/.. toctree/" ${INDEX}
sed -i "${lineno_start},${lineno_end} s/^ */ /" ${INDEX}
# Remove unnecessary toctree for each distribution
if [[ "$tag" == "debian" ]]; then
sed -i "${lineno_notdebian},${lineno_debian}d" ${INDEX}
else else
sed -i "${lineno_debian},$((${lineno_end}-1))d" ${INDEX} ##
sed -i "${lineno_notdebian}d" ${INDEX} # Because Sphinx uses the first heading as title regardless of
fi # only directive, replace title directive with the proper title
# for each distribution to set the title explicitly.
title=$(grep -m 1 -A 5 "^.. only:: ${tag}" ${INDEX} | \
sed -n 4p | sed -e 's/^ *//g')
sed -i -e "s/\.\. title::.*/.. title:: ${title}/" ${INDEX}
# Build the guide ##
BUILD_DIR="${DOC_DIR}${book}/build-${tag}/html" # Sphinx builds the navigation before processing directives,
DOCTREES="${BUILD_DIR}.doctrees" # so the conditional toctree does not work.
tox -evenv "sphinx-build -q -E -t $tag \ # We need to prepare toctree depending on distribution
-D language=${language} # only with one toctree before exectuing sphinx-build.
-d ${DOCTREES}
${DOC_DIR}${book}/source/ \
${BUILD_DIR}"
mkdir -p publish-docs/${language}/${book}-${tag}
rsync -a ${DOC_DIR}${book}/build-${tag}/html/ \
publish-docs/${language}/${book}-${tag}
# Restore the index file # Build the guide
cp -f ${INDEX}.save ${INDEX} BUILD_DIR="${DOC_DIR}${book}/build-${tag}/html"
DOCTREES="${BUILD_DIR}.doctrees"
# Remove Debian specific content from other guides tox -evenv "sphinx-build -q -E -t $tag \
if [[ "$tag" != "debian" ]]; then -D language=${language}
rm -rf publish-docs/${language}/{book}-$tag/debconf -d ${DOCTREES}
${DOC_DIR}${book}/source/ \
${BUILD_DIR}"
mkdir -p publish-docs/${language}/${book}-${tag}
rsync -a ${DOC_DIR}${book}/build-${tag}/html/ \
publish-docs/${language}/${book}-${tag}
fi fi
done done
else else