Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-updates-src > by-pkgid > 0b9227b6fd3f198024fdef65bd4afb45 > files > 3

kernel-2.6.38.8-6.mga1.src.rpm

# -*- Mode: rpm-spec -*-
#
# This Specfile is based on kernel-tmb spec done by
# Thomas Backlund <tmb@mandriva.org>
# 
# The mkflavour() macroization done by Anssi Hannula <anssi@mandriva.org>
#
# Mageia kernels use kernel.org versioning
#
%define kernelversion	2
%define patchlevel	6
%define sublevel	38

# Package release
%define mgarel		6

# kernel Makefile extraversion is substituted by 
# kpatch/kgit/kstable wich are either 0 (empty), rc (kpatch), git (kgit) 
# or stable release (kstable)
%define kpatch		0
%define kstable		8
# kernel.org -gitX patch (only the number after "git")
%define kgit		0

# kernel base name (also name of srpm)
%define kname 		kernel

# Patch tarball tag
%define ktag		mga

%define rpmtag		%distsuffix
%if %kpatch
%if %kgit
%define rpmrel		%mkrel 0.%{kpatch}.%{kgit}.%{mgarel}%{?uclevel:.%{uclevel}}
%else
%define rpmrel		%mkrel 0.%{kpatch}.%{mgarel}%{?uclevel:.%{uclevel}}
%endif
%else
%define rpmrel		%mkrel %{mgarel}%{?uclevel:.%{uclevel}}
%endif
%define fakerel 	%mkrel 1

# fakerel above and fakever below never change, they are used to fool
# rpm/urpmi/smart
%define fakever		1

# When we are using a pre/rc patch, the tarball is a sublevel -1
%if %kpatch
%if %kstable
%define tar_ver	  	%{kernelversion}.%{patchlevel}.%{sublevel}
%else
%define tar_ver	  	%{kernelversion}.%{patchlevel}.%(expr %{sublevel} - 1)
%endif
%define patch_ver 	%{kversion}-%{kpatch}-%{ktag}%{mgarel}
%else
%define tar_ver   	%{kernelversion}.%{patchlevel}.%{sublevel}
%define patch_ver 	%{kversion}-%{ktag}%{mgarel}
%endif
%if %kstable
%define kversion  	%{kernelversion}.%{patchlevel}.%{sublevel}.%{kstable}
%else
%define kversion  	%{kernelversion}.%{patchlevel}.%{sublevel}
%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}.%{mgarel}%{?uclevel:.%{uclevel}}%{rpmtag}
%else
%define buildrpmrel     0.%{kpatch}.%{mgarel}%{?uclevel:.%{uclevel}}%{rpmtag}
%endif
%else
%define buildrpmrel     %{mgarel}%{?uclevel:.%{uclevel}}%{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_debug 		1

# Build desktop i586 / 4GB
%ifarch %{ix86}
%define build_desktop586	1
%endif

# Build desktop (i686 / 4GB) / x86_64 / sparc64 sets
%define build_desktop		1

# Build netbook (i686 / 4GB) / x86_64
%define build_netbook		1

# Build server (i686 / 64GB)/x86_64 / sparc64 sets
%define build_server		1

# Build xen-pvops (i686 / 64GB)/x86_64
%define build_xen_pvops		1

# ARM builds
%ifarch %{arm}
%define build_desktop          0
%define build_netbook          0
%define build_server           0
%define build_xen_pvops        0
%define build_iop32x           0
%define build_kirkwood         1
%define build_versatile        1
%endif
# End of user definitions

# buildtime flags
%{?_without_desktop586: %global build_desktop586 0}
%{?_without_desktop: %global build_desktop 0}
%{?_without_netbook: %global build_netbook 0}
%{?_without_server: %global build_server 0}
%{?_without_xen_pvops: %global build_xen_pvops 0}
%{?_without_doc: %global build_doc 0}
%{?_without_source: %global build_source 0}
%{?_without_devel: %global build_devel 0}
%{?_without_debug: %global build_debug 0}

%{?_with_desktop586: %global build_desktop586 1}
%{?_with_desktop: %global build_desktop 1}
%{?_with_netbook: %global build_netbook 1}
%{?_with_server: %global build_server 1}
%{?_with_xen_pvops: %global build_xen_pvops 1}
%{?_with_doc: %global build_doc 1}
%{?_with_source: %global build_source 1}
%{?_with_devel: %global build_devel 1}
%{?_with_debug: %global build_debug 1}

# ARM builds
%{?_with_iop32x: %global build_iop32x 1}
%{?_with_kirkwood: %global build_kirkwood 1}
%{?_with_versatile: %global build_versatile 1}
%{?_without_iop32x: %global build_iop32x 0}
%{?_without_kirkwood: %global build_kirkwood 0}
%{?_without_versatile: %global build_versatile 0}

# For the .nosrc.rpm
%define build_nosrc 	0
%{?_with_nosrc: %global build_nosrc 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")

# Sparc arch wants sparc64 kernels
%define target_arch    %(echo %{_arch} | sed -e "s/sparc/sparc64/" -e 's/mips.*/mips/' -e 's/arm.*/arm/')


#
# SRC RPM description
#
Summary: 	Linux kernel built for Mageia
Name:		%{kname}
Version: 	%{kversion}
Release: 	%{rpmrel}
License: 	GPLv2
Group: 	 	System/Kernel and hardware
ExclusiveArch: %{ix86} x86_64 %{arm}
ExclusiveOS: 	Linux
URL:            http://www.kernel.org

####################################################################
#
# Sources
#
### This is for full SRC RPM
Source0: 	ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/linux-%{tar_ver}.tar.bz2
Source1: 	ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/linux-%{tar_ver}.tar.bz2.sign
### This is for stripped SRC RPM
%if %build_nosrc
NoSource: 0
%endif
# This is for disabling *config, mrproper, prepare, scripts on -devel rpms
Source2: 	disable-mrproper-prepare-scripts-configs-in-devel-rpms.patch

Source4: 	README.kernel-sources

Source100: 	linux-%{patch_ver}.tar.xz

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

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

# Pre linus patch: ftp://ftp.kernel.org/pub/linux/kernel/v2.6/testing

%if %kpatch
%if %kstable
Patch2:		ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/stable-review/patch-%{kversion}-%{kpatch}.bz2
Source11:	ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/stable-review/patch-%{kversion}-%{kpatch}.bz2.sign
%else
Patch1:		ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/testing/patch-%{kversion}-%{kpatch}.bz2
Source10: 	ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/testing/patch-%{kversion}-%{kpatch}.bz2.sign
%endif
%endif
%if %kgit
Patch2:		ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/snapshots/patch-%{kernelversion}.%{patchlevel}.%{sublevel}-%{kpatch}-git%{kgit}.bz2
Source11: 	ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/snapshots/patch-%{kernelversion}.%{patchlevel}.%{sublevel}-%{kpatch}-git%{kgit}.bz2.sign
%endif
%if %kstable
%if %kpatch
%define prev_stable %(expr %{kstable} - 1)
%if %prev_stable
Patch1:   	ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/patch-%{kernelversion}.%{patchlevel}.%{sublevel}.%{prev_stable}.bz2
Source10: 	ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/patch-%{kernelversion}.%{patchlevel}.%{sublevel}.%{prev_stable}.bz2.sign
%endif
%else
Patch1:   	ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/patch-%{kversion}.bz2
Source10: 	ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/patch-%{kversion}.bz2.sign
%endif
%endif

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

# Defines for the things that are needed for all the kernels
#
%define common_desc_kernel The kernel package contains the Linux kernel (vmlinuz), the core of your \
Mageia operating system. The kernel handles the basic functions \
of the operating system: memory allocation, process allocation, device \
input and output, etc.

%define common_desc_kernel_smp 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.

### Global Requires/Provides
%define requires1	bootloader-utils >= 1.13-1
%define requires2	mkinitrd >= 4.2.17-31
%define requires3	module-init-tools >= 3.0-7
%define requires4	sysfsutils >= 1.3.0-1
%define requires5	kernel-firmware >= 20101024-2

%define kprovides 	%{kname} = %{kverrel}, kernel = %{tar_ver}, alsa = 1.0.24, drbd-api = 88

%define kconflicts	drakxtools-backend < 10.4.190-2

%define kobsoletes	dkms-iwlwifi < 1.2.26

BuildRoot: 		%{_tmppath}/%{kname}-%{kversion}-%{_arch}-build
Autoreqprov: 		no
BuildRequires: 		gcc module-init-tools
%ifarch %{arm}
BuildRequires:         uboot-mkimage
%endif

%description
%common_desc_kernel
%ifnarch %{arm}
%common_desc_kernel_smp
%endif

# mkflavour() name flavour processor
# name: the flavour name in the package name
# flavour: first parameter of CreateKernel()
%define mkflavour()					\
%package -n %{kname}-%{1}-%{buildrel}			\
Version:	%{fakever}				\
Release:	%{fakerel}				\
Provides:	%kprovides				\
Provides:	%{kname}-%{1}				\
Requires(pre):	%requires1 %requires2 %requires3 %requires4 \
Requires:	%requires5				\
Provides:	should-restart = system			\
Suggests:	crda					\
Obsoletes:	%kobsoletes				\
Conflicts:	%kconflicts				\
%ifarch %{ix86}						\
Conflicts:	arch(x86_64)				\
%endif							\
Summary:	%{expand:%{summary_%(echo %{1} | sed -e "s/-/_/")}} \
Group:		System/Kernel and hardware		\
%description -n %{kname}-%{1}-%{buildrel}		\
%common_desc_kernel %{expand:%{info_%(echo %{1} | sed -e "s/-/_/")}}	\
%ifnarch %{arm}						\
%common_desc_kernel_smp					\
%endif							\
							\
%if %build_devel					\
%package -n	%{kname}-%{1}-devel-%{buildrel}		\
Version:	%{fakever}				\
Release:	%{fakerel}				\
Requires:	glibc-devel ncurses-devel make gcc perl	\
Summary:	The kernel-devel files for %{kname}-%{1}-%{buildrel} \
Group:		Development/Kernel			\
Provides:	%{kname}-devel = %{kverrel} 		\
Provides:	%{kname}-%{1}-devel			\
%ifarch %{ix86}						\
Conflicts:	arch(x86_64)				\
%endif							\
%description -n %{kname}-%{1}-devel-%{buildrel}		\
This package contains the kernel files (headers and build tools) \
that should be enough to build additional drivers for   \
use with %{kname}-%{1}-%{buildrel}.                     \
							\
If you want to build your own kernel, you need to install the full \
%{kname}-source-%{buildrel} rpm.			\
							\
%endif							\
							\
%if %build_debug					\
%package -n	%{kname}-%{1}-%{buildrel}-debug		\
Version:	%{fakever}				\
Release:	%{fakerel}				\
Summary:	Files with debug info for %{kname}-%{1}-%{buildrel} \
Group:		Development/Debug			\
Provides:	kernel-debug = %{kverrel} 		\
%ifarch %{ix86}						\
Conflicts:	arch(x86_64)				\
%endif							\
%description -n %{kname}-%{1}-%{buildrel}-debug		\
This package contains the files with debug info to aid in debug tasks \
when using %{kname}-%{1}-%{buildrel}.			\
							\
If you need to look at debug information or use some application that \
needs debugging info from the kernel, this package may help. \
							\
%endif							\
							\
%package -n %{kname}-%{1}-latest			\
Version:	%{kversion}				\
Release:	%{rpmrel}				\
Summary:	Virtual rpm for latest %{kname}-%{1}	\
Group:		System/Kernel and hardware		\
Requires:	%{kname}-%{1}-%{buildrel}		\
%ifarch %{ix86}						\
Conflicts:	arch(x86_64)				\
%endif							\
%description -n %{kname}-%{1}-latest			\
This package is a virtual rpm that aims to make sure you always have the \
latest %{kname}-%{1} installed...			\
							\
%if %build_devel					\
%package -n %{kname}-%{1}-devel-latest			\
Version:	%{kversion}				\
Release:	%{rpmrel}				\
Summary:	Virtual rpm for latest %{kname}-%{1}-devel \
Group:		Development/Kernel			\
Requires:	%{kname}-%{1}-devel-%{buildrel}		\
%ifarch %{ix86}						\
Conflicts:	arch(x86_64)				\
%endif							\
Provides:	%{kname}-devel-latest			\
%description -n %{kname}-%{1}-devel-latest		\
This package is a virtual rpm that aims to make sure you always have the \
latest %{kname}-%{1}-devel installed...			\
							\
%endif							\
							\
%post -n %{kname}-%{1}-%{buildrel} -f kernel_files.%{1}-post \
%preun -n %{kname}-%{1}-%{buildrel} -f kernel_files.%{1}-preun \
%postun -n %{kname}-%{1}-%{buildrel} -f kernel_files.%{1}-postun \
							\
%if %build_devel					\
%post -n %{kname}-%{1}-devel-%{buildrel} -f kernel_devel_files.%{1}-post \
%preun -n %{kname}-%{1}-devel-%{buildrel} -f kernel_devel_files.%{1}-preun \
%endif							\
							\
%files -n %{kname}-%{1}-%{buildrel} -f kernel_files.%{1} \
%files -n %{kname}-%{1}-latest				\
%defattr(-,root,root)					\
							\
%if %build_devel					\
%files -n %{kname}-%{1}-devel-%{buildrel} -f kernel_devel_files.%{1} \
%files -n %{kname}-%{1}-devel-latest			\
%defattr(-,root,root)					\
%endif							\
							\
%if %build_debug					\
%files -n %{kname}-%{1}-%{buildrel}-debug -f kernel_debug_files.%{1} \
%defattr(-,root,root)					\
%endif

%ifarch %{ix86}
#
# kernel-desktop586: i586, smp-alternatives, 4GB
#
%if %build_desktop586
%define summary_desktop586 Linux kernel for desktop use with i586 & 4GB RAM
%define info_desktop586 This kernel is compiled for desktop use, single or \
multiple i586 processor(s)/core(s) and less than 4GB RAM, using voluntary \
preempt, CFS cpu scheduler and cfq i/o scheduler.
%mkflavour desktop586
%endif
%endif

#
# kernel-desktop: i686, smp-alternatives, 4 GB / x86_64
#
%if %build_desktop
%ifarch %{ix86}
%define summary_desktop Linux Kernel for desktop use with i686 & 4GB RAM
%define info_desktop This kernel is compiled for desktop use, single or \
multiple i686 processor(s)/core(s) and less than 4GB RAM, using HZ_1000, \
voluntary preempt, CFS cpu scheduler and cfq i/o scheduler.
%else
%define summary_desktop Linux Kernel for desktop use with %{_arch}
%define info_desktop This kernel is compiled for desktop use, single or \
multiple %{_arch} processor(s)/core(s), using HZ_1000, voluntary preempt, \
CFS cpu scheduler and cfq i/o scheduler.
%endif
%mkflavour desktop
%endif

#
# kernel-netbook: i686, smp-alternatives, 4 GB / x86_64
#
%if %build_netbook
%ifarch %{ix86}
%define summary_netbook Linux Kernel for netbook use with i686 & 4GB RAM
%define info_netbook This kernel is compiled for netbook use, single or \
multiple i686 processor(s)/core(s) and less than 4GB RAM, using HZ_1000, \
voluntary preempt, CFS cpu scheduler and cfq i/o scheduler.
%else
%define summary_netbook Linux Kernel for netbook use with %{_arch}
%define info_netbook This kernel is compiled for netbook use, single or \
multiple %{_arch} processor(s)/core(s), using HZ_1000, voluntary preempt, \
CFS cpu scheduler and cfq i/o scheduler.
%endif
%mkflavour netbook
%endif

#
# kernel-server: i686, smp-alternatives, 64 GB / x86_64
#
%if %build_server
%ifarch %{ix86}
%define summary_server Linux Kernel for server use with i686 & 64GB RAM
%define info_server This kernel is compiled for server use, single or \
multiple i686 processor(s)/core(s) and up to 64GB RAM using PAE, using \
no preempt, HZ_100, CFS cpu scheduler and cfq i/o scheduler.
%else
%define summary_server Linux Kernel for server use with %{_arch}
%define info_server This kernel is compiled for server use, single or \
multiple %{_arch} processor(s)/core(s), using no preempt, HZ_100, \
CFS cpu scheduler and cfq i/o scheduler.
%endif
%mkflavour server
%endif

#
# kernel-xen-pvops: i686, smp-alternatives, 64 GB / x86_64
#
%if %build_xen_pvops
%ifarch %{ix86}
%define summary_xen_pvops Linux Kernel for xen-pvops use with i686 & 64GB RAM
%define info_xen_pvops This kernel is compiled for xen-pvops use, single or \
multiple i686 processor(s)/core(s) and up to 64GB RAM using PAE, using \
no preempt, HZ_100, CFS cpu scheduler and cfq i/o scheduler.
%else
%define summary_xen_pvops Linux Kernel for xen-pvops use with %{_arch}
%define info_xen_pvops This kernel is compiled for xen-pvops use, single or \
multiple %{_arch} processor(s)/core(s), using no preempt, HZ_100, \
CFS cpu scheduler and cfq i/o scheduler.
%endif
%mkflavour xen-pvops
%endif

#
# ARM kernels
#
%ifarch %{arm}
%if %build_iop32x
%define summary_iop32x Linux Kernel for Arm machines based on Xscale IOP32X
%define info_iop32x This kernel is compiled for iop32x boxes. It will run on n2100 \
or ss4000e or sanmina boards.
%mkflavour iop32x
%endif
%if %build_kirkwood
%define summary_kirkwood Linux Kernel for Arm machines based on Kirkwood
%define info_kirkwood This kernel is compiled for kirkwood boxes. It will run on openrd boards.
%mkflavour kirkwood
%endif
%if %build_versatile
%define summary_versatile Linux Kernel for Versatile arm machines
%define info_versatile This kernel is compiled for Versatile boxes. It will run on Qemu for instance.
%mkflavour versatile
%endif
%endif

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

%description -n %{kname}-source-%{buildrel}
The %{kname}-source package contains the source code files for the Mageia
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.

%post -n %{kname}-source-%{buildrel}
for i in /lib/modules/%{kversion}-{desktop586,desktop,server}-%{buildrpmrel}; do
        if [ -d $i ]; then
		if [ ! -L $i/build -a ! -L $i/source ]; then
			ln -sf /usr/src/linux-%{kversion}-%{buildrpmrel} $i/build
			ln -sf /usr/src/linux-%{kversion}-%{buildrpmrel} $i/source
		fi
        fi
done
cd /usr/src
rm -f linux
ln -snf linux-%{kversion}-%{buildrpmrel} linux

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

#
# kernel-source-latest: virtual rpm
#
%package -n %{kname}-source-latest
Version: 	%{kversion}
Release: 	%{rpmrel}
Summary: 	Virtual rpm for latest %{kname}-source
Group:   	Development/Kernel
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

#
# 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 %{kname} source
Group: 		Books/Computer books
Buildarch:	noarch

%description -n %{kname}-doc
This package contains documentation files from the %{kname} 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

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

%define patches_dir ../%{patch_ver}/

cd %src_dir

%if %kstable
%if %kpatch
%if %prev_stable
%patch1 -p1
%endif
%patch2 -p1
%else
%patch1 -p1
%endif
%else
%if %kpatch
%patch1 -p1
%endif
%endif
%if %kgit
%patch2 -p1
%endif

%{patches_dir}/scripts/apply_patches

# PATCH END


#
# Setup Begin
#

# Prepare all the variables for calling create_configs

%if %build_debug
%define debug --debug
%else
%define debug --no-debug
%endif


%{patches_dir}/scripts/create_configs %debug --user_cpu="%{target_arch}"

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

# get rid of unwanted files
find . -name '*~' -o -name '*.orig' -o -name '*.append' | %kxargs rm -f


%build
# Common target directories
%define _kerneldir /usr/src/linux-%{kversion}-%{buildrpmrel}
%define _bootdir /boot
%define _modulesdir /lib/modules
%define _efidir %{_bootdir}/efi/mageia

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

PrepareKernel() {
	name=$1
	extension=$2
	x86_dir=arch/x86/configs

	echo "Make config for kernel $extension"

	%smake -s mrproper

	if [ "%{target_arch}" == "i386" -o "%{target_arch}" == "x86_64" ]; then
	    if [ -z "$name" ]; then
		cp ${x86_dir}/%{target_arch}_defconfig-desktop .config
	    else
		cp ${x86_dir}/%{target_arch}_defconfig-$name .config
	    fi
	else
	    if [ -z "$name" ]; then
		cp arch/%{target_arch}/defconfig-desktop .config
	    else
		cp arch/%{target_arch}/defconfig-$name .config
	    fi
	fi

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

	%smake oldconfig
}

BuildKernel() {
	KernelVer=$1

	echo "Building kernel $KernelVer"

	%kmake -s all

	# kirkwood boxes have u-boot
	if [ "$KernelVer" = "%{kversion}-kirkwood-%{buildrpmrel}" ]; then
		%kmake uImage
	fi

	# Start installing stuff
	install -d %{temp_boot}
	install -m 644 System.map %{temp_boot}/System.map-$KernelVer
	install -m 644 .config %{temp_boot}/config-$KernelVer
	gzip -c Module.symvers > %{temp_boot}/symvers-$KernelVer.gz

        %ifarch ppc powerpc
	        cp -f vmlinux %{temp_boot}/vmlinuz-$KernelVer
		%ifarch ppc
			cp -f arch/ppc/boot/images/zImage.chrp-rs6k %{temp_boot}/vmlinuz-rs6k-$KernelVer
		%endif
	%else
		%ifarch %{arm}
			if [ -f arch/arm/boot/uImage ]; then
				cp -f arch/arm/boot/uImage %{temp_boot}/uImage-$KernelVer
			else
				cp -f arch/arm/boot/zImage %{temp_boot}/vmlinuz-$KernelVer
			fi
		%else
			%ifarch sparc sparc64
				gzip -9c vmlinux > %{temp_boot}/vmlinuz-$KernelVer
			%else
				cp -f arch/%{target_arch}/boot/bzImage %{temp_boot}/vmlinuz-$KernelVer
			%endif
		%endif
	%endif

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

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

SaveDevel() {
	devel_flavour=$1

	DevelRoot=/usr/src/linux-%{kversion}-$devel_flavour-%{buildrpmrel}
	TempDevelRoot=%{temp_root}$DevelRoot

	mkdir -p $TempDevelRoot
	for i in $(find . -name 'Makefile*'); do cp -R --parents $i $TempDevelRoot;done
	for i in $(find . -name 'Kconfig*' -o -name 'Kbuild*'); do cp -R --parents $i $TempDevelRoot;done
	cp -fR include $TempDevelRoot
	cp -fR scripts $TempDevelRoot
	cp -fR kernel/bounds.c $TempDevelRoot/kernel
	%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} $TempDevelRoot/arch/x86/kernel/
		cp -fR arch/x86/kernel/asm-offsets_{32,64}.c $TempDevelRoot/arch/x86/kernel/
		cp -fR arch/x86/include $TempDevelRoot/arch/x86/
	%else
		cp -fR arch/%{target_arch}/kernel/asm-offsets.{c,s} $TempDevelRoot/arch/%{target_arch}/kernel/
		for f in $(find arch/%{target_arch} -name include); do cp -fR --parents $f $TempDevelRoot; done
	%endif
	cp -fR .config Module.symvers $TempDevelRoot
	cp -fR 3rdparty/mkbuild.pl $TempDevelRoot/3rdparty

	# Needed for truecrypt build (Danny)
	cp -fR drivers/md/dm.h $TempDevelRoot/drivers/md/

	# Needed for lguest
	cp -fR drivers/lguest/lg.h $TempDevelRoot/drivers/lguest/

	# Needed for lirc_gpio (#39004)
	cp -fR drivers/media/video/bt8xx/bttv{,p}.h $TempDevelRoot/drivers/media/video/bt8xx/
	cp -fR drivers/media/video/bt8xx/bt848.h $TempDevelRoot/drivers/media/video/bt8xx/
	cp -fR drivers/media/video/btcx-risc.h $TempDevelRoot/drivers/media/video/

	# Needed for external dvb tree (#41418)
	cp -fR drivers/media/dvb/dvb-core/*.h $TempDevelRoot/drivers/media/dvb/dvb-core/
	cp -fR drivers/media/dvb/frontends/lgdt330x.h $TempDevelRoot/drivers/media/dvb/frontends/

	# add acpica header files, needed for fglrx build
	cp -fR drivers/acpi/acpica/*.h $TempDevelRoot/drivers/acpi/acpica/

	# aufs2 has a special file needed
	cp -fR fs/aufs/magic.mk $TempDevelRoot/fs/aufs

	for i in alpha avr32 blackfin cris frv h8300 ia64 m32r m68knommu \
	         microblaze mips mn10300 parisc s390 score sh tile xtensa; do
		rm -rf $TempDevelRoot/arch/$i
	done

	# ppc needs only m68k headers
	rm -rf $TempDevelRoot/arch/m68k

	%ifnarch %{arm}
		rm -rf $TempDevelRoot/arch/arm
	%endif
	%ifnarch ppc powerpc
		rm -rf $TempDevelRoot/arch/powerpc
	%endif
	%ifnarch sparc sparc64
		rm -rf $TempDevelRoot/arch/sparc
		rm -rf $TempDevelRoot/arch/sparc64
	%endif
	%ifnarch %{ix86} x86_64
		rm -rf $TempDevelRoot/arch/x86
	%endif

	# Clean the scripts tree, and make sure everything is ok (sanity check)
	# running prepare+scripts (tree was already "prepared" in build)
	pushd $TempDevelRoot >/dev/null
		%smake -s prepare scripts
		%smake -s clean
	popd >/dev/null
	rm -f $TempDevelRoot/.config.old

	# fix permissions
	chmod -R a+rX $TempDevelRoot

	# disable mrproper in -devel rpms
	patch -p1 --fuzz=0 -d $TempDevelRoot -i %{SOURCE2}

	kernel_devel_files=../kernel_devel_files.$devel_flavour


### Create the kernel_devel_files.*
cat > $kernel_devel_files <<EOF
%defattr(-,root,root)
%dir $DevelRoot
%dir $DevelRoot/arch
%dir $DevelRoot/include
$DevelRoot/3rdparty
$DevelRoot/Documentation
%ifarch %{arm}
$DevelRoot/arch/arm
%endif
%ifarch ppc powerpc
$DevelRoot/arch/powerpc
$DevelRoot/arch/ppc
%endif
%ifarch sparc sparc64
$DevelRoot/arch/sparc
$DevelRoot/arch/sparc64
%endif
$DevelRoot/arch/um
%ifarch %{ix86} x86_64
$DevelRoot/arch/x86
%endif
$DevelRoot/block
$DevelRoot/crypto
$DevelRoot/drivers
$DevelRoot/firmware
$DevelRoot/fs
$DevelRoot/include/Kbuild
$DevelRoot/include/acpi
$DevelRoot/include/asm-generic
$DevelRoot/include/config
$DevelRoot/include/crypto
$DevelRoot/include/drm
$DevelRoot/include/generated
$DevelRoot/include/keys
$DevelRoot/include/linux
$DevelRoot/include/math-emu
$DevelRoot/include/media
$DevelRoot/include/mtd
$DevelRoot/include/net
$DevelRoot/include/pcmcia
$DevelRoot/include/rdma
$DevelRoot/include/rxrpc
$DevelRoot/include/scsi
$DevelRoot/include/sound
$DevelRoot/include/target
$DevelRoot/include/trace
$DevelRoot/include/video
$DevelRoot/include/xen
$DevelRoot/init
$DevelRoot/ipc
$DevelRoot/kernel
$DevelRoot/lib
$DevelRoot/mm
$DevelRoot/net
$DevelRoot/samples
$DevelRoot/scripts
$DevelRoot/security
$DevelRoot/sound
$DevelRoot/tools
$DevelRoot/usr
$DevelRoot/virt
$DevelRoot/.config
$DevelRoot/Kbuild
$DevelRoot/Kconfig
$DevelRoot/Makefile
$DevelRoot/Module.symvers
$DevelRoot/arch/Kconfig
%doc README.kernel-sources
EOF


### Create -devel Post script on the fly
cat > $kernel_devel_files-post <<EOF
if [ -d /lib/modules/%{kversion}-$devel_flavour-%{buildrpmrel} ]; then
	rm -f /lib/modules/%{kversion}-$devel_flavour-%{buildrpmrel}/{build,source}
	ln -sf $DevelRoot /lib/modules/%{kversion}-$devel_flavour-%{buildrpmrel}/build
	ln -sf $DevelRoot /lib/modules/%{kversion}-$devel_flavour-%{buildrpmrel}/source
fi
EOF


### Create -devel Preun script on the fly
cat > $kernel_devel_files-preun <<EOF
if [ -L /lib/modules/%{kversion}-$devel_flavour-%{buildrpmrel}/build ]; then
	rm -f /lib/modules/%{kversion}-$devel_flavour-%{buildrpmrel}/build
fi
if [ -L /lib/modules/%{kversion}-$devel_flavour-%{buildrpmrel}/source ]; then
	rm -f /lib/modules/%{kversion}-$devel_flavour-%{buildrpmrel}/source
fi
exit 0
EOF
}

SaveDebug() {
	debug_flavour=$1

	install -m 644 vmlinux \
	      %{temp_boot}/vmlinux-%{kversion}-$debug_flavour-%{buildrpmrel}
	kernel_debug_files=../kernel_debug_files.$debug_flavour
	echo "%defattr(-,root,root)" > $kernel_debug_files
	echo "%{_bootdir}/vmlinux-%{kversion}-$debug_flavour-%{buildrpmrel}" \
		>> $kernel_debug_files

	find %{temp_modules}/%{kversion}-$debug_flavour-%{buildrpmrel}/kernel \
		-name "*.ko" | \
		%kxargs -I '{}' objcopy --only-keep-debug '{}' '{}'.debug
	find %{temp_modules}/%{kversion}-$debug_flavour-%{buildrpmrel}/kernel \
		-name "*.ko" | %kxargs -I '{}' \
		sh -c 'cd `dirname {}`; \
		       objcopy --add-gnu-debuglink=`basename {}`.debug \
		       --strip-debug `basename {}`'

	pushd %{temp_modules}
	find %{kversion}-$debug_flavour-%{buildrpmrel}/kernel \
		-name "*.ko.debug" > debug_module_list
	popd
	cat %{temp_modules}/debug_module_list | \
		sed 's|\(.*\)|%{_modulesdir}/\1|' >> $kernel_debug_files
	cat %{temp_modules}/debug_module_list | \
		sed 's|\(.*\)|%exclude %{_modulesdir}/\1|' \
		>> ../kernel_exclude_debug_files.$debug_flavour
	rm -f %{temp_modules}/debug_module_list
}

CreateFiles() {
	kernel_flavour=$1

	kernel_files=../kernel_files.$kernel_flavour

ker="vmlinuz"
if [ "$kernel_flavour" = "kirkwood" ]; then
       ker="uImage"
fi
### Create the kernel_files.*
cat > $kernel_files <<EOF
%defattr(-,root,root)
%{_bootdir}/System.map-%{kversion}-$kernel_flavour-%{buildrpmrel}
%{_bootdir}/symvers-%{kversion}-$kernel_flavour-%{buildrpmrel}.gz
%{_bootdir}/config-%{kversion}-$kernel_flavour-%{buildrpmrel}
%{_bootdir}/$ker-%{kversion}-$kernel_flavour-%{buildrpmrel}
%dir %{_modulesdir}/%{kversion}-$kernel_flavour-%{buildrpmrel}/
%{_modulesdir}/%{kversion}-$kernel_flavour-%{buildrpmrel}/kernel
%{_modulesdir}/%{kversion}-$kernel_flavour-%{buildrpmrel}/modules.*
%doc README.kernel-sources
EOF

	%if %build_debug
	cat ../kernel_exclude_debug_files.$kernel_flavour >> $kernel_files
	%endif

### Create kernel Post script
cat > $kernel_files-post <<EOF
%ifarch %{arm}
/sbin/installkernel -i -N %{kversion}-$kernel_flavour-%{buildrpmrel}
%else
/sbin/installkernel %{kversion}-$kernel_flavour-%{buildrpmrel}
pushd /boot > /dev/null
if [ -L vmlinuz-$kernel_flavour ]; then
	rm -f vmlinuz-$kernel_flavour
fi
ln -sf vmlinuz-%{kversion}-$kernel_flavour-%{buildrpmrel} vmlinuz-$kernel_flavour
if [ -L initrd-$kernel_flavour.img ]; then
	rm -f initrd-$kernel_flavour.img
fi
ln -sf initrd-%{kversion}-$kernel_flavour-%{buildrpmrel}.img initrd-$kernel_flavour.img
popd > /dev/null
%endif
%if %build_devel
# create kernel-devel symlinks if matching -devel- rpm is installed
if [ -d /usr/src/linux-%{kversion}-$kernel_flavour-%{buildrpmrel} ]; then
	rm -f /lib/modules/%{kversion}-$kernel_flavour-%{buildrpmrel}/{build,source}
	ln -sf /usr/src/linux-%{kversion}-$kernel_flavour-%{buildrpmrel} /lib/modules/%{kversion}-$kernel_flavour-%{buildrpmrel}/build
	ln -sf /usr/src/linux-%{kversion}-$kernel_flavour-%{buildrpmrel} /lib/modules/%{kversion}-$kernel_flavour-%{buildrpmrel}/source
fi
%endif
%if %build_source
# create kernel-source symlinks only if matching -devel- rpm is not installed
if [ -d /usr/src/linux-%{kversion}-%{buildrpmrel} -a ! -d /usr/src/linux-%{kversion}-$kernel_flavour-%{buildrpmrel} ]; then
	rm -f /lib/modules/%{kversion}-$kernel_flavour-%{buildrpmrel}/{build,source}
	ln -sf /usr/src/linux-%{kversion}-%{buildrpmrel} /lib/modules/%{kversion}-$kernel_flavour-%{buildrpmrel}/build
	ln -sf /usr/src/linux-%{kversion}-%{buildrpmrel} /lib/modules/%{kversion}-$kernel_flavour-%{buildrpmrel}/source
fi
%endif
EOF


### Create kernel Preun script on the fly
cat > $kernel_files-preun <<EOF
/sbin/installkernel -R %{kversion}-$kernel_flavour-%{buildrpmrel}
pushd /boot > /dev/null
if [ -L vmlinuz-$kernel_flavour ]; then
	if [ "$(readlink vmlinuz-$kernel_flavour)" = "vmlinuz-%{kversion}-$kernel_flavour-%{buildrpmrel}" ]; then
		rm -f vmlinuz-$kernel_flavour
	fi
fi
if [ -L initrd-$kernel_flavour.img ]; then
	if [ "$(readlink initrd-$kernel_flavour.img)" = "initrd-%{kversion}-$kernel_flavour-%{buildrpmrel}.img" ]; then
		rm -f initrd-$kernel_flavour.img
	fi
fi
popd > /dev/null
%if %build_devel
if [ -L /lib/modules/%{kversion}-$kernel_flavour-%{buildrpmrel}/build ]; then
	rm -f /lib/modules/%{kversion}-$kernel_flavour-%{buildrpmrel}/build
fi
if [ -L /lib/modules/%{kversion}-$kernel_flavour-%{buildrpmrel}/source ]; then
	rm -f /lib/modules/%{kversion}-$kernel_flavour-%{buildrpmrel}/source
fi
%endif
exit 0
EOF


### Create kernel Postun script on the fly
cat > $kernel_files-postun <<EOF
/sbin/kernel_remove_initrd %{kversion}-$kernel_flavour-%{buildrpmrel}
rm -rf /lib/modules/%{kversion}-$kernel_flavour-%{buildrpmrel} >/dev/null
EOF
}


CreateKernel() {
	flavour=$1

	PrepareKernel $flavour $flavour-%{buildrpmrel}

	BuildKernel %{kversion}-$flavour-%{buildrpmrel}
	%if %build_devel
		SaveDevel $flavour
	%endif
	%if %build_debug
		SaveDebug $flavour
	%endif
	CreateFiles $flavour
}


###
# DO it...
###


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


#make sure we are in the directory
cd %src_dir

%ifarch %{ix86}
%if %build_desktop586
CreateKernel desktop586
%endif
%endif

%if %build_desktop
CreateKernel desktop
%endif

%if %build_netbook
CreateKernel netbook
%endif

%if %build_server
CreateKernel server
%endif

%if %build_xen_pvops
CreateKernel xen-pvops
%endif

%ifarch %{arm}
%if %build_iop32x
CreateKernel iop32x
%endif
%if %build_kirkwood
CreateKernel kirkwood
%endif
%if %build_versatile
CreateKernel versatile
%endif
%endif


# We don't make to repeat the depend code at the install phase
%if %build_source
%ifarch %{arm}
    PrepareKernel "kirkwood" %{buildrpmrel}custom
%else
    PrepareKernel "" %{buildrpmrel}custom
%endif
%smake -s mrproper
%endif


###
### 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}

# 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 cris frv h8300 ia64 m32r m68knommu \
         microblaze mips parisc s390 score sh sh64 tile v850 xtensa mn10300; do
	rm -rf %{target_source}/arch/$i
done

# ppc needs only m68k headers
rm -rf %{target_source}/arch/m68k

%ifnarch ppc powerpc
	rm -rf %{target_source}/arch/ppc
	rm -rf %{target_source}/arch/powerpc
%endif
%ifnarch sparc sparc64
	rm -rf %{target_source}/arch/sparc
	rm -rf %{target_source}/arch/sparc64
%endif

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

#endif %build_source
%endif

# gzipping modules
find %{target_modules} -name "*.ko" | %kxargs gzip -9

# 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 gzipped all the modules, we change the stamp :(
# we really need the depmod -ae here
pushd %{target_modules}
for i in *; do
	/sbin/depmod -u -ae -b %{buildroot} -r -F %{target_boot}/System.map-$i $i
	echo $?
done

for i in *; do
	pushd $i
	echo "Creating modules.description for $i"
	modules=`find . -name "*.ko.gz"`
	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}

###
### source and doc file lists
###

%if %build_source
%files -n %{kname}-source-%{buildrel}
%defattr(-,root,root)
%dir %{_kerneldir}
%dir %{_kerneldir}/arch
%dir %{_kerneldir}/include
%{_kerneldir}/3rdparty
%{_kerneldir}/Documentation
%{_kerneldir}/arch/Kconfig
%{_kerneldir}/arch/arm
%ifarch powerpc ppc
%{_kerneldir}/arch/powerpc
%{_kerneldir}/arch/ppc
%endif
%ifarch sparc sparc64
%{_kerneldir}/arch/sparc
%{_kerneldir}/arch/sparc64
%endif
%{_kerneldir}/arch/um
%{_kerneldir}/arch/x86
%{_kerneldir}/block
%{_kerneldir}/crypto
%{_kerneldir}/drivers
%{_kerneldir}/firmware
%{_kerneldir}/fs
%{_kerneldir}/include/Kbuild
%{_kerneldir}/include/acpi
%{_kerneldir}/include/asm-generic
%ifarch powerpc ppc
%{_kerneldir}/include/m68k
%{_kerneldir}/include/powerpc
%{_kerneldir}/include/ppc
%endif
%{_kerneldir}/include/crypto
%{_kerneldir}/include/drm
%{_kerneldir}/include/keys
%{_kerneldir}/include/linux
%{_kerneldir}/include/math-emu
%{_kerneldir}/include/media
%{_kerneldir}/include/mtd
%{_kerneldir}/include/net
%{_kerneldir}/include/pcmcia
%{_kerneldir}/include/rdma
%{_kerneldir}/include/rxrpc
%{_kerneldir}/include/scsi
%{_kerneldir}/include/sound
%{_kerneldir}/include/target
%{_kerneldir}/include/trace
%{_kerneldir}/include/video
%{_kerneldir}/include/xen
%{_kerneldir}/init
%{_kerneldir}/ipc
%{_kerneldir}/kernel
%{_kerneldir}/lib
%{_kerneldir}/mm
%{_kerneldir}/net
%{_kerneldir}/virt
%{_kerneldir}/samples
%{_kerneldir}/scripts
%{_kerneldir}/security
%{_kerneldir}/sound
%{_kerneldir}/tools
%{_kerneldir}/usr
%{_kerneldir}/COPYING
%{_kerneldir}/CREDITS
%{_kerneldir}/Kbuild
%{_kerneldir}/Kconfig
%{_kerneldir}/MAINTAINERS
%{_kerneldir}/Makefile
%{_kerneldir}/README
%{_kerneldir}/REPORTING-BUGS
%doc README.kernel-sources

%files -n %{kname}-source-latest
%defattr(-,root,root)
%endif

%if %build_doc
%files -n %{kname}-doc
%defattr(-,root,root)
%doc linux-%{tar_ver}/Documentation/*
%endif


%changelog

* Mon Sep 26 2011 tmb <tmb> 2.6.38.8-6.mga1
+ Revision: 148975
- fix keucr in staging to not conflict with scsi namespace
- revert "ide: Convert to bdops->check_events()" merged in upstream
  2.6.38.8 as it introduced regression for some users regarding
  udev getting stuck at 100%% cpu (mga #1954)
- add Intel C600 Series Chipset SAS Controller support
- fuse: check size of FUSE_NOTIFY_INVAL_ENTRY message (CVE-2011-3353)
- proc: fix a race in do_io_accounting
- tasktats: make taskstats require root access (prevents information leak)
- Input: wacom - add support for Lenovo tablet ID 0xE6 (mga #2811)
- ahci: add ids for Intel Panther Point 1E0E and Marvell 91A3
- pata_marvell: add ids for Marvell 91A0 and 91A4
- build kernels with -s(ilent) to only log warning and errors
- convert kernel-source to noarch
- drop debug-latest rpms as they are not really used
- rename debug rpms so the name ends with -debug like all other debug packages
- ndiswrapper: add IoUnregisterPlugPlayNotification symbol (mga #2162)
- USB: xhci: fix OS want to own HC
- add Sagemcom HiLo3G support
- staging: rtl8192u: declare MODULE_FIRMWARE
- efi: corrupted GUID partition tables can cause kernel oops (CVE-2011-1776)
- firewire: ohci: do not bind to Pinnacle cards, avert panic
- libata: fix unexpectedly frozen port after ata_eh_reset()
- option: add support for yuga series and huawei k3770, k3771, k3806, k4510, k4511, k4605
- xhci: Reject double add of active endpoints
- xhci: Add reset on resume quirk for asrock p67 host
- xhci: Always set urb->status to zero for isoc endpoints
- md: avoid endless recovery loop when waiting for fail device to complete
- nbd: limit module parameters to a sane value (prevents oops)
- vmscan: fix a livelock in kswapd
- usb: xhci: Add defines for hardcoded slot state
- usb: xhci: Do not issue device reset when device is not setup
- usb: xhci: Disable MSI for some Fresco Logic hosts
- usb: xhci: fix interval calculation for FS isoc endpoints
- md: check ->hot_remove_disk when removing disk
- md/raid5: fix raid5_set_bi_hw_segments
- md/raid5: fix FUA request handling in ops_run_io()
- drm/radeon/r300/kms: do bounds checking for 3D_LOAD_VBPNTR and bump array limit
- cifs: fix possible memory corruption in CIFSFindNext (CVE-2011-3191)
- crypto: Move md5_transform to lib/md5.c (needed for CVE-2011-3188)
- net: Compute protocol sequence numbers and fragment IDs using MD5 (CVE-2011-3188)
- befs: Validate length of long symbolic links (CVE-2011-2928)
- move RLIMIT_NPROC check from set_user() to do_execve_common()
  (blocks privilege escalations related to buggy programs not
   checking setuid() return code)
- pmcraid: reject negative request size
- staging: comedi: fix infoleak to userspace (CVE-2011-2909)
- af_packet: prevent information leak (CVE-2011-2898)
- gro: Only reset frag0 when skb can be pulled (CVE-2011-2723)
- media/radio: si4713-i2c: avoid potential buffer overflow on si4713 (CVE-2011-2700)
- ipv6: make fragment identifications less predictable (CVE-2011-2699)
- ext4: Fix max file size and logical block counting of extent format file (CVE-2011-2695)
- gfs2: make sure fallocate bytes is a multiple of blksize (CVE-2011-2689)
- NLM: Don't hang forever on NLM unlock requests (CVE-2011-2491)
- mm: vmscan: Stop kswapd consuming 100%% CPU when highest zone is small
- fix non-expanding xen-pvops macros
- net/ipv4: Check for mistakenly passed in non-IPv4 address
- Bluetooth: Prevent buffer overflow in l2cap config request (CVE-2011-2497)
- Bluetooth: l2cap and rfcomm: fix 1 byte infoleak to userspace (CVE-2011-2492)
- proc: restrict access to /proc/PID/io (CVE-2011-2495)
- ext4: init timer earlier to avoid a kernel panic in __save_error_info (CVE-2011-2493)
- nl80211: fix overflow in ssid_len (CVE-2011-2517)
- update to 2.6.38.8 (CVE-2011-1017)
  * drop merged patches
- inet_diag: fix inet_diag_bc_audit() (CVE-2011-2213)
- ksm: fix race between ksmd and exiting task (CVE-2011-2183)
- taskstats: don't allow duplicate entries in listener mode (CVE-2011-2484)
- ath9k: revert changes that crashes the kernel (mga #144, regression since 2.6.35)
- ath9k: fix two more bugs in tx power
- ath9k: Reset chip on baseband hang
- ath9k: set 40 Mhz rate only if hw is configured in ht40
- block: export blk_{get,put}_queue()
- block: blkdev_get() should access ->bd_disk only after success
- drm/i915: Add a no lvds quirk for the Asus EeeBox PC EB1007
- drm/radeon/kms: viewport height has to be even
- drm/radeon/kms: fix for radeon on systems >4GB without hardware iommu
- fat: Fix corrupt inode flags when remove ATTR_SYS flag
- hwmon: coretemp: Relax target temperature range check
- intel-iommu: Flush unmaps at domain_exit
- intel-iommu: Only unlink device domains from iommu
- intel-iommu: Check for identity mapping candidate using system dma mask
- intel-iommu: Speed up processing of the identity_mapping function
- intel-iommu: Dont cache iova above 32bit
- intel-iommu: Use coherent DMA mask when requested
- intel-iommu: Remove Host Bridge devices from identity mapping
- intel-iommu: Add domain check in domain_remove_one_dev_info
- nl80211: fix check for valid SSID size in scan operations (CVE-2011-2517)
- option: add Zoom 4597 modem USB IDs
- option: add Alcatel X200 to sendsetup blacklist
- option: add Prolink PH300 modem IDs
- option: Add blacklist for ZTE K3765-Z
- Revert "USB: option: add ID for ZTE MF 330" as its a usb hub
- scsi:  Fix oops caused by queue refcounting failure
- TOMOYO: Fix oops in tomoyo_mount_acl() (CVE-2011-2518)
- usb: core: Tolerate protocol stall during hub and port status read
- usb-storage: redo incorrect reads
- usbnet/cdc_ncm: add missing .reset_resume hook
- usb: cdc-acm: Adding second ACM channel support for Nokia E7 and C7
- usb: serial: add another 4N-GALAXY.DE PID to ftdi_sio driver
- video: Fix use-after-free by vga16fb on rmmod
- x86/amd-iommu: Fix 3 possible endless loops
- x86/amd-iommu: Use only per-device dma_ops
- x86/amd-iommu: Fix boot crash with hidden PCI devices
- xen: fix off by one errors in multicalls.c

* Sun May 22 2011 tmb <tmb> 2.6.38.7-1.mga1
+ Revision: 100106
- r8169: add a new chip for RTL8105
- r8169: add a new chip for RTL8168DP
- r8169: add support for RTL8168E/RTL8111E
- update to 2.6.38.7 final (CVE-2011-1770, CVE-2011-1776, CVE-2011-1927, CVE-2011-2496)
- drop merged stable-queue fixes

* Thu May 19 2011 tmb <tmb> 2.6.38.6-2.mga1
+ Revision: 99781
- watchdog: iTCO_wdt: TCO Watchdog patch for Intel Panther Point PCH
- more stable fixes
  * cifs: clean up various nits in unicode routines
  * cifs: fix cifsConvertToUCS() for the mapchars case
  * iwlegacy: fix IBSS mode crashes
- merge current stable queue:
  * ARM: zImage: make sure the stack is 64-bit aligned
  * ASoC: SSM2602: Fix 'Mic Boost2' control
  * ASoC: UDA134x: Remove POWER_OFF_ON_STANDBY define
  * block: rescan partitions on invalidated devices on -ENOMEDIA too
  * can: fix SJA1000 dlc for RTR packets
  * cdrom: always check_disk_change() on open
  * cifs: add fallback in is_path_accessible for old servers
  * cifs: Fix memory over bound bug in cifs_parse_mount_options
  * clocksource: Install completely before selecting
  * dccp: handle invalid feature options length (CVE-2011-1770)
  * drm/radeon/kms: fix extended lvds info parsing
  * ehea: Fix memory hotplug oops
  * ehea: fix wrongly reported speed and port
  * media: Fix cx88 remote control input
  * hydra: Fix regression caused during net_device_ops conversion
  * ipheth: Properly distinguish length and alignment in URBs and skbs
  * libata: fix oops when LPM is used with PMP
  * libertas: fix cmdpendingq locking
  * megaraid_sas: Sanity check user supplied length before passing it to
    dma_alloc_coherent()
  * mm: use alloc_bootmem_node_nopanic() on really needed path
  * ne-h8300: Fix regression caused during net_device_ops conversion
  * net: dev_close() should check IFF_UP
  * net: ip_expire() must revalidate route (CVE-2011-1927)
  * net: slip, fix ldisc->open retval
  * PCH_GbE : Fixed the issue of checksum judgment
  * PCH_GbE : Fixed the issue of collision detection
  * pch_gbe: support ML7223 IOH
  * PM: Fix warning in pm_restrict_gfp_mask() during SNAPSHOT_S2RAM ioctl
  * PM / Hibernate: Fix ioctl SNAPSHOT_S2RAM
  * PM / Hibernate: Make snapshot_release() restore GFP mask
  * rapidio: fix default routing initialization
  * Revert "mmc: fix a race between card-detect rescan and clock-gate work
    instances"
  * rtc-s3c: fixup wake support for rtc
  * scsi: Revert "[SCSI] Retrieve the Caching mode page"
  * Revert "x86, AMD: Fix APIC timer erratum 400 affecting K8 Rev.A-E
    processors"
  * slcan: fix ldisc->open retval
  * tick: Clear broadcast active bit when switching to oneshot
  * tmpfs: fix off-by-one in max_blocks checks
  * tmpfs: fix race between swapoff and writepage
  * tmpfs: fix race between umount and swapoff
  * tmpfs: fix race between umount and writepage
  * tmpfs: fix spurious ENOSPC when racing with unswap
  * media/v4l: Release module if subdev registration fails
  * vmxnet3: Consistently disable irqs when taking adapter->cmd_lock
  * vmxnet3: Fix inconsistent LRO state after initialization
  * x86, AMD: Fix ARAT feature setting again
  * x86, apic: Fix spurious error interrupts triggering on all non-boot APs
  * x86: Fix UV BAU for non-consecutive nasids
  * x86, mce, AMD: Fix leaving freed data in a list
  * zorro8390: Fix regression caused during net_device_ops conversion

  + rtp <rtp>
    - Revert to unionfs 2.5.8 until 2.5.9 problems are solved (cf bug #1326 and
      unionfs ml)

* Tue May 10 2011 tmb <tmb> 2.6.38.6-1.mga1
+ Revision: 97089
- merge current stable queue:
  cifs: change bleft in decode_unicode_ssetup back to signed type
  cifs: check for bytes_remaining going to zero in CIFS_SessSetup
  cifs: handle errors from coalesce_t2
  cifs: refactor mid finding loop in cifs_demultiplex_thread
  cifs: sanitize length checking in coalesce_t2
  drm/radeon/kms: add pci id to acer travelmate quirk for 5730
  drm/radeon/kms: fix gart setup on fusion parts (v2) backport
  drm/i915/dp: Be paranoid in case we disable a DP before it is attached
  drm/i915/lvds: Only act on lid notify when the device is on
  drm/i915: Release object along create user fb error path
  efi: Validate size of EFI GUID partition entries (CVE-2011-1776)
  hw_breakpoints, powerpc: Fix CONFIG_HAVE_HW_BREAKPOINT off-case in ptrace_set_debugreg()
  iwlwifi: add {ack, plpc}_check module parameters
  ptrace: Prepare to fix racy accesses on task breakpoints
  thinkpad-acpi: module autoloading for newer Lenovo ThinkPads
  vm: Don't lock guardpage if the stack is growing up
  vm: fix vm_pgoff wrap in upward expansion
  x86, hw_breakpoints: Fix racy access to ptrace breakpoints
- revert: "dell-laptop: Toggle the unsupported hardware killswitch"
  as it causes regressions on existing hw (reported by Colin Guthrie)
- drop Amd K8 erratum 400 fix (merged)
- update to 2.6.38.6
- clean /lib/modules tree on uninstall
- disable ACPI_PROCFS_POWER as its obsoleted by the sysfs interface

* Tue May 03 2011 tmb <tmb> 2.6.38.5-1.mga1
+ Revision: 94519
- update unionfs to 2.5.9
- update to 2.6.38.5 (CVE-2011-2479, CVE-2011-2498)

* Sat Apr 30 2011 tmb <tmb> 2.6.38.5-0.rc1.1.mga1
+ Revision: 93738
- raise default vmalloc area to 192MB (Anssi, #904)
- r8169: be verbose when unable to load firmware
- samsung-laptop: drop backlight type setting patch as its 2.6.39 specific
- r8169: add support for RTL8105E
- samsung-laptop: set backlight type and add support for N230, R410P
- x86, AMD: K8 Rev.A-E processors are subject to erratum 400
- enable DEBUG_RODATA and DEBUG_SET_MODULE_RONX
- update to 2.6.38.5-rc1
- hp-wmi: add support for rfkill on HP Mini 5102 (Anssi)

* Fri Apr 22 2011 tmb <tmb> 2.6.38.4-1.mga1
+ Revision: 89804
- enable radeon kernel modesetting
- add aliases for old ieee1394 modules to the new firewire stack
- add ide/ahci/raid ids for Intel Panther Point
- update ipset to 6.4 (includes ipv6 support)
- intel_ips: fix monitor thread to use TASK_INTERRUPTIBLE
- disable powersaving on rt2800 as it is broken (noted by rtp)
- update aufs to aufs2.1-38 stable branch
- update to 2.6.38.4 (CVE-2011-2496)

* Sat Apr 16 2011 tmb <tmb> 2.6.38.3-1.mga1
+ Revision: 86561
- drm/radeon/kms: fix suspend on rv530 asics
- drm/radeon/kms: pll tweaks for rv6xx
- vm: fix mlock() on stack guard page
- vm: fix vm_pgoff wrap in stack expansion
- update 'drm/i915: Fix tiling corruption from pipelined fencing'
- drm: Retry i2c transfer of EDID block after failure
- drm/i915/dp: Sanity check eDP existence
- drm/i915: Restore missing command flush before interrupt on BLT ring
- drm/i915: Avoid unmapping pages from a NULL address space
- drm/i915: Enable GPU semaphores by default
- update to 2.6.38.3 final (CVE-2011-2496)
- drop merged xen revert patch
- re-enable debug

* Tue Apr 12 2011 tmb <tmb> 2.6.38.3-0.rc1.1.mga1
+ Revision: 84037
- add missing virtual provides
- revert: 'x86-64, mm: Put early page table high' as it breaks xen
- rediff HP Compaq DC7900 alsa patch
- update to 2.6.38.3-rc1
- drop merged patches

* Mon Apr 11 2011 tmb <tmb> 2.6.38.2-4.mga1
+ Revision: 83133
- add xen netdev backend support
- compress patch tarball with xz
- ath9k: fix a chip wakeup related crash in ath9k_start
- add xen-pvops kernel
- spec cleanup

  + rtp <rtp>
    - import arm support. The kernel can build iop32x, kirkwood and versatile (qemu)
      kernels but build only kirkwood and versatile atm.

* Sat Apr 02 2011 tmb <tmb> 2.6.38.2-2.mga1
+ Revision: 79847
- add module_alias matching old dm-raid45
- ALSA: Fix yet another race in disconnection
- ALSA: hda - Fix SPDIF out regression on ALC889
- ALSA: vmalloc buffers should use normal mmap
- ath9k: Fix kernel panic in AR2427
- cciss: fix lost command issue
- crypto: aesni-intel - fix problem with packets that are not multiple of 64b
- eCryptfs: ecryptfs_keyring_auth_tok_for_sig() bug fix
- eCryptfs: Unlock page in write_begin error path
- mac80211: initialize sta->last_rx in sta_info_alloc
- myri10ge: fix rmmod crash
- PCI/ACPI: Report ASPM support to BIOS if not disabled from command line
- perf: Better fit max unprivileged mlock pages for tools needs
- scsi/ses: Avoid kernel panic when lun 0 is not mapped
- scsi/ses: show devices for enclosures with no page 7
- sound/oss/opl3: validate voice and channel indexes
- x86-64, mm: Put early page table high
- drop -devel provides from -source as dkms fails to build correctly with -source
- Relax si_code check in rt_sigqueueinfo and rt_tgsigqueueinfo
- Revert "x86: Cleanup highmap after brk is concluded",
  as it causes systems to freeze on resume
- restore framebuffer oops and deadlock fixes by Herton as
  they seem to work better than the Ubuntu one (mdv#62864)

* Mon Mar 28 2011 tmb <tmb> 2.6.38.2-1.mga1
+ Revision: 78347
- update to 2.6.38.2 (CVE-2011-0726)
- add kernel-netbook build (mga #313)

* Thu Mar 24 2011 tmb <tmb> 2.6.38.1-1.mga1
+ Revision: 76866
- drm/i915: Fix pipelined fencing (colin, fdo bug #34584)
- enable ath9k debugging
- ath9k: Fix a locking related issue
- update to 2.6.38.1

* Sun Mar 20 2011 tmb <tmb> 2.6.38-1.mga1
+ Revision: 74958
- add 70 fixes from upstream -stable queue
- rediff S2 to apply cleanly
- fix acerhk build with 2.6.38 series kernels
- update filelists
- fix ndiswrapper build with 2.6.38
- update aufs2 to 2.6.38-rc
- update defconfigs
- rediff 3rd-3rdparty-merge.patch
- rediff fs-aufs2.1-for-2.6.37.patch
- rediff platform-x86-add-shuttle-wmi-driver.patch
- rediff char-agp-intel-new-Q57-id.patch
- rediff acpi-video-add-blacklist-to-use-vendor-driver.patch
- rediff acpi-add-proc-event-regs.patch
- rediff x86-pci-toshiba-equium-a60-assign-busses.patch
- update unionfs to 2.5.8
- update samsung-laptop driver
- drop old samsung-backlight driver
- update plymouth framebuffer oops fix (from ubuntu)
- disable broken docomo patches
- update to 2.6.38
   * drop merged patches:
     block-fix-mis-synchronisation-in-blkdev_issue_zeroout.patch
     btrfs-deal-with-short-returns-from-copy_from_user.patch
     dm-crypt-scale-to-multiple-CPUs-v5-2.6.36.patch
     drm-i915-fix-calculation-of-backlight-value-in-combined-mode.patch
     fs-squashfs-add-XZ-compression-configuration-option.patch
     fs-squashfs-add-XZ-compression-support.patch
     fs-squashfs-fix-use-of-uninitialised-variable-in-zlib-and-xz-decompressors.patch
     idle-intel_idle-update-Sandy-Bridge-core-C-state-residency-targets.patch
     kbuild-do-not-remove-a.out-kvm.h-and-kvm_para.h-on-headers_install_all.patch
     kernel-sched-autogroup-Fix-reference-leak.patch
     kernel-sched-automated-per-session-task-groups-20101130.patch
     kernel-sched-fix-potential-access-to-freed-memory.patch
     kernel-sched-Fix-struct-autogroup-memory-leak.patch
     lib-decompressors-add-boot-time-XZ-support.patch
     lib-decompressors-add-XZ-decompressor-module.patch
     net-wireless-ath9k-fix-race-conditions-when-stop-device.patch
     net-wireless-rtl8187-avoid-redundant-write-to-register-FF72.patch
     net-wireless-rtl8187-consolidate-anaparam-on-off-write-sequences.patch
     net-wireless-rtl8187-do-not-do-per-packet-TX-AGC.patch
     net-wireless-rtl8187-don-t-set-RTL818X_CONFIG3_GNT_SELECT.patch
     net-wireless-rtl8187-fix-wrong-register-initialization-in-8187B.patch
     net-wireless-rtl8187-move-pll-reset-at-start-out-of-ANAPARAM-write.patch
     net-wireless-rtl8187-remove-redundant-initialization-of-ARFR.patch
     net-wireless-rtl8187-remove-setting-of-beacon-atim-regs-from-init.patch
     net-wireless-rtl8187-remove-uneeded-setting-of-anaparam-write.patch
     net-wireless-rtl8187-restore-anaparam-registers-after-reset.patch
     net-wireless-zd1201-add-id.patch
     net-wireless-zd1211rw-add-id.patch
     nfs-fix-compilation-warning.patch
     nfs-nfsroot-should-default-to-proto-udp.patch
     x86-support-XZ-compressed-kernel.patch

* Tue Mar 15 2011 tmb <tmb> 2.6.37.4-1.mga1
+ Revision: 71895
- block: fix mis-synchronisation in blkdev_issue_zeroout()
- btrfs: deal with short returns from copy_from_user
- drm/i915: Fix calculation of backlight value in combined mode
- nfs: nfsroot should default to: proto=udp
- nfs: fix compilation warning
- update to 2.6.37.4

* Tue Mar 08 2011 tmb <tmb> 2.6.37.3-1.mga1
+ Revision: 66712
- add Mageia framebuffer boot logo
- update to 2.6.37.3 (CVE-2011-1013, CVE-2011-1076)
  * drop merged patches:
    mm-prevent-concurrent-unmap_mapping_range-on-the-same-inode.patch
    net-ipv4-tcp-fix-inet_twsk_deschedule.patch
    usb-serial-usb_wwan-fix-tty-null-dereference.patch
    revert-bluetooth-enable-usb-autosuspend-by-default-on-btusb.patch
    staging-brcm80211-bugfix-for-softmac-crash-on-multi-cpu-configurations.patch
    staging-brcm80211-remove-assert-to-avoid-panic-since-2.6.37-kernel.patch

* Sat Feb 26 2011 tmb <tmb> 2.6.37.2-1.mga1
+ Revision: 60143
- fix aufs2 -devel includes
- add aufs2 support
- staging: brcm80211: remove assert to avoid panic since 2.6.37 kernel
- staging: brcm80211: bugfix for softmac crash on multi cpu configurations
- USB: serial/usb_wwan, fix tty NULL dereference
- Revert 'Bluetooth: Enable USB autosuspend by default on btusb'
- mm: prevent concurrent unmap_mapping_range() on the same inode
- tcp: fix inet_twsk_deschedule()
- ath9k: fix race conditions when stop device (#144)
- i586 server kernel and x86_64 kernels needs to be compressed with gzip
  so they work with xen (got broken during lzma -> xz update, noted by
  Guillaume Rousse on mdv kernel-discuss ml)
- update to 2.6.37.2
  * drop merged patch
    fs-xfs-fix-dquot-shaker-deadlock.patch

* Sat Feb 19 2011 tmb <tmb> 2.6.37.1-1.mga1
+ Revision: 54140
- xfs: fix dquot shaker deadlock
- drop merged patches:
  idle-intel_idle-open-broadcast-clock-event-to-fix-boot-hang.patch
  idle-intel_idle-fix-a-shutdown-regression.patch
- rediff patches:
  kernel-sched-automated-per-session-task-groups-20101130.patch
  kernel-sched-autogroup-Fix-reference-leak.patch
  kernel-sched-Fix-struct-autogroup-memory-leak.patch
- update to 2.6.37.1
- intel_idle: update Sandy Bridge core C-state residency targets
- intel_idle: open broadcast clock event to prevent boot hang
              due to local apic stalls
- intel_idle: fix a shutdown regression due to open broadcast fix

* Tue Jan 25 2011 tmb <tmb> 2.6.37-3.mga1
+ Revision: 38796
- drop obsoletes/provides for ancient mandriva releases
- Squashfs: Fix use of uninitialised variable in zlib & xz decompressors
- update defconfigs
- add xz support for kernel, initrd and squashfs
  (from upstream 2.6.38-rc1)
- drop lzma support (obsoleted by xz support)
- disable sparc and powerpc in buildscripts too
- unpack patches tarball
- convert 3rdparty tarballs to patches
- build only for i586 and x86_64 for now

* Sat Jan 08 2011 tmb <tmb> 2.6.37-2.mga1
+ Revision: 1280
- drop SOURCE5, not needed anymore
- imported package kernel
- Created package structure for kernel.