repack 2.4 KB

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