Sophie

Sophie

distrib > Mageia > 3 > i586 > media > core-release-src > by-pkgid > dcc5a9d0701c4fcf7b6ac983558e1e72 > files > 33

kernel-rt-3.8.13-0.rt8.1.mga3.src.rpm

# kernel version
%define kernelversion	3
%define patchlevel	8
# sublevel is now used for -stable patches
%define sublevel	13

# kernel Makefile extraversion is substituted by
# kpatch/kgit wich are either 0 (empty), rc (kpatch), git (kgit)
%define kpatch		0

# kernel.org -gitX patch (only the number after "git")
%define kgit		0

# this is the releaseversion
%define mgarelease 	1

# this is the -rt release
%define rt_ver		3.8.11
%define rt_rel		rt8

# This is only to make life easier for people that creates derivated kernels
# a.k.a name it kernel-tmb :)
%define kname 		kernel-rt

%define rpmtag		%{distsuffix}%{mgaver}
%if %kpatch
%if %kgit
%define rpmrel		%mkrel 0.%{kpatch}.%{kgit}.%{rt_rel}.%{mgarelease}
%else
%define rpmrel		%mkrel 0.%{kpatch}.%{rt_rel}.%{mgarelease}
%endif
%else
%define rpmrel		%mkrel 0.%{rt_rel}.%{mgarelease}
%endif

# theese two never change, they are used to fool rpm/urpmi/smart
%define fakever		1
%define fakerel		%mkrel 1

# When we are using a pre/rc patch, the tarball is a sublevel -1
%if %kpatch
%define kversion  	%{kernelversion}.%{patchlevel}.%{sublevel}
%define tar_ver	  	%{kernelversion}.%(expr %{patchlevel} - 1)
%else
%define kversion  	%{kernelversion}.%{patchlevel}.%{sublevel}
%define tar_ver   	%{kernelversion}.%{patchlevel}
%endif
%define kverrel   	%{kversion}-%{rpmrel}

# used for not making too long names for rpms or search paths
%if %kpatch
%if %kgit
%define buildrpmrel     0.%{kpatch}.%{kgit}.%{rt_rel}.%{mgarelease}%{rpmtag}
%else
%define buildrpmrel     0.%{kpatch}.%{rt_rel}.%{mgarelease}%{rpmtag}
%endif
%else
%define buildrpmrel     0.%{rt_rel}.%{mgarelease}%{rpmtag}
%endif

%define buildrel        %{kversion}-%{buildrpmrel}

# having different top level names for packges means that you have to remove them by hard :(
%define top_dir_name    %{kname}-%{_arch}

%define build_dir       ${RPM_BUILD_DIR}/%{top_dir_name}
%define src_dir         %{build_dir}/linux-%{tar_ver}

# disable useless debug rpms...
%define _enable_debug_packages  %{nil}
%define debug_package           %{nil}

# build defines
%define build_doc 1
%define build_source 1
%define build_devel 1

%define build_kernel 1

%define distro_branch %(perl -pe '/(\\d+)\\.(\\d)\\.?(\\d)?/; $_="$1.$2"' /etc/mageia-release)

# End of user definitions
%{?_without_kernel: %global build_kernel 0}
%{?_without_doc: %global build_doc 0}
%{?_without_source: %global build_source 0}
%{?_without_devel: %global build_devel 0}

%{?_with_kernel: %global build_kernel 1}
%{?_with_doc: %global build_doc 1}
%{?_with_source: %global build_source 1}
%{?_with_devel: %global build_devel 1}

%if %(if [ -z "$CC" ] ; then echo 0; else echo 1; fi)
%define kmake %make CC="$CC"
%else
%define kmake %make
%endif
# there are places where parallel make don't work
%define smake make

# Parallelize xargs invocations on smp machines
%define kxargs xargs %([ -z "$RPM_BUILD_NCPUS" ] \\\
	&& RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\
	[ "$RPM_BUILD_NCPUS" -gt 1 ] && echo "-P $RPM_BUILD_NCPUS")

# Aliases for amd64 builds (better make source links?)
%define target_cpu	%(echo %{_target_cpu} | sed -e "s/amd64/x86_64/")
%define target_arch	%(echo %{_arch} | sed -e "s/amd64/x86_64/" -e 's/arm.*/arm/')

# src.rpm description
Summary: 	The Linux kernel (the core of the Linux operating system)
Name:           %{kname}
Version:        %{kversion}
Release:        %{rpmrel}
License: 	GPLv2
Group: 		System/Kernel and hardware
ExclusiveArch: 	%{ix86} x86_64 %{arm}
ExclusiveOS: 	Linux
URL: 		https://rt.wiki.kernel.org/

####################################################################
#
# Sources
#
### This is for full SRC RPM
Source0:        ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/linux-%{tar_ver}.tar.xz
Source1:        ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/linux-%{tar_ver}.tar.sign

# This is for disabling mrproper and other targets on -devel rpms
Source2:	disable-mrproper-in-devel-rpms.patch

Source4:  	README.kernel-sources

# Kernel defconfigs
Source20: 	i386_defconfig
Source21: 	x86_64_defconfig
Source22:	arm_defconfig

####################################################################
#
# Patches

#
# Patch0 to Patch100 are for core kernel upgrades.
#

# Pre linus patch: ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/testing

%if %kpatch
Patch1:         ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/testing/patch-%{kernelversion}.%{patchlevel}-%{kpatch}.xz
Source10:       ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/testing/patch-%{kernelversion}.%{patchlevel}-%{kpatch}.sign
%endif
%if %sublevel
Patch1:         ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/patch-%{kversion}.xz
Source10:       ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/patch-%{kversion}.sign
%endif
# kernel.org -git
%if %kgit
Patch2:         ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/snapshots/patch-%{kernelversion}.%{patchlevel}-%{kpatch}-git%{kgit}.xz
Source11:       ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/snapshots/patch-%{kernelversion}.%{patchlevel}-%{kpatch}-git%{kgit}.sign
%endif

# -rt patches
Patch101:	ftp://ftp.kernel.org/pub/linux/kernel/projects/rt/patch-%{rt_ver}-%{rt_rel}.patch.xz
Source101:	ftp://ftp.kernel.org/pub/linux/kernel/projects/rt/patch-%{rt_ver}-%{rt_rel}.patch.sign

### other fixes
# alx driver
Patch250:	net-ethernet-atheros-alx.patch
Patch251:	net-ethernet-atheros-alx-Kconfig.patch
Patch252:	net-ethernet-atheros-alx-BigFoot-e2200.patch

# input updates (synced from core kernel)
# Cypress ps2 (TTL: 3.9)
Patch300:	input-increase-struct-ps2dev-cmdbuf-to-8-bytes.patch
Patch301:	input-add-support-for-Cypress-PS2-Trackpads.patch
Patch302:	input-cypress_ps2-fix-trackpad-found-in-Dell-XPS12.patch
# Cypress APA (TTL: 3.9)
Patch310:	input-add-driver-for-Cypress-APA-I2C-Trackpad.patch
Patch311:	input-cyapa-add-support-for-smbus-protocol.patch
# Synaptics (TTL: 3.9)
Patch320:	input-synaptics-fix-1-3-contact-transition-reporting.patch
Patch321:	input-synaptics-initialize-pointer-emulation-usage.patch
# ALPS code rework (needed for new hw support) (TTL: 3.9)
Patch330:	input-ALPS-document-the-alps.h-data-structures.patch
Patch331:	input-ALPS-copy-model-info-into-alps_data-struct.patch
Patch332:	input-ALPS-move-alps_get_model-down-below-hw_init-co.patch
Patch333:	input-ALPS-introduce-helper-function-for-repeated-co.patch
Patch334:	input-ALPS-rework-detection-sequence.patch
Patch335:	input-ALPS-use-function-pointers-for-different-proto.patch
Patch336:	input-ALPS-move-addr-nibble-_command-settings-into-a.patch
Patch337:	input-ALPS-rework-detection-of-Pinnacle-AGx-touchpad.patch
Patch338:	input-ALPS-fix-command-mode-check.patch
Patch339:	input-ALPS-move-pixel-and-bitmap-info-into-alps_data.patch
Patch340:	input-ALPS-make-the-V3-packet-field-decoder-pluggabl.patch
# ALPS new hw (TTL: 3.9)
Patch341:	input-ALPS-add-support-for-Rushmore-touchpads.patch
Patch342:	input-ALPS-enable-trackstick-on-Rushmore-touchpads.patch
Patch343:	input-ALPS-remove-unused-argument-to-alps_enter_comm.patch
Patch344:	input-ALPS-add-Dolphin-V1-touchpad-support.patch
# Wacom
Patch350:	input-wacom-correct-reported-resolution-for-Intuos4-.patch
Patch351:	input-wacom-add-support-for-0x10d.patch
Patch352:	input-wacom-add-support-for-DTH-2242.patch
Patch353:	input-wacom-DTH2242-Grip-Pen-id-was-off-by-one-bit.patch
Patch354:	input-wacom-fix-can-not-retrieve-extra-class-desc-DTH2242.patch
Patch355:	input-wacom-fix-can-not-retrieve-extra-class-desc-24HDT.patch

#END
####################################################################

# Defines for the things that are needed for all the kernels
%define requires1 kmod >= 7-6
%define requires2 dracut >= 017-9
%define requires3 bootloader-utils >= 1.9
%define requires4 sysfsutils
%define requires5 kernel-firmware >= 20101024

%define kprovides kernel = %{tar_ver}, alsa

Autoreqprov: 	no
BuildRequires: 	gcc kmod >= 7-6
%ifarch %{arm}
BuildRequires:  uboot-mkimage
%endif

%description
Source package to build the Linux kernel.


#
# kernel: Symmetric MultiProcessing kernel
#
%if %build_kernel
%package -n %{kname}-%{buildrel}
Version:	%{fakever}
Release:	%{fakerel}
%ifarch %{ix86}
Summary:	Linux realtime kernel for desktop use with i686 & 4GB RAM
%else
%ifarch %{arm}
		Linux realtime kernel for Arm machines based on Kirkwood
%else
Summary:	Linux realtime kernel for desktop use with %{_arch}
%endif
%endif
Group:		System/Kernel and hardware
Provides:	%kprovides
Provides:	should-restart = system
Requires:	%requires1
Requires:	%requires2
Requires:	%requires3
Requires:	%requires4
Requires: 	%requires5

%ifarch %{ix86}
Conflicts:	arch(x86_64)
%endif

%description -n %{kname}-%{buildrel}
%ifarch %{ix86}
This kernel is compiled for desktop use, single or multiple i686
processor(s)/core(s) and less than 4GB RAM, using HZ_1000, realtime
preempt, CFS cpu scheduler and cfq i/o scheduler.
This kernel relies on in-kernel smp alternatives to switch between
up & smp mode depending on detected hardware. To force the kernel
to boot in single processor mode, use the "nosmp" boot parameter.
%else
%ifarch %{arm}
This kernel is compiled for Arm Kirkwood boxes. It will run on openrd
boards. It's configured using HZ_100, realtime preempt, CFS cpu scheduler
and cfq i/o scheduler.
This kernel relies on in-kernel smp alternatives to switch between
up & smp mode depending on detected hardware. To force the kernel
to boot in single processor mode, use the "nosmp" boot parameter.
%else
This kernel is compiled for desktop use, single or multiple %{_arch}
processor(s)/core(s), using HZ_1000, realtime preempt, CFS cpu
scheduler and cfq i/o scheduler.
This kernel relies on in-kernel smp alternatives to switch between
up & smp mode depending on detected hardware. To force the kernel
to boot in single processor mode, use the "nosmp" boot parameter.
%endif
%endif

%endif # build_kernel


#
# kernel-source: kernel sources
#
%if %build_source
%package -n %{kname}-source-%{buildrel}
Version:	%{fakever}
Release:	%{fakerel}
Provides:	%{kname}-source, kernel-source = %{kverrel}
Provides:	%{kname}-source-%{kernelversion}.%{patchlevel}
Requires:	glibc-devel, ncurses-devel, make, gcc, perl, diffutils
Summary:	The source code for the Linux kernel
Group:		Development/Kernel
Autoreqprov: 	no
Buildarch:	noarch

%description -n %{kname}-source-%{buildrel}
The %{kname}-source package contains the source code files for the
Linux kernel. Theese source files are only needed if you want to build
your own custom kernel that is better tuned to your particular hardware.

If you only want the files needed to build 3rdparty (nVidia, Ati, dkms-*,...)
drivers against, install the *-devel-* rpm that is matching your kernel.

%endif #build_source


#
# kernel-devel: stripped kernel sources
#
%if %build_devel
%package -n %{kname}-devel-%{buildrel}
Version:	%{fakever}
Release:	%{fakerel}
Provides:	kernel-devel = %{kverrel}
Summary:	The %{kname} devel files for 3rdparty modules build
Group:		Development/Kernel
Autoreqprov:	no
Requires:	glibc-devel, ncurses-devel, make, gcc, perl
%ifarch %{ix86}
Conflicts:	arch(x86_64)
%endif

%description -n %{kname}-devel-%{buildrel}
This package contains the kernel-devel files that should be enough to build
3rdparty drivers against for use with the %{kname}-%{buildrel}.

If you want to build your own kernel, you need to install the full
%{kname}-source-%{buildrel} rpm.

%endif #build_devel


#
# kernel-doc: documentation for the Linux kernel
#
%if %build_doc
%package -n %{kname}-doc
Version:        %{kversion}
Release:        %{rpmrel}
Summary:	Various documentation bits found in the kernel source
Group:		Documentation
Buildarch:	noarch

%description -n %{kname}-doc
This package contains documentation files form the kernel source. Various
bits of information about the Linux kernel and the device drivers shipped
with it are documented in these files. You also might want install this
package if you need a reference to the options that can be passed to Linux
kernel modules at load time.

%endif #build_doc


#
# kernel-latest: virtual rpm
#
%if %build_kernel
%package -n %{kname}-latest
Version:        %{kversion}
Release:        %{rpmrel}
Summary: 	Virtual rpm for latest %{kname}
Group: 	  	System/Kernel and hardware
Requires: 	%{kname}-%{buildrel}
%ifarch %{ix86}
Conflicts:	arch(x86_64)
%endif

%description -n %{kname}-latest
This package is a virtual rpm that aims to make sure you always have the
latest %{kname} installed...

%endif #build_kernel


#
# kernel-source-latest: virtual rpm
#
%if %build_source
%package -n %{kname}-source-latest
Version:        %{kversion}
Release:        %{rpmrel}
Summary: 	Virtual rpm for latest %{kname}-source
Group: 	  	System/Kernel and hardware
Requires: 	%{kname}-source-%{buildrel}
Buildarch:	noarch

%description -n %{kname}-source-latest
This package is a virtual rpm that aims to make sure you always have the
latest %{kname}-source installed...

%endif #build_source


#
# kernel-devel-latest: virtual rpm
#
%if %build_devel
%package -n %{kname}-devel-latest
Version:        %{kversion}
Release:        %{rpmrel}
Summary: 	Virtual rpm for latest %{kname}-devel
Group: 	  	System/Kernel and hardware
Requires: 	%{kname}-devel-%{buildrel}
%ifarch %{ix86}
Conflicts:	arch(x86_64)
%endif

%description -n %{kname}-devel-latest
This package is a virtual rpm that aims to make sure you always have the
latest %{kname}-devel installed...

%endif #build_devel


#
# End packages - here begins build stage
#
%prep
%setup -q -n %top_dir_name -c

pushd %src_dir
%if %kpatch
%patch1 -p1
%endif
%if %sublevel
%patch1 -p1
%endif
%if %kgit
%patch2 -p1
%endif

# rt patches
%patch101 -p1

### other fixes
# alx driver
%patch250 -p1
%patch251 -p1
%patch252 -p1

# input updates (synced from core kernel)
# Cypress ps2 (TTL: 3.9)
%patch300 -p1
%patch301 -p1
%patch302 -p1
# Cypress APA (TTL: 3.9)
%patch310 -p1
%patch311 -p1
# Synaptics (TTL: 3.9)
%patch320 -p1
%patch321 -p1
# ALPS code rework (needed for new hw support) (TTL: 3.9)
%patch330 -p1
%patch331 -p1
%patch332 -p1
%patch333 -p1
%patch334 -p1
%patch335 -p1
%patch336 -p1
%patch337 -p1
%patch338 -p1
%patch339 -p1
%patch340 -p1
# ALPS new hw (TTL: 3.9)
%patch341 -p1
%patch342 -p1
%patch343 -p1
%patch344 -p1
# Wacom
%patch350 -p1
%patch351 -p1
%patch352 -p1
%patch353 -p1
%patch354 -p1
%patch355 -p1

popd

# PATCH END


#
# Setup Begin
#


# Install defconfigs...
install %{SOURCE20} %{build_dir}/linux-%{tar_ver}/arch/x86/configs/
install %{SOURCE21} %{build_dir}/linux-%{tar_ver}/arch/x86/configs/
install %{SOURCE22} %{build_dir}/linux-%{tar_ver}/arch/arm/configs/

# make sure the kernel has the sublevel we know it has...
LC_ALL=C perl -p -i -e "s/^SUBLEVEL.*/SUBLEVEL = %{sublevel}/" linux-%{tar_ver}/Makefile

# drop localversion before build or it will mess up uname -r (we have it in kernel name/version)
rm -f %{build_dir}/linux-%{tar_ver}/localversion-rt

%build
# Common target directories
%define _bootdir /boot
%define _modulesdir /lib/modules
%define _kerneldir /usr/src/%{kname}-%{buildrel}
%define _develdir /usr/src/%{kname}-devel-%{buildrel}


# Directories definition needed for building
%define temp_root %{build_dir}/temp-root
%define temp_boot %{temp_root}%{_bootdir}
%define temp_modules %{temp_root}%{_modulesdir}
%define temp_source %{temp_root}%{_kerneldir}
%define temp_devel %{temp_root}%{_develdir}


# Create a simulacro of buildroot
rm -rf %{temp_root}
install -d %{temp_root}


# make sure we are in the directory
cd %{src_dir}

# make sure EXTRAVERSION says what we want it to say
LC_ALL=C perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{buildrpmrel}/" Makefile

# Prepare the kernel
%smake -s mrproper
%ifarch %{ix86} x86_64 %{arm}
	cp arch/x86/configs/%{target_arch}_defconfig .config
%else
	cp arch/%{target_arch}/defconfig .config
%endif
%smake oldconfig

# Build the kernel
%kmake -s all
%ifarch %{arm}
	%kmake uImage
%endif
# Install kernel
install -d %{temp_boot}
install -m 644 System.map %{temp_boot}/System.map-%{buildrel}
install -m 644 .config %{temp_boot}/config-%{buildrel}
%ifarch %{arm}
	cp -f arch/%{target_arch}/boot/uImage %{temp_boot}/uImage-$KernelVer
%else
	cp -f arch/%{target_arch}/boot/bzImage %{temp_boot}/vmlinuz-%{buildrel}
%endif

# Install modules
install -d %{temp_modules}/%{buildrel}
%smake INSTALL_MOD_PATH=%{temp_root} KERNELRELEASE=%{buildrel} modules_install

# remove /lib/firmware, we use a separate kernel-firmware
rm -rf %{temp_root}/lib/firmware

# Save devel tree
%if %build_devel
mkdir -p %{temp_devel}
for i in $(find . -name 'Makefile*'); do cp -R --parents $i %{temp_devel};done
for i in $(find . -name 'Kconfig*' -o -name 'Kbuild*' -o -name config.mk); do cp -R --parents $i %{temp_devel};done
cp -fR include %{temp_devel}
cp -fR scripts %{temp_devel}
cp -fR tools/include %{temp_devel}/tools/
%ifarch %{arm}
	cp -fR arch/%{target_arch}/tools $TempDevelRoot/arch/%{target_arch}/
%endif
%ifarch %{ix86} x86_64
	cp -fR arch/x86/kernel/asm-offsets.{c,s} %{temp_devel}/arch/x86/kernel/
	cp -fR arch/x86/kernel/asm-offsets_{32,64}.c %{temp_devel}/arch/x86/kernel/
	cp -fR arch/x86/syscalls/syscall* %{temp_devel}/arch/x86/syscalls/
	cp -fR arch/x86/include %{temp_devel}/arch/x86/
	cp -fR arch/x86/tools/relocs.c %{temp_devel}/arch/x86/tools/
%else
	cp -fR arch/%{target_arch}/kernel/asm-offsets.{c,s} %{temp_devel}/arch/%{target_arch}/kernel/
	for f in $(find arch/%{target_arch} -name include); do cp -fR --parents $f $TempDevelRoot; done
%endif

# Needed for generation of kernel/bounds.s
cp -fR kernel/bounds.c %{temp_devel}/kernel/

# Needed for lguest
cp -fR drivers/lguest/lg.h %{temp_devel}/drivers/lguest/

cp -fR .config Module.symvers %{temp_devel}

# Needed for truecrypt build (Danny)
cp -fR drivers/md/dm.h %{temp_devel}/drivers/md/

# Needed for external dvb tree (#41418)
cp -fR drivers/media/dvb-core/*.h %{temp_devel}/drivers/media/dvb-core/
cp -fR drivers/media/dvb-frontends/lgdt330x.h %{temp_devel}/drivers/media/dvb-frontends/

# add acpica header files, needed for fglrx build
cp -fR drivers/acpi/acpica/*.h %{temp_devel}/drivers/acpi/acpica/

# Check and clean the -devel tree
pushd %{temp_devel} >/dev/null
    %smake -s prepare scripts clean
    rm -f .config.old
popd >/dev/null

# Disable mrproper and other targets
patch -p1 -d %{temp_devel} -i %{SOURCE2}

# Fix permissions
chmod -R a+rX %{temp_devel}
%endif # build_devel

#make sure we are in the directory
cd %src_dir

# kernel-source is shipped as an unprepared tree
%smake -s mrproper


###
### Install
###
%install
install -m 644 %{SOURCE4}  .

cd %src_dir
# Directories definition needed for installing
%define target_source %{buildroot}/%{_kerneldir}
%define target_boot %{buildroot}%{_bootdir}
%define target_modules %{buildroot}%{_modulesdir}
%define target_devel %{buildroot}%{_develdir}

# We want to be able to test several times the install part
rm -rf %{buildroot}
cp -a %{temp_root} %{buildroot}

# Create directories infastructure
%if %build_source
install -d %{target_source}

tar cf - . | tar xf - -C %{target_source}
chmod -R a+rX %{target_source}

# we remove all the source files that we don't ship

# first architecture files
for i in alpha avr32 blackfin c6x cris frv hexagon h8300 ia64 m32r mips \
	 microblaze m68k m68knommu mn10300 openrisc parisc powerpc ppc \
	 s390 score sh sh64 sparc tile unicore32 v850 xtensa; do
	rm -rf %{target_source}/arch/$i

%if %build_devel
	rm -rf %{target_devel}/arch/$i
%endif
done

# remove arch files based on target arch in -devel rpms
%if %build_devel
%ifnarch %{ix86} x86_64
	rm -rf %{target_devel}/arch/x86
%endif
%ifnarch %{arm}
	rm -rf %{target_devel}/arch/arm
	rm -rf %{target_devel}/arch/arm64
%endif
%endif


# other misc files
rm -f %{target_source}/{.config.old,.config.cmd,.tmp_gas_check,.mailmap,.missing-syscalls.d,arch/.gitignore}
rm -rf %{target_source}/.tmp_depmod/

#endif %build_source
%endif


# compressing modules
find %{target_modules} -name "*.ko" | %kxargs xz -6e


# We used to have a copy of PrepareKernel here
# Now, we make sure that the thing in the linux dir is what we want it to be

for i in %{target_modules}/*; do
  rm -f $i/build $i/source
done


# sniff, if we compressed all the modules, we change the stamp :(
# we really need the depmod -ae here
pushd %{target_modules}
for i in *; do
	/sbin/depmod -ae -b %{buildroot} -F %{target_boot}/System.map-$i $i
	echo $?
done

for i in *; do
	pushd $i
	echo "Creating module.description for $i"
	modules=`find . -name "*.ko.[g,x]z"`
	echo $modules | %kxargs /sbin/modinfo \
	| perl -lne 'print "$name\t$1" if $name && /^description:\s*(.*)/; $name = $1 if m!^filename:\s*(.*)\.k?o!; $name =~ s!.*/!!' > modules.description
	popd
done
popd


###
### Clean
###

%clean
rm -rf %{buildroot}
# We don't want to remove this, the whole reason of its existence is to be
# able to do several rpm --short-circuit -bi for testing install 
# phase without repeating compilation phase
#rm -rf %{temp_root}


###
### Scripts
###

### kernel
%if %build_kernel
%preun -n %{kname}-%{buildrel}
/sbin/installkernel -R %{buildrel}
if [ -L /lib/modules/%{buildrel}/build ]; then
    rm -f /lib/modules/%{buildrel}/build
fi
if [ -L /lib/modules/%{buildrel}/source ]; then
    rm -f /lib/modules/%{buildrel}/source
fi
pushd /boot > /dev/null
if [ -L vmlinuz-linus ]; then
    if [ "$(readlink vmlinuz-linus)" = "vmlinuz-%{buildrel}" ]; then
	rm -f vmlinuz-linus
    fi
fi
if [ -L initrd-linus.img ]; then
    if [ "$(readlink initrd-linus.img)" = "initrd-%{buildrel}.img" ]; then
	rm -f initrd-linus.img
    fi
fi
popd > /dev/null
exit 0

%post -n %{kname}-%{buildrel}
/sbin/installkernel -L %{buildrel}
if [ -d /usr/src/%{kname}-devel-%{buildrel} ]; then
    ln -sf /usr/src/%{kname}-devel-%{buildrel} /lib/modules/%{buildrel}/build
    ln -sf /usr/src/%{kname}-devel-%{buildrel} /lib/modules/%{buildrel}/source
fi
pushd /boot > /dev/null
if [ -L vmlinuz-linus ]; then
    rm -f vmlinuz-linus
fi
ln -sf vmlinuz-%{buildrel} vmlinuz-linus
if [ -L initrd-linus.img ]; then
    rm -f initrd-linus.img
fi
ln -sf initrd-%{buildrel}.img initrd-linus.img
popd > /dev/null

%posttrans -n %{kname}-%{buildrel}
if [ -x /usr/sbin/dkms_autoinstaller -a -d /usr/src/%{kname}-devel-%{buildrel} ]; then
    /usr/sbin/dkms_autoinstaller start %{buildrel}
fi

%postun -n %{kname}-%{buildrel}
/sbin/kernel_remove_initrd %{buildrel}
rm -rf /lib/modules/%{buildrel} > /dev/null
%endif # build_kernel


### kernel-devel
%if %build_devel
%post -n %{kname}-devel-%{buildrel}
# place /build and /source symlinks in place.
if [ -d /lib/modules/%{buildrel} ]; then
    ln -sf /usr/src/%{kname}-devel-%{buildrel} /lib/modules/%{buildrel}/build
    ln -sf /usr/src/%{kname}-devel-%{buildrel} /lib/modules/%{buildrel}/source
fi

%preun -n %{kname}-devel-%{buildrel}
# we need to delete <modules>/{build,source} at uninstall
if [ -L /lib/modules/%{buildrel}/build ]; then
    rm -f /lib/modules/%{buildrel}/build
fi
if [ -L /lib/modules/%{buildrel}/source ]; then
    rm -f /lib/modules/%{buildrel}/source
fi
exit 0
%endif #build_devel


### kernel-source
%if %build_source
%post -n %{kname}-source-%{buildrel}
for i in /lib/modules/%{buildrel}*; do
	if [ -d $i ]; then
		if [ ! -L $i/build -a ! -L $i/source ]; then
			rm -f $i/{build,source}
		        ln -sf /usr/src/%{kname}-%{buildrel} $i/build
		        ln -sf /usr/src/%{kname}-%{buildrel} $i/source
		fi
	fi
done

%preun -n %{kname}-source-%{buildrel}
for i in /lib/modules/%{buildrel}/{build,source}; do
	if [ -L $i ]; then
		if [ "$(readlink $i)" = "/usr/src/%{kname}-%{buildrel}" ]; then
			rm -f $i
		fi
	fi
done
exit 0
%endif # build_source


###
### file lists
###

# kernel
%if %build_kernel
%files -n %{kname}-%{buildrel}
%{_bootdir}/config-%{buildrel}
%ifarch %{arm}
%{_bootdir}/uImage-%{buildrel}
%else
%{_bootdir}/vmlinuz-%{buildrel}
%endif
%{_bootdir}/System.map-%{buildrel}
%dir %{_modulesdir}/%{buildrel}/
%{_modulesdir}/%{buildrel}/kernel
%{_modulesdir}/%{buildrel}/modules.*
%doc README.kernel-sources
%endif # build_kernel

# kernel-source
%if %build_source
%files -n %{kname}-source-%{buildrel}
%dir %{_kerneldir}
%dir %{_kerneldir}/arch
%dir %{_kerneldir}/include
%{_kerneldir}/.gitignore
%{_kerneldir}/COPYING
%{_kerneldir}/CREDITS
%{_kerneldir}/Documentation
%{_kerneldir}/Kbuild
%{_kerneldir}/Kconfig
%{_kerneldir}/MAINTAINERS
%{_kerneldir}/Makefile
%{_kerneldir}/README
%{_kerneldir}/REPORTING-BUGS
%{_kerneldir}/arch/Kconfig
%{_kerneldir}/arch/arm
%{_kerneldir}/arch/arm64
%{_kerneldir}/arch/x86
%{_kerneldir}/arch/um
%{_kerneldir}/block
%{_kerneldir}/crypto
%{_kerneldir}/drivers
%{_kerneldir}/firmware
%{_kerneldir}/fs
%{_kerneldir}/include/Kbuild
%{_kerneldir}/include/acpi
%{_kerneldir}/include/asm-generic
%{_kerneldir}/include/clocksource
%{_kerneldir}/include/crypto
%{_kerneldir}/include/drm
%{_kerneldir}/include/linux
%{_kerneldir}/include/math-emu
%{_kerneldir}/include/memory
%{_kerneldir}/include/net
%{_kerneldir}/include/pcmcia
%{_kerneldir}/include/ras
%{_kerneldir}/include/scsi
%{_kerneldir}/include/sound
%{_kerneldir}/include/target
%{_kerneldir}/include/trace
%{_kerneldir}/include/uapi
%{_kerneldir}/include/video
%{_kerneldir}/include/media
%{_kerneldir}/include/misc
%{_kerneldir}/include/rxrpc
%{_kerneldir}/include/keys
%{_kerneldir}/include/rdma
%{_kerneldir}/include/xen
%{_kerneldir}/init
%{_kerneldir}/ipc
%{_kerneldir}/kernel
%{_kerneldir}/lib
%{_kerneldir}/mm
%{_kerneldir}/net
%{_kerneldir}/samples
%{_kerneldir}/scripts
%{_kerneldir}/security
%{_kerneldir}/sound
%{_kerneldir}/tools
%{_kerneldir}/usr
%{_kerneldir}/virt
%doc README.kernel-sources
%endif # build_source

# kernel-devel
%if %build_devel
%files -n %{kname}-devel-%{buildrel}
%dir %{_develdir}
%dir %{_develdir}/arch
%dir %{_develdir}/include
%{_develdir}/.config
%{_develdir}/Documentation
%{_develdir}/Kbuild
%{_develdir}/Kconfig
%{_develdir}/Makefile
%{_develdir}/Module.symvers
%{_develdir}/arch/Kconfig
%ifarch %{arm}
%{_develdir}/arch/arm
%{_develdir}/arch/arm64
%endif
%ifarch %{ix86} x86_64
%{_develdir}/arch/x86
%endif
%{_develdir}/arch/um
%{_develdir}/block
%{_develdir}/crypto
%{_develdir}/drivers
%{_develdir}/firmware
%{_develdir}/fs
%{_develdir}/include/Kbuild
%{_develdir}/include/acpi
%{_develdir}/include/asm-generic
%{_develdir}/include/clocksource
%{_develdir}/include/config
%{_develdir}/include/crypto
%{_develdir}/include/drm
%{_develdir}/include/generated
%{_develdir}/include/keys
%{_develdir}/include/linux
%{_develdir}/include/math-emu
%{_develdir}/include/memory
%{_develdir}/include/misc
%{_develdir}/include/net
%{_develdir}/include/pcmcia
%{_develdir}/include/ras
%{_develdir}/include/rdma
%{_develdir}/include/scsi
%{_develdir}/include/sound
%{_develdir}/include/target
%{_develdir}/include/trace
%{_develdir}/include/uapi
%{_develdir}/include/video
%{_develdir}/include/media
%{_develdir}/include/rxrpc
%{_develdir}/include/xen
%{_develdir}/init
%{_develdir}/ipc
%{_develdir}/kernel
%{_develdir}/lib
%{_develdir}/mm
%{_develdir}/net
%{_develdir}/samples
%{_develdir}/scripts
%{_develdir}/security
%{_develdir}/sound
%{_develdir}/tools
%{_develdir}/usr
%{_develdir}/virt
%doc README.kernel-sources
%endif # build_devel


%if %build_doc
%files -n %{kname}-doc
%doc linux-%{tar_ver}/Documentation/*
%endif # build_doc

%if %build_kernel
%files -n %{kname}-latest
%endif # build_kernel

%if %build_source
%files -n %{kname}-source-latest
%endif # build_source

%if %build_devel
%files -n %{kname}-devel-latest
%endif # build_devel


%changelog

* Sun May 12 2013 tmb <tmb> 3.8.13-0.rt8.1.mga3
+ Revision: 413038
- Input: add support for Cypress PS2 Trackpads
- Input: Cypress/ps2 - fix trackpad found in Dell XPS12
- Input: add Cypress APA I2C Trackpad support
- Input: Cypress APA - add support for smbus protocol
- Input: synaptics - fix 1->3 contact transition reporting
- Input: synaptics - initialize pointer emulation usage
- Input: ALPS: add Rushmore and Dolphin V1 support (mga #8033)
- Input: Wacom: add support for DTH-2242 and 0x10d
- drop note about using -rt patch only, as we also add new hw support
- update to 3.8.13

* Wed May 08 2013 tmb <tmb> 3.8.12-0.rt8.1.mga3
+ Revision: 412662
- update alx ethernet to latest upstream, and add BigFoot e2200 support
- update to 3.8.12-rt8

* Wed May 01 2013 tmb <tmb> 3.8.11-0.rt6.1.mga3
+ Revision: 411813
- tty: fix up atime/mtime mess, take three (Linus, upstream)
- update to 3.8.11-rt6

* Sat Apr 27 2013 tmb <tmb> 3.8.10-0.rt4.1.mga3
+ Revision: 411410
- revert: drm/i915: move i915_trace_irq_get() out of the tracing macro
- make EFI_VARS builtin on x86_64
- set NLS_DEFAULT to utf8
- update to 3.8.10-rt4

* Sun Apr 07 2013 tmb <tmb> 3.8.6-0.rt2.1.mga3
+ Revision: 408970
- update filelists
- update defconfigs
- add -rt2 patchset
- add alx buildfixes (P252, P253)
- update to 3.8.6

* Fri Nov 02 2012 tmb <tmb> 3.6.5-0.rt14.1.mga3
+ Revision: 312350
- update to -rt14
- drop P110 (merged)

* Thu Nov 01 2012 tmb <tmb> 3.6.5-0.rt11.1.mga3
+ Revision: 312124
- use correct defconfigs
- update filelists
- x86_32: preempt-lazy: fix invalid compare for bit 9 in cl (P110)
- update defconfigs
- ext4: fix unjournaled inode bitmap modification
  (P200, fixes possible data corruption bug)
- md/raid1: Fix assembling of arrays containing Replacements
  (P201, fixes reduced data safety)
- net: add new QCA alx ethernet driver (P250, P251)
- revert cpufreq/powenow-k8 fix that is also in -rt patch
- drop P200-P204: Intuos5 support (merged)
- update to 3.6.5-rt11
- move -doc to Documentation group

* Mon Oct 08 2012 tmb <tmb> 3.4.13-0.rt20.1.mga3
+ Revision: 303646
- update to 3.4.13-rt20

* Mon Oct 08 2012 tmb <tmb> 3.4.11-0.rt18.2.mga3
+ Revision: 303605
- add Wacom Intuos 5 support (P200-P204, mga #7659)

* Sat Sep 15 2012 tmb <tmb> 3.4.11-0.rt18.1.mga3
+ Revision: 294094
- update to 3.4.11-rt18

* Fri Aug 17 2012 tmb <tmb> 3.4.9-0.rt17.1.mga3
+ Revision: 281765
- update to 3.4.9-rt17

* Thu Aug 16 2012 tmb <tmb> 3.4.8-0.rt16.1.mga3
+ Revision: 281678
- update to 3.4.8-rt16
- enable EFI_STUB support (#6598)

* Wed Jun 27 2012 tmb <tmb> 3.4.4-0.rt13.1.mga3
+ Revision: 264357
- update to 3.4.4-rt13

* Wed Jun 20 2012 tmb <tmb> 3.4.3-0.rt11.1.mga3
+ Revision: 262374
- update to 3.4.3-rt11

* Sat Jun 09 2012 tmb <tmb> 3.4.2-0.rt9.1.mga3
+ Revision: 259009
- update to 3.4.2

* Sat Jun 09 2012 tmb <tmb> 3.4.1-0.rt9.1.mga3
+ Revision: 258776
- more filelist updates
- BR kmod instead of module-init-tools
- update filelists
- update defconfigs
- update to 3.4.1-rt9
- require kmod instead of module-init-tools

* Sat Apr 28 2012 tmb <tmb> 3.2.16-0.rt27.1.mga2
+ Revision: 234039
- update to 3.2.16-rt27
- require dracut >= 017-9

* Sun Apr 22 2012 tmb <tmb> 3.2.15-0.rt26.1.mga2
+ Revision: 232561
- update to 3.2.15-rt26

* Tue Apr 03 2012 tmb <tmb> 3.2.14-0.rt23.1.mga2
+ Revision: 228111
- update to 3.2.14 and -rt23

* Tue Mar 06 2012 tmb <tmb> 3.2.9-0.rt16.1.mga2
+ Revision: 220247
- update to -rt16

* Mon Mar 05 2012 tmb <tmb> 3.2.9-0.rt15.1.mga2
+ Revision: 219292
- update to 3.2.9-rt15

* Fri Feb 17 2012 tmb <tmb> 3.2.6-0.rt13.1.mga2
+ Revision: 210002
- require dracut >= 016-1 for xz compressed modules support and other fixes
- compress modules with xz
- update to 3.2.6-rt13

* Thu Jan 26 2012 tmb <tmb> 3.2.2-0.rt10.1.mga2
+ Revision: 201865
- correct requires: module-init-tools >= 3.16-14 for xz support
- update defconfigs
- update filelists
- drop buildroot and defattr
- require module-init-tools >= 3.6-14 for xz support
- require dracut instead of mkinitrd
- update to 3.2.2-rt10

* Sat Dec 24 2011 tmb <tmb> 3.0.14-0.rt31.1.mga2
+ Revision: 187276
- update to 3.0.14-rt31
- trigger dkms build in posttrans so modules get built at kernel install
  instead of at boot (speeds up boot time with new kernel)

* Thu Dec 08 2011 tmb <tmb> 3.0.12-0.rt30.1.mga2
+ Revision: 178946
- update to rt30

* Tue Nov 29 2011 tmb <tmb> 3.0.12-0.rt27.1.mga2
+ Revision: 174085
- update to 3.0.12
  * reverts usb patch that broke isochronous devices
    (i.e. webcam, audio, or other streaming devices)

* Sun Nov 27 2011 tmb <tmb> 3.0.11-0.rt27.1.mga2
+ Revision: 173093
- update to 3.0.11-rt27

* Sun Nov 13 2011 tmb <tmb> 3.0.9-0.rt25.1.mga2
+ Revision: 167076
- update to 3.0.9-rt25

* Thu Nov 10 2011 tmb <tmb> 3.0.8-0.rt23.1.mga2
+ Revision: 166265
- update to -rt23

* Tue Oct 25 2011 tmb <tmb> 3.0.8-0.rt20.1.mga2
+ Revision: 158007
- update to 3.0.8
- rediff -rt patch
- drop P200 (merged)

* Wed Oct 19 2011 tmb <tmb> 3.0.7-0.rt20.1.mga2
+ Revision: 156592
- update to 3.0.7-rt20
- re-enable usblp as it is needed by both usb-pp adapters and some printers (mga #2240, #2264)
  (cups is patched to work with both usblp and libusb)

* Fri Oct 07 2011 tmb <tmb> 3.0.6-0.rt17.1.mga2
+ Revision: 152858
- update to rt17

* Wed Oct 05 2011 tmb <tmb> 3.0.6-0.rt16.1.mga2
+ Revision: 151884
- fix boot hang on uvc webcam init (mga #2425)
- update to 3.0.6-rt16

* Thu Sep 15 2011 tmb <tmb> 3.0.4-0.rt14.1.mga2
+ Revision: 144094
- update to 3.0.4-rt14

* Tue Aug 30 2011 tmb <tmb> 3.0.4-0.rt11.1.mga2
+ Revision: 136518
- update to 3.0.4
- rediff rt11 patch
- update to 3.0.3
- rediff rt11 patch
- update to 3.0.1-rt11
- update to 3.0.1-rt10
- update to 3.0.1-rt8
- rediff -rt7 patch for 3.0.1
- update to 3.0.1 final
- build with -s(ilent) so only warnings and errors gets logged
- disable all CGROUPS support, besides basic support needed for systemd
  (it slows down / bloats the kernel, especially unwanted on -rt)
- re-enable HIGHMEM4G support on i586
- update to 3.0-rt7
- fix 'uname -r' to match install paths (mga #2362)
- update to 3.0-rt6
- update to 3.0-rt5
- update rt patch to 3.0-rt3
- update url, summary and description to match realtime kernel
- imported package kernel-rt