]> git.ipfire.org Git - thirdparty/util-linux.git/blob - po/update-potfiles
Merge branch 'issue832' of https://github.com/kerolasa/util-linux
[thirdparty/util-linux.git] / po / update-potfiles
1 #!/bin/sh
2 #
3 # Copyright (C) 2009 Karel Zak <kzak@redhat.com>
4 #
5
6 # find all git-tracked and existing *.c and *.h files
7 # exclude some (sub)directories
8 # sort the list
9
10 if [ ! -f "po/Makevars" ]; then
11 echo "error: update-potfiles must run in the top-level directory" >&2
12 exit 1
13 fi
14
15 # find all git-tracked files
16 source_files=$(git ls-files . 2>/dev/null)
17 if [ $? -ne 0 ] || [ -z "$source_files" ]; then
18 echo "$0: warning: update-potfiles requires git" >&2
19 # we still go through the rest of this script to provide at least an empty
20 # list or remove non-existing (deleted) files
21 source_files=$(cat po/POTFILES.in 2>/dev/null)
22 fi
23
24 # apply include/exclude patterns
25 source_files=$(
26 echo "$source_files" \
27 | sed \
28 -e '/\(\.h\|\.c\)$/!d' \
29 -e '/^tests\//d' \
30 -e '/\/samples\//d' \
31 -e '/^Documentation\//d' \
32 )
33
34 # throw away non-existing files (dirty git repo)
35 echo "$source_files" \
36 | xargs -r find 2>/dev/null \
37 | sort \
38 > po/POTFILES.in
39
40 # if this script is broken then we have probably an empty list
41 [ -s po/POTFILES.in ] || echo "$0: warning: po/POTFILES.in is empty" >&2