| 1 |
#!/bin/bash |
| 2 |
# |
| 3 |
# Authors: |
| 4 |
# Pavel Březina <[email protected]> |
| 5 |
# |
| 6 |
# Copyright (C) 2018 Red Hat |
| 7 |
# |
| 8 |
# This program is free software; you can redistribute it and/or modify |
| 9 |
# it under the terms of the GNU General Public License as published by |
| 10 |
# the Free Software Foundation; either version 3 of the License, or |
| 11 |
# (at your option) any later version. |
| 12 |
# |
| 13 |
# This program is distributed in the hope that it will be useful, |
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
# GNU General Public License for more details. |
| 17 |
# |
| 18 |
# You should have received a copy of the GNU General Public License |
| 19 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
# |
| 21 |
# |
| 22 |
# Install manual pages translations. |
| 23 |
# |
| 24 |
# Usage: manpages-install.sh prefix DESTDIR |
| 25 |
# |
| 26 |
|
| 27 |
prefix=$1 |
| 28 |
DESTDIR=$2 |
| 29 |
shift 2 |
| 30 |
MANPAGES=$@ |
| 31 |
MANDIR="@mandir@" |
| 32 |
|
| 33 |
# Find translated and compiled manual pages. |
| 34 |
# Usage: manpages-find PAGE |
| 35 |
manpages-find() { |
| 36 |
local PAGE="$1" |
| 37 |
|
| 38 |
find @abs_top_builddir@/src/man/translations \ |
| 39 |
-type f -name "$PAGE" -printf '%d\t%p\n' | sort -nk1 | cut -f2- |
| 40 |
} |
| 41 |
|
| 42 |
# Install translated manual page. |
| 43 |
# Usage: manpages-install PAGE |
| 44 |
manpages-install() { |
| 45 |
local PATHNAME="$1" |
| 46 |
local NAME=`basename "$PATHNAME"` |
| 47 |
local LANG=`echo $PATHNAME | sed -E 's|.*/([^./]+)/[^/]+|\1|'` |
| 48 |
local SECTION=`echo $PATHNAME | sed -E 's|.*\.(.)|\1|'` |
| 49 |
local DEST="$DESTDIR/$MANDIR/$LANG/man$SECTION" |
| 50 |
|
| 51 |
echo "Installing $PATHNAME to $DEST/$NAME" |
| 52 |
mkdir -p $DEST |
| 53 |
install -c -m 644 $PATHNAME "$DEST/$NAME" |
| 54 |
} |
| 55 |
|
| 56 |
for MANPAGE in $MANPAGES; do |
| 57 |
TRANSLATIONS=`manpages-find $MANPAGE` |
| 58 |
for PAGE in $TRANSLATIONS; do |
| 59 |
manpages-install $PAGE |
| 60 |
done |
| 61 |
done |