Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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# use %{debug_package} machinery to generate -debuginfo
27with_debuginfo_rpm=0
28# manually generate -debuginfo package
29with_debuginfo_manual=0
30# debuginfo package generation uses find-debuginfo.sh under the hood,
31# which only works on uncompressed modules that contain debuginfo
32if grep -q CONFIG_DEBUG_INFO=y include/config/auto.conf &&
33 (! grep -q CONFIG_MODULE_COMPRESS=y include/config/auto.conf) &&
34 (! grep -q CONFIG_DEBUG_INFO_SPLIT=y include/config/auto.conf); then
35 # If module signing is enabled (which may be required to boot with
36 # lockdown enabled), the find-debuginfo.sh machinery cannot be used
37 # because the signatures will be stripped off the modules. However, due
38 # to an rpm bug in versions prior to 4.20.0
39 #
40 # https://github.com/rpm-software-management/rpm/issues/3057
41 # https://github.com/rpm-software-management/rpm/commit/49f906998f3cf1f4152162ca61ac0869251c380f
42 #
43 # We cannot provide our own debuginfo package because it does not listen
44 # to our custom files list, failing the build due to unpackaged files.
45 # Manually generate the debug info package if using rpm 4.20.0. If not
46 # using rpm 4.20.0, avoid generating a -debuginfo package altogether,
47 # as it is not safe.
48 if grep -q CONFIG_MODULE_SIG=y include/config/auto.conf; then
49 rpm_ver_str=$(rpm --version 2>/dev/null)
50 # Split the version on spaces
51 IFS=' '
52 set -- $rpm_ver_str
53 if [ "${1:-}" = RPM -a "${2:-}" = version ]; then
54 IFS=.
55 set -- $3
56 rpm_ver=$(( 1000000 * $1 + 10000 * $2 + 100 * $3 + ${4:-0} ))
57 if [ "$rpm_ver" -ge 4200000 ]; then
58 with_debuginfo_manual='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}'
59 fi
60 fi
61 else
62 with_debuginfo_rpm='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}'
63 fi
64fi
65echo "%define with_debuginfo_manual $with_debuginfo_manual"
66echo "%define with_debuginfo_rpm $with_debuginfo_rpm"
67
68cat<<EOF
69%define ARCH ${ARCH}
70%define KERNELRELEASE ${KERNELRELEASE}
71%define pkg_release $("${srctree}/scripts/build-version")
72EOF
73
74cat "${srctree}/scripts/package/kernel.spec"
75
76# collect the user's name and email address for the changelog entry
77if [ "$(command -v git)" ]; then
78 name=$(git config user.name) || true
79 email=$(git config user.email) || true
80fi
81
82if [ ! "${name:+set}" ]; then
83 name=${KBUILD_BUILD_USER:-$(id -nu)}
84fi
85
86if [ ! "${email:+set}" ]; then
87 buildhost=${KBUILD_BUILD_HOST:-$(hostname -f 2>/dev/null || hostname)}
88 builduser=${KBUILD_BUILD_USER:-$(id -nu)}
89 email="${builduser}@${buildhost}"
90fi
91
92cat << EOF
93
94%changelog
95* $(LC_ALL=C date +'%a %b %d %Y') ${name} <${email}>
96- Custom built Linux kernel.
97EOF