]> git.decadent.org.uk Git - dak.git/blob - scripts/debian/generate-i18n-Index
9b166bd261217e653f2c83ba8aff5aaabd2d15e4
[dak.git] / scripts / debian / generate-i18n-Index
1 #!/bin/bash
2 #
3 # Copyright (C) 2011, Ansgar Burchardt <ansgar@debian.org>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # On Debian systems, you can find the full text of the license in
11 # /usr/share/common-licenses/GPL-2
12
13 set -eu
14 export LC_ALL=C
15
16 usage () {
17         echo "Usage: $0 <dist-directory>" >&2
18         exit 1
19 }
20
21 # Parse options
22 if [ $# != 1 ] ; then
23         usage
24 fi
25 if [ ! -d "$1" ] ; then
26         echo "$1 does not exist or is not a directory." >&2
27         usage
28 fi
29 if [ ! -d "$1"/main/i18n ] ; then
30         echo "No main/i18n directory in $1." >&2
31         usage
32 fi
33 cd "$1/main/i18n"
34
35 # If it's trapped, something bad happened.
36 trap_exit () {
37         rm -f Index
38         exit 1
39 }
40 trap trap_exit EXIT HUP INT QUIT TERM
41
42 exec 3>Index
43
44 echo "SHA1:" >&3
45 for file in Translation-* ; do
46         sha=$(sha1sum "$file"); sha="${sha%% *}"
47         size=$(stat -c %s "${file}")
48         printf ' %s % 7s %s\n' "$sha" "$size" "$file" >&3
49 done
50
51 exec 3>&-
52
53 trap - EXIT