summaryrefslogtreecommitdiffstats
path: root/po/update-potfiles
diff options
context:
space:
mode:
authorRuediger Meier2014-06-03 19:07:37 +0200
committerRuediger Meier2014-06-04 10:13:45 +0200
commit0a8e0e8b2f336806110071eabb80bca609b97759 (patch)
treea91424308378279f5c913eaae52ba8b009c69d90 /po/update-potfiles
parentbuild-sys: restore make distcheck's configure flags (diff)
downloadkernel-qcow2-util-linux-0a8e0e8b2f336806110071eabb80bca609b97759.tar.gz
kernel-qcow2-util-linux-0a8e0e8b2f336806110071eabb80bca609b97759.tar.xz
kernel-qcow2-util-linux-0a8e0e8b2f336806110071eabb80bca609b97759.zip
build-sys: fix update-potfiles script
Now are using "git ls-files" to avoid finding non-project files or autoheaders which could break the dist tarball. For non-git source dirs we assume that any existing POTFILES.in is up-todate (build from tarball) or we provide at least an empty list to not be a show-stopper for builds from poor "git archive". Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'po/update-potfiles')
-rwxr-xr-xpo/update-potfiles42
1 files changed, 32 insertions, 10 deletions
diff --git a/po/update-potfiles b/po/update-potfiles
index c92abd8b7..925f386c4 100755
--- a/po/update-potfiles
+++ b/po/update-potfiles
@@ -3,16 +3,38 @@
# Copyright (C) 2009 Karel Zak <kzak@redhat.com>
#
-# find all *.c files,
+# find all git-tracked and existing *.c and *.h files
+# exclude some (sub)directories
# sort the list
-# exclude /samples/ subdirectories
-# exclude ./tests/ from the list
-# and remove "./" prefix
-[ ! -f "po/Makevars" ] && \
- echo "You must run this script in the top-level directory"
+if [ ! -f "po/Makevars" ]; then
+ echo "error: update-potfiles must run in the top-level directory" >&2
+ exit 1
+fi
-find -name "*.c" -or -name "*.h" | \
- sort | \
- sed '/samples/d; /config\.h/d; /util-linux-.*/d; /\.\/tests/d; s/^\.\///' \
- > po/POTFILES.in
+# find all git-tracked files
+source_files=$(git ls-files . 2>/dev/null)
+if [ $? -ne 0 ] || [ -z "$source_files" ]; then
+ echo "$0: warning: update-potfiles requires git" >&2
+ # 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
+
+# apply include/exclude patterns
+source_files=$(
+ echo "$source_files" \
+ | sed \
+ -e '/\(\.h\|\.c\)$/!d' \
+ -e '/^tests\//d' \
+ -e '/\/samples\//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