From ed54e994825b10251bd2d832de143cb73019cf68 Mon Sep 17 00:00:00 2001 From: Bug Bounty Zip <133497067+BugBountyzip@users.noreply.github.com> Date: Sat, 13 Jun 2026 07:00:06 +0800 Subject: [PATCH] Add Fedora 44 (GNOME) image support New fedora distro: distrobuilder fedora-http recipe with full GNOME desktop (GDM autologin), the PS5 IW620 internal WiFi modules built from nxp-imx/mwifiex + ps5-linux-mwifiex, and an RPM packaging path for the shared PS5 kernel (docker/kernel-builder-rpm). Notable PS5-specific fix: the kernel patches write into the request_firmware() buffer to skip the firmware signature header (gfx_v10_0_early_init, amdgpu_sdma_init_microcode). Fedora ships firmware xz-compressed, and the kernel maps xz-decompressed firmware read-only (fw_decompress_xz_pages -> fw_map_paged_buf -> vmap PAGE_KERNEL_RO), so the write oopses amdgpu before /dev/dri exists and the display never comes up. Distros with zstd or uncompressed firmware decompress into writable buffers, which is why only Fedora was affected. The recipe therefore ships the cyan_skillfish GPU firmware uncompressed, materializing linux-firmware's dedup symlinks first (unxz refuses symlinks). Also installs umoci/skopeo in the image builder (Fedora 41+ bases ship as OCI archives) and wires fedora into build_image.sh (FORMAT=rpm) and the image-builder entrypoint. Tested on PS5 hardware: GNOME displays over HDMI, internal WiFi scans and connects. [skip ci] Co-Authored-By: Claude Fable 5 --- .github/workflows/build-image.yml | 7 +- README.md | 9 +- build_image.sh | 17 +- distros/fedora/cmdline.txt | 1 + distros/fedora/grow-rootfs | 19 ++ distros/fedora/grow-rootfs.service | 10 + distros/fedora/image.yaml | 297 +++++++++++++++++++++++ docker/image-builder/Dockerfile | 6 + docker/image-builder/entrypoint.sh | 7 + docker/kernel-builder-rpm/Dockerfile | 15 ++ docker/kernel-builder-rpm/build.sh | 49 ++++ docker/kernel-builder-rpm/linux-ps5.spec | 54 +++++ 12 files changed, 484 insertions(+), 7 deletions(-) create mode 100644 distros/fedora/cmdline.txt create mode 100644 distros/fedora/grow-rootfs create mode 100644 distros/fedora/grow-rootfs.service create mode 100644 distros/fedora/image.yaml create mode 100644 docker/kernel-builder-rpm/Dockerfile create mode 100644 docker/kernel-builder-rpm/build.sh create mode 100644 docker/kernel-builder-rpm/linux-ps5.spec diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 5ffd594..8575c93 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -8,7 +8,7 @@ on: description: 'Distribution' default: 'ubuntu2604' type: choice - options: [all, ubuntu2604, arch, cachyos, kali] + options: [all, ubuntu2604, arch, cachyos, kali, fedora] workflow_call: inputs: distro: @@ -34,7 +34,7 @@ jobs: run: | INPUT="${{ inputs.distro || 'ubuntu2604' }}" if [ "$INPUT" = "all" ]; then - echo 'distros=["kali","ubuntu2604","arch","cachyos"]' >> "$GITHUB_OUTPUT" + echo 'distros=["kali","ubuntu2604","arch","cachyos","fedora"]' >> "$GITHUB_OUTPUT" else echo "distros=[\"$INPUT\"]" >> "$GITHUB_OUTPUT" fi @@ -161,6 +161,9 @@ jobs: if [ -f meta/kali.sha256 ]; then echo "| Kali | [\`ps5-kali.img.xz\`](https://pub-561df4012f1a46fbbdf618d5cc5941f6.r2.dev/ps5-kali.img.xz) |" fi + if [ -f meta/fedora.sha256 ]; then + echo "| Fedora 44 | [\`ps5-fedora.img.xz\`](https://pub-561df4012f1a46fbbdf618d5cc5941f6.r2.dev/ps5-fedora.img.xz) |" + fi echo "" echo "**SHA256 checksums:**" echo "\`\`\`" diff --git a/README.md b/README.md index 439a1eb..d09124d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PS5 Linux Image Builder -Builds bootable Linux USB images for PlayStation 5 using Docker containers. Supports Ubuntu 26.04, Arch, CachyOS (Gamescope + Steam), and full Kali Linux, individually or as a multi-distro image with kexec switching. +Builds bootable Linux USB images for PlayStation 5 using Docker containers. Supports Ubuntu 26.04, Arch, CachyOS (Gamescope + Steam), Fedora (GNOME), and full Kali Linux, individually or as a multi-distro image with kexec switching. ## Prerequisites @@ -34,6 +34,11 @@ OR OR +# Build Fedora (GNOME desktop) +./build_image.sh --distro fedora + +OR + # Build a multi-distro image (ubuntu2604 + arch + cachyos) ./build_image.sh --distro all ``` @@ -118,7 +123,7 @@ can use noticeable CPU time while it runs. | Flag | Description | Default | |------|-------------|---------| -| `--distro` | `ubuntu2604`, `arch`, `cachyos`, `kali`, or `all` | `ubuntu2604` | +| `--distro` | `ubuntu2604`, `arch`, `cachyos`, `kali`, `fedora`, or `all` | `ubuntu2604` | | `--kernel` | Path to kernel source directory | auto-clone version selected by PS5 patch set | | `--img-size` | Disk image size in MB | `12000` (`32000` for `all`, `98304` for `kali`) | | `--clean` | Remove all cached build artifacts and start fresh | off | diff --git a/build_image.sh b/build_image.sh index 08a494f..16f8d0d 100755 --- a/build_image.sh +++ b/build_image.sh @@ -17,7 +17,7 @@ usage() { echo "Usage: $0 [--distro ] [--kernel ] [--img-size ] [--clean]" echo "" echo "Options:" - echo " --distro Distribution to build: ubuntu2604, arch, cachyos, kali, all (default: ubuntu2604)" + echo " --distro Distribution to build: ubuntu2604, arch, cachyos, kali, fedora, all (default: ubuntu2604)" echo " --kernel Path to kernel source directory (default: auto-clone to work/linux/)" echo " --img-size Disk image size in MB (default: 12000, 32000 for --distro all, 98304 for kali)" echo " --clean Remove all cached build artifacts and start from scratch" @@ -69,7 +69,7 @@ if [ "$DISTRO" = "kali" ] && [ "$IMG_SIZE" = "12000" ]; then fi if [ -z "$FORMAT" ]; then - case "$DISTRO" in arch|cachyos) FORMAT="arch" ;; all) FORMAT="all" ;; *) FORMAT="deb" ;; esac + case "$DISTRO" in arch|cachyos) FORMAT="arch" ;; fedora) FORMAT="rpm" ;; all) FORMAT="all" ;; *) FORMAT="deb" ;; esac fi KERNEL_BUILDER_PLATFORM="linux/amd64" @@ -109,6 +109,7 @@ SKIP_CHROOT=false case "$FORMAT" in arch) ls "$KERNEL_OUT"/*.pkg.tar.zst 1>/dev/null 2>&1 && SKIP_KERNEL=true ;; + rpm) ls "$KERNEL_OUT"/*.rpm 1>/dev/null 2>&1 && SKIP_KERNEL=true ;; all) ls "$KERNEL_OUT"/*.deb 1>/dev/null 2>&1 && \ ls "$KERNEL_OUT"/*.pkg.tar.zst 1>/dev/null 2>&1 && SKIP_KERNEL=true ;; *) ls "$KERNEL_OUT"/*.deb 1>/dev/null 2>&1 && SKIP_KERNEL=true ;; @@ -279,7 +280,7 @@ else KERNEL_SRC="$(cd "$KERNEL_SRC" && pwd)" - rm -f "$KERNEL_OUT"/*.deb "$KERNEL_OUT"/*.pkg.tar.zst + rm -f "$KERNEL_OUT"/*.deb "$KERNEL_OUT"/*.pkg.tar.zst "$KERNEL_OUT"/*.rpm run_stage "Build kernel builder image" \ docker build --platform "$KERNEL_BUILDER_PLATFORM" -t ps5-kernel-builder \ @@ -313,6 +314,16 @@ else -v "$KERNEL_OUT":/out \ ps5-kernel-packager-arch esac + + case "$FORMAT" in rpm) + run_stage "Build rpm packager image" \ + docker build -t ps5-kernel-packager-rpm \ + -f "$SCRIPT_DIR/docker/kernel-builder-rpm/Dockerfile" "$SCRIPT_DIR" + run_stage "Package kernel (.rpm)" \ + docker run --rm --name "$DOCKER_NAME" \ + -v "$KERNEL_OUT":/out \ + ps5-kernel-packager-rpm + esac fi if [ "$KERNEL_ONLY" = true ]; then diff --git a/distros/fedora/cmdline.txt b/distros/fedora/cmdline.txt new file mode 100644 index 0000000..c6c419e --- /dev/null +++ b/distros/fedora/cmdline.txt @@ -0,0 +1 @@ +root=LABEL=__DISTRO__ rw rootwait console=ttyTitania0 console=tty0 video=DP-1:1920x1080@60 mitigations=off idle=halt preempt=full selinux=0 diff --git a/distros/fedora/grow-rootfs b/distros/fedora/grow-rootfs new file mode 100644 index 0000000..8c24f17 --- /dev/null +++ b/distros/fedora/grow-rootfs @@ -0,0 +1,19 @@ +#!/bin/bash +# Grows the root partition and filesystem to fill the disk. +# Runs once on first boot, then disables itself. +# If resize fails, the service stays enabled and retries next boot. + +ROOT_DEV=$(findmnt -no SOURCE /) || { echo "Cannot find root device"; exit 1; } +DISK=$(lsblk -ndo PKNAME "$ROOT_DEV") +PART_NUM=$(cat /sys/class/block/$(basename "$ROOT_DEV")/partition 2>/dev/null) + +if [ -z "$DISK" ] || [ -z "$PART_NUM" ]; then + echo "Cannot determine disk layout (DISK=$DISK PART_NUM=$PART_NUM)" + exit 1 +fi + +growpart "/dev/$DISK" "$PART_NUM" || true +partprobe "/dev/$DISK" +resize2fs "$ROOT_DEV" + +systemctl disable grow-rootfs.service diff --git a/distros/fedora/grow-rootfs.service b/distros/fedora/grow-rootfs.service new file mode 100644 index 0000000..dc5350a --- /dev/null +++ b/distros/fedora/grow-rootfs.service @@ -0,0 +1,10 @@ +[Unit] +Description=Grow root filesystem to fill disk +After=local-fs.target + +[Service] +Type=oneshot +ExecStart=/usr/local/sbin/grow-rootfs + +[Install] +WantedBy=multi-user.target diff --git a/distros/fedora/image.yaml b/distros/fedora/image.yaml new file mode 100644 index 0000000..3c56b9c --- /dev/null +++ b/distros/fedora/image.yaml @@ -0,0 +1,297 @@ +image: + name: ps5-fedora + distribution: fedora + release: "44" + description: Fedora GNOME (Wayland) desktop for PS5 + architecture: x86_64 + +source: + downloader: fedora-http + url: https://kojipkgs.fedoraproject.org + skip_verification: true + +packages: + manager: dnf + update: true + cleanup: true + + sets: + - packages: + # Full GNOME desktop + GDM display manager. + - gnome-shell + - gnome-session + - gnome-terminal + - gdm + - mutter + - nautilus + - gnome-control-center + - gnome-settings-daemon + - gnome-keyring + - gnome-backgrounds + - gnome-text-editor + - gnome-system-monitor + - gnome-disk-utility + - gnome-calculator + - gnome-tweaks + - gnome-extensions-app + - gnome-software + - gnome-initial-setup + - file-roller + - loupe + - evince + - baobab + - xdg-desktop-portal-gnome + - xdg-user-dirs-gtk + - xorg-x11-server-Xwayland + - polkit + + # Audio / media + - pipewire + - wireplumber + - pipewire-pulseaudio + + # Display / GPU (AMD) — userspace GL/Vulkan only; the kernel amdgpu driver + # comes from the linux-ps5 rpm. amdgpu is loaded LATE (by udev after pivot), + # exactly like the working Arch/Ubuntu images — NOT forced into the initramfs. + - mesa-dri-drivers + - mesa-vulkan-drivers + - mesa-va-drivers + - libinput + + # Networking + - NetworkManager + - NetworkManager-wifi + - network-manager-applet + - linux-firmware + - iw + - wpa_supplicant + - wireless-regdb + - util-linux + + # Toolchain for the out-of-tree PS5 IW620 WiFi module build + - gcc + - make + - git-core + - bc + - bison + - flex + - elfutils-libelf-devel + - openssl-devel + + # System + - glibc-langpack-en + - openssh-server + - sudo + - nano + - dracut + - kmod + - e2fsprogs + - parted + - cloud-utils-growpart + - kexec-tools + - zram-generator-defaults + - firefox + + # Fonts + - dejavu-sans-fonts + - liberation-fonts + - google-noto-sans-fonts + - google-noto-emoji-fonts + - fontconfig + action: install + +files: +- path: /etc/hostname + generator: hostname + +- path: /etc/hosts + generator: hosts + +- path: /etc/machine-id + generator: dump + +- path: /etc/kernel/postinst.d/zz-update-boot + generator: copy + source: /tmp/build-staging/zz-update-boot + mode: "0755" + +- path: /etc/fstab + generator: copy + source: /tmp/build-staging/fstab + +- path: /usr/local/sbin/grow-rootfs + generator: copy + source: /tmp/build-staging/grow-rootfs + mode: "0755" + +- path: /etc/systemd/system/grow-rootfs.service + generator: copy + source: /tmp/build-staging/grow-rootfs.service + +- path: /opt/rpms/ + generator: copy + source: /tmp/build-staging/rpms + +actions: +- trigger: post-unpack + action: |- + #!/bin/bash + set -eux + echo "retries=10" >> /etc/dnf/dnf.conf + dnf makecache || true + +- trigger: post-update + action: |- + #!/bin/bash + set -eux + passwd -l root + +- trigger: post-packages + action: |- + #!/bin/bash + set -eux + fc-cache -f 2>/dev/null || true + + # SSH — password auth only, root login via sudo + sed -i 's/^#*PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config + sed -i 's/^#*PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config + systemctl enable sshd + systemctl enable NetworkManager + systemctl enable gdm + systemctl set-default graphical.target + + # The PS5 kernel patch writes into the request_firmware() buffer to skip + # Sony's signature header (gfx_v10_0_early_init, amdgpu_sdma_init_microcode). + # Firmware loaded from a .xz file is decompressed into pages the kernel + # maps PAGE_KERNEL_RO, so that write oopses and /dev/dri never appears. + # Fedora is the only distro shipping .xz firmware — Ubuntu/Arch use .zst + # (writable vzalloc buffer) and Debian/Kali ship raw .bin, which is why + # only this image black-screened. Keep the PS5 GPU firmware uncompressed. + # linux-firmware dedupes identical blobs as symlinks (mec2 -> mec) and + # unxz refuses symlinks, so materialize links first while targets exist. + cd /usr/lib/firmware/amdgpu + for f in cyan_skillfish*.xz; do + if [ -L "$f" ]; then + tgt=$(readlink -f "$f") + rm "$f" + xz -dc "$tgt" > "${f%.xz}" + fi + done + unxz cyan_skillfish*.xz + ls -la cyan_skillfish* + +- trigger: post-files + action: |- + #!/bin/bash + set -eux + systemctl enable grow-rootfs.service + + # Built in a chroot → filesystem never SELinux-labelled. Disable SELinux. + mkdir -p /etc/selinux + if [ -f /etc/selinux/config ]; then + sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config + else + printf 'SELINUX=disabled\nSELINUXTYPE=targeted\n' > /etc/selinux/config + fi + + # --- Default user + GDM autologin --- + useradd -m -G wheel,video,input,render -s /bin/bash ps5 + echo "ps5:ps5" | chpasswd + echo "%wheel ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/wheel + + # GDM autologin so the GNOME desktop appears without a login prompt. + mkdir -p /etc/gdm + sed -i 's/^\[daemon\]/[daemon]\nAutomaticLoginEnable=True\nAutomaticLogin=ps5/' /etc/gdm/custom.conf 2>/dev/null || \ + cat > /etc/gdm/custom.conf <<'EOF' + [daemon] + AutomaticLoginEnable=True + AutomaticLogin=ps5 + + [security] + + [xdmcp] + + [chooser] + + [debug] + EOF + + # Skip gnome-initial-setup for the autologin user. + mkdir -p /home/ps5/.config + echo 'yes' > /home/ps5/.config/gnome-initial-setup-done + chown -R ps5:ps5 /home/ps5 + + # zram swap + printf '[zram0]\nzram-size = ram / 2\ncompression-algorithm = zstd\n' > /etc/systemd/zram-generator.conf + + # --- Install custom kernel rpm (its %post builds initramfs + deploys boot) - + # amdgpu is NOT forced into the initramfs — it loads late via udev, exactly + # like the working Arch/Ubuntu images. + mkdir -p /boot/efi + rpm -ivh /opt/rpms/*.rpm + rm -rf /opt/rpms + KVER=$(ls -1t /lib/modules | head -1) + [ -f "/boot/efi/bzImage" ] && [ -f "/boot/efi/initrd.img" ] + + # --- PS5 internal WiFi: build the PS5-patched NXP IW620 mwifiex modules --- + IW620_SRC=/tmp/ps5-iw620-mwifiex + IW620_PATCHES=/tmp/ps5-linux-mwifiex + IW620_NXP_REF=a5fe4e194bf99315e349d81d77d6dfacec70757a + IW620_PATCH_REF=5cfd063449f27e2f8a7d17c814a3bb21c27aa903 + rm -rf "$IW620_SRC" "$IW620_PATCHES" + git clone https://github.com/nxp-imx/mwifiex.git "$IW620_SRC" + git -C "$IW620_SRC" checkout "$IW620_NXP_REF" + git clone https://github.com/ps5-linux/ps5-linux-mwifiex.git "$IW620_PATCHES" + git -C "$IW620_PATCHES" checkout "$IW620_PATCH_REF" + git -C "$IW620_SRC" apply "$IW620_PATCHES/ps5-iw620.patch" + make -C "$IW620_SRC" CONFIG_OBJTOOL= KERNELDIR="/usr/lib/modules/$KVER/build" ARCH=x86 -j"$(nproc)" + test -f "$IW620_SRC/mlan.ko" + test -f "$IW620_SRC/moal.ko" + install -d "/usr/lib/modules/$KVER/extra/ps5-iw620" + install -m 0644 "$IW620_SRC/mlan.ko" "/usr/lib/modules/$KVER/extra/ps5-iw620/mlan.ko" + install -m 0644 "$IW620_SRC/moal.ko" "/usr/lib/modules/$KVER/extra/ps5-iw620/moal.ko" + install -d /etc/modprobe.d /usr/local/sbin /etc/systemd/system /usr/share/doc/ps5-iw620 + cat > /etc/modprobe.d/ps5-iw620.conf <<'EOF' + blacklist moal + blacklist mlan + softdep moal pre: cfg80211 mlan + options moal fw_name=nxp/pcieuartiw620_combo_v1.bin pcie_int_mode=1 drv_mode=1 cfg80211_wext=4 sta_name=mlan ext_scan=0 auto_fw_reload=0 wifi_reset_config=0 sched_scan=0 ps_mode=2 auto_ds=2 amsdu_disable=1 + EOF + cat > /usr/local/sbin/ps5-iw620-load <<'EOF' + #!/bin/sh + set -eu + FW_NAME=nxp/pcieuartiw620_combo_v1.bin + FW_DST=/lib/firmware/$FW_NAME + FW_SRC= + for candidate in "/boot/efi/lib/$FW_NAME" "/boot/lib/$FW_NAME" "$FW_DST"; do + [ -f "$candidate" ] && { FW_SRC="$candidate"; break; } + done + [ -z "$FW_SRC" ] && FW_SRC="$(find /boot /boot/efi -path "*/$FW_NAME" -type f 2>/dev/null | head -n 1)" + [ -n "$FW_SRC" ] && [ -f "$FW_SRC" ] && install -D -m 0644 "$FW_SRC" "$FW_DST" + [ -f "$FW_DST" ] || { echo "PS5 IW620 firmware not found; skipping"; exit 0; } + modprobe -r moal mlan 2>/dev/null || true + modprobe cfg80211 || true + modprobe moal + rfkill unblock all 2>/dev/null || true + nmcli radio wifi on 2>/dev/null || true + EOF + chmod 0755 /usr/local/sbin/ps5-iw620-load + cat > /etc/systemd/system/ps5-iw620.service <<'EOF' + [Unit] + Description=Load PS5 IW620 internal WiFi + RequiresMountsFor=/boot/efi + Wants=systemd-udev-settle.service + After=local-fs.target systemd-udev-settle.service + Before=NetworkManager.service network-pre.target + + [Service] + Type=oneshot + ExecStart=/usr/local/sbin/ps5-iw620-load + RemainAfterExit=yes + + [Install] + WantedBy=multi-user.target + EOF + depmod -a "$KVER" + systemctl enable ps5-iw620.service + rm -rf "$IW620_SRC" "$IW620_PATCHES" diff --git a/docker/image-builder/Dockerfile b/docker/image-builder/Dockerfile index 2fc6f96..e8246cb 100644 --- a/docker/image-builder/Dockerfile +++ b/docker/image-builder/Dockerfile @@ -26,6 +26,12 @@ RUN mkdir -p /root/go/src/github.com/lxc/ && \ cp /root/go/bin/distrobuilder /usr/local/bin/ && \ rm -rf /root/go/src /root/go/pkg +# Fedora 41+ base images ship as OCI archives; distrobuilder's fedora-http +# downloader unpacks them with umoci/skopeo. +RUN apt-get update && apt-get install -y --no-install-recommends \ + umoci skopeo \ + && rm -rf /var/lib/apt/lists/* + WORKDIR /build COPY docker/image-builder/entrypoint.sh /entrypoint.sh diff --git a/docker/image-builder/entrypoint.sh b/docker/image-builder/entrypoint.sh index f7eab7d..dd94ab2 100755 --- a/docker/image-builder/entrypoint.sh +++ b/docker/image-builder/entrypoint.sh @@ -44,6 +44,12 @@ EOF cp /repo/distros/${DISTRO}/kali-archive-keyring.asc "$STAGING/" cp /kernel-debs/*.deb "$STAGING/debs/" ;; + fedora) + cp /repo/distros/${DISTRO}/grow-rootfs "$STAGING/" + cp /repo/distros/${DISTRO}/grow-rootfs.service "$STAGING/" + mkdir -p "$STAGING/rpms" + cp /kernel-debs/*.rpm "$STAGING/rpms/" + ;; arch) cp /repo/distros/${DISTRO}/grow-rootfs "$STAGING/" cp /repo/distros/arch/grow-rootfs.service "$STAGING/" @@ -71,6 +77,7 @@ EOF find "$STAGING" -type f \ ! -path "$STAGING/debs/*" \ ! -path "$STAGING/pkgs/*" \ + ! -path "$STAGING/rpms/*" \ -exec sed -i 's/\r$//' {} + # --- Build rootfs --- diff --git a/docker/kernel-builder-rpm/Dockerfile b/docker/kernel-builder-rpm/Dockerfile new file mode 100644 index 0000000..490803c --- /dev/null +++ b/docker/kernel-builder-rpm/Dockerfile @@ -0,0 +1,15 @@ +FROM --platform=linux/amd64 fedora:44 + +# Only packaging tools needed — kernel is already compiled +RUN dnf install -y rpm-build kmod && dnf clean all + +WORKDIR /out/staging + +# Pre-built artifacts are bind-mounted at /out/staging +# Output packages go to /out + +COPY docker/kernel-builder-rpm/build.sh /build.sh +COPY docker/kernel-builder-rpm/linux-ps5.spec /linux-ps5.spec +RUN chmod +x /build.sh + +CMD ["/build.sh"] diff --git a/docker/kernel-builder-rpm/build.sh b/docker/kernel-builder-rpm/build.sh new file mode 100644 index 0000000..500b6fb --- /dev/null +++ b/docker/kernel-builder-rpm/build.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Packages pre-built kernel artifacts as an rpm. +# Runs inside Docker as root. +# Expects build artifacts staged in /out/staging by the kernel build step. +set -e + +if [ ! -f /out/staging/boot/bzImage ]; then + echo "Error: no staged artifacts in /out/staging — run the kernel build step first" + exit 1 +fi + +# Determine version from staged modules directory +KVER=$(ls /out/staging/lib/modules/) +PKGNAME="linux-ps5" +VERSION=${KVER%%-*} + +echo "==> Packaging kernel $KVER as rpm" + +RPMROOT=$(mktemp -d) +STAGE="$RPMROOT/stage" + +# Copy staged boot artifacts +mkdir -p "$STAGE/boot" +cp /out/staging/boot/bzImage "$STAGE/boot/vmlinuz-$KVER" +cp /out/staging/System.map "$STAGE/boot/System.map-$KVER" +cp /out/staging/.config "$STAGE/boot/config-$KVER" + +# Copy pre-installed modules (Fedora uses /usr/lib/modules) +mkdir -p "$STAGE/usr/lib/modules" +cp -a "/out/staging/lib/modules/$KVER" "$STAGE/usr/lib/modules/" + +# Build headers for out-of-tree module builds. UAPI headers (/usr/include) +# are intentionally excluded — they would conflict with Fedora's +# kernel-headers package. +if [ -d "/out/staging/headers/lib/modules/$KVER/build" ]; then + cp -a "/out/staging/headers/lib/modules/$KVER/build" \ + "$STAGE/usr/lib/modules/$KVER/build" +fi + +rpmbuild -bb \ + --define "_topdir $RPMROOT/rpmbuild" \ + --define "stagedir $STAGE" \ + --define "kver $KVER" \ + --define "ver $VERSION" \ + /linux-ps5.spec + +cp "$RPMROOT/rpmbuild/RPMS/x86_64/${PKGNAME}-${VERSION}-1.x86_64.rpm" /out/ + +echo "==> Done: /out/${PKGNAME}-${VERSION}-1.x86_64.rpm" diff --git a/docker/kernel-builder-rpm/linux-ps5.spec b/docker/kernel-builder-rpm/linux-ps5.spec new file mode 100644 index 0000000..af03a53 --- /dev/null +++ b/docker/kernel-builder-rpm/linux-ps5.spec @@ -0,0 +1,54 @@ +# Binary repackaging of pre-built kernel artifacts — no compilation here. +# Invoked by build.sh with: stagedir, kver, ver defined. +%global debug_package %{nil} +%global _build_id_links none +%global __os_install_post %{nil} +%global __strip /bin/true + +Name: linux-ps5 +Version: %{ver} +Release: 1 +Summary: PS5 Linux kernel %{kver} (image + modules + headers) +License: GPL-2.0-only +URL: https://kernel.org +ExclusiveArch: x86_64 +AutoReqProv: no + +Provides: kernel = %{ver} +Provides: kernel-core = %{ver} +Provides: kernel-modules = %{ver} +Provides: kernel-devel = %{ver} + +%description +Linux kernel %{kver} with PlayStation 5 support patches +(https://github.com/ps5-linux/ps5-linux-patches). + +%install +cp -a %{stagedir}/. %{buildroot}/ + +%files +/boot/vmlinuz-%{kver} +/boot/System.map-%{kver} +/boot/config-%{kver} +/usr/lib/modules/%{kver} + +%post +echo ">> linux-ps5 post-install: kernel %{kver}" +depmod -a %{kver} || true + +# Rebuild initramfs (hardware-independent — the build host is not the PS5) +if command -v dracut >/dev/null 2>&1; then + echo ">> Rebuilding initramfs with dracut for %{kver}" + dracut --force --no-hostonly "/boot/initrd.img-%{kver}" %{kver} +fi + +# Copy kernel + initrd to EFI partition +if [ -d /boot/efi ]; then + echo ">> Copying /boot/vmlinuz-%{kver} -> /boot/efi/bzImage" + cp "/boot/vmlinuz-%{kver}" /boot/efi/bzImage + echo ">> Copying /boot/initrd.img-%{kver} -> /boot/efi/initrd.img" + cp "/boot/initrd.img-%{kver}" /boot/efi/initrd.img + echo ">> Kernel %{kver} deployed to /boot/efi" +else + echo ">> /boot/efi not found, skipping EFI deploy" +fi