From fc22b3d6507c6745911b9dfcc68f1e665ae13dbc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 21:43:11 +0200 Subject: Adding upstream version 4.22.0. Signed-off-by: Daniel Baumann --- templates/generate-template.sh | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 templates/generate-template.sh (limited to 'templates/generate-template.sh') diff --git a/templates/generate-template.sh b/templates/generate-template.sh new file mode 100755 index 00000000..9c172ba5 --- /dev/null +++ b/templates/generate-template.sh @@ -0,0 +1,68 @@ +#!/bin/sh +# +# Copyright © 2019 Dr. Tobias Quathamer +# © 2022,2023,2024 Dr. Helge Kreutzmann +# +# 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 . + +# Require first argument (the name of the distribution) +if [ -z "$1" ]; then + echo "Please specify the name of the distribution." >&2 + exit 1 +fi +distribution="$1" + +# Require a second argument (the name of the manpage) +if [ -z "$2" ]; then + echo "Please specify the name of the manpage, e.g. 'arch.1'." >&2 + exit 1 +fi + +# Normalize to the basename of the manpage +manpage=$(basename $2) + +# Find upstream manpages with a matching name +upstream_manpage=$(find "../upstream/$distribution/" -type f -name "$manpage") + +if [ -z "$upstream_manpage" ]; then + echo "A manpage named '$manpage' could not be found in distribution '$distribution'." >&2 + exit 1 +fi + +# Necessary, size 0 file of mktemp fails for UTF-8 characters, see Debian bug #1022216 +tdir=$(mktemp -d) +mkdir $tdir/$distribution + +# Remove / Uncomment some macros po4a cannot handle +# #1 / #2 Errors in some pages +# #3 / #4 The last two can be removed, if mkpasswd (Debian BTS #1036908) and gawk (fixed upstream) are fixed (or Debian #1036826) +# #5 Po4a sometimes has troubles parsing \c - This crude pattern gets around this, but adding additional spaces and sometimes moving arguments into main text, see Debian #1036826 +cat $upstream_manpage | sed "s/^.ft C$/^\".ft C$/" | sed "s/^.ft P$/^\".ft P$/" | sed "s/\\\\fb/\\fB/" | sed "s/^\.BI \(\\\\.*\)\"\\\\c$/.BI \1\"/" | sed "s/^\.BR \(\\\\.*\)\"\\\\c$/.BI \1\"/" | sed "s/\\\\c$//" > $tdir/$distribution/$manpage +#cat $upstream_manpage | sed "s/^.ft C$/^\".ft C$/" | sed "s/^.ft P$/^\".ft P$/" | sed "s/\\\\fb/\\fB/" | sed "s/^\.BI \(\\\\.*\)\"\\\\c$/.BI \1\"/" | sed "s/^\.BR \(\\\\.*\)\"\\\\c$/.BI \1\"/" | perl -p -e 's/\\c\n//' > $tdir/$distribution/$manpage + +po4a-updatepo -f man \ + --no-deprecation \ + --option groff_code=verbatim \ + --option generated \ + --option untranslated="}1,Ds,zY,zZ,Ee,ES,dT,FN,NE,NS,EX,EE,Id,rstReportMargin,INDENT,UNINDENT,UN,a.RE,\|" \ + --option unknown_macros=untranslated \ + --master "$tdir/$distribution/$manpage" -M utf-8 \ + -p $tdir/tmp.pot + +# Reduce the location lines from the full path and line number +cat $tdir/tmp.pot | sed -e "s,/tmp/\.private/[a-zA-Z0-9]*/tmp\.,/tmp/tmp.," | sed -e "s,^#: /tmp/tmp\.[a-zA-Z0-9]*/\([^/]\+\)/.*,#: \1," |\ + # Ensure the correct encoding is set + sed -e "s/^\"Content-Type: text\/plain; charset=CHARSET\\\\n\"$/\"Content-Type: text\/plain; charset=UTF-8\\\\n\"/" + +rm -rf $tdir -- cgit v1.2.3