File kernel-source.spec of Package kernel-source

#
# spec file for package kernel-source (Version 2.6.27.56)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild
# icecream 0

Url:            http://www.kernel.org/
%if 0%{?opensuse_bs}
# Strip off the build number ("y") from the "x.y" release number
%define source_rel %(release=%release; echo ${release%.*})
%else
# We don't have build numbers internally
%define source_rel %release
%endif

Name:           kernel-source
Summary:        The Linux Kernel Sources
Version:        2.6.27.56
Release:        0.<RELEASE1>
License:        GPL v2 only
Group:          Development/Sources
AutoReqProv:    off
BuildRequires:  coreutils sed
BuildRequires:  fdupes
Requires(post): coreutils sed
%if ! 0%{?opensuse_bs}
BuildRequires:  kernel-dummy
%endif
ExclusiveArch:  %ix86 ppc ppc64 s390 s390x ia64 x86_64
Provides:       linux
Provides:       kernel-source = 2.6.27.56-%source_rel
%if "kernel-source" == "kernel-source"
Provides:       linux lx_suse lx_sus22 lx_sus24
Obsoletes:      linux lx-gdt lx-hack lx-suse lx1162_1 lx1162_2 lx1212_1 lx1212_2 lx1213_1 lx1213_2 lx121_1 lx121_2 lx126_1 lx126_2 lx129_1 lx129_2 lx_large kernel_headers lx_suse lx_sus22 lx_sus24
%endif
Source0:        http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.27.tar.bz2
Source1:        source-pre.sh
Source2:        source-post.sh
Source3:        kernel-source.rpmlintrc
Source10:       preun.sh
Source11:       postun.sh
Source12:       pre.sh
Source13:       post.sh
Source14:       series.conf
Source15:       arch-symbols
Source16:       guards
Source21:       config.conf
Source23:       supported.conf
Source30:       config-subst
Source33:       check-for-config-changes
Source34:       check-supported-list
Source37:       README.SUSE
Source39:       generic_serial-blacklist
Source40:       build-source-timestamp
Source41:       built-in-where
Source44:       find-provides
Source45:       module-renames
Source46:       modversions
Source47:       extract-modaliases
Source48:       macros.kernel-source
Source49:       kernel-module-subpackage
Source50:       symsets.pl
Source50:       kernel-syms.spec
Source51:       kernel-debug.spec
Source52:       kernel-default.spec
Source53:       kernel-ec2.spec
Source54:       kernel-kdump.spec
Source55:       kernel-pae.spec
Source56:       kernel-ppc64.spec
Source57:       kernel-ps3.spec
Source58:       kernel-s390.spec
Source59:       kernel-trace.spec
Source60:       kernel-vanilla.spec
Source61:       kernel-vmi.spec
Source62:       kernel-xen.spec
Source100:      config.tar.bz2
Source101:      patches.arch.tar.bz2
Source102:      patches.drivers.tar.bz2
Source103:      patches.fixes.tar.bz2
Source104:      patches.rpmify.tar.bz2
Source105:      patches.suse.tar.bz2
Source107:      patches.xen.tar.bz2
Source108:      patches.addon.tar.bz2
Source109:      patches.kernel.org.tar.bz2
Source110:      patches.apparmor.tar.bz2
Source111:      patches.rt.tar.bz2
Source112:      patches.trace.tar.bz2
Source113:      patches.kabi.tar.bz2
Source120:      kabi.tar.bz2
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Prefix:         /usr/src

# Build with bash instead of sh as the shell: this turns on bash
# extensions like <(...).
%define _buildshell /bin/bash

%define my_builddir %_builddir/%{name}-%{version}

%(chmod +x %_sourcedir/{arch-symbols,guards,config-subst,check-for-config-changes,symsets.pl})

%define symbols %(set -- $(%_sourcedir/arch-symbols %_target_cpu) $([ -e %_sourcedir/extra-symbols ] && cat %_sourcedir/extra-symbols) ; echo $*)

%define tolerate_unknown_new_config_options 0

%description
Linux kernel sources with many fixes and improvements.



Authors:
--------
    Linus Torvalds <torvalds@osdl.org>
    
    see /usr/src/linux/CREDITS for more details.

Source Timestamp: 2010-12-01 16:57:58 +0100
GIT Revision: 1b5f62cf35ce9157f69781339df846ab7661e31d
GIT Branch: SLE11_BRANCH

%prep
if ! [ -e %_sourcedir/linux-2.6.27.tar.bz2 ]; then
    echo "Please get a copy of linux-2.6.27.tar.bz2 from" \
	 "ftp://ftp.kernel.org/pub/linux/kernel/v2.6/."
fi

echo "Architecture symbol(s): %symbols"

# Unpack all sources and patches
%setup -q -c -T -a 100 -a 101 -a 102 -a 103 -a 104 -a 105 -a 107 -a 108 -a 109 -a 110 -a 111 -a 112 -a 113

# bnc#519188
for spec in kernel-syms.spec kernel-debug.spec kernel-default.spec kernel-ec2.spec kernel-kdump.spec kernel-pae.spec kernel-ppc64.spec kernel-ps3.spec kernel-s390.spec kernel-trace.spec kernel-vanilla.spec kernel-vmi.spec kernel-xen.spec ; do
	sed -ri 's/^(Release:[[:space:]]+)[^[:space:]]*/\1%release/' \
		%_sourcedir/$spec
done

%build
# Release number without the EXTRAVERSION
RELEASE=%source_rel
while [ "$RELEASE" != "${RELEASE#[^0-9]*.}" ]; do
    RELEASE=${RELEASE#[^0-9]*.}
done

KERNELRELEASE=2.6.27.56-$RELEASE

case kernel-source in
(*-rt)
    variant=-rt
    variant_symbols=RT
    ;;
(*)
    variant=
    variant_symbols=
    ;;
esac

cat > %_builddir/%{name}-%{version}/.rpm-defs <<EOF
KERNELRELEASE=$KERNELRELEASE
variant=$variant
EOF

mkdir -p $RPM_BUILD_ROOT/usr/src
cd $RPM_BUILD_ROOT/usr/src

ln -sf linux$variant linux$variant  # dummy symlink
mkdir linux-obj

# Unpack the vanilla kernel sources
bzip2 -cd %_sourcedir/linux-2.6.27.tar.bz2 \
| tar xf -

mv linux-2.6.27 linux-$KERNELRELEASE$variant
cd linux-$KERNELRELEASE$variant

chmod -x arch/arm/mach-at91/board-yl-9200.c # executable by accident (fixed in 2.6.27)

%_sourcedir/guards $variant_symbols %symbols < %_sourcedir/series.conf \
    > .patches
for patch in $(< .patches); do
    if ! patch -s -F0 -E -p1 --no-backup-if-mismatch \
	      -i %_builddir/kernel-source-2.6.27.56/$patch; then
    echo "*** Patch $patch failed ***"
    exit 1
    fi
done

if [ -f %_sourcedir/localversion ] ; then
    cat %_sourcedir/localversion > localversion
fi

cat > %my_builddir/kernel-source.files <<EOF
%%defattr(-, root, root)
%%ghost /usr/src/linux$variant
%%dir /usr/src/linux-obj
/usr/src/linux-$KERNELRELEASE$variant
/usr/src/linux-$KERNELRELEASE$variant-obj
/usr/share/doc/packages/%name
/etc/rpm/macros.kernel-source
/usr/lib/rpm/kernel-module-subpackage
/lib/modules/*
EOF

this_cpu_arch=
flavors=
for config in $(%_sourcedir/guards %symbols < %_sourcedir/config.conf | grep -v vanilla); do
    cpu_arch=${config%/*}
    flavor=${config#*/}
    config=%_builddir/%buildsubdir/config/$config
    if test -n "$this_cpu_arch" -a "$this_cpu_arch" != "$cpu_arch"; then
        echo "error: configs for multiple architectures?? (symbols: %symbols)"
        exit 1
    fi
    this_cpu_arch="$cpu_arch"
    flavors="$flavors $flavor"

    if [ ! -d ../linux-obj/$cpu_arch ]; then
        mkdir ../linux-obj/$cpu_arch
	echo "%%dir /usr/src/linux-obj/$cpu_arch" >>%my_builddir/%name.files
    fi
    ln -s $flavor ../linux-obj/$cpu_arch/$flavor # dummy symlink
    echo "%%ghost /usr/src/linux-obj/$cpu_arch/$flavor" >>%my_builddir/%name.files

    case "$flavor" in
    *-*)
	echo "Flavor '$flavor' must not contain dashes." >&2
	exit 1
	;;
    esac

    set -- kernel-$flavor $flavor
    case $flavor in
    (rt|rt_*)
	set -- "$@" RT
	;;
    esac

    diff -q .patches \
	 <(%_sourcedir/guards $* %symbols < %_sourcedir/series.conf) \
       || continue

#    source_tree=linux-$KERNELRELEASE$variant
    o=$RPM_BUILD_ROOT/usr/src/linux-$KERNELRELEASE$variant-obj/$cpu_arch/$flavor
    mkdir -p $o
    cat $config \
    | %_sourcedir/config-subst CONFIG_LOCALVERSION '"'-$RELEASE-$flavor'"' \
    | %_sourcedir/config-subst CONFIG_SUSE_KERNEL y \
%if 0%{?__debug_package:1}
    | %_sourcedir/config-subst CONFIG_DEBUG_INFO y \
%endif
    > $o/.config

    MAKE_ARGS="O=$o"

    # Works around a "fix" in mainline that ends up causing the makefile
    # to not be regenerated.
    echo "Automatically" > $o/Makefile

%if %{tolerate_unknown_new_config_options}
    yes '' | make oldconfig $MAKE_ARGS
%else
    cp $o/.config $o/.config.before
    make silentoldconfig $MAKE_ARGS < /dev/null
    %_sourcedir/check-for-config-changes $o/.config.before $o/.config
    rm -r $o/.config.before
%endif

    make prepare $MAKE_ARGS
    make scripts $MAKE_ARGS
    krel=$(make -s kernelrelease $MAKE_ARGS)
    if [ $KERNELRELEASE != "${krel%%-*}" ]; then
	echo "Kernel release mismatch: $KERNELRELEASE != ${krel%%-*}" >&2
	exit 1
    fi
    make clean $MAKE_ARGS

    mkdir -p $RPM_BUILD_ROOT/lib/modules/$krel
    ln -s ../../../usr/src/linux-$KERNELRELEASE$variant \
    	$RPM_BUILD_ROOT/lib/modules/$krel/source

    # Replace the absolute with a relative path
    sed -e "s,$RPM_BUILD_ROOT/usr/src/linux-$KERNELRELEASE$variant,../../../linux-$KERNELRELEASE$variant,g" \
	-i $o/Makefile
    rm -f $o/.config.old
done
rm -f linux-$KERNELRELEASE$variant/.patches

for script in pre post; do
    sed -e "s:@KERNELRELEASE@:$KERNELRELEASE:g" \
        -e "s:@VARIANT@:$variant:g" \
        -e "s:@CPUARCH@:$this_cpu_arch:g" \
        -e "s:@FLAVORS@:$flavors:g" \
        %_sourcedir/source-$script.sh > %my_builddir/%name-$script.sh
done

# Hardlink duplicate files automatically (from package fdupes).
%fdupes $RPM_BUILD_ROOT

cd $RPM_BUILD_ROOT/usr/src/linux-$KERNELRELEASE$variant-obj
set -- *
if [ ! -e %_target_cpu ]; then
    ln -s $1 %_target_cpu
    ln -s $1 ../linux-obj/%_target_cpu
    echo "/usr/src/linux-obj/%_target_cpu" >>%my_builddir/%name.files
fi

cd $RPM_BUILD_ROOT/usr/src

rm -f `find linux-$KERNELRELEASE$variant -name ".gitignore"`

# Remove $RPM_BUILD_ROOT prefix from symlinks.
for link in $(find $RPM_BUILD_ROOT/usr/src/linux-$KERNELRELEASE$variant-obj -type l); do
    target=$(readlink $link)
    rm -f $link
    ln -s ${target/$RPM_BUILD_ROOT/} $link
done

%install
source .rpm-defs

# Install the documentation and example Kernel Module Package.
DOC=$RPM_BUILD_ROOT/usr/share/doc/packages/%name
mkdir -p $DOC
cp %_sourcedir/README.SUSE $DOC
ln -s /usr/share/doc/packages/%name/README.SUSE \
    $RPM_BUILD_ROOT/usr/src/linux-$KERNELRELEASE$variant/

install -m 755 -d $RPM_BUILD_ROOT/etc/rpm
install -m 644 %_sourcedir/macros.kernel-source $RPM_BUILD_ROOT/etc/rpm/
install -m 755 -d $RPM_BUILD_ROOT/usr/lib/rpm
install -m 644 %_sourcedir/kernel-module-subpackage \
    $RPM_BUILD_ROOT/usr/lib/rpm/

%pre -f kernel-source-pre.sh

%post -f kernel-source-post.sh

%files -f kernel-source.files

%changelog
openSUSE Build Service is sponsored by