generate-i18n-Index 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. set -e
  13. set -u
  14. export LC_ALL=C
  15. usage () {
  16. echo "Usage: $0 <dist-directory>" >&2
  17. exit 1
  18. }
  19. # Parse options
  20. if [ $# != 1 ] ; then
  21. usage
  22. fi
  23. if [ ! -d "$1" ] ; then
  24. echo "$1 does not exist or is not a directory." >&2
  25. usage
  26. fi
  27. if [ ! -d "$1"/main/i18n ] ; then
  28. echo "No main/i18n directory in $1." >&2
  29. usage
  30. fi
  31. cd "$1/main/i18n"
  32. # If it's trapped, something bad happened.
  33. trap_exit () {
  34. rm -f Index
  35. exit 1
  36. }
  37. trap trap_exit EXIT HUP INT QUIT TERM
  38. exec 3>Index
  39. echo "SHA1:" >&3
  40. for file in Translation-*.bz2 ; do
  41. sha=$(sha1sum "$file"); sha="${sha%% *}"
  42. size=$(stat -c %s "${file}")
  43. printf ' %s % 7s %s\n' "$sha" "$size" "$file" >&3
  44. done
  45. exec 3>&-
  46. trap - EXIT