2
0

distfiles.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env bash
  2. # Copyright (C) Viktor Szakats
  3. #
  4. # SPDX-License-Identifier: curl
  5. # Compare git repo files with tarball files and report a mismatch
  6. # after excluding exceptions.
  7. set -eu
  8. gitonly=".git*
  9. ^.*
  10. ^appveyor.*
  11. ^buildconf
  12. ^GIT-INFO.md
  13. ^README.md
  14. ^renovate.json
  15. ^REUSE.toml
  16. ^SECURITY.md
  17. ^LICENSES/*
  18. ^docs/examples/adddocsref.pl
  19. ^docs/THANKS-filter
  20. ^projects/Windows/*
  21. ^scripts/ciconfig.pl
  22. ^scripts/cijobs.pl
  23. ^scripts/contributors.sh
  24. ^scripts/contrithanks.sh
  25. ^scripts/delta
  26. ^scripts/installcheck.sh
  27. ^scripts/release-notes.pl
  28. ^scripts/singleuse.pl
  29. ^src/tool_hugehelp.c.cvs
  30. ^tests/CI.md"
  31. tarfiles="$(mktemp)"
  32. gitfiles="$(mktemp)"
  33. tar -tf "$1" \
  34. | sed -E 's|^[^/]+/||g' \
  35. | grep -v -E '(/|^)$' \
  36. | sort > "${tarfiles}"
  37. git -C "${2:-.}" ls-files \
  38. | grep -v -E "($(printf '%s' "${gitonly}" | tr $'\n' '|' | sed -e 's|\.|\\.|g' -e 's|\*|.+|g'))$" \
  39. | sort > "${gitfiles}"
  40. dif="$(diff -u "${tarfiles}" "${gitfiles}" | tail -n +3 || true)"
  41. rm -rf "${tarfiles:?}" "${gitfiles:?}"
  42. echo 'Only in tarball:'
  43. echo "${dif}" | grep '^-' || true
  44. echo
  45. echo 'Missing from tarball:'
  46. if echo "${dif}" | grep '^+'; then
  47. exit 1
  48. fi