#!/bin/bash
set -e

img_path="$1"
prefix="/"
if [[ -n "$2" ]]; then
    prefix="$2"
fi

dnf -y --installroot "$img_path" --releasever=8 install system-release bash yum

rsync -av "${prefix}var/local/mkosi/mkosi.extra/" "$img_path"

cp "${prefix}var/local/mkosi/mkosi.postinst" "$img_path"

systemd-nspawn -D "$img_path" bash /mkosi.postinst
