diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index fe19a28..c7b087c 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, fedora, proxmox] + options: [all, ubuntu2604, arch, cachyos, kali, fedora, proxmox, debian] workflow_call: inputs: distro: @@ -34,7 +34,7 @@ jobs: run: | INPUT="${{ inputs.distro || 'ubuntu2604' }}" if [ "$INPUT" = "all" ]; then - echo 'distros=["kali","ubuntu2604","arch","cachyos","fedora","proxmox"]' >> "$GITHUB_OUTPUT" + echo 'distros=["kali","ubuntu2604","arch","cachyos","fedora","proxmox","debian"]' >> "$GITHUB_OUTPUT" else echo "distros=[\"$INPUT\"]" >> "$GITHUB_OUTPUT" fi diff --git a/build_image.sh b/build_image.sh index 20323b1..3503076 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, fedora, proxmox, all (default: ubuntu2604)" + echo " --distro Distribution to build: ubuntu2604, arch, cachyos, kali, fedora, proxmox, debian, 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" diff --git a/distros/debian/cmdline.txt b/distros/debian/cmdline.txt new file mode 100644 index 0000000..6660afc --- /dev/null +++ b/distros/debian/cmdline.txt @@ -0,0 +1 @@ +root=LABEL=__DISTRO__ rw rootwait console=ttyTitania0 console=tty0 mitigations=off idle=halt preempt=full diff --git a/distros/debian/grow-rootfs b/distros/debian/grow-rootfs new file mode 100644 index 0000000..8c24f17 --- /dev/null +++ b/distros/debian/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/debian/grow-rootfs.service b/distros/debian/grow-rootfs.service new file mode 100644 index 0000000..dc5350a --- /dev/null +++ b/distros/debian/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/debian/image.yaml b/distros/debian/image.yaml new file mode 100644 index 0000000..9168d5f --- /dev/null +++ b/distros/debian/image.yaml @@ -0,0 +1,246 @@ +image: + name: ps5-debian + distribution: debian + release: bookworm + description: Debian 12 XFCE desktop for PS5 + architecture: x86_64 + +source: + downloader: debootstrap + url: http://deb.debian.org/debian + variant: minbase + keyserver: keyserver.ubuntu.com + +packages: + manager: apt + update: true + cleanup: true + + repositories: + - name: sources.list + url: |- + deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware + deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware + deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware + architectures: + - amd64 + + sets: + - packages: + # XFCE desktop (proven on PS5 via the Kali image) + - task-xfce-desktop + - lightdm + - lightdm-gtk-greeter + - xserver-xorg + - xserver-xorg-video-amdgpu + - dbus-x11 + - x11-xserver-utils + + # Audio / media + - pipewire + - pipewire-pulse + - wireplumber + - pavucontrol + + # GPU + - mesa-vulkan-drivers + - mesa-va-drivers + + # Networking + - network-manager + - network-manager-gnome + - openssh-server + - iputils-ping + - iw + - wpasupplicant + - wireless-regdb + - rfkill + + # Firmware + PS5 boot support + - firmware-linux + - firmware-linux-nonfree + - firmware-amd-graphics + - firmware-realtek + - firmware-atheros + - firmware-misc-nonfree + - initramfs-tools + - kexec-tools + - kmod + - busybox + - zstd + - systemd-zram-generator + + # Apps + - firefox-esr + - thunar + - mousepad + - ristretto + - xfce4-terminal + - xfce4-screenshooter + - file-roller + - synaptic + - gnome-disk-utility + - htop + + # Base utilities + - sudo + - cloud-guest-utils + - parted + - e2fsprogs + - usbutils + - pciutils + - util-linux + - curl + - wget + - git + - ca-certificates + - vim + - nano + - tmux + - ethtool + + # Build tools (for WiFi module — prebuilt, but keep headers usable) + - build-essential + - bc + - bison + - flex + - libssl-dev + - libelf-dev + + # Fonts + - fonts-dejavu + - fonts-liberation2 + - fonts-noto + - 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/debs/ + generator: copy + source: /tmp/build-staging/debs + +actions: +- trigger: post-unpack + action: |- + #!/bin/bash + set -eux + echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry + apt-get update + +- trigger: post-update + action: |- + #!/bin/bash + set -eux + passwd -l root + +- trigger: post-packages + action: |- + #!/bin/bash + set -eux + export DEBIAN_FRONTEND=noninteractive + + # Default user (ps5/ps5) + useradd -m -G sudo,video,input,render -s /bin/bash ps5 + echo "ps5:ps5" | chpasswd + + printf 'ps5\n' > /etc/hostname + if grep -q '^127\.0\.1\.1' /etc/hosts; then + sed -i 's/^127\.0\.1\.1.*/127.0.1.1 ps5/' /etc/hosts + else + printf '127.0.1.1 ps5\n' >> /etc/hosts + fi + + # LightDM autologin into XFCE + mkdir -p /etc/lightdm/lightdm.conf.d + cat > /etc/lightdm/lightdm.conf.d/50-ps5-autologin.conf <<'EOF' + [Seat:*] + autologin-user=ps5 + autologin-user-timeout=0 + user-session=xfce + EOF + + # SSH off by default (public default credentials) + sed -i 's/^#*PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config + sed -i 's/^#*PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config + systemctl disable ssh.service || true + systemctl disable ssh.socket || true + + systemctl set-default graphical.target + systemctl enable NetworkManager + systemctl enable lightdm + + ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime + printf 'Etc/UTC\n' > /etc/timezone + + # zram swap + printf '[zram0]\nzram-size = ram / 2\ncompression-algorithm = zstd\n' > /etc/systemd/zram-generator.conf + + # Disable screen blanking for demos + install -d -m 0755 /home/ps5/.config/autostart + cat > /home/ps5/.config/autostart/ps5-display.desktop <<'EOF' + [Desktop Entry] + Type=Application + Name=PS5 Display Defaults + Exec=sh -c 'xset s off -dpms; xset s noblank' + X-GNOME-Autostart-enabled=true + EOF + chown -R ps5:ps5 /home/ps5 + +- trigger: post-files + action: |- + #!/bin/bash + set -eux + systemctl enable grow-rootfs.service + mkdir -p /boot/efi + + mkdir -p /etc/initramfs-tools/conf.d + printf 'RESUME=none\n' > /etc/initramfs-tools/conf.d/resume + + # Install the PS5-patched kernel + dpkg -i /opt/debs/*.deb + rm -rf /opt/debs + apt-mark hold linux-ps5 || true + + KVER=$(ls -1t /lib/modules | head -1) + depmod -a "$KVER" + + # NOTE: PS5 WiFi (IW620) is not built here. The linux-ps5 headers ship + # host tools prebuilt on Ubuntu (needs glibc 2.38+) which Debian 12's + # glibc 2.36 can't run. WiFi modules will be added as prebuilt artifacts + # in a future update. Use ethernet or a USB WiFi dongle for now. + + # Front-load amdgpu for PS5 display + grep -qxF amdgpu /etc/initramfs-tools/modules || printf '\namdgpu\n' >> /etc/initramfs-tools/modules + printf 'MODULES=most\nBUSYBOX=y\n' > /etc/initramfs-tools/conf.d/ps5-amdgpu + update-initramfs -c -k "$KVER" + /etc/kernel/postinst.d/zz-update-boot "$KVER" + +mappings: + architecture_map: debian diff --git a/docker/image-builder/entrypoint.sh b/docker/image-builder/entrypoint.sh index 4ec1a04..ce639a0 100755 --- a/docker/image-builder/entrypoint.sh +++ b/docker/image-builder/entrypoint.sh @@ -50,6 +50,11 @@ EOF cp /repo/distros/${DISTRO}/proxmox-release-bookworm.gpg "$STAGING/" cp /kernel-debs/*.deb "$STAGING/debs/" ;; + debian) + cp /repo/distros/${DISTRO}/grow-rootfs "$STAGING/" + cp /repo/distros/${DISTRO}/grow-rootfs.service "$STAGING/" + cp /kernel-debs/*.deb "$STAGING/debs/" + ;; fedora) cp /repo/distros/${DISTRO}/grow-rootfs "$STAGING/" cp /repo/distros/${DISTRO}/grow-rootfs.service "$STAGING/"