repack 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #! /bin/bash
  2. #
  3. # debian/repack
  4. # Part of the Debian package ‘inform6-library’.
  5. #
  6. # Copyright © 2010–2016 Ben Finney <ben+debian@benfinney.id.au>
  7. #
  8. # This is free software; you may copy, modify, and/or distribute this
  9. # work under the terms of the GNU General Public License as published
  10. # by the Free Software Foundation; version 3 of that License or later.
  11. # No warranty expressed or implied.
  12. # See the file ‘/usr/share/common-licenses/GPL-3’ for details.
  13. # Convert the pristine upstream source to the Debian upstream source.
  14. #
  15. # This program is designed for use with the ‘uscan(1)’ tool, as the
  16. # “action” parameter for the ‘debian/watch’ configuration file.
  17. set -o errexit
  18. set -o errtrace
  19. set -o pipefail
  20. set -o nounset
  21. program_dir="$(dirname "$(realpath --strip "$0")")"
  22. source "${program_dir}"/source_package_build.bash
  23. function usage() {
  24. local progname=$(basename $0)
  25. printf "$progname --upstream-version VERSION FILENAME\n"
  26. }
  27. if [ $# -ne 3 ] ; then
  28. usage
  29. exit 1
  30. fi
  31. upstream_version="$2"
  32. downloaded_file="$3"
  33. target_filename="${upstream_tarball_basename}.tar.gz"
  34. target_working_file="${working_dir}/${target_filename}"
  35. target_file="$(dirname "${downloaded_file}")/${target_filename}"
  36. repack_dir="${working_dir}/${upstream_dirname}"
  37. printf "Unpacking pristine upstream source ‘%s’:\n" "${downloaded_file}"
  38. extract_tarball_to_working_dir "${downloaded_file}"
  39. upstream_source_dirname=$(ls -1 "${working_dir}")
  40. upstream_source_dir="${working_dir}/${upstream_source_dirname}"
  41. printf "Repackaging upstream source from ‘%s’ to ‘%s’:\n" \
  42. "${upstream_source_dir}" "${repack_dir}"
  43. mv "${upstream_source_dir}" "${repack_dir}"
  44. printf "Removing non-source files:\n"
  45. nonsource_files=(
  46. # Generated files without corresponding source form.
  47. infglk.h
  48. )
  49. for f in "${nonsource_files[@]}" ; do
  50. rm -f -v "${repack_dir}"/$f
  51. done
  52. printf "Rebuilding DFSG-free upstream source tarball:\n"
  53. archive_working_dir_to_tarball "${upstream_dirname}" "${target_working_file}"
  54. printf "Moving completed upstream tarball to ‘%s’:\n" "${target_file}"
  55. rm -v "${downloaded_file}"
  56. mv "${target_working_file}" "${target_file}"
  57. printf "Done.\n"
  58. # Local variables:
  59. # coding: utf-8
  60. # mode: shell-script
  61. # indent-tabs-mode: nil
  62. # End:
  63. # vim: fileencoding=utf-8 filetype=bash expandtab :