#!/usr/bin/bash # # SPDX-FileCopyrightText: 2022 Celeste Liu # SPDX-License-Identifier: GPL-3.0-or-later # shellcheck disable=1091 . /usr/share/makepkg/util.sh colorize toggle-systemd-firstboot() { msg2 "Toggle systemd-firstboot..." sudo rm -f qcow2/etc/{machine-id,localtime,hostname,shadow,locale.conf} sudo mkdir -p qcow2/etc/systemd/system/systemd-firstboot.service.d cat << EOF | sudo tee qcow2/etc/systemd/system/systemd-firstboot.service.d/install.conf [Service] ExecStart= ExecStart=/usr/bin/systemd-firstboot --prompt --force [Install] WantedBy=sysinit.target EOF sudo arch-chroot qcow2 systemctl enable systemd-firstboot.service } use-fixed-password() { msg2 "Using fixed password..." : # set in rootfs } msg "Building u-boot..." git clone https://github.com/u-boot/u-boot.git pushd u-boot git checkout v2022.07 msg2 "Apply binutils 2.38 compitible patch" git apply ../0001-riscv-fix-compitible-with-binutils-2.38.patch make \ CROSS_COMPILE=riscv64-linux-gnu- \ qemu-riscv64_smode_defconfig make CROSS_COMPILE=riscv64-linux-gnu- popd msg "Building OpenSBI..." git clone https://github.com/riscv-software-src/opensbi pushd opensbi git checkout v1.0 msg2 "Apply binutils 2.38 compitible patch" git cherry-pick -n 5d53b55aa77ffeefd4012445dfa6ad3535e1ff2c make \ CROSS_COMPILE=riscv64-linux-gnu- \ PLATFORM=generic \ FW_PAYLOAD_PATH=../u-boot/u-boot.bin popd msg "Create image file..." qemu-img create -f qcow2 "archriscv-$(date --rfc-3339=date).qcow2" 10G sudo modprobe nbd max_part=16 sudo qemu-nbd -c /dev/nbd0 "archriscv-$(date --rfc-3339=date).qcow2" sudo sfdisk /dev/nbd0 <