|
| 1 | +# Open Gaming Collective (OGC) kernel, the project kernel for ALL |
| 2 | +# Dakota variants, wired in unconditionally via the junction override in |
| 3 | +# elements/freedesktop-sdk.bst. Reproduces FDSDK's artifact contract |
| 4 | +# exactly: vmlinuz/config at %{bootdir}, modules at |
| 5 | +# /usr/lib/modules/<kver>/ with a `build` symlink into |
| 6 | +# /usr/src/linux-<kver> (nvidia-drivers.bst compiles against it). |
| 7 | +# |
| 8 | +# The recipe is FDSDK 25.08 components/linux.bst with three deltas: |
| 9 | +# 1. Source: OGC's stable-tree fork; FDSDK's patch queue is dropped, |
| 10 | +# the OGC tree carries its own gaming patchset. |
| 11 | +# 2. Config: FDSDK's fdsdk-config.sh pass (vendored at |
| 12 | +# files/linux-ogc/, keep in sync when bumping the junction), then |
| 13 | +# OGC's ogc.config.set/unset fragments (sched_ext, ntsync, BTF). |
| 14 | +# 3. Modules stripped (INSTALL_MOD_STRIP=1) and vmlinux to the devel |
| 15 | +# split: OGC forces DEBUG_INFO=y for BTF. |
| 16 | +# |
| 17 | +# Bumps: `just bst source track core/linux-ogc.bst` follows v*-ogc* |
| 18 | +# tags; update the ogc-localversion variable to match the new tag. On a |
| 19 | +# stable-series jump, nvidia-drivers.bst must compile against the new |
| 20 | +# tree before shipping. |
| 21 | +kind: make |
| 22 | +description: OGC Linux kernel (all Dakota variants) |
| 23 | + |
| 24 | +build-depends: |
| 25 | +- freedesktop-sdk.bst:public-stacks/buildsystem-make.bst |
| 26 | +- freedesktop-sdk.bst:components/bison.bst |
| 27 | +- freedesktop-sdk.bst:components/cpio.bst |
| 28 | +- freedesktop-sdk.bst:components/flex.bst |
| 29 | +- freedesktop-sdk.bst:components/bc.bst |
| 30 | +- freedesktop-sdk.bst:components/gzip.bst |
| 31 | +- freedesktop-sdk.bst:components/pahole.bst |
| 32 | +- freedesktop-sdk.bst:components/python3.bst |
| 33 | +- freedesktop-sdk.bst:components/rsync.bst |
| 34 | +- freedesktop-sdk.bst:components/rust.bst |
| 35 | +- freedesktop-sdk.bst:components/rust-bindgen.bst |
| 36 | +- freedesktop-sdk.bst:components/rust-src.bst |
| 37 | +- freedesktop-sdk.bst:components/util-linux.bst |
| 38 | +- freedesktop-sdk.bst:components/zstd.bst |
| 39 | +# Provides /keys/linux-module-cert.crt; fdsdk-config.sh wires it into |
| 40 | +# SYSTEM_TRUSTED_KEYS when present. |
| 41 | +- filename: freedesktop-sdk.bst:components/linux-module-cert.bst |
| 42 | + strict: true |
| 43 | + |
| 44 | +variables: |
| 45 | + # OGC patchset revision of the pinned tag; keep in sync with the |
| 46 | + # `ref:` under sources (v<kver>-ogcN-...). Not derivable at build |
| 47 | + # time: the tree ships no EXTRAVERSION or localversion files. |
| 48 | + ogc-localversion: '-ogc1' |
| 49 | + bootdir: /boot |
| 50 | + indep-libdir: '%{prefix}/lib' |
| 51 | + # Modules are stripped by kbuild (INSTALL_MOD_STRIP=1) *before* the |
| 52 | + # module signature is appended; a post-build strip pass would tear |
| 53 | + # the signatures off again. |
| 54 | + strip-binaries: '' |
| 55 | + kernel_arch: '%{arch}' |
| 56 | + src-arch: '%{kernel_arch}' |
| 57 | + image-name: '$(make -s image_name)' |
| 58 | + (?): |
| 59 | + - arch == "x86_64": |
| 60 | + src-arch: x86 |
| 61 | + - arch == "aarch64": |
| 62 | + kernel_arch: arm64 |
| 63 | + - arch == "riscv64": |
| 64 | + kernel_arch: riscv |
| 65 | + |
| 66 | +environment: |
| 67 | + ARCH: '%{kernel_arch}' |
| 68 | + # compile.h has hardcoded timestamp, let's seed it |
| 69 | + KBUILD_BUILD_TIMESTAMP: 'Thu Nov 10 15:00:00 UTC 2011' |
| 70 | + KBUILD_BUILD_USER: 'tomjon' |
| 71 | + MAXJOBS: "%{max-jobs}" |
| 72 | + |
| 73 | +environment-nocache: |
| 74 | +- MAXJOBS |
| 75 | + |
| 76 | +config: |
| 77 | + configure-commands: |
| 78 | + - | |
| 79 | + # Generate the default kernel config for the target architecture |
| 80 | + make defconfig |
| 81 | +
|
| 82 | + - | |
| 83 | + . ./config-utils.sh |
| 84 | + rm -f expected-configs |
| 85 | + . ./fdsdk-config.sh "%{arch}" |
| 86 | +
|
| 87 | + - | |
| 88 | + # Layer the OGC gaming fragments over the FDSDK config. Format: |
| 89 | + # ogc.config.set holds CONFIG_X=y|m|"str"|<int> lines, unset holds |
| 90 | + # bare CONFIG names. Options whose dependencies aren't met on this |
| 91 | + # config are dropped by olddefconfig below, same as OGC's own |
| 92 | + # cross-distro packaging. |
| 93 | + while IFS= read -r line; do |
| 94 | + case "$line" in ''|'#'*) continue ;; esac |
| 95 | + name=${line%%=*} |
| 96 | + val=${line#*=} |
| 97 | + case "$val" in |
| 98 | + y) scripts/config --keep-case -e "$name" ;; |
| 99 | + m) scripts/config --keep-case -m "$name" ;; |
| 100 | + \"*\") |
| 101 | + val=${val#\"}; val=${val%\"} |
| 102 | + scripts/config --keep-case --set-str "$name" "$val" |
| 103 | + ;; |
| 104 | + *) scripts/config --keep-case --set-val "$name" "$val" ;; |
| 105 | + esac |
| 106 | + done < ogc.config.set |
| 107 | + while IFS= read -r name; do |
| 108 | + case "$name" in ''|'#'*) continue ;; esac |
| 109 | + scripts/config --keep-case -d "$name" |
| 110 | + # The fragment wins over FDSDK's pass: if fdsdk-config.sh marked |
| 111 | + # this option expected (module/enable), stop requiring it. FDSDK |
| 112 | + # records names without the CONFIG_ prefix; match both forms. |
| 113 | + sed -i "/^\(CONFIG_\)\{0,1\}${name#CONFIG_}\$/d" expected-configs |
| 114 | + done < ogc.config.unset |
| 115 | + # OGC's fragment enables the C binder (+ binderfs, which needs it); |
| 116 | + # the Rust binder FDSDK expects is mutually exclusive with it |
| 117 | + # (depends on !ANDROID_BINDER_IPC), so olddefconfig drops it. |
| 118 | + # Waydroid only needs *a* binder providing binder/hwbinder/vndbinder |
| 119 | + # -- swap the expectation to the C driver OGC configures. |
| 120 | + sed -i '/^\(CONFIG_\)\{0,1\}ANDROID_BINDER_IPC_RUST$/d' expected-configs |
| 121 | + echo CONFIG_ANDROID_BINDER_IPC >> expected-configs |
| 122 | + echo CONFIG_ANDROID_BINDERFS >> expected-configs |
| 123 | + # The gaming point of this kernel; fail the build if these regress. |
| 124 | + echo CONFIG_SCHED_CLASS_EXT >> expected-configs |
| 125 | + echo CONFIG_NTSYNC >> expected-configs |
| 126 | +
|
| 127 | + - | |
| 128 | + # Stamp `uname -r` with the OGC revision (e.g. 7.1.4-ogc1). |
| 129 | + # kernelrelease drives the modules dir, build tree and NVIDIA |
| 130 | + # module build alike, so co-versioning holds. |
| 131 | + scripts/config --keep-case --set-str LOCALVERSION "%{ogc-localversion}" |
| 132 | + scripts/config --keep-case -d LOCALVERSION_AUTO |
| 133 | +
|
| 134 | + - | |
| 135 | + # Keep fdsdk's expected SP800-90A DRBGs: linux 7.1 dropped the |
| 136 | + # RNG_DEFAULT select that used to switch this menu on, and with it |
| 137 | + # off olddefconfig discards the child options. |
| 138 | + scripts/config --keep-case -e CRYPTO_DRBG_MENU |
| 139 | +
|
| 140 | + - | |
| 141 | + # The zswap.compressor=zstd karg needs the compressor built in, not =m. |
| 142 | + scripts/config --keep-case -e CRYPTO_ZSTD |
| 143 | +
|
| 144 | + - | |
| 145 | + # Drop expectations for options this tree no longer offers (the |
| 146 | + # vendored fdsdk config pass targets an older kernel era). Gaming- |
| 147 | + # critical symbols are exempt: losing them must fail the build. |
| 148 | + find . -name 'Kconfig*' -exec grep -h '^\(menu\)\{0,1\}config ' {} + \ |
| 149 | + | awk '{print $2}' | sort -u > .kconfig-symbols |
| 150 | + cp expected-configs expected-configs.orig |
| 151 | + while IFS= read -r cfg; do |
| 152 | + sym=${cfg#CONFIG_} |
| 153 | + case "$sym" in |
| 154 | + SCHED_CLASS_EXT|NTSYNC|ANDROID_BINDER_IPC|ANDROID_BINDERFS) continue ;; |
| 155 | + esac |
| 156 | + if ! grep -qx "$sym" .kconfig-symbols; then |
| 157 | + echo "note: pruning expectation for ${cfg} (absent from this tree)" 1>&2 |
| 158 | + sed -i "/^\(CONFIG_\)\{0,1\}${sym}\$/d" expected-configs |
| 159 | + fi |
| 160 | + done < expected-configs.orig |
| 161 | + rm -f expected-configs.orig |
| 162 | +
|
| 163 | + - | |
| 164 | + make -j1 olddefconfig |
| 165 | +
|
| 166 | + - | |
| 167 | + . ./config-utils.sh |
| 168 | +
|
| 169 | + missing_configs=0 |
| 170 | + for config in $(cat expected-configs); do |
| 171 | + if ! has "${config}"; then |
| 172 | + echo "Missing ${config}" 1>&2 |
| 173 | + missing_configs=1 |
| 174 | + fi |
| 175 | + done |
| 176 | + # Only fail for... |
| 177 | + case "%{arch}" in |
| 178 | + x86_64|aarch64) |
| 179 | + [ "${missing_configs}" = 0 ] |
| 180 | + ;; |
| 181 | + esac |
| 182 | +
|
| 183 | + # has() accepts =m; the zswap karg requires =y. |
| 184 | + grep -q '^CONFIG_CRYPTO_ZSTD=y$' .config |
| 185 | +
|
| 186 | + install-commands: |
| 187 | + - | |
| 188 | + install -Dm644 "%{image-name}" '%{install-root}%{bootdir}/vmlinuz' |
| 189 | + install -Dm644 vmlinux '%{install-root}%{bootdir}/vmlinux' |
| 190 | + install -Dm644 System.map '%{install-root}%{bootdir}/System.map' |
| 191 | + install -Dm644 .config '%{install-root}%{bootdir}/config' |
| 192 | + make -j1 INSTALL_MOD_PATH='%{install-root}%{prefix}' INSTALL_MOD_STRIP=1 modules_install |
| 193 | +
|
| 194 | + - | |
| 195 | + release=$(make -s kernelrelease) |
| 196 | + targetdir="%{install-root}%{prefix}/src/linux-${release}" |
| 197 | +
|
| 198 | + rm "%{install-root}%{indep-libdir}/modules/${release}"/build |
| 199 | +
|
| 200 | + to_copy=( |
| 201 | + Makefile |
| 202 | + Module.symvers |
| 203 | + .config |
| 204 | + "arch/%{src-arch}/include" |
| 205 | + "arch/%{src-arch}/Makefile" |
| 206 | + scripts |
| 207 | + include |
| 208 | + ) |
| 209 | + if [ "$(scripts/config -s OBJTOOL)" = y ]; then |
| 210 | + to_copy+=(tools/objtool/objtool) |
| 211 | + fi |
| 212 | + for file in "${to_copy[@]}" |
| 213 | + do |
| 214 | + targetfile="${targetdir}/${file}" |
| 215 | + dir="$(dirname "${targetfile}")" |
| 216 | + [ -d "${dir}" ] || install -d "${dir}" |
| 217 | + cp -aT "${file}" "${targetfile}" |
| 218 | + done |
| 219 | +
|
| 220 | + ln -sr "${targetdir}" "%{install-root}%{indep-libdir}/modules/${release}/build" |
| 221 | +
|
| 222 | + (?): |
| 223 | + - arch in ["aarch64", "riscv64"]: |
| 224 | + install-commands: |
| 225 | + (>): |
| 226 | + - | |
| 227 | + make -j1 INSTALL_DTBS_PATH='%{install-root}%{bootdir}/dtbs' dtbs_install |
| 228 | +
|
| 229 | +public: |
| 230 | + bst: |
| 231 | + split-rules: |
| 232 | + devel: |
| 233 | + (>): |
| 234 | + - '%{bootdir}/System.map' |
| 235 | + # DEBUG_INFO=y (forced by OGC for BTF) makes vmlinux ~0.5 GB; |
| 236 | + # runtime consumers (scx schedulers) read /sys/kernel/btf/vmlinux, |
| 237 | + # not this file, so keep it out of the composed images. |
| 238 | + - '%{bootdir}/vmlinux' |
| 239 | + |
| 240 | +sources: |
| 241 | +- kind: git_repo |
| 242 | + url: github:OpenGamingCollective/linux.git |
| 243 | + track: v*-ogc* |
| 244 | + ref: v7.1.4-ogc1-0-g29e5cbbcc123d68c41fc41b9c15afc3a2a98469e |
| 245 | +- kind: local |
| 246 | + path: files/linux-ogc/config-utils.sh |
| 247 | +- kind: local |
| 248 | + path: files/linux-ogc/fdsdk-config.sh |
| 249 | +- kind: local |
| 250 | + path: files/linux-ogc/ogc.config.set |
| 251 | +- kind: local |
| 252 | + path: files/linux-ogc/ogc.config.unset |
0 commit comments