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^tests/CI.md" 33 34tarfiles="$(mktemp)" 35gitfiles="$(mktemp)" 36 37tar -tf "$1" \ 38 | sed -E 's|^[^/]+/||g' \ 39 | grep -v -E '(/|^)$' \ 40 | sort > "${tarfiles}" 41 42git -C "${2:-.}" ls-files \ 43 | grep -v -E "($(printf '%s' "${gitonly}" | tr $'\n' '|' | sed -e 's|\.|\\.|g' -e 's|\*|.+|g'))$" \ 44 | sort > "${gitfiles}" 45 46dif="$(diff -u "${tarfiles}" "${gitfiles}" | tail -n +3 || true)" 47 48rm -rf "${tarfiles:?}" "${gitfiles:?}" 49 50echo 'Only in tarball:' 51echo "${dif}" | grep '^-' || true 52echo 53 54echo 'Missing from tarball:' 55if echo "${dif}" | grep '^+'; then 56 exit 1 57fi 58