#!/usr/bin/env bash set -euo pipefail export DEBIAN_FRONTEND=noninteractive if [[ -f /etc/apt/sources.list.d/ubuntu.sources ]] then sed -i 's/^Types: deb$/Types: deb deb-src/' \ /etc/apt/sources.list.d/ubuntu.sources fi apt-get update apt-get install --yes build-essential ca-certificates devscripts dpkg-dev patch xz-utils apt-get build-dep --yes gamescope BUILD_ROOT="$(mktemp -d /tmp/ptlinux-gamescope.XXXXXX)" trap 'rm -rf -- "$BUILD_ROOT"' EXIT tar --extract \ --file /sources/gamescope_3.16.20+ds.orig.tar.xz \ --directory "$BUILD_ROOT" SOURCE_ROOT="$(find "$BUILD_ROOT" -mindepth 1 -maxdepth 1 -type d -print -quit)" if [[ -z "$SOURCE_ROOT" ]] then printf '%s\n' "The Gamescope source archive has no top-level directory." >&2 exit 1 fi tar --extract \ --file /sources/gamescope_3.16.20+ds-1.debian.tar.xz \ --directory "$SOURCE_ROOT" PATCH_ROOT="/workspace/native/gamescope/patches" PATCH_SERIES=( gamescope-wayland-letterbox-backing.patch gamescope-wayland-libdecor-input-scope.patch gamescope-lazy-output-images.patch gamescope-wayland-live-resize.patch gamescope-keep-nested-windows-visible.patch ) mkdir -p -- "${SOURCE_ROOT}/debian/patches" touch "${SOURCE_ROOT}/debian/patches/series" for patch_name in "${PATCH_SERIES[@]}" do install -m 0644 \ "${PATCH_ROOT}/${patch_name}" \ "${SOURCE_ROOT}/debian/patches/${patch_name}" if ! grep -Fqx -- "$patch_name" "${SOURCE_ROOT}/debian/patches/series" then printf '%s\n' "$patch_name" >> "${SOURCE_ROOT}/debian/patches/series" fi done ( cd "$SOURCE_ROOT" DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage --build=binary --no-sign -jauto ) PACKAGE="$(find "$BUILD_ROOT" -maxdepth 1 -type f \ -name 'gamescope_*_amd64.deb' -print -quit)" if [[ -z "$PACKAGE" ]] then printf '%s\n' "The Gamescope build did not produce an amd64 Debian package." >&2 exit 1 fi EXTRACT_ROOT="${BUILD_ROOT}/package" dpkg-deb --extract "$PACKAGE" "$EXTRACT_ROOT" if [[ -x "${EXTRACT_ROOT}/usr/games/gamescope" ]] then BINARY="${EXTRACT_ROOT}/usr/games/gamescope" elif [[ -x "${EXTRACT_ROOT}/usr/bin/gamescope" ]] then BINARY="${EXTRACT_ROOT}/usr/bin/gamescope" else printf '%s\n' "The Gamescope Debian package contains no executable." >&2 exit 1 fi install -m 0755 "$BINARY" \ /output/gamescope-3.16.20-ubuntu26.04-amd64 chown "${HOST_UID}:${HOST_GID}" \ /output/gamescope-3.16.20-ubuntu26.04-amd64