#!/bin/bash
# Install buildroot requirements for Fedora derivatives
set -xeuo pipefail
cd $(dirname $0)
. /usr/lib/os-release
case "${ID}${ID_LIKE:-}" in
  *centos*|*rhel*)
    # We'll use crb at build time
    dnf config-manager --set-enabled crb
    ;;
esac
# Deal with dnf4 vs dnf5
if test -x /usr/bin/dnf5; then
  dnf -y install 'dnf5-command(builddep)'
else
  dnf -y install 'dnf-command(builddep)'
fi
# Handle version skew, xref https://gitlab.com/redhat/centos-stream/containers/bootc/-/issues/1174
dnf -y distro-sync ostree{,-libs} systemd
# Install base build requirements
dnf -y builddep bootc.spec
# And extra packages
grep -Ev -e '^#' fedora-extra.txt | xargs dnf -y install
