#!/bin/bash
# selftest — build six twice and assert the wheels tarballs are byte-identical.
# The smallest check that fails if the reproducible-tar normalization breaks.
set -eu

here=$(cd "$(dirname "$0")" && pwd)
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT

# Fixed epoch so both runs use the same mtime (we are testing tar determinism,
# not epoch derivation).
OUTPUT="$tmp/a" "$here/mkwheels" six 1.16.0 1620000000 >/dev/null
OUTPUT="$tmp/b" "$here/mkwheels" six 1.16.0 1620000000 >/dev/null

a=$(md5sum "$tmp/a/six-wheels-1.16.0.tar.gz" | cut -d' ' -f1)
b=$(md5sum "$tmp/b/six-wheels-1.16.0.tar.gz" | cut -d' ' -f1)

if [ "$a" = "$b" ]; then
    echo "PASS: reproducible ($a)"
else
    echo "FAIL: tarballs differ ($a != $b)" >&2
    exit 1
fi
