get-orig-source 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #! /bin/bash
  2. # debian/get-orig-source
  3. # Part of the ‘lojban-common’ package.
  4. #
  5. # Copyright © 2005–2013 Ben Finney <ben+debian@benfinney.id.au>
  6. # This is free software; you may copy, modify, and/or distribute this work
  7. # under the terms of the GNU General Public License, version 3 or later.
  8. # No warranty expressed or implied.
  9. # See the file ‘/usr/share/common-licenses/GPL-3’ for details.
  10. set -o errexit
  11. set -o errtrace
  12. set -o nounset
  13. PACKAGE_NAME=lojban-common
  14. PACKAGE_VERSION=$(
  15. dpkg-parsechangelog --count 1 \
  16. | grep '^Version: ' \
  17. | cut -d ' ' -f 2 \
  18. | sed -e 's/-[^-]\+$//' \
  19. )
  20. LOJBAN_FILES_URL=http://www.lojban.org/publications
  21. upstream_urls=(
  22. ${LOJBAN_FILES_URL}/wordlists/gismu.txt
  23. ${LOJBAN_FILES_URL}/wordlists/cmavo.txt
  24. ${LOJBAN_FILES_URL}/wordlists/rafsi.txt
  25. ${LOJBAN_FILES_URL}/wordlists/lujvo.txt
  26. )
  27. function command_not_found_handle() {
  28. # Bash will (as per ‘bash(1)’ § “COMMAND EXECUTION”) invoke this
  29. # function on failure of a search through PATH for a command.
  30. local command="$1"
  31. local -a command_args="$@"
  32. case "$command" in
  33. wget | /usr/bin/wget)
  34. printf \
  35. "This program depends on the program ‘%s’, installed from the Debian package ‘%s’.\n" \
  36. "wget" "wget"
  37. ;;
  38. *)
  39. ;;
  40. esac
  41. printf "%s: %s: command not found\n" "$SHELL" "$command"
  42. return 127
  43. }
  44. program_dir="$(dirname $(readlink --canonicalize-existing $0))"
  45. working_root=$(mktemp -t -d)
  46. upstream_archive_name=${PACKAGE_NAME}-${PACKAGE_VERSION}
  47. archive_working_dir=${working_root}/${upstream_archive_name}
  48. mkdir ${archive_working_dir}
  49. WGET_OPTS="--timestamping --directory-prefix ${archive_working_dir}"
  50. wget ${WGET_OPTS} "${upstream_urls[@]}"
  51. sha1sums_file="${program_dir}/upstream.sha1sums"
  52. (
  53. cd ${archive_working_dir}
  54. sha1sum -c "${sha1sums_file}"
  55. )
  56. TARBALL_SUFFIX=".tar.gz"
  57. tarball_name=${PACKAGE_NAME}_${PACKAGE_VERSION}.orig${TARBALL_SUFFIX}
  58. (
  59. cd ${working_root}
  60. tar -cf - ${upstream_archive_name}
  61. ) | gzip --best > ${tarball_name}
  62. rm -r ${working_root}
  63. # Local variables:
  64. # coding: utf-8
  65. # mode: sh
  66. # End:
  67. # vim: fileencoding=utf-8 filetype=sh :