https://docs.google.com/open?id=0B_nTbpzPbbNJU0h1RzFLMG1lR2s
The following tries to dissect the script and how it works
Build dependencies
The portion below is used to install build environment in ubuntu, if the following are already installed, script just does not install it again(thanks to apt)
sudo apt-get install fakeroot build-essential crash kexec-tools makedumpfile kernel-wedge libncurses5 binutils-dev libelf-dev libdw-dev libnewt-dev libncurses5-dev
sudo apt-get install flex
sudo apt-get install bison
sudo apt-get --no-install-recommends install asciidoc xmlto
Downloading kernel source and patching it with ubuntu patches to build ubuntu package
mkdir -p ~/Builds/Kernel362
cd ~/Builds/Kernel362
wget -c http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.6.2.tar.bz2
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.6.2-quantal/0001-base-packaging.patch
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.6.2-quantal/0002-debian-changelog.patch
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.6.2-quantal/0003-default-configs.patch
rm -rf linux-3.6.2
rm -rf linux
tar xvjf linux-3.6.2.tar.bz2
ln -s linux-3.6.2 linux
cd linux
patch -p1 < ../0001-base-packaging.patch
patch -p1 < ../0002-debian-changelog.patch
patch -p1 < ../0003-default-configs.patch
Creating new flavor and giving execute permissions to debian build scripts
chmod -Rv +x debian/rules
chmod -Rv +x debian/scripts/
cp debian.master/config/amd64/config.flavour.generic debian.master/config/amd64/config.flavour.native
fakeroot debian/rules clean
fakeroot debian/rules updateconfigs
Changing kernel config based on stable config
#copy existing config from rock stable 12.04 kernel using uname -r, do not save it in .config, as this file is heavily modified when calling editconfigs
cp /boot/config-`uname -r` stableconfig
#cp /boot/config-3.2.0-31-generic stableconfig
#give y to native config
#Load alternate config and choose stableconfig which is untouched by editconfigs, save alternate config and save .config after changing processor type and kernel frequency
fakeroot debian/rules editconfigs
This step needs a bit more explanation on how to base kernel config based on stable config, to do this I just put screenshots explaining briefly how this is done
When the script is running and comes to asking if we want to edit config, choose Y for native flavor
see below (I am giving n for every other flavor)
When the kernel config screen comes, scroll down and select Load an Alternate Configuration File
In the dialog, erase .config using backspace and type stableconfig
Following screens show, that I change processor type and kernel frequency, the old and new
Processor type old
Processor type new
Kernel frequency old
Kernel frequency new
After finishing all configuration changes, do not just exit!
Scroll down to Save an Alternation Configuration File
In the popped up dialog, erase stableconfig and type .config
Now choose exit in the main configuration screen
ABI entries for new flavor and makefile changes
ABI_DIR=`ls debian.master/abi/`
cp debian.master/abi/$ABI_DIR/amd64/generic debian.master/abi/$ABI_DIR/amd64/native
cp debian.master/abi/$ABI_DIR/amd64/generic.modules debian.master/abi/$ABI_DIR/amd64/native.modules
sed -i s/getall\ amd64\ generic/getall\ amd64\ generic\ native/g debian.master/etc/getabis
grep native debian.master/etc/getabis
sed -i s/\=\ generic/\=\ generic\ native/g debian.master/rules.d/amd64.mk
grep native debian.master/rules.d/amd64.mk
cp debian.master/control.d/vars.generic debian.master/control.d/vars.native
sed -i s/\"Generic\"/\"core\ native\"/g debian.master/control.d/vars.native
grep native debian.master/control.d/vars.native
sed -i s/\=\ gcc/\=\ gcc\ \-march\=native\ \-pipe/g Makefile
sed -i s/\=\ g++/\=\ g++\ \-march\=native\ \-pipe/g Makefile
grep "march=native" Makefile
sed -i s/core2/native/g arch/x86/Makefile
sed -i s/core2/native/g arch/x86/Makefile_32.cpu
grep native arch/x86/Makefile_32.cpu
grep native arch/x86/Makefile
you can see above, I have given march=native you can choose whichever is your processor architecture
Building headers and kernel flavor
fakeroot debian/rules clean
skipabi=true skipmodule=true fakeroot debian/rules binary-headers
time skipabi=true skipmodule=true no_dumpfile=yes fakeroot debian/rules binary-native
The above builds kernel headers and kernel image for our new flavor
Just install the newly built packages using
sudo dpkg -i *.deb
Core i7 optimized Ubuntu Kernel
Kernel Headers All
Kernel Header corei7
Kernel Image
SHA256SUMS of the above in order
537e87a7c3200aab82624810526d25031ffd5093f406b32bc0f2e053e6213477 linux-headers-3.6.2-030602_3.6.2-030602.201210121823_all.deb