xref: /linux/scripts/package/mkspec (revision 956b9cbd7f156c8672dac94a00de3c6a0939c692)
11da177e4SLinus Torvalds#!/bin/sh
21da177e4SLinus Torvalds#
32174d292SMike Marciniszyn#	Output a simple RPM spec file.
4169dd780SArend van Spriel#	This version assumes a minimum of RPM 4.13
51da177e4SLinus Torvalds#
61da177e4SLinus Torvalds#	The only gothic bit here is redefining install_post to avoid
71da177e4SLinus Torvalds#	stripping the symbols from files in the kernel which we want
81da177e4SLinus Torvalds#
91da177e4SLinus Torvalds#	Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net>
101da177e4SLinus Torvalds#
111da177e4SLinus Torvalds
12c0414419SMasahiro Yamadaset -eu
13c0414419SMasahiro Yamada
14ffa46bbcSMasahiro Yamadaoutput=$1
15ffa46bbcSMasahiro Yamada
16ffa46bbcSMasahiro Yamadamkdir -p "$(dirname "${output}")"
17ffa46bbcSMasahiro Yamada
18ffa46bbcSMasahiro Yamadaexec >"${output}"
19ffa46bbcSMasahiro Yamada
2081f59a26SMasahiro Yamadaif grep -q CONFIG_MODULES=y include/config/auto.conf; then
212a291fc3SMasahiro Yamadaecho '%define with_devel %{?_without_devel: 0} %{?!_without_devel: 1}'
220b7f12f5SMasahiro Yamadaelse
232a291fc3SMasahiro Yamadaecho '%define with_devel 0'
240b7f12f5SMasahiro Yamadafi
250b7f12f5SMasahiro Yamada
26*ffe9ac1aSNathan Chancellor# use %{debug_package} machinery to generate -debuginfo
27*ffe9ac1aSNathan Chancellorwith_debuginfo_rpm=0
286d6b8b0eSNathan Chancellor# manually generate -debuginfo package
296d6b8b0eSNathan Chancellorwith_debuginfo_manual=0
30a7c699d0SUday Shankar# debuginfo package generation uses find-debuginfo.sh under the hood,
31a7c699d0SUday Shankar# which only works on uncompressed modules that contain debuginfo
32a7c699d0SUday Shankarif grep -q CONFIG_DEBUG_INFO=y include/config/auto.conf &&
33a7c699d0SUday Shankar   (! grep -q CONFIG_MODULE_COMPRESS=y include/config/auto.conf) &&
34a7c699d0SUday Shankar   (! grep -q CONFIG_DEBUG_INFO_SPLIT=y include/config/auto.conf); then
356d6b8b0eSNathan Chancellor	# If module signing is enabled (which may be required to boot with
366d6b8b0eSNathan Chancellor	# lockdown enabled), the find-debuginfo.sh machinery cannot be used
376d6b8b0eSNathan Chancellor	# because the signatures will be stripped off the modules. However, due
386d6b8b0eSNathan Chancellor	# to an rpm bug in versions prior to 4.20.0
396d6b8b0eSNathan Chancellor	#
406d6b8b0eSNathan Chancellor	#     https://github.com/rpm-software-management/rpm/issues/3057
416d6b8b0eSNathan Chancellor	#     https://github.com/rpm-software-management/rpm/commit/49f906998f3cf1f4152162ca61ac0869251c380f
426d6b8b0eSNathan Chancellor	#
436d6b8b0eSNathan Chancellor	# We cannot provide our own debuginfo package because it does not listen
446d6b8b0eSNathan Chancellor	# to our custom files list, failing the build due to unpackaged files.
456d6b8b0eSNathan Chancellor	# Manually generate the debug info package if using rpm 4.20.0. If not
466d6b8b0eSNathan Chancellor	# using rpm 4.20.0, avoid generating a -debuginfo package altogether,
476d6b8b0eSNathan Chancellor	# as it is not safe.
486d6b8b0eSNathan Chancellor	if grep -q CONFIG_MODULE_SIG=y include/config/auto.conf; then
496d6b8b0eSNathan Chancellor		rpm_ver_str=$(rpm --version 2>/dev/null)
506d6b8b0eSNathan Chancellor		# Split the version on spaces
516d6b8b0eSNathan Chancellor		IFS=' '
526d6b8b0eSNathan Chancellor		set -- $rpm_ver_str
536d6b8b0eSNathan Chancellor		if [ "${1:-}" = RPM -a "${2:-}" = version ]; then
546d6b8b0eSNathan Chancellor			IFS=.
556d6b8b0eSNathan Chancellor			set -- $3
566d6b8b0eSNathan Chancellor			rpm_ver=$(( 1000000 * $1 + 10000 * $2 + 100 * $3 + ${4:-0} ))
576d6b8b0eSNathan Chancellor			if [ "$rpm_ver" -ge 4200000 ]; then
586d6b8b0eSNathan Chancellor				with_debuginfo_manual='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}'
59a7c699d0SUday Shankar			fi
606d6b8b0eSNathan Chancellor		fi
61*ffe9ac1aSNathan Chancellor	else
62*ffe9ac1aSNathan Chancellor		with_debuginfo_rpm='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}'
636d6b8b0eSNathan Chancellor	fi
646d6b8b0eSNathan Chancellorfi
656d6b8b0eSNathan Chancellorecho "%define with_debuginfo_manual $with_debuginfo_manual"
66*ffe9ac1aSNathan Chancellorecho "%define with_debuginfo_rpm $with_debuginfo_rpm"
67a7c699d0SUday Shankar
6849c803cdSMasahiro Yamadacat<<EOF
69a06d9ef8SMasahiro Yamada%define ARCH ${ARCH}
7093ed5605SMasahiro Yamada%define KERNELRELEASE ${KERNELRELEASE}
71ae4c4ceeSMasahiro Yamada%define pkg_release $("${srctree}/scripts/build-version")
728c5d4b64SMasahiro YamadaEOF
7349c803cdSMasahiro Yamada
7449c803cdSMasahiro Yamadacat "${srctree}/scripts/package/kernel.spec"
75301c1090SRafael Aquini
76301c1090SRafael Aquini# collect the user's name and email address for the changelog entry
77301c1090SRafael Aquiniif [ "$(command -v git)" ]; then
78301c1090SRafael Aquini	name=$(git config user.name) || true
79301c1090SRafael Aquini	email=$(git config user.email) || true
80301c1090SRafael Aquinifi
81301c1090SRafael Aquini
82301c1090SRafael Aquiniif [ ! "${name:+set}" ]; then
83301c1090SRafael Aquini	name=${KBUILD_BUILD_USER:-$(id -nu)}
84301c1090SRafael Aquinifi
85301c1090SRafael Aquini
86301c1090SRafael Aquiniif [ ! "${email:+set}" ]; then
87301c1090SRafael Aquini	buildhost=${KBUILD_BUILD_HOST:-$(hostname -f 2>/dev/null || hostname)}
88301c1090SRafael Aquini	builduser=${KBUILD_BUILD_USER:-$(id -nu)}
89301c1090SRafael Aquini	email="${builduser}@${buildhost}"
90301c1090SRafael Aquinifi
91301c1090SRafael Aquini
92301c1090SRafael Aquinicat << EOF
93301c1090SRafael Aquini
94301c1090SRafael Aquini%changelog
95ba6c6640SPetr Vorel* $(LC_ALL=C date +'%a %b %d %Y') ${name} <${email}>
96301c1090SRafael Aquini- Custom built Linux kernel.
97301c1090SRafael AquiniEOF
98