3 # A file-manager extension which offers configurable context menu actions.
5 # Copyright (C) 2005 The GNOME Foundation
6 # Copyright (C) 2006-2008 Frederic Ruaudel and others (see AUTHORS)
7 # Copyright (C) 2009-2015 Pierre Wieser and others (see AUTHORS)
9 # FileManager-Actions is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
14 # FileManager-Actions is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with FileManager-Actions; see the file COPYING. If not, see
21 # <http://www.gnu.org/licenses/>.
24 # Frederic Ruaudel <grumz@grumz.net>
25 # Rodrigo Moya <rodrigo@gnome-db.org>
26 # Pierre Wieser <pwieser@trychlos.org>
27 # ... and many others (see AUTHORS)
29 errs
=0 # will be the exit code of the script
30 my_cmd
="${0}" # e.g. "./make-ks.sh"
31 my_parms
="$*" # e.g. "-host toaster"
32 my_cmdline
="${my_cmd} ${my_parms}"
33 me
="${my_cmd##*/}" # e.g. "make-ks.sh"
34 # used in msg and msgerr functions
35 my_tmproot
="/tmp/$(echo ${me} | sed 's?\..*$??').$$"
36 # e.g. "/tmp/make-ks.1978"
38 # These three functions must be defined using the name() syntax in order
39 # to share traps with the caller process (cf. man (1) ksh).
44 [ "${opt_verbose}" = "yes" -o ${errs} -gt 0 ] && msg "exiting with code ${errs}"
50 msg
"quitting on keyboard interrupt"
57 [ "${opt_verbose}" = "yes" ] && msg
"quitting on TERM signal"
61 # setup the different trap functions
66 function clear_tmpfiles
68 \rm
-f ${my_tmproot}.
*
74 [ $# -ge 2 ] && _eol
="${2}"
75 printf "[%s] %s${_eol}" ${me} "${1}"
81 msg
"error: ${1}" 1>&2
87 msg
"warning: ${1}" 1>&2
95 This script checks for POTFILES.in consistency and completeness.
97 Usage: ${my_cmd} [options]
98 --[no]help print this message, and exit [${opt_help_def}]
99 --[no]version print script version, and exit [${opt_version_def}]
100 --[no]dummy dummy execution [${opt_dummy_def}]
101 --[no]verbose runs verbosely [${opt_verbose_def}]
102 --potfile=filename POTFILES.in to be checked [${opt_potfile_def}]"
107 makefile
="${top_srcdir}/_build/Makefile"
108 pck_name
=$
(grep '^PACKAGE_NAME' ${makefile} 2>/dev
/null |
awk '{ print $3 }')
109 pck_version
=$
(grep '^PACKAGE_VERSION' ${makefile} 2>/dev
/null |
awk '{ print $3 }')
111 ${pck_name} v ${pck_version}
112 Copyright (C) 2010, 2011, 2012, 2013 Pierre Wieser."
115 # initialize common command-line options
126 # a first loop over command line arguments to detect verbose mode
129 # break when all arguments have been read
136 # get and try to interpret the next argument
140 # make all options have two hyphens
141 _orig_option
=${_option}
150 # now process options and their argument
152 --noverb |
--noverbo |
--noverbos |
--noverbose)
155 --verb |
--verbo |
--verbos |
--verbose)
161 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_verbose to 'yes'"
163 # we have scanned all command-line arguments in order to detect an
164 # opt_verbose option;
165 # reset now arguments so that they can be scanned again in main script
168 # interpreting command-line arguments
170 opt_potfile_def
="po/POTFILES.in"
172 # loop over command line arguments
176 # break when all arguments have been read
183 # get and try to interpret the next argument
187 # make all options have two hyphens
188 orig_option
=${option}
197 # split and extract argument for options that take one
200 optarg
=$
(echo ${option} |
sed -e 's/^[^=]*=//')
201 option
=$
(echo ${option} |
sed 's/=.*//')
203 # these options take a mandatory argument
204 # since, we didn't find it in 'option', so it should be
205 # next word in the command line
206 --p |
-po |
-pot |
-potf |
-potfi |
-potfil |
-potfile)
212 # now process options and their argument
214 --d |
--du |
--dum |
--dumm |
--dummy)
215 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_dummy to 'yes'"
218 --h |
--he |
--hel |
--help)
219 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_help to 'yes'"
222 --nod |
--nodu |
--nodum |
--nodumm |
--nodummy)
223 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_dummy to 'no'"
226 --noh |
--nohe |
--nohel |
--nohelp)
227 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_help to 'no'"
230 --noverb |
--noverbo |
--noverbos |
--noverbose)
232 --novers |
--noversi |
--noversio |
--noversion)
233 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_version to 'no'"
236 --p |
-po |
-pot |
-potf |
-potfi |
-potfil |
-potfile)
237 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_potfile to '${optarg}'"
240 --verb |
--verbo |
--verbos |
--verbose)
242 --vers |
--versi |
--versio |
--version)
243 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_version to 'yes'"
247 msgerr
"unrecognized option: '${orig_option}'"
250 # positional parameters
253 #if [ ${pos} -eq 1 ]; then
254 # [ "${opt_verbose}" = "yes" ] && msg "setting opt_output to '${option}'"
255 # opt_output=${option}
257 msgerr
"unexpected positional parameter #${pos}: '${option}'"
264 # set option defaults
265 # does not work with /bin/sh ??
266 #set | grep -e '^opt_' | cut -d= -f1 | while read _name; do
267 # if [ "$(echo ${_name} | sed 's/.*\(_def\)/\1/')" != "_def" ]; then
268 # _value="$(eval echo "$"${_name})"
269 # if [ "${_value}" = "" ]; then
270 # eval ${_name}="$(eval echo "$"${_name}_def)"
275 opt_help
=${opt_help:-${opt_help_def}}
276 opt_dummy
=${opt_dummy:-${opt_dummy_def}}
277 opt_verbose
=${opt_verbose:-${opt_verbose_def}}
278 opt_version
=${opt_version:-${opt_version_def}}
280 opt_potfile
=${opt_potfile:-${opt_potfile_def}}
282 # check that we are running from the top of srcdir
283 maintainer_dir
=$
(cd ${0%/*}; pwd)
284 top_srcdir
="${maintainer_dir%/*}"
285 if [ ! -f "${top_srcdir}/configure.ac" ]; then
286 msgerr
"this script is only meant to be run by the maintainer,"
287 msgerr
"and current working directory should be the top source directory."
292 if [ "${opt_help}" = "yes" -o ${nbopt} -eq 0 ]; then
298 if [ "${opt_version}" = "yes" ]; then
304 if [ ! -r ${opt_potfile} ]; then
305 msgerr
"${opt_potfile}: file not found or not readable"
309 if [ ${errs} -gt 0 ]; then
310 msg
"${errs} error(s) have been detected"
311 msg
"try '${my_cmd} --help' for usage"
315 # ---------------------------------------------------------------------
321 # first, check that all .ui are in po/POTFILE.in
325 msg
"pass ${nbpass}/${totpass}: checking that all .ui are in ${opt_potfile}..."
326 for f
in $
(git ls-files
*.ui
); do
327 if [ "$(grep -xe "\
[type:\s
*gettext
/glade
]\s
*${f}" ${opt_potfile})" = "" ]; then
328 msg
" ${f} should be added to ${opt_potfile}"
330 elif [ "${opt_verbose}" = "yes" ]; then
335 msg
" nbfiles=${nbfiles} error(s)=${nberrs}"
338 # second, check that all .ui in PO exist
342 msg
"pass ${nbpass}/${totpass}: checking that all .ui from ${opt_potfile} actually exist..."
343 for f
in $
(grep -e '\.ui$' ${opt_potfile} |
sed 's,\[type:\s*gettext/glade]\s*,,'); do
344 if [ ! -r ${f} ]; then
345 msg
" ${f} should be removed from ${opt_potfile}"
347 elif [ "${opt_verbose}" = "yes" ]; then
352 msg
" nbfiles=${nbfiles} error(s)=${nberrs}"
355 # third, check that all files which use _( construct are in PO
359 msg
"pass ${nbpass}/${totpass}: checking that all translatable files are in ${opt_potfile}..."
360 for f
in $
(git
grep -I '_(' src | cut
-d: -f1 |
sort -u); do
361 if [ "$(grep -x ${f} ${opt_potfile})" != "${f}" ]; then
362 msg
" ${f} should be added to ${opt_potfile}"
364 elif [ "${opt_verbose}" = "yes" ]; then
369 msg
" nbfiles=${nbfiles} error(s)=${nberrs}"
372 # fourth, check that all files in PO actually use the _( construct
376 msg
"pass ${nbpass}/${totpass}: checking that all files in ${opt_potfile} actually use the '_(' construct..."
377 for f
in $
(grep -E '^src/' ${opt_potfile} |
grep -vE '\.ui$' |
grep -vE '\.in$'); do
378 grep '_(' ${f} 1>/dev
/null
2>&1
379 if [ $?
-ne 0 ]; then
380 msg
" ${f} should be removed from ${opt_potfile}"
382 elif [ "${opt_verbose}" = "yes" ]; then
387 msg
" nbfiles=${nbfiles} error(s)=${nberrs}"
390 # last, check that all files which include gi18n.h are relevant
394 msg
"pass ${nbpass}/${totpass}: checking that all files have a good reason to include gi18n.h..."
395 for f
in $
(git
grep '#include <glib/gi18n.h>' src | cut
-d: -f1 |
sort -u); do
396 grep '_(' ${f} 1>/dev
/null
2>&1
397 if [ $?
-ne 0 ]; then
398 msg
" ${f} should not include <glib/gi18n.h>"
400 elif [ "${opt_verbose}" = "yes" ]; then
405 msg
" nbfiles=${nbfiles} error(s)=${nberrs}"
408 msg
"total: ${errs} error(s)."