summaryrefslogtreecommitdiffstats
path: root/po/update-potfiles
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:30:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:30:35 +0000
commit378c18e5f024ac5a8aef4cb40d7c9aa9633d144c (patch)
tree44dfb6ca500d32cabd450649b322a42e70a30683 /po/update-potfiles
parentInitial commit. (diff)
downloadutil-linux-378c18e5f024ac5a8aef4cb40d7c9aa9633d144c.tar.xz
util-linux-378c18e5f024ac5a8aef4cb40d7c9aa9633d144c.zip
Adding upstream version 2.38.1.upstream/2.38.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'po/update-potfiles')
-rwxr-xr-xpo/update-potfiles43
1 files changed, 43 insertions, 0 deletions
diff --git a/po/update-potfiles b/po/update-potfiles
new file mode 100755
index 0000000..1cbfdc4
--- /dev/null
+++ b/po/update-potfiles
@@ -0,0 +1,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