openstack-manuals/tools/build-install-guides-rst.sh
Ian Y. Choi 6cb3801396 Fix install-guides build in Mac OS X
In Mac OS X environment, the actual behavior of grep command
with "-m" option is different from the expected behavior.

Instead of using "-m 1" option, adding one pipeline
with "head -n 6" (since "-A 5" looks after 5 lines more)
makes the build compatible not only Linux but also
Mac OS X environment.

Change-Id: I63fc0fd0c8afde883ffaf69c9b674c88d8079014
Closes-Bug: #1619358
2016-09-02 02:38:40 +09:00

46 lines
1.4 KiB
Bash
Executable File

#!/bin/bash -e
mkdir -p publish-docs
TAGS=${1:-obs rdo ubuntu debian debconf}
INDEX=doc/install-guide/source/index.rst
LINKCHECK=""
if [[ $# > 0 ]] ; then
if [ "$1" = "--linkcheck" ] ; then
LINKCHECK="$1"
fi
fi
# For translation work, we should have only one index file,
# because our tools generate translation resources from
# only one index file.
# Therefore, this tool uses one combined index file
# while processing title for each distribution.
# Save and restore the index file
cp -f ${INDEX} ${INDEX}.save
trap "mv -f ${INDEX}.save ${INDEX}" EXIT
for tag in $TAGS; do
if [[ "$tag" == "debconf" ]]; then
# Build the guide with debconf
# To use debian only contents, use "debian" tag.
tools/build-rst.sh doc/install-guide-debconf \
--tag debian --target "draft/install-guide-${tag}" $LINKCHECK
else
##
# Because Sphinx uses the first heading as title regardless of
# only directive, replace title directive with the proper title
# for each distribution to set the title explicitly.
title=$(grep -A 5 "^.. only:: ${tag}" ${INDEX} | \
head -n 6 | sed -n 4p | sed -e 's/^ *//g')
sed -i -e "s/\.\. title::.*/.. title:: ${title}/" ${INDEX}
# Build the guide
tools/build-rst.sh doc/install-guide \
--tag ${tag} --target "draft/install-guide-${tag}" $LINKCHECK
fi
done