#!/bin/bash

set -x -v

ORIG=/home/dan/repos/mariadb-server-10.6-test
NEW=/home/dan/repos/mariadb-server-10.6

test()
{
  distro=$1
  release=$2
  testimage=quay.io/mariadb-foundation/bb-worker:${distro}${release}

  pushd $ORIG
  git checkout .
  chmod a+x $ORIG/debian/autobake-deb.sh
  echo exit > $ORIG/VERSION
  podman run --arch $arch --rm -v $ORIG:/source:z --user root --workdir /source $testimage bash -x -v debian/autobake-deb.sh
  git diff > ../$distro-$release-$arch-orig.txt
  popd
 
  pushd $NEW
  git checkout .
  chmod a+x $NEW/debian/autobake-deb.sh
  echo exit > $NEW/VERSION
  podman run --arch $arch --rm -v $NEW:/source:z --user root --workdir /source $testimage bash -x -v debian/autobake-deb.sh
  git diff > ../$distro-$release-$arch-new.txt
  popd
  diff -i $distro-$release-$arch-orig.txt $distro-$release-$arch-new.txt > $distro-$release-$arch-changes.txt
}

for arch in amd64 arm64 ppc64le
do
  for u in 18.04 20.04 21.10 22.04
  do
    test ubuntu $u
  done
  for u in 9 10 11 sid
  do
    test debian $u
  done
done
