#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
# SPDX-FileCopyrightText: 2023-2024 Harald Sitter <sitter@kde.org>

build() {
    map add_binary \
        /usr/lib/systemd/systemd-volatile-root \
        /usr/lib/rootfs-transition \
        /usr/lib/btrfs-migrator \
        /usr/lib/systemd/system-generators/00-kde-linux-os-release \
        /usr/lib/systemd/system-generators/kde-linux-live-generator \
        /usr/lib/systemd/system-generators/kde-linux-mount-generator \
        /usr/lib/systemd/systemd-bootchart \
        /usr/lib/etc-factory \
        /usr/lib/udev/cdrom_id \
        /usr/bin/btrfs \
        /usr/bin/blkid \
        /usr/bin/systemd-dissect

    # The loop service will make the ISO be found by gpt-auto-root
    map add_systemd_unit \
        systemd-loop@.service \
        systemd-volatile-root.service \
        systemd-bootchart.service \
        etc-factory.service

    # Make double sure the dissection rule is present. Without it booting doesn't work because we can't find a root.
    # Notably not getting added by the release initcpio combined with aur systemd-git at the time of writing.
    # 60-cdrom will make parsing the ISO in the Initrd easier and 99-systemd will triger the loop service for GPT mismatch
    map add_udev_rule \
        60-cdrom_id.rules \
        90-image-dissect.rules \
        99-systemd.rules
}
