Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 #
0003 #       Output a simple RPM spec file.
0004 #       This version assumes a minimum of RPM 4.0.3.
0005 #
0006 #       The only gothic bit here is redefining install_post to avoid
0007 #       stripping the symbols from files in the kernel which we want
0008 #
0009 #       Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net>
0010 #
0011 
0012 # how we were called determines which rpms we build and how we build them
0013 if [ "$1" = prebuilt ]; then
0014         S=DEL
0015         MAKE="$MAKE -f $srctree/Makefile"
0016 else
0017         S=
0018 fi
0019 
0020 if grep -q CONFIG_MODULES=y .config; then
0021         M=
0022 else
0023         M=DEL
0024 fi
0025 
0026 if grep -q CONFIG_DRM=y .config; then
0027         PROVIDES=kernel-drm
0028 fi
0029 
0030 PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
0031 __KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g")
0032 EXCLUDES="$RCS_TAR_IGNORE --exclude=*vmlinux* --exclude=*.mod \
0033 --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
0034 --exclude=.config.old --exclude=.missing-syscalls.d --exclude=*.s"
0035 
0036 # We can label the here-doc lines for conditional output to the spec file
0037 #
0038 # Labels:
0039 #  $S: this line is enabled only when building source package
0040 #  $M: this line is enabled only when CONFIG_MODULES is enabled
0041 sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
0042         Name: kernel
0043         Summary: The Linux Kernel
0044         Version: $__KERNELRELEASE
0045         Release: $(cat .version 2>/dev/null || echo 1)
0046         License: GPL
0047         Group: System Environment/Kernel
0048         Vendor: The Linux Community
0049         URL: https://www.kernel.org
0050 $S      Source: kernel-$__KERNELRELEASE.tar.gz
0051         Provides: $PROVIDES
0052         # $UTS_MACHINE as a fallback of _arch in case
0053         # /usr/lib/rpm/platform/*/macros was not included.
0054         %define _arch %{?_arch:$UTS_MACHINE}
0055         %define __spec_install_post /usr/lib/rpm/brp-compress || :
0056         %define debug_package %{nil}
0057 
0058         %description
0059         The Linux Kernel, the operating system core itself
0060 
0061         %package headers
0062         Summary: Header files for the Linux kernel for use by glibc
0063         Group: Development/System
0064         Obsoletes: kernel-headers
0065         Provides: kernel-headers = %{version}
0066         %description headers
0067         Kernel-headers includes the C header files that specify the interface
0068         between the Linux kernel and userspace libraries and programs.  The
0069         header files define structures and constants that are needed for
0070         building most standard programs and are also needed for rebuilding the
0071         glibc package.
0072 
0073 $S$M    %package devel
0074 $S$M    Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel
0075 $S$M    Group: System Environment/Kernel
0076 $S$M    AutoReqProv: no
0077 $S$M    %description -n kernel-devel
0078 $S$M    This package provides kernel headers and makefiles sufficient to build modules
0079 $S$M    against the $__KERNELRELEASE kernel package.
0080 $S$M
0081 $S      %prep
0082 $S      %setup -q
0083 $S
0084 $S      %build
0085 $S      $MAKE %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
0086 $S
0087         %install
0088         mkdir -p %{buildroot}/boot
0089         %ifarch ia64
0090         mkdir -p %{buildroot}/boot/efi
0091         cp \$($MAKE image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE
0092         ln -s efi/vmlinuz-$KERNELRELEASE %{buildroot}/boot/
0093         %else
0094         cp \$($MAKE image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
0095         %endif
0096 $M      $MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install
0097         $MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
0098         cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
0099         cp .config %{buildroot}/boot/config-$KERNELRELEASE
0100         bzip2 -9 --keep vmlinux
0101         mv vmlinux.bz2 %{buildroot}/boot/vmlinux-$KERNELRELEASE.bz2
0102 $S$M    rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
0103 $S$M    rm -f %{buildroot}/lib/modules/$KERNELRELEASE/source
0104 $S$M    mkdir -p %{buildroot}/usr/src/kernels/$KERNELRELEASE
0105 $S$M    tar cf - $EXCLUDES . | tar xf - -C %{buildroot}/usr/src/kernels/$KERNELRELEASE
0106 $S$M    cd %{buildroot}/lib/modules/$KERNELRELEASE
0107 $S$M    ln -sf /usr/src/kernels/$KERNELRELEASE build
0108 $S$M    ln -sf /usr/src/kernels/$KERNELRELEASE source
0109 
0110         %clean
0111         rm -rf %{buildroot}
0112 
0113         %post
0114         if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then
0115         cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm
0116         cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm
0117         rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE
0118         /sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
0119         rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
0120         fi
0121 
0122         %preun
0123         if [ -x /sbin/new-kernel-pkg ]; then
0124         new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img
0125         elif [ -x /usr/bin/kernel-install ]; then
0126         kernel-install remove $KERNELRELEASE
0127         fi
0128 
0129         %postun
0130         if [ -x /sbin/update-bootloader ]; then
0131         /sbin/update-bootloader --remove $KERNELRELEASE
0132         fi
0133 
0134         %files
0135         %defattr (-, root, root)
0136 $M      /lib/modules/$KERNELRELEASE
0137 $M      %exclude /lib/modules/$KERNELRELEASE/build
0138 $M      %exclude /lib/modules/$KERNELRELEASE/source
0139         /boot/*
0140 
0141         %files headers
0142         %defattr (-, root, root)
0143         /usr/include
0144 $S$M
0145 $S$M    %files devel
0146 $S$M    %defattr (-, root, root)
0147 $S$M    /usr/src/kernels/$KERNELRELEASE
0148 $S$M    /lib/modules/$KERNELRELEASE/build
0149 $S$M    /lib/modules/$KERNELRELEASE/source
0150 EOF