|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# This is a simple script to check if builds are reproducible. The steps are: |
| 4 | +# 1. Build Hibernate Reactive with `./gradlew --no-daemon clean publishToMavenLocal --no-build-cache -Dmaven.repo.local=some-path/out/build1` |
| 5 | +# 2. Build Hibernate Reactive with `./gradlew --no-daemon clean publishToMavenLocal --no-build-cache -Dmaven.repo.local=some-path/out/build2` second time pointing to a different local maven repository to publish |
| 6 | +# 3. Compare the build results with sh ./ci/compare-build-results.sh some-path/out/build1 some-path/out/build2 |
| 7 | +# 4. The generated .buildcompare file will also contain the diffscope commands to see/compare the problematic build artifacts |
| 8 | + |
| 9 | +outputDir1=$1 |
| 10 | +outputDir2=$2 |
| 11 | +outputDir1=${outputDir1%/} |
| 12 | +outputDir2=${outputDir2%/} |
| 13 | + |
| 14 | +ok=() |
| 15 | +okFiles=() |
| 16 | +ko=() |
| 17 | +koFiles=() |
| 18 | + |
| 19 | +for f in `find ${outputDir1} -type f | grep -v "javadoc.jar$" | grep -v "maven-metadata-local.xml$" | sort` |
| 20 | +do |
| 21 | + flocal=${f#$outputDir1} |
| 22 | + # echo "comparing ${flocal}" |
| 23 | + sha1=`shasum -a 512 $f | cut -f 1 -d ' '` |
| 24 | + sha2=`shasum -a 512 $outputDir2$flocal | cut -f 1 -d ' '` |
| 25 | + # echo "$sha1" |
| 26 | + # echo "$sha2" |
| 27 | + if [ "$sha1" = "$sha2" ]; then |
| 28 | + ok+=($flocal) |
| 29 | + okFiles+=(${flocal##*/}) |
| 30 | + else |
| 31 | + ko+=($flocal) |
| 32 | + koFiles+=(${flocal##*/}) |
| 33 | + fi |
| 34 | +done |
| 35 | + |
| 36 | +# generate .buildcompare |
| 37 | +buildcompare=".buildcompare" |
| 38 | +echo "ok=${#ok[@]}" >> ${buildcompare} |
| 39 | +echo "ko=${#ko[@]}" >> ${buildcompare} |
| 40 | +echo "okFiles=\"${okFiles[@]}\"" >> ${buildcompare} |
| 41 | +echo "koFiles=\"${koFiles[@]}\"" >> ${buildcompare} |
| 42 | +echo "" >> ${buildcompare} |
| 43 | +echo "# see what caused the mismatch in the checksum by executing the following diffscope commands" >> ${buildcompare} |
| 44 | +for f in ${ko[@]} |
| 45 | +do |
| 46 | + echo "# diffoscope $outputDir1$f $outputDir2$f" >> ${buildcompare} |
| 47 | +done |
| 48 | + |
| 49 | +if [ ${#ko[@]} -eq 0 ]; then |
| 50 | + exit 0 |
| 51 | +else |
| 52 | + exit 1 |
| 53 | +fi |
0 commit comments