xref: /linux/scripts/package/mkspec (revision 1260ed77798502de9c98020040d2995008de10cc)
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# debuginfo package generation uses find-debuginfo.sh under the hood,
27# which only works on uncompressed modules that contain debuginfo
28if grep -q CONFIG_DEBUG_INFO=y include/config/auto.conf &&
29   (! grep -q CONFIG_MODULE_COMPRESS=y include/config/auto.conf) &&
30   (! grep -q CONFIG_DEBUG_INFO_SPLIT=y include/config/auto.conf); then
31echo '%define with_debuginfo %{?_without_debuginfo: 0} %{?!_without_debuginfo: 1}'
32else
33echo '%define with_debuginfo 0'
34fi
35
36cat<<EOF
37%define ARCH ${ARCH}
38%define KERNELRELEASE ${KERNELRELEASE}
39%define pkg_release $("${srctree}/scripts/build-version")
40EOF
41
42cat "${srctree}/scripts/package/kernel.spec"
43
44# collect the user's name and email address for the changelog entry
45if [ "$(command -v git)" ]; then
46	name=$(git config user.name) || true
47	email=$(git config user.email) || true
48fi
49
50if [ ! "${name:+set}" ]; then
51	name=${KBUILD_BUILD_USER:-$(id -nu)}
52fi
53
54if [ ! "${email:+set}" ]; then
55	buildhost=${KBUILD_BUILD_HOST:-$(hostname -f 2>/dev/null || hostname)}
56	builduser=${KBUILD_BUILD_USER:-$(id -nu)}
57	email="${builduser}@${buildhost}"
58fi
59
60cat << EOF
61
62%changelog
63* $(LC_ALL=C date +'%a %b %d %Y') ${name} <${email}>
64- Custom built Linux kernel.
65EOF
66