Automate the kernel version faking.

This commit is contained in:
Chuck Ebbert 2011-08-24 16:07:37 -04:00
parent 7acacb7383
commit 8728f9c48f
1 changed files with 53 additions and 124 deletions

View File

@ -3,11 +3,6 @@
Summary: The Linux kernel
# For a stable, released kernel, released_kernel should be 1. For rawhide
# and/or a kernel built from an rc or git snapshot, released_kernel should
# be 0.
%global released_kernel 1
# Save original buildid for later if it's defined
%if 0%{?buildid:1}
%global orig_buildid %{buildid}
@ -44,24 +39,16 @@ Summary: The Linux kernel
#
# We used to have some extra magic weirdness to bump this automatically,
# but now we don't. Just use: rpmdev-bumpspec -c 'comment for changelog'
# When changing base_sublevel below or going from rc to a final kernel,
# reset this by hand to 1 (or to 0 and then use rpmdev-bumpspec).
# scripts/rebase.sh should be made to do that for you, actually.
#
# For non-released -rc kernels, this will be prepended with "0.", so
# for example a 3 here will become 0.3
# When changing real_sublevel below, reset this by hand to 1
# (or to 0 and then use rpmdev-bumpspec).
#
%global baserelease 1
%global fedora_build %{baserelease}
# base_sublevel is the kernel version we're starting with and patching
# on top of -- for example, 2.6.22-rc7-git1 starts with a 2.6.21 base,
# which yields a base_sublevel of 21.
%define base_sublevel 39
%define fake_sublevel 40
## If this is a released kernel ##
%if 0%{?released_kernel}
# real_sublevel is the 3.x kernel version we're starting with
%define real_sublevel 0
# fake_sublevel is the 2.6.x version we're faking
%define fake_sublevel %(echo $((40 + %{real_sublevel})))
# Do we have a -stable update to apply?
%define stable_update 3
@ -78,9 +65,6 @@ Summary: The Linux kernel
%endif
%define rpmversion 2.6.%{fake_sublevel}%{?stablerev}
%endif
# Nb: The above rcrev and gitrev values automagically define Patch00 and Patch01 below.
# What parts do we want to build? We must build at least one kernel.
# These are the kernels that are built IF the architecture allows it.
# All should default to 1 (enabled) and be flipped to 0 (disabled)
@ -119,11 +103,7 @@ Summary: The Linux kernel
# Build the kernel-doc package, but don't fail the build if it botches.
# Here "true" means "continue" and "false" means "fail the build".
%if 0%{?released_kernel}
%define doc_build_fail false
%else
%define doc_build_fail true
%endif
%define rawhide_skip_docs 0
%if 0%{?rawhide_skip_docs}
@ -154,33 +134,15 @@ Summary: The Linux kernel
%define with_vanilla %{?_with_vanilla: 1} %{?!_with_vanilla: 0}
# pkg_release is what we'll fill in for the rpm Release: field
%if 0%{?released_kernel}
%if 0%{?stable_rc}
%define stable_rctag .rc%{stable_rc}
%endif
%define pkg_release %{fedora_build}%{?stable_rctag}%{?buildid}%{?dist}
%else
# non-released_kernel
%if 0%{?rcrev}
%define rctag .rc%rcrev
%else
%define rctag .rc0
%endif
%if 0%{?gitrev}
%define gittag .git%gitrev
%else
%define gittag .git0
%endif
%define pkg_release 0%{?rctag}%{?gittag}.%{fedora_build}%{?buildid}%{?dist}
%endif
# The kernel tarball/base version
# % define kversion 3.%{base_sublevel}
%define kversion 2.6.%{base_sublevel}
%define realversion 3.%{real_sublevel}
%define fakeversion 2.6.%{fake_sublevel}
%define make_target bzImage
@ -541,8 +503,7 @@ BuildRequires: rpm-build >= 4.4.2.1-4
%define debuginfo_args --strict-build-id
%endif
Source0: ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-%{kversion}.tar.bz2
#Source0: ftp://ftp.kernel.org/pub/linux/kernel/v3.0/linux-3.0-rc5.tar.bz2
Source0: ftp://ftp.kernel.org/pub/linux/kernel/v3.x/linux-%{realversion}.tar.bz2
Source11: genkey
Source14: find-provides
@ -580,8 +541,17 @@ Source1000: config-local
# Here should be only the patches up to the upstream canonical Linus tree.
Patch00: patch-3.0.bz2
Patch01: patch-3.0.3.bz2
# For a stable release kernel
%if 0%{?stable_update}
%if 0%{?stable_base}
%define stable_patch_00 patch-3.%{real_sublevel}.%{stable_base}.bz2
Patch00: %{stable_patch_00}
%endif
%if 0%{?stable_rc}
%define stable_patch_01 patch-3.%{real_sublevel}.%{stable_update}-rc%{stable_rc}.bz2
Patch01: %{stable_patch_01}
%endif
%endif
# we also need compile fixes for -vanilla
Patch04: linux-2.6-compile-fixes.patch
@ -819,7 +789,8 @@ AutoReqProv: no\
Requires(pre): /usr/bin/find\
Requires: perl\
%description -n kernel%{?variant}%{?1:-%{1}}-devel\
This package provides kernel headers and makefiles sufficient to build modules\
This package provides kernel headers and
makefiles sufficient to build modules\
against the %{?2:%{2} }kernel package.\
%{nil}
@ -978,46 +949,24 @@ ApplyOptionalPatch()
# which speeds things up quite a bit.
# Update to latest upstream.
%if 0%{?released_kernel}
%define vanillaversion 2.6.%{base_sublevel}
# non-released_kernel case
%else
%if 0%{?rcrev}
%define vanillaversion 2.6.%{upstream_sublevel}-rc%{rcrev}
%if 0%{?gitrev}
%define vanillaversion 2.6.%{upstream_sublevel}-rc%{rcrev}-git%{gitrev}
%endif
%else
# pre-{base_sublevel+1}-rc1 case
%if 0%{?gitrev}
%define vanillaversion 2.6.%{base_sublevel}-git%{gitrev}
%else
%define vanillaversion 2.6.%{base_sublevel}
%endif
%endif
%endif
# %%{vanillaversion} : the full version name, e.g. 2.6.35-rc6-git3
# %%{kversion} : the base version, e.g. 2.6.34
# Use kernel-%%{kversion}%%{?dist} as the top-level directory name
# Use kernel-%%{fakeversion}%%{?dist} as the top-level directory name
# so we can prep different trees within a single git directory.
# Build a list of the other top-level kernel tree directories.
# This will be used to hardlink identical vanilla subdirs.
sharedirs=$(find "$PWD" -maxdepth 1 -type d -name 'kernel-3.*' \
| grep -x -v "$PWD"/kernel-%{kversion}%{?dist}) ||:
| grep -x -v "$PWD"/kernel-%{fakeversion}%{?dist}) ||:
if [ ! -d kernel-%{kversion}%{?dist}/vanilla-%{vanillaversion} ]; then
if [ ! -d kernel-%{fakeversion}%{?dist}/vanilla-%{realversion} ]; then
if [ -d kernel-%{kversion}%{?dist}/vanilla-%{kversion} ]; then
if [ -d kernel-%{fakeversion}%{?dist}/vanilla-%{realversion} ]; then
# The base vanilla version already exists.
cd kernel-%{kversion}%{?dist}
cd kernel-%{fakeversion}%{?dist}
# Any vanilla-* directories other than the base one are stale.
for dir in vanilla-*; do
[ "$dir" = vanilla-%{kversion} ] || rm -rf $dir &
[ "$dir" = vanilla-%{realversion} ] || rm -rf $dir &
done
else
@ -1025,58 +974,39 @@ if [ ! -d kernel-%{kversion}%{?dist}/vanilla-%{vanillaversion} ]; then
rm -f pax_global_header
# Look for an identical base vanilla dir that can be hardlinked.
for sharedir in $sharedirs ; do
if [[ ! -z $sharedir && -d $sharedir/vanilla-%{kversion} ]] ; then
if [[ ! -z $sharedir && -d $sharedir/vanilla-%{realversion} ]] ; then
break
fi
done
if [[ ! -z $sharedir && -d $sharedir/vanilla-%{kversion} ]] ; then
%setup -q -n kernel-%{kversion}%{?dist} -c -T
cp -rl $sharedir/vanilla-%{kversion} .
if [[ ! -z $sharedir && -d $sharedir/vanilla-%{realversion} ]] ; then
%setup -q -n kernel-%{fakeversion}%{?dist} -c -T
cp -rl $sharedir/vanilla-%{realversion} .
else
%setup -q -n kernel-%{kversion}%{?dist} -c
mv linux-%{kversion} vanilla-%{kversion}
%setup -q -n kernel-%{fakeversion}%{?dist} -c
mv linux-%{realversion} vanilla-%{realversion}
fi
fi
%if "%{kversion}" != "%{vanillaversion}"
for sharedir in $sharedirs ; do
if [[ ! -z $sharedir && -d $sharedir/vanilla-%{vanillaversion} ]] ; then
break
fi
done
if [[ ! -z $sharedir && -d $sharedir/vanilla-%{vanillaversion} ]] ; then
cp -rl $sharedir/vanilla-%{vanillaversion} .
else
# Need to apply patches to the base vanilla version.
cp -rl vanilla-%{kversion} vanilla-%{vanillaversion}
fi
%endif
else
# We already have all vanilla dirs, just change to the top-level directory.
cd kernel-%{kversion}%{?dist}
cd kernel-%{fakeversion}%{?dist}
fi
# Now build the fedora kernel tree.
if [ -d linux-%{kversion}.%{_target_cpu} ]; then
if [ -d linux-%{fakeversion}.%{_target_cpu} ]; then
# Just in case we ctrl-c'd a prep already
rm -rf deleteme.%{_target_cpu}
# Move away the stale away, and delete in background.
mv linux-%{kversion}.%{_target_cpu} deleteme.%{_target_cpu}
mv linux-%{fakeversion}.%{_target_cpu} deleteme.%{_target_cpu}
rm -rf deleteme.%{_target_cpu} &
fi
cp -rl vanilla-%{vanillaversion} linux-%{kversion}.%{_target_cpu}
cp -rl vanilla-%{realversion} linux-%{fakeversion}.%{_target_cpu}
cd linux-%{kversion}.%{_target_cpu}
cd linux-%{fakeversion}.%{_target_cpu}
%if %{using_upstream_branch}
### BRANCH APPLY ###
@ -1109,9 +1039,13 @@ do
done
%endif
# Update vanilla to the latest upstream. (2.6.39 -> 3.0)
ApplyPatch patch-3.0.bz2
ApplyPatch patch-3.0.3.bz2
# released_kernel with possible stable updates
%if 0%{?stable_base}
ApplyPatch %{stable_patch_00}
%endif
%if 0%{?stable_rc}
ApplyPatch %{stable_patch_01}
%endif
ApplyPatch linux-2.6-makefile-after_link.patch
@ -1377,15 +1311,7 @@ BuildKernel() {
perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = %{?stablerev}-%{release}.%{_target_cpu}${Flavour:+.${Flavour}}/" Makefile
perl -p -i -e 's/^VERSION.*/VERSION = 2/' Makefile
perl -p -i -e 's/^PATCHLEVEL.*/PATCHLEVEL = 6/' Makefile
perl -p -i -e 's/^SUBLEVEL.*/SUBLEVEL = 40/' Makefile
# if pre-rc1 devel kernel, must fix up SUBLEVEL for our versioning scheme
### XXX this will probably be dead code in 3.0 --kyle
%if !0%{?rcrev}
%if 0%{?gitrev}
perl -p -i -e 's/^SUBLEVEL.*/SUBLEVEL = %{upstream_sublevel}/' Makefile
%endif
%endif
perl -p -i -e 's/^SUBLEVEL.*/SUBLEVEL = %{fake_sublevel}/' Makefile
# and now to start the build process
@ -1563,7 +1489,7 @@ rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/boot
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}
cd linux-%{kversion}.%{_target_cpu}
cd linux-%{fakeversion}.%{_target_cpu}
%if %{with_debug}
BuildKernel %make_target %kernel_image debug
@ -1636,7 +1562,7 @@ find Documentation -type d | xargs chmod u+w
%install
cd linux-%{kversion}.%{_target_cpu}
cd linux-%{fakeversion}.%{_target_cpu}
%if %{with_doc}
docdir=$RPM_BUILD_ROOT%{_datadir}/doc/kernel-doc-%{rpmversion}
@ -1802,7 +1728,7 @@ fi
%files firmware
%defattr(-,root,root)
/lib/firmware/*
%doc linux-%{kversion}.%{_target_cpu}/firmware/WHENCE
%doc linux-%{fakeversion}.%{_target_cpu}/firmware/WHENCE
%endif
%if %{with_bootwrapper}
@ -1900,6 +1826,9 @@ fi
# and build.
%changelog
* Wed Aug 24 2011 Chuck Ebbert <cebbert@redhat.com>
- Automate the kernel version faking.
* Tue Aug 23 2011 Ben Skeggs <bskeggs@redhat.com>
- nouveau: pull patches from 3.1 to fix some suspend/hibernate problems (rhbz#730582)