#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later

set -e

root_fs=$(mount | grep "on /target " | tail -n1 | cut -d' ' -f1)
if [ -z "$root_fs" ]; then
    echo "Could not determine root filesystem"
    exit 1
fi

root_uuid=$(blkid -s UUID -o value "$root_fs")
if [ -z "$root_uuid" ]; then
    echo "Could not determine root filesystem UUID"
    exit 1
fi

mkdir -p /target/etc/kernel/
echo "root=UUID=$root_uuid" > /target/etc/kernel/cmdline

apt-install systemd-boot
