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