2009-03-28 21:55:28 +00:00
|
|
|
#!/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/>.
|
|
|
|
|
2009-09-05 19:38:44 +00:00
|
|
|
# name and location of the config file
|
|
|
|
# relative to the top level source directory of the translations
|
|
|
|
# i.e. the directory containing ./po/
|
|
|
|
CONFIG="doc/po4a.config"
|
|
|
|
# POTFILE path
|
|
|
|
POTFILE="po/emdebian-rootfs.pot"
|
2009-09-15 15:30:59 +00:00
|
|
|
# The scripts with translated output
|
|
|
|
SCRIPTS="em_multistrap"
|
|
|
|
# The language to declare for the SCRIPTS
|
|
|
|
SCRIPTS_LANG="perl"
|
2009-09-05 19:38:44 +00:00
|
|
|
# the binary packages that will contain generated manpages
|
|
|
|
BINARIES="emdebian-rootfs multistrap"
|
|
|
|
# the binary packages with manpages in Section 3.
|
|
|
|
HASMAN3="emdebian-rootfs"
|
|
|
|
# the binary packages using DocBook XML & xsltproc
|
|
|
|
XMLPACKAGES="emdebian-rootfs"
|
|
|
|
# the DocBook XML files (TODO: let this take paths)
|
|
|
|
XMLFILE="emdebian-rootfs.1.xml"
|
2009-09-15 15:30:59 +00:00
|
|
|
# the directory containing the XML files
|
|
|
|
XMLDIR="doc/xml"
|
|
|
|
# the pattern to find the .docbook files
|
|
|
|
DOCBOOKDIR=""
|
2009-09-05 19:38:44 +00:00
|
|
|
# the XSL file to use for Docbook XSL
|
|
|
|
XSLFILE="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
|
|
|
|
# the POD files (TODO: let this take paths)
|
|
|
|
PODFILE="em_multistrap"
|
|
|
|
# the binary packages using POD
|
|
|
|
PODPACKAGES="multistrap"
|
2009-09-15 15:30:59 +00:00
|
|
|
# html output
|
|
|
|
HTMLDIR="doc/html"
|
|
|
|
# html DocBook file
|
|
|
|
HTMLFILE="emdebian-rootfs.1.xml"
|
2009-09-05 19:38:44 +00:00
|
|
|
|
|
|
|
# remember to add something to the clean:: rule in debian/rules
|
|
|
|
# to remove each binary package sub-directory.
|
|
|
|
# $(RM) -r doc/emdebian-rootfs doc/multistrap
|
|
|
|
|
|
|
|
# below this point, no changes should be needed.
|
|
|
|
|
2009-03-28 21:55:28 +00:00
|
|
|
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
|
2009-09-05 19:38:44 +00:00
|
|
|
|
2009-03-28 21:55:28 +00:00
|
|
|
# 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
|
|
|
|
echo "[po4a_langs] $LANGS" > $CONFIG
|
|
|
|
else
|
|
|
|
echo > $CONFIG
|
|
|
|
fi
|
2009-09-05 19:38:44 +00:00
|
|
|
wrap_langs "[po4a_paths]" "$POTFILE" "\$lang:po/\$lang.po"
|
2009-03-28 21:55:28 +00:00
|
|
|
|
2009-09-05 19:38:44 +00:00
|
|
|
for d in $BINARIES; do
|
|
|
|
for l in $LANGS; do
|
|
|
|
mkdir -p doc/$d/man/$l/man1/
|
|
|
|
if [ "$d" = "$HASMAN3" ]; then
|
|
|
|
mkdir -p doc/$d/man/$l/man3/
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
mkdir -p doc/$d/man/man1/
|
|
|
|
if [ "$d" = "$HASMAN3" ]; then
|
|
|
|
mkdir -p doc/$d/man/man3/
|
|
|
|
fi
|
2009-09-04 20:57:59 +00:00
|
|
|
mkdir -p doc/pod/$l/
|
2009-03-28 21:55:28 +00:00
|
|
|
done
|
|
|
|
mkdir -p doc/html/
|
|
|
|
|
2009-09-15 15:30:59 +00:00
|
|
|
#for file in $SCRIPTS; do
|
|
|
|
# wrap_langs "[type:$SCRIPTS_LANG]" "$file"
|
|
|
|
#done
|
|
|
|
for file in $XMLDIR/*.xml; do
|
2009-03-28 21:55:28 +00:00
|
|
|
LOCAL=`basename $file`
|
2009-09-15 15:34:42 +00:00
|
|
|
wrap_langs "[type:docbook]" "$file" "\$lang:$XMLDIR/\$lang/$LOCAL"
|
2009-03-28 21:55:28 +00:00
|
|
|
done
|
2009-09-15 15:30:59 +00:00
|
|
|
for file in $DOCBOOKDIR; do
|
|
|
|
LOCAL=`basename $file`
|
|
|
|
wrap_langs "[type:docbook]" "$file" "\$lang:doc/\$lang/$LOCAL"
|
2009-03-28 21:55:28 +00:00
|
|
|
done
|
2009-09-15 15:30:59 +00:00
|
|
|
if [ -n "$PODFILE" ]; then
|
|
|
|
for file in "$PODFILE"; do
|
|
|
|
wrap_langs "[type:pod]" "$file" "\$lang:doc/pod/\$lang/$file"
|
|
|
|
done
|
|
|
|
fi
|
2009-03-28 21:55:28 +00:00
|
|
|
|
|
|
|
# use -k to create all XML even if untranslated or the XSL breaks the build.
|
|
|
|
po4a -k 0 $CONFIG
|
|
|
|
|
2009-09-05 19:38:44 +00:00
|
|
|
for d in $BINARIES; do
|
|
|
|
for P in $XMLPACKAGES; do
|
|
|
|
for X in $XMLFILE; do
|
|
|
|
XML_CATALOG_FILES="/etc/xml/catalog" \
|
2009-09-15 15:30:59 +00:00
|
|
|
xsltproc -o doc/$P/man/ --nonet $XSLFILE $XMLDIR/$X
|
2009-09-05 19:38:44 +00:00
|
|
|
done
|
|
|
|
if [ "$d" = "$HASMAN3" ]; then
|
2009-09-15 15:30:59 +00:00
|
|
|
mv doc/$P/man/*.3 doc/$P/man/man3/
|
2009-09-05 19:38:44 +00:00
|
|
|
fi
|
2009-09-15 15:30:59 +00:00
|
|
|
mv doc/$P/man/*.1 doc/$P/man/man1/
|
2009-09-05 19:38:44 +00:00
|
|
|
done
|
|
|
|
for POD in $PODPACKAGES; do
|
2009-09-05 20:01:43 +00:00
|
|
|
pod2man $PODFILE > doc/$POD/man/man1/$PODFILE.1
|
2009-09-05 19:38:44 +00:00
|
|
|
done
|
2009-09-15 15:30:59 +00:00
|
|
|
mkdir -p $HTMLDIR/$d/
|
|
|
|
xsltproc -o $HTMLDIR/$d/ --nonet \
|
|
|
|
http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl \
|
|
|
|
$XMLDIR/$HTMLFILE
|
2009-09-05 19:38:44 +00:00
|
|
|
for l in $LANGS; do
|
|
|
|
for P in $XMLPACKAGES; do
|
|
|
|
for X in $XMLFILE; do
|
|
|
|
XML_CATALOG_FILES="/etc/xml/catalog" \
|
2009-09-15 15:30:59 +00:00
|
|
|
xsltproc -o doc/$P/man/ --nonet $XSLFILE $XMLDIR/$l/$X
|
2009-09-05 19:38:44 +00:00
|
|
|
done
|
|
|
|
if [ "$d" = "$HASMAN3" ]; then
|
2009-09-15 15:30:59 +00:00
|
|
|
mv doc/$P/man/*.3 doc/$P/man/$l/man3/
|
2009-09-05 19:38:44 +00:00
|
|
|
fi
|
2009-09-15 15:30:59 +00:00
|
|
|
mv doc/$P/man/*.1 doc/$P/man/$l/man1/
|
2009-09-05 19:38:44 +00:00
|
|
|
done
|
|
|
|
for POD in $PODPACKAGES; do
|
2009-09-05 20:01:43 +00:00
|
|
|
pod2man doc/pod/$l/$PODFILE > doc/$POD/man/$l/man1/$PODFILE.1
|
2009-09-05 19:38:44 +00:00
|
|
|
done
|
2009-09-15 15:30:59 +00:00
|
|
|
mkdir -p $HTMLDIR/$d/$l/
|
|
|
|
xsltproc -o $HTMLDIR/$d/$l/ --nonet \
|
|
|
|
http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl \
|
|
|
|
$XMLDIR/$l/$HTMLFILE
|
2009-09-05 19:38:44 +00:00
|
|
|
done
|
2009-09-15 15:30:59 +00:00
|
|
|
for i in `ls doc/html/$d/*.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
|
2009-09-05 19:38:44 +00:00
|
|
|
done
|
2009-09-15 15:30:59 +00:00
|
|
|
|
2009-03-28 21:55:28 +00:00
|
|
|
for l in $LANGS; do
|
2009-09-15 15:30:59 +00:00
|
|
|
rm -rf $XMLDIR/$l
|
2009-03-28 21:55:28 +00:00
|
|
|
done
|
2009-09-05 19:38:44 +00:00
|
|
|
rm -rf doc/pod/
|