File: update-potfiles

package info (click to toggle)
util-linux 2.41-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 95,208 kB
  • sloc: ansic: 179,016; sh: 22,689; yacc: 1,284; makefile: 528; xml: 422; python: 316; lex: 89; ruby: 75; csh: 37; exp: 19; sed: 16; perl: 15; sql: 9
file content (43 lines) | stat: -rwxr-xr-x 1,142 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
#
# Copyright (C) 2009 Karel Zak <kzak@redhat.com>
#

# find all git-tracked and existing *.c and *.h files
# exclude some (sub)directories
# sort the list

if [ ! -f "po/Makevars" ]; then
	echo "error: update-potfiles must run in the top-level directory" >&2
	exit 1
fi

# find all git-tracked files
source_files=$(git ls-files . 2>/dev/null)
if [ $? -ne 0 ] || [ -z "$source_files" ]; then
	# we still go through the rest of this script to provide at least an empty
	# list or remove non-existing (deleted) files
	source_files=$(cat po/POTFILES.in 2>/dev/null)
fi
if [ $? -ne 0 ] || [ -z "$source_files" ]; then
	source_files=$(find . -type f -printf "%P\\n" 2>/dev/null)
fi

# apply include/exclude patterns
source_files=$(
	echo "$source_files" \
	| sed \
		-e '/\(\.h\|\.c\)$/!d' \
		-e '/^tests\//d' \
		-e '/\/samples\//d' \
		-e '/^Documentation\//d' \
)

# throw away non-existing files (dirty git repo)
echo "$source_files" \
	| xargs -r find 2>/dev/null \
	| sort \
	> po/POTFILES.in

# if this script is broken then we have probably an empty list
[ -s po/POTFILES.in ] || echo "$0: warning: po/POTFILES.in is empty" >&2