You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.6 KiB
Bash

#!/bin/sh
set -e
# Copyright (C) 2006-2009 Neil Williams <codehelp@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
wrap_langs () {
if [ -z "$LANGS" ]; then
echo "$1 $2" >> $CONFIG
else
echo "$1 $2 $3" >> $CONFIG
fi
}
if [ -f po4a.config ]; then
cd ../
fi
if [ -f ../po4a.config ]; then
cd ../../
fi
CONFIG="doc/po4a.config"
# calculate the langs, automatically.
LANGS=`ls po/*.po 2>/dev/null || true`
if [ ! -z "$LANGS" ]; then
LANGS=`ls po/*.po | sed -e 's/.*\/\(.*\)\.po/\1 /' || true`
fi
if [ ! -z "$LANGS" ]; then
# LANGS should not include the specification, just the root.
LANGS=`echo $LANGS | sed -e 's/_.*//'`
LANGS=`echo $LANGS | sed -e 's/@.*//'`
LANGS=`echo $LANGS | sed -e 's/\+.*//'`
echo "[po4a_langs] $LANGS" > $CONFIG
else
echo > $CONFIG
fi
wrap_langs "[po4a_paths]" "po/emdebian-rootfs.pot" "\$lang:po/\$lang.po"
# need to determine directory for the target package.
# rootfs only has empbuilderlib.3, emrootfslib.3 and emsandbox.1
for l in $LANGS; do
mkdir -p doc/html/$l/
mkdir -p doc/man/$l/man1/
mkdir -p doc/man/$l/man3/
done
mkdir -p doc/html/
mkdir -p doc/man/man3/
mkdir -p doc/man/man1/
echo "Checking emrootfslib for POSIX compatibility"
# doesn't expect a shell library, hence nuisance message
# about interpreter that just needs to be ignored.
checkbashisms emrootfslib
echo "Processing Docbook XML . . . "
for file in `ls doc/xml/*.xml`; do
xmllint --format "$file" --output "$file"
LOCAL=`basename $file`
wrap_langs "[type:xml]" "$file" "\$lang:doc/xml/\$lang/$LOCAL"
done
echo "Processing POD . . ."
# rootfs
for file in em_multistrap; do
pod2html -outfile doc/html/$file.html -title $file < $file
pod2man $file > doc/man/man1/$file.1
wrap_langs "[type: pod]" "$file" "\$lang:doc/pod/\$lang/$file"
done
echo "Refreshing POT file for translators"
# use -k to create all XML even if untranslated or the XSL breaks the build.
po4a -k 0 $CONFIG
# just make sure the XML catalog is available for XSL.
# never go to the internet for build config, use -nonet.
XML_CATALOG_FILES="/etc/xml/catalog" \
xsltproc -o doc/man/ -''-nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl doc/xml/emdebian-rootfs.1.xml
mv doc/man/empbuilderlib.3 doc/man/man3/empbuilderlib.3
mv doc/man/emrootfslib.3 doc/man/man3/emrootfslib.3
mv doc/man/emsandbox.1 doc/man/man1/emsandbox.1
mv doc/man/*.1 doc/man/man1/
#mv doc/man/*.3 doc/man/man3/
for l in $LANGS; do
mkdir -p doc/man/$l/man3/
mkdir -p doc/man/$l/man1/
mv doc/man/$l/empbuilderlib.3 doc/man/$l/man3/empbuilderlib.3
mv doc/man/$l/emsandbox.1 doc/man/$l/man1/emsandbox.1
mv doc/man/$l/*.1 doc/man/$l/man1/
done
# never go to the internet for build config, use -nonet.
xsltproc -o doc/html/ -nonet http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl doc/xml/emdebian-rootfs.1.xml
for i in `ls doc/html/*.html`; do
iconv -t utf-8 -f iso8859-1 $i > doc/html/tmp
sed < doc/html/tmp > $i -e 's:charset=ISO-8859-1:charset=UTF-8:'
done
rm -f doc/html/tmp
rm -f pod2htmd.tmp
rm -f pod2htmi.tmp
rm -rf doc/pod/