xref: /openbmc/linux/scripts/package/mkspec (revision 25b080bd)
11da177e4SLinus Torvalds#!/bin/sh
21da177e4SLinus Torvalds#
32174d292SMike Marciniszyn#	Output a simple RPM spec file.
42174d292SMike Marciniszyn#	This version assumes a minimum of RPM 4.0.3.
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
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"
3025b080bdSMasahiro Yamadaecho "Release: $(cat .version 2>/dev/null || echo 1)"
311da177e4SLinus Torvaldsecho "License: GPL"
321da177e4SLinus Torvaldsecho "Group: System Environment/Kernel"
331da177e4SLinus Torvaldsecho "Vendor: The Linux Community"
341da177e4SLinus Torvaldsecho "URL: http://www.kernel.org"
351da177e4SLinus Torvalds
361da177e4SLinus Torvaldsif ! $PREBUILT; then
371da177e4SLinus Torvaldsecho "Source: kernel-$__KERNELRELEASE.tar.gz"
381da177e4SLinus Torvaldsfi
391da177e4SLinus Torvalds
40880df92fSJohn Saalwaechterecho "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root"
411da177e4SLinus Torvaldsecho "Provides: $PROVIDES"
421da177e4SLinus Torvaldsecho "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
431da177e4SLinus Torvaldsecho "%define debug_package %{nil}"
441da177e4SLinus Torvaldsecho ""
451da177e4SLinus Torvaldsecho "%description"
461da177e4SLinus Torvaldsecho "The Linux Kernel, the operating system core itself"
471da177e4SLinus Torvaldsecho ""
480bd41dfcSArun Sharmaecho "%package headers"
490bd41dfcSArun Sharmaecho "Summary: Header files for the Linux kernel for use by glibc"
500bd41dfcSArun Sharmaecho "Group: Development/System"
510bd41dfcSArun Sharmaecho "Obsoletes: kernel-headers"
520bd41dfcSArun Sharmaecho "Provides: kernel-headers = %{version}"
530bd41dfcSArun Sharmaecho "%description headers"
540bd41dfcSArun Sharmaecho "Kernel-headers includes the C header files that specify the interface"
550bd41dfcSArun Sharmaecho "between the Linux kernel and userspace libraries and programs.  The"
560bd41dfcSArun Sharmaecho "header files define structures and constants that are needed for"
570bd41dfcSArun Sharmaecho "building most standard programs and are also needed for rebuilding the"
580bd41dfcSArun Sharmaecho "glibc package."
590bd41dfcSArun Sharmaecho ""
602174d292SMike Marciniszynecho "%package devel"
612174d292SMike Marciniszynecho "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel"
622174d292SMike Marciniszynecho "Group: System Environment/Kernel"
632174d292SMike Marciniszynecho "AutoReqProv: no"
642174d292SMike Marciniszynecho "%description -n kernel-devel"
652174d292SMike Marciniszynecho "This package provides kernel headers and makefiles sufficient to build modules"
662174d292SMike Marciniszynecho "against the $__KERNELRELEASE kernel package."
672174d292SMike Marciniszynecho ""
681da177e4SLinus Torvalds
691da177e4SLinus Torvaldsif ! $PREBUILT; then
701da177e4SLinus Torvaldsecho "%prep"
711da177e4SLinus Torvaldsecho "%setup -q"
721da177e4SLinus Torvaldsecho ""
731da177e4SLinus Torvaldsfi
741da177e4SLinus Torvalds
751da177e4SLinus Torvaldsecho "%build"
761da177e4SLinus Torvalds
771da177e4SLinus Torvaldsif ! $PREBUILT; then
7825b080bdSMasahiro Yamadaecho "make clean && make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}"
791da177e4SLinus Torvaldsecho ""
801da177e4SLinus Torvaldsfi
811da177e4SLinus Torvalds
821da177e4SLinus Torvaldsecho "%install"
83c398ff00SMike Marciniszynecho 'KBUILD_IMAGE=$(make image_name)'
84d2cb1a95SGreg Edwardsecho "%ifarch ia64"
85a5fa393bSRolf Eike Beerecho 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules'
86d2cb1a95SGreg Edwardsecho "%else"
87a5fa393bSRolf Eike Beerecho 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules'
88d2cb1a95SGreg Edwardsecho "%endif"
891da177e4SLinus Torvalds
909e090074SMasahiro Yamadaecho 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= modules_install'
91d2cb1a95SGreg Edwardsecho "%ifarch ia64"
92d2cb1a95SGreg Edwardsecho 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
93d2cb1a95SGreg Edwardsecho 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
94d2cb1a95SGreg Edwardsecho "%else"
951a0f3d42SMike Wolfecho "%ifarch ppc64"
961a0f3d42SMike Wolfecho "cp vmlinux arch/powerpc/boot"
971a0f3d42SMike Wolfecho "cp arch/powerpc/boot/"'$KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
981a0f3d42SMike Wolfecho "%else"
991da177e4SLinus Torvaldsecho 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
100d2cb1a95SGreg Edwardsecho "%endif"
1011a0f3d42SMike Wolfecho "%endif"
1021da177e4SLinus Torvalds
103e0367a61SDavid R. Bildecho 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install'
1041da177e4SLinus Torvaldsecho 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
1051da177e4SLinus Torvalds
1061da177e4SLinus Torvaldsecho 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
107fc370ecfSJosh Hunt
108fc370ecfSJosh Huntecho "%ifnarch ppc64"
10992f43c45SBorislav Petkovecho 'bzip2 -9 --keep vmlinux'
110fc370ecfSJosh Huntecho 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2"
111fc370ecfSJosh Huntecho "%endif"
112fc370ecfSJosh Hunt
113b9a54424SJérôme Glisseif ! $PREBUILT; then
11451a5f810SAnton Tikhomirovecho 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build"
11551a5f810SAnton Tikhomirovecho 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source"
1162174d292SMike Marciniszynecho "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE"
1179e090074SMasahiro Yamadaecho "EXCLUDES=\"$RCS_TAR_IGNORE --exclude .tmp_versions --exclude=*vmlinux* --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation --exclude .config.old --exclude .missing-syscalls.d\""
1182174d292SMike Marciniszynecho "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)"
1192174d292SMike Marciniszynecho 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE"
1202174d292SMike Marciniszynecho "ln -sf /usr/src/kernels/$KERNELRELEASE build"
1212174d292SMike Marciniszynecho "ln -sf /usr/src/kernels/$KERNELRELEASE source"
122b9a54424SJérôme Glissefi
1232174d292SMike Marciniszyn
1241da177e4SLinus Torvaldsecho ""
1251da177e4SLinus Torvaldsecho "%clean"
126a2ebcc7aSJosh Huntecho 'rm -rf $RPM_BUILD_ROOT'
1271da177e4SLinus Torvaldsecho ""
1283c9c7a14SMike Marciniszynecho "%post"
1293c9c7a14SMike Marciniszynecho "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then"
130c8b08ca5SJiri Kosinaecho "cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm"
131c8b08ca5SJiri Kosinaecho "cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm"
1323c9c7a14SMike Marciniszynecho "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE"
133c8b08ca5SJiri Kosinaecho "/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm"
134c8b08ca5SJiri Kosinaecho "rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm"
1353c9c7a14SMike Marciniszynecho "fi"
1363c9c7a14SMike Marciniszynecho ""
1376ef41e22SPaolo Abeniecho "%preun"
1386ef41e22SPaolo Abeniecho "if [ -x /sbin/new-kernel-pkg ]; then"
1396ef41e22SPaolo Abeniecho "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img"
1406ef41e22SPaolo Abeniecho "fi"
1416ef41e22SPaolo Abeniecho ""
14227c3bffdSJiri Kosinaecho "%postun"
14327c3bffdSJiri Kosinaecho "if [ -x /sbin/update-bootloader ]; then"
14427c3bffdSJiri Kosinaecho "/sbin/update-bootloader --remove $KERNELRELEASE"
14527c3bffdSJiri Kosinaecho "fi"
14627c3bffdSJiri Kosinaecho ""
1471da177e4SLinus Torvaldsecho "%files"
1481da177e4SLinus Torvaldsecho '%defattr (-, root, root)'
1491da177e4SLinus Torvaldsecho "/lib/modules/$KERNELRELEASE"
1502174d292SMike Marciniszynecho "%exclude /lib/modules/$KERNELRELEASE/build"
1512174d292SMike Marciniszynecho "%exclude /lib/modules/$KERNELRELEASE/source"
1521da177e4SLinus Torvaldsecho "/boot/*"
1531da177e4SLinus Torvaldsecho ""
1540bd41dfcSArun Sharmaecho "%files headers"
1550bd41dfcSArun Sharmaecho '%defattr (-, root, root)'
1560bd41dfcSArun Sharmaecho "/usr/include"
1570bd41dfcSArun Sharmaecho ""
158b9a54424SJérôme Glisseif ! $PREBUILT; then
1592174d292SMike Marciniszynecho "%files devel"
1602174d292SMike Marciniszynecho '%defattr (-, root, root)'
1612174d292SMike Marciniszynecho "/usr/src/kernels/$KERNELRELEASE"
1622174d292SMike Marciniszynecho "/lib/modules/$KERNELRELEASE/build"
1632174d292SMike Marciniszynecho "/lib/modules/$KERNELRELEASE/source"
1642174d292SMike Marciniszynecho ""
165b9a54424SJérôme Glissefi
166