xref: /linux-6.15/scripts/package/mkspec (revision 41612378)
11da177e4SLinus Torvalds#!/bin/sh
21da177e4SLinus Torvalds#
3f77f13e2SGilles Espinasse#	Output a simple RPM spec file that uses no fancy features requiring
41da177e4SLinus Torvalds#	RPM v4. This is intended to work with any RPM distro.
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 <[email protected]>
101da177e4SLinus Torvalds#
111da177e4SLinus Torvalds
121da177e4SLinus Torvalds# how we were called determines which rpms we build and how we build them
131da177e4SLinus Torvaldsif [ "$1" = "prebuilt" ]; then
141da177e4SLinus Torvalds	PREBUILT=true
151da177e4SLinus Torvaldselse
161da177e4SLinus Torvalds	PREBUILT=false
171da177e4SLinus Torvaldsfi
181da177e4SLinus Torvalds
191da177e4SLinus Torvalds# starting to output the spec
201da177e4SLinus Torvaldsif [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then
211da177e4SLinus Torvalds	PROVIDES=kernel-drm
221da177e4SLinus Torvaldsfi
231da177e4SLinus Torvalds
241da177e4SLinus TorvaldsPROVIDES="$PROVIDES kernel-$KERNELRELEASE"
25e1287eb8SArun Sharma__KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"`
261da177e4SLinus Torvalds
271da177e4SLinus Torvaldsecho "Name: kernel"
281da177e4SLinus Torvaldsecho "Summary: The Linux Kernel"
291da177e4SLinus Torvaldsecho "Version: $__KERNELRELEASE"
301da177e4SLinus Torvalds# we need to determine the NEXT version number so that uname and
311da177e4SLinus Torvalds# rpm -q will agree
321da177e4SLinus Torvaldsecho "Release: `. $srctree/scripts/mkversion`"
331da177e4SLinus Torvaldsecho "License: GPL"
341da177e4SLinus Torvaldsecho "Group: System Environment/Kernel"
351da177e4SLinus Torvaldsecho "Vendor: The Linux Community"
361da177e4SLinus Torvaldsecho "URL: http://www.kernel.org"
371da177e4SLinus Torvalds
381da177e4SLinus Torvaldsif ! $PREBUILT; then
391da177e4SLinus Torvaldsecho "Source: kernel-$__KERNELRELEASE.tar.gz"
401da177e4SLinus Torvaldsfi
411da177e4SLinus Torvalds
42880df92fSJohn Saalwaechterecho "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root"
431da177e4SLinus Torvaldsecho "Provides: $PROVIDES"
441da177e4SLinus Torvaldsecho "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
451da177e4SLinus Torvaldsecho "%define debug_package %{nil}"
461da177e4SLinus Torvaldsecho ""
471da177e4SLinus Torvaldsecho "%description"
481da177e4SLinus Torvaldsecho "The Linux Kernel, the operating system core itself"
491da177e4SLinus Torvaldsecho ""
500bd41dfcSArun Sharmaecho "%package headers"
510bd41dfcSArun Sharmaecho "Summary: Header files for the Linux kernel for use by glibc"
520bd41dfcSArun Sharmaecho "Group: Development/System"
530bd41dfcSArun Sharmaecho "Obsoletes: kernel-headers"
540bd41dfcSArun Sharmaecho "Provides: kernel-headers = %{version}"
550bd41dfcSArun Sharmaecho "%description headers"
560bd41dfcSArun Sharmaecho "Kernel-headers includes the C header files that specify the interface"
570bd41dfcSArun Sharmaecho "between the Linux kernel and userspace libraries and programs.  The"
580bd41dfcSArun Sharmaecho "header files define structures and constants that are needed for"
590bd41dfcSArun Sharmaecho "building most standard programs and are also needed for rebuilding the"
600bd41dfcSArun Sharmaecho "glibc package."
610bd41dfcSArun Sharmaecho ""
621da177e4SLinus Torvalds
631da177e4SLinus Torvaldsif ! $PREBUILT; then
641da177e4SLinus Torvaldsecho "%prep"
651da177e4SLinus Torvaldsecho "%setup -q"
661da177e4SLinus Torvaldsecho ""
671da177e4SLinus Torvaldsfi
681da177e4SLinus Torvalds
691da177e4SLinus Torvaldsecho "%build"
701da177e4SLinus Torvalds
711da177e4SLinus Torvaldsif ! $PREBUILT; then
7213797b77SJeremy Kerrecho "make clean && make %{?_smp_mflags}"
731da177e4SLinus Torvaldsecho ""
741da177e4SLinus Torvaldsfi
751da177e4SLinus Torvalds
761da177e4SLinus Torvaldsecho "%install"
77c398ff00SMike Marciniszynecho 'KBUILD_IMAGE=$(make image_name)'
78d2cb1a95SGreg Edwardsecho "%ifarch ia64"
79a5fa393bSRolf Eike Beerecho 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules'
80d2cb1a95SGreg Edwardsecho "%else"
81a5fa393bSRolf Eike Beerecho 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules'
82d2cb1a95SGreg Edwardsecho "%endif"
83*41612378SMike Marciniszynecho 'mkdir -p $RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE"
841da177e4SLinus Torvalds
85*41612378SMike Marciniszynecho 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= mod-fw= modules_install'
86*41612378SMike Marciniszynecho 'INSTALL_FW_PATH=$RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE"
87*41612378SMike Marciniszynecho 'make INSTALL_FW_PATH=$INSTALL_FW_PATH' firmware_install
88d2cb1a95SGreg Edwardsecho "%ifarch ia64"
89d2cb1a95SGreg Edwardsecho 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
90d2cb1a95SGreg Edwardsecho 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
91d2cb1a95SGreg Edwardsecho "%else"
921a0f3d42SMike Wolfecho "%ifarch ppc64"
931a0f3d42SMike Wolfecho "cp vmlinux arch/powerpc/boot"
941a0f3d42SMike Wolfecho "cp arch/powerpc/boot/"'$KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
951a0f3d42SMike Wolfecho "%else"
961da177e4SLinus Torvaldsecho 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
97d2cb1a95SGreg Edwardsecho "%endif"
981a0f3d42SMike Wolfecho "%endif"
991da177e4SLinus Torvalds
100e0367a61SDavid R. Bildecho 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install'
1011da177e4SLinus Torvaldsecho 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
1021da177e4SLinus Torvalds
1031da177e4SLinus Torvaldsecho 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
104fc370ecfSJosh Hunt
105fc370ecfSJosh Huntecho "%ifnarch ppc64"
106fc370ecfSJosh Huntecho 'cp vmlinux vmlinux.orig'
107fc370ecfSJosh Huntecho 'bzip2 -9 vmlinux'
108fc370ecfSJosh Huntecho 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2"
109fc370ecfSJosh Huntecho 'mv vmlinux.orig vmlinux'
110fc370ecfSJosh Huntecho "%endif"
111fc370ecfSJosh Hunt
1121da177e4SLinus Torvaldsecho ""
1131da177e4SLinus Torvaldsecho "%clean"
114a2ebcc7aSJosh Huntecho 'rm -rf $RPM_BUILD_ROOT'
1151da177e4SLinus Torvaldsecho ""
1163c9c7a14SMike Marciniszynecho "%post"
1173c9c7a14SMike Marciniszynecho "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then"
1183c9c7a14SMike Marciniszynecho "cp /boot/vmlinuz-$KERNELRELEASE /boot/vmlinuz-$KERNELRELEASE-rpm"
1193c9c7a14SMike Marciniszynecho "cp /boot/System.map-$KERNELRELEASE /boot/System.map-$KERNELRELEASE-rpm"
1203c9c7a14SMike Marciniszynecho "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE"
1213c9c7a14SMike Marciniszynecho "/sbin/installkernel $KERNELRELEASE /boot/vmlinuz-$KERNELRELEASE-rpm /boot/System.map-$KERNELRELEASE-rpm"
1223c9c7a14SMike Marciniszynecho "rm -f /boot/vmlinuz-$KERNELRELEASE-rpm /boot/System.map-$KERNELRELEASE-rpm"
1233c9c7a14SMike Marciniszynecho "fi"
1243c9c7a14SMike Marciniszynecho ""
1251da177e4SLinus Torvaldsecho "%files"
1261da177e4SLinus Torvaldsecho '%defattr (-, root, root)'
1271da177e4SLinus Torvaldsecho "%dir /lib/modules"
1281da177e4SLinus Torvaldsecho "/lib/modules/$KERNELRELEASE"
129*41612378SMike Marciniszynecho "/lib/firmware/$KERNELRELEASE"
1301da177e4SLinus Torvaldsecho "/boot/*"
1311da177e4SLinus Torvaldsecho ""
1320bd41dfcSArun Sharmaecho "%files headers"
1330bd41dfcSArun Sharmaecho '%defattr (-, root, root)'
1340bd41dfcSArun Sharmaecho "/usr/include"
1350bd41dfcSArun Sharmaecho ""
136