generate-i18n-Index 1.1 KB

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