Debian Codegraph @

po/pt_BR/list-manpages.sh

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 #
3 # list-manpages - Find man pages available for translation
4 # Copyright © 2020 Rafael Fontenelle <[email protected]>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 prog="./$(basenamescip-shell system . . basename. $0)"
20 distros=$(findscip-shell system . . find. '../../upstream/' -maxdepth 1 -type d | sedscip-shell system . . sed. 's|../../upstream/||' | trscip-shell system . . tr. '\n' ' ')
21 untranslatedflag=0
22
23
24 while getopts 'hd:f:u' arg; do
25 case $arg in
26 h)
27 echoscip-shell system . . echo. "Usage: $prog [options]"
28 echoscip-shell system . . echo. "List man pages available for translation with or without filters;"
29 echoscip-shell system . . echo. "List all by default, unless a filter is used."
30 echoscip-shell system . . echo. ""
31 echoscip-shell system . . echo. "Options supported:"
32 echoscip-shell system . . echo. " -d DISTRO filter by distribution name DISTRO; valid names:"
33 echoscip-shell system . . echo. " $distros"
34 echoscip-shell system . . echo. " -f FILE filter by FILE, which is a part or the whole man page filename"
35 echoscip-shell system . . echo. " -u filter by untranslated man pages (i.e. no po file yet)"
36 echoscip-shell system . . echo. " -h show this message and quit"
37 echoscip-shell system . . echo. ""
38 echoscip-shell system . . echo. "Example of uses:"
39 echoscip-shell system . . echo. " $prog (to list all man pages available)"
40 echoscip-shell system . . echo. " $prog -d debian-buster (to list debian-buster's man pages)"
41 echoscip-shell system . . echo. " $prog -f ext4 (to list man pages with 'ext4' in filename)"
42 echoscip-shell system . . echo. " $prog -uf intro (to list untranslated 'intro' man pages)"
43 echoscip-shell system . . echo. ""
44 exit
45 ;;
46 d)
47 for distro in $distros; do
48 if [scip-shell system . . `[`. "$distro" = "$OPTARG" ]; then
49 distrofilter=$OPTARG
50 break
51 fi
52 done
53
54 if [scip-shell system . . `[`. -z "$distrofilter" ]; then
55 echoscip-shell system . . echo. "Invalid distribution name \"$distrofilter\". Valid name: $distros" >&2
56 exit 1
57 fi
58 ;;
59 f)
60 filenamefilter=$OPTARG
61 ;;
62 u)
63 untranslatedflag=1
64 ;;
65 esac
66 done
67
68
69 # If -d passed, filter by distribution name, or get all man page filenames
70 if [scip-shell system . . `[`. -n "$distrofilter" ]; then
71 manpages=$(findscip-shell system . . find. "../../upstream/$distrofilter"/man* -type f | cutscip-shell system . . cut. -d/ -f4- | LC_ALL=C sortscip-shell system . . sort.)
72 else
73 manpages=$(findscip-shell system . . find. "../../upstream"/*/man* -type f | cutscip-shell system . . cut. -d/ -f4- | LC_ALL=C sortscip-shell system . . sort.)
74 fi
75
76
77 # If -f passed, filter by man page filename
78 if [scip-shell system . . `[`. -n "$filenamefilter" ]; then
79 manpages=$(echoscip-shell system . . echo. "$manpages" | trscip-shell system . . tr. ' ' '\n' | grepscip-shell system . . grep. "$filenamefilter")
80 fi
81
82
83 # If -u passed, show only untranslated man pages (i.e. not complete neither incomplete)
84 if [scip-shell system . . `[`. $untranslatedflag -eq 1 ]; then
85
86 # store man pages in temporary file
87 tmpfile=$(mktempscip-shell system . . mktemp.)
88 echoscip-shell system . . echo. "$manpages" > "$tmpfile"
89
90 # list translation files
91 translatedfiles=$(findscip-shell system . . find. man?/ -type f -name '*.po')
92
93 for translatedfile in $translatedfiles; do
94 filename=$(echoscip-shell system . . echo. "${translatedfile%%.po}" | sedscip-shell system . . sed. 's|/|\\/|g')
95 sedscip-shell system . . sed. -i "/$filename/d" "$tmpfile"
96 done
97
98 manpages=$(catscip-shell system . . cat. $tmpfile)
99 fi
100
101 echoscip-shell system . . echo. "$manpages" | trscip-shell system . . tr. ' ' '\n'