1#!/bin/sh 2# 3# Output a simple RPM spec file. 4# This version assumes a minimum of RPM 4.13 5# 6# The only gothic bit here is redefining install_post to avoid 7# stripping the symbols from files in the kernel which we want 8# 9# Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net> 10# 11 12set -eu 13 14output=$1 15 16mkdir -p "$(dirname "${output}")" 17 18exec >"${output}" 19 20if grep -q CONFIG_MODULES=y include/config/auto.conf; then 21echo '%define with_devel %{?_without_devel: 0} %{?!_without_devel: 1}' 22else 23echo '%define with_devel 0' 24fi 25 26# manually generate -debuginfo package 27with_debuginfo_manual=0 28# debuginfo package generation uses find-debuginfo.sh under the hood, 29# which only works on uncompressed modules that contain debuginfo 30if grep -q CONFIG_DEBUG_INFO=y include/config/auto.conf && 31 (! grep -q CONFIG_MODULE_COMPRESS=y include/config/auto.conf) && 32 (! grep -q CONFIG_DEBUG_INFO_SPLIT=y include/config/auto.conf); then 33 # If module signing is enabled (which may be required to boot with 34 # lockdown enabled), the find-debuginfo.sh machinery cannot be used 35 # because the signatures will be stripped off the modules. However, due 36 # to an rpm bug in versions prior to 4.20.0 37 # 38 # https://github.com/rpm-software-management/rpm/issues/3057 39 # https://github.com/rpm-software-management/rpm/commit/49f906998f3cf1f4152162ca61ac0869251c380f 40 # 41 # We cannot provide our own debuginfo package because it does not listen 42 # to our custom files list, failing the build due to unpackaged files. 43 # Manually generate the debug info package if using rpm 4.20.0. If not 44 # using rpm 4.20.0, avoid generating a -debuginfo package altogether, 45 # as it is not safe. 46 if grep -q CONFIG_MODULE_SIG=y include/config/auto.conf; then 47 rpm_ver_str=$(rpm --version 2>/dev/null) 48 # Split the version on spaces 49 IFS=' ' 50 set -- $rpm_ver_str 51 if [ "${1:-}" = RPM -a "${2:-}" = version ]; then 52 IFS=. 53 set -- $3 54 rpm_ver=$(( 1000000 * $1 + 10000 * $2 + 100 * $3 + ${4:-0} )) 55 if [ "$rpm_ver" -ge 4200000 ]; then 56 with_debuginfo_manual='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}' 57 fi 58 fi 59 fi 60fi 61echo "%define with_debuginfo_manual $with_debuginfo_manual" 62 63cat<<EOF 64%define ARCH ${ARCH} 65%define KERNELRELEASE ${KERNELRELEASE} 66%define pkg_release $("${srctree}/scripts/build-version") 67EOF 68 69cat "${srctree}/scripts/package/kernel.spec" 70 71# collect the user's name and email address for the changelog entry 72if [ "$(command -v git)" ]; then 73 name=$(git config user.name) || true 74 email=$(git config user.email) || true 75fi 76 77if [ ! "${name:+set}" ]; then 78 name=${KBUILD_BUILD_USER:-$(id -nu)} 79fi 80 81if [ ! "${email:+set}" ]; then 82 buildhost=${KBUILD_BUILD_HOST:-$(hostname -f 2>/dev/null || hostname)} 83 builduser=${KBUILD_BUILD_USER:-$(id -nu)} 84 email="${builduser}@${buildhost}" 85fi 86 87cat << EOF 88 89%changelog 90* $(LC_ALL=C date +'%a %b %d %Y') ${name} <${email}> 91- Custom built Linux kernel. 92EOF 93