improve flexibility of genmanpages with changes from po4a.

git-svn-id: http://emdebian.org/svn/current@6675 563faec7-e20c-0410-992a-a66f704d0ccd
This commit is contained in:
codehelp 2009-11-10 21:50:24 +00:00
parent a90ab5a093
commit 6c6f08b6bf
3 changed files with 142 additions and 31 deletions

3
debian/changelog vendored
View file

@ -7,8 +7,9 @@ emdebian-rootfs (2.0.4) unstable; urgency=low
* Apply useNativeDist to package POT file * Apply useNativeDist to package POT file
* Add support for translated program output in multistrap * Add support for translated program output in multistrap
* [INTL:pt] Initial Portuguese program translation (Closes: #555485) * [INTL:pt] Initial Portuguese program translation (Closes: #555485)
* improve flexibility of genmanpages with changes from po4a.
-- Neil Williams <codehelp@debian.org> Mon, 09 Nov 2009 23:12:55 +0000 -- Neil Williams <codehelp@debian.org> Tue, 10 Nov 2009 21:45:07 +0000
emdebian-rootfs (2.0.3) unstable; urgency=low emdebian-rootfs (2.0.3) unstable; urgency=low

View file

@ -41,8 +41,12 @@ XMLDIR=""
DOCBOOKDIR="" DOCBOOKDIR=""
# the XSL file to use for Docbook XSL # the XSL file to use for Docbook XSL
XSLFILE="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl" XSLFILE="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
# the POD files (TODO: let this take paths) # the POD files for man1
PODFILE="" PODFILE=""
# the POD files for man3/ - module names regenerated from the path.
PODMODULES=""
# POD files for section 7
POD7FILES=""
# the binary packages using POD # the binary packages using POD
PODPACKAGES="" PODPACKAGES=""
# html output (subdirectory of BASEDIR) # html output (subdirectory of BASEDIR)
@ -51,6 +55,8 @@ HTMLDIR=""
HTMLFILE="" HTMLFILE=""
# the XSL file to use for Docbook XSL # the XSL file to use for Docbook XSL
HTMLXSL="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl" HTMLXSL="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"
# Minimal threshold for translation percentage to keep
KEEP=
# remember to add something to the clean:: rule in debian/rules # remember to add something to the clean:: rule in debian/rules
# to remove each binary package sub-directory. # to remove each binary package sub-directory.
@ -95,12 +101,12 @@ case "$1" in
;; ;;
--pot-only) --pot-only)
POTONLY=1 POTONLY=1
break; shift
;; ;;
-f|--file) -f|--file)
shift shift
FILE=$1 FILE=$1
break; shift
;; ;;
*) *)
echo "Unrecognised command: $1" echo "Unrecognised command: $1"
@ -109,11 +115,6 @@ case "$1" in
esac esac
done done
if [ ! -f "debian/changelog" ]; then
echo "genmanpages started from the wrong directory.";
exit 2
fi
if [ ! -f "$FILE" ]; then if [ ! -f "$FILE" ]; then
# without config, there's nothing to do. # without config, there's nothing to do.
echo "Cannot find config file! '$FILE'"; echo "Cannot find config file! '$FILE'";
@ -121,6 +122,8 @@ if [ ! -f "$FILE" ]; then
else else
. ./$FILE . ./$FILE
fi fi
OURS=`pwd|tr -d '\n'`
cd `dirname $FILE`
# calculate the langs, automatically. # calculate the langs, automatically.
LANGS=`ls $PODIR/*.po 2>/dev/null || true` LANGS=`ls $PODIR/*.po 2>/dev/null || true`
@ -135,22 +138,44 @@ if [ ! -z "$LANGS" ]; then
fi fi
wrap_langs "[po4a_paths]" "$POTFILE" "\$lang:$PODIR/\$lang.po" wrap_langs "[po4a_paths]" "$POTFILE" "\$lang:$PODIR/\$lang.po"
for file in $XMLDIR/*.xml; do if [ -n "$XMLDIR" ]; then
LOCAL=`basename $file` for file in $XMLDIR/*.xml; do
wrap_langs "[type:docbook]" "$file" "\$lang:$XMLDIR/\$lang/$LOCAL" LOCAL=`basename $file`
done wrap_langs "[type:docbook]" "$file" "\$lang:$XMLDIR/\$lang/$LOCAL"
for file in $DOCBOOKDIR; do done
LOCAL=`basename $file` fi
wrap_langs "[type:docbook]" "$file" "\$lang:$BASEDIR/\$lang/$LOCAL" if [ -n "$DOCBOOKDIR" ]; then
done for file in $DOCBOOKDIR; do
LOCAL=`basename $file`
wrap_langs "[type:docbook]" "$file" "\$lang:$BASEDIR/\$lang/$LOCAL"
done
fi
if [ -n "$PODFILE" ]; then if [ -n "$PODFILE" ]; then
for file in "$PODFILE"; do for file in $PODFILE; do
wrap_langs "[type:pod]" "$file" "\$lang:$BASEDIR/pod/\$lang/$file" LOCAL=`basename $file`
wrap_langs "[type:pod]" "$file" "\$lang:$BASEDIR/pod/1/\$lang/$LOCAL"
done
fi
if [ -n "$POD7FILES" ]; then
for file in $POD7FILES; do
LOCAL=`basename $file`
wrap_langs "[type:pod]" "$file" "\$lang:$BASEDIR/pod/7/\$lang/$LOCAL"
done
fi
if [ -n "$PODMODULES" ]; then
for file in $PODMODULES; do
wrap_langs "[type:pod]" "$file" "\$lang:$BASEDIR/pod/3/\$lang/$file"
done done
fi fi
if [ "$POTONLY" = "1" ]; then if [ "$POTONLY" = "1" ]; then
po4a --no-translations $CONFIG # Allow internal builds within po4a
if [ "$USE_INTERNAL_PO4A" = "yes" ]; then
echo "Internal po4a from $OURS being used instead of /usr/bin/"
PERL5LIB=$OURS/lib perl $OURS/po4a --no-translations $CONFIG
else
po4a --no-translations $CONFIG
fi
exit exit
fi fi
@ -160,17 +185,41 @@ for d in $BINARIES; do
if [ "$d" = "$HASMAN3" ]; then if [ "$d" = "$HASMAN3" ]; then
mkdir -p $BASEDIR/$d/man/$l/man3/ mkdir -p $BASEDIR/$d/man/$l/man3/
fi fi
mkdir -p $BASEDIR/$d/$l/$HTMLDIR/ if [ -n "$PODMODULES" ]; then
mkdir -p $BASEDIR/$d/man/$l/man3/
fi
if [ -n "$HTMLDIR" ]; then
mkdir -p $BASEDIR/$d/$l/$HTMLDIR/
fi
if [ -n "$POD7FILES" ]; then
mkdir -p $BASEDIR/$d/man/$l/man7/
fi
done done
mkdir -p $BASEDIR/$d/man/man1/ mkdir -p $BASEDIR/$d/man/man1/
if [ "$d" = "$HASMAN3" ]; then if [ "$d" = "$HASMAN3" ]; then
mkdir -p $BASEDIR/$d/man/man3/ mkdir -p $BASEDIR/$d/man/man3/
fi fi
mkdir -p $BASEDIR/pod/$l/ mkdir -p $BASEDIR/pod/$l/
if [ -n "$PODMODULES" ]; then
mkdir -p $BASEDIR/$d/man/man3/
fi
if [ -n "$POD7FILES" ]; then
mkdir -p $BASEDIR/$d/man/man7/
fi
done done
# use -k to create all XML even if untranslated or the XSL breaks the build. # use -k to create all XML even if untranslated or the XSL breaks the build.
po4a -k 0 $CONFIG if [ -n "$KEEP" ]; then
K="-k $KEEP"
fi
# Allow internal builds within po4a
if [ "$USE_INTERNAL_PO4A" = "yes" ]; then
echo "Internal po4a from $OURS being used instead of /usr/bin/"
PERL5LIB=$OURS/lib perl $OURS/po4a $K $CONFIG
else
po4a $K $CONFIG
fi
for d in $BINARIES; do for d in $BINARIES; do
for P in $XMLPACKAGES; do for P in $XMLPACKAGES; do
@ -190,8 +239,32 @@ for d in $BINARIES; do
done done
for POD in $PODPACKAGES; do for POD in $PODPACKAGES; do
if [ $d = "$POD" ]; then if [ $d = "$POD" ]; then
echo "Processing untranslated files for $POD . . ." for file in $PODFILE; do
pod2man $PODFILE > $BASEDIR/$POD/man/man1/$PODFILE.1 LOCAL=`basename $file`
echo "Processing untranslated files for $file (1) . . ."
pod2man $file $BASEDIR/$POD/man/man1/$LOCAL.1
done
if [ -n "$PODMODULES" ]; then
for file in $PODMODULES; do
# a bit of sed magic to convert a path to a module name.
name=`echo $file| sed -e 's/^lib\///'|sed -e 's/\//::/g'|sed -e 's/\.pm$//'`
echo "Processing untranslated files for $name (3) . . ."
pod2man $file $BASEDIR/$POD/man/man3/$name.3
done
fi
if [ -n "$POD7FILES" ]; then
for file in $POD7FILES; do
LOCAL=`basename $file`
echo "Processing untranslated files for $file (7) . . ."
# shorten names that already contain the 7.
SHORT=`echo $LOCAL|cut -d'7' -f1|tr -d .`
if [ -n "$SHORT" ]; then
pod2man -s 7 $file $BASEDIR/$POD/man/man7/${SHORT}.7
else
pod2man -s 7 $file $BASEDIR/$POD/man/man7/${LOCAL}.7
fi
done
fi
fi fi
done done
if [ -n "$HTMLDIR" ]; then if [ -n "$HTMLDIR" ]; then
@ -200,10 +273,12 @@ for d in $BINARIES; do
for l in $LANGS; do for l in $LANGS; do
for P in $XMLPACKAGES; do for P in $XMLPACKAGES; do
if [ $d = "$P" ]; then if [ $d = "$P" ]; then
echo "Processing $l translations for $d . . ."
for X in $XMLFILE; do for X in $XMLFILE; do
XML_CATALOG_FILES="/etc/xml/catalog" \ if [ -f $XMLDIR/$l/$X ]; then
xsltproc -o $BASEDIR/$P/man/ --nonet $XSLFILE $XMLDIR/$l/$X echo "Processing $l translations for $d . . ."
XML_CATALOG_FILES="/etc/xml/catalog" \
xsltproc -o $BASEDIR/$P/man/ --nonet $XSLFILE $XMLDIR/$l/$X
fi
done done
if [ "$d" = "$HASMAN3" ]; then if [ "$d" = "$HASMAN3" ]; then
mv $BASEDIR/$P/man/*.3 $BASEDIR/$P/man/$l/man3/ mv $BASEDIR/$P/man/*.3 $BASEDIR/$P/man/$l/man3/
@ -215,9 +290,38 @@ for d in $BINARIES; do
done done
for POD in $PODPACKAGES; do for POD in $PODPACKAGES; do
if [ $d = "$POD" ]; then if [ $d = "$POD" ]; then
echo "Processing $l translations for $POD . . ." for file in $PODFILE; do
echo "pod2man $BASEDIR/pod/$l/$PODFILE > $BASEDIR/$POD/man/$l/man1/$PODFILE.1" LOCAL=`basename $file`
pod2man $BASEDIR/pod/$l/$PODFILE > $BASEDIR/$POD/man/$l/man1/$PODFILE.1 if [ -f $BASEDIR/pod/1/$l/$LOCAL ]; then
echo "Processing $l translations for $file (1). . ."
pod2man $BASEDIR/pod/1/$l/$LOCAL $BASEDIR/$POD/man/$l/man1/$LOCAL.1
fi
done
fi
if [ -n "$PODMODULES" ]; then
for file in $PODMODULES; do
# a bit of sed magic to convert a path to a module name.
name=`echo $file| sed -e 's/^lib\///'|sed -e 's/\//::/g'|sed -e 's/\.pm$//'`
if [ -f $BASEDIR/pod/3/$l/$file ]; then
echo "Processing $l translations for $name (3). . ."
pod2man $BASEDIR/pod/3/$l/$file $BASEDIR/$POD/man/$l/man3/$name.3
fi
done
fi
if [ -n "$POD7FILES" ]; then
for file in $POD7FILES; do
LOCAL=`basename $file`
if [ -f $BASEDIR/pod/7/$l/$LOCAL ]; then
echo "Processing $l translations for $file (7). . ."
# shorten names that already contain the 7.
SHORT=`echo $LOCAL|cut -d'7' -f1|tr -d .`
if [ -n "$SHORT" ]; then
pod2man -s 7 $BASEDIR/pod/7/$l/$LOCAL $BASEDIR/$POD/man/$l/man7/${SHORT}.7
else
pod2man -s 7 $BASEDIR/pod/7/$l/$LOCAL $BASEDIR/$POD/man/$l/man7/$LOCAL.7
fi
fi
done
fi fi
done done
if [ -n "$HTMLDIR" ]; then if [ -n "$HTMLDIR" ]; then

View file

@ -22,13 +22,19 @@ XMLDIR="doc/xml/"
DOCBOOKDIR="" DOCBOOKDIR=""
# the XSL file to use for Docbook XSL # the XSL file to use for Docbook XSL
XSLFILE="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl" XSLFILE="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
# the POD files (TODO: let this take paths) # the POD files for man1
PODFILE="em_multistrap" PODFILE="em_multistrap"
# the POD files for man3/ - module names regenerated from the path.
PODMODULES=""
# POD files for section 7
POD7FILES=""
# the binary packages using POD # the binary packages using POD
PODPACKAGES="multistrap" PODPACKAGES="multistrap"
# html output (subdirectory of BASEDIR) # html output (subdirectory of BASEDIR)
HTMLDIR="" HTMLDIR=""
# html DocBook file # html DocBook file
HTMLFILE="" HTMLFILE=""
# Minimal threshold for translation percentage to keep
KEEP=
# the XSL file to use for Docbook XSL # the XSL file to use for Docbook XSL
HTMLXSL="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl" HTMLXSL="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"