#!/bin/sh # Install what SchOS needs to build and test, on Fedora. # # tools/posix/setup-fedora.sh install everything # tools/posix/setup-fedora.sh --check report what is missing, install nothing # # Written for Fedora 44. Package names are stable enough that older and newer # releases should work unchanged; the --check mode exists so a wrong guess # reports itself instead of failing halfway through a dnf transaction. set -eu CHECK=0 [ "${1:-}" = "--check" ] && CHECK=1 # Toolchain. clang and lld are the whole cross-compiler story -- see # docs/building.md for why there is no cross-gcc here. PKGS="clang lld llvm make gcc perl-interpreter python3 git" # Running and testing. PKGS="$PKGS qemu-system-x86 edk2-ovmf xorriso" # mtools is for building a real FAT ESP image. Not needed yet -- the UEFI # target serves a directory as FAT through QEMU -- but it is what `make iso` # will want once the ISO carries an EFI entry. PKGS="$PKGS mtools" # Ports are built from source on this host, which is the reason a Linux box # matters: they cannot be built on Windows at all. PKGS="$PKGS tar curl xz bzip2 diffutils findutils" missing="" for p in $PKGS; do rpm -q "$p" >/dev/null 2>&1 || missing="$missing $p" done if [ -z "$missing" ]; then echo "all packages present" else echo "missing:$missing" if [ "$CHECK" -eq 0 ]; then echo echo "installing..." sudo dnf install -y $missing fi fi # PowerShell is not in Fedora's repositories and is not an rpm you can name. # # It matters because tools/windows/bootcheck.ps1 is the test harness, and pwsh # runs it on Linux perfectly well -- there is simply no dnf package. Microsoft # publish a repo; the tarball is the lighter option and needs no root beyond # the install path. if command -v pwsh >/dev/null 2>&1; then echo "pwsh: $(command -v pwsh)" else cat <<'EOF' pwsh is not installed. tools/windows/bootcheck.ps1 is the boot test suite and needs it. Either: sudo dnf install -y https://packages.microsoft.com/config/rhel/9/packages-microsoft-prod.rpm sudo dnf install -y powershell or take the tarball from https://github.com/PowerShell/PowerShell/releases and put pwsh on PATH. Nothing else in the build depends on it -- `make`, `make schfs-check` and `make qemu` all work without. EOF fi echo echo "checks:" for t in clang ld.lld llvm-objcopy make gcc perl python3 qemu-system-x86_64 xorriso; do if command -v "$t" >/dev/null 2>&1; then printf ' %-22s ok\n' "$t" else printf ' %-22s MISSING\n' "$t" fi done # KVM is the difference between a boot test that takes seconds and one that # takes half a minute. It needs the module loaded and the user in the kvm # group; a Ryzen box has it unless virtualisation is off in firmware. echo if [ -e /dev/kvm ]; then if [ -r /dev/kvm ] && [ -w /dev/kvm ]; then echo "kvm: available and usable -- add -enable-kvm to QEMU for much faster boots" else echo "kvm: present but not accessible. Fix with:" echo " sudo usermod -aG kvm $(id -un) && newgrp kvm" fi else echo "kvm: /dev/kvm missing -- check that SVM/virtualisation is enabled in firmware" fi