0% found this document useful (0 votes)
123 views6 pages

Kernel Recompile - SH

This script downloads the source code for the current Linux kernel, enables support for high memory configurations, recompiles the kernel and optional modules, and installs the new kernel and modules. It allows the user to choose options like recompiling the kernel, changing the kernel flavor, and installing the new files. If selected, it will recompile the linux-ubuntu-modules and linux-restricted-modules packages to match the new kernel.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
123 views6 pages

Kernel Recompile - SH

This script downloads the source code for the current Linux kernel, enables support for high memory configurations, recompiles the kernel and optional modules, and installs the new kernel and modules. It allows the user to choose options like recompiling the kernel, changing the kernel flavor, and installing the new files. If selected, it will recompile the linux-ubuntu-modules and linux-restricted-modules packages to match the new kernel.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

#!

/bin/bash # # # # # # # # # # # # # # # # # # # # # # # # Script that downloads the source and recompiles the current kernel, enabling the support for HIGHMEM64G Author: EdSena <[email protected]> Steps: 1) 2) 3) 4) 5) 6) 7) 8) 9) 10) 11) 12) 13) 14) 15) 16) 17) Read parameters from STDIN Switch directory to /usr/src Download (and install) necessary packages Change kernel's ABI version Enable HIGHMEM64G support on the kernel Rebuild the configuration files (Optional) Create a backup of the configured kernel source Kernel recompile (Optional) Kernel instalation Change kernel's ABI version on linux-ubuntu-modules Recompile linux-ubuntu-modules (Optional) Install linux-ubuntu-modules Change kernel's ABI version on linux-restricted-modules Recompile linux-restricted-modules (Optional) Install linux-restricted-modules Move all created files into a new sub-directory Clean unecessaries files

function readArgs { readKernelRecompile KERNEL=$? if [ $KERNEL -eq 1 ]; then readKernelInstallation fi readFlavour readModules MODULES=$? if [ $MODULES -eq 1 ]; then if [ $KERNEL -eq 1 ]; then KERNEL_INSTALL=1 fi readModulesInstallation fi MODULES_INSTALL=$? echo "Current kernel=$KRELEASE" echo "Current version=$KVERSION" echo "Will use KNEWFLAVOUR=$KNEWFLAVOUR" echo "Will install kernel=$KERNEL_INSTALL" echo "Will compile modules=$MODULES" echo "Will install modules=$MODULES_INSTALL" ask "Are this settings OK?" if [ $? -ne 1 ]; then readArgs return $? fi } function readKernelRecompile { ask "Do you want to recompile the kernel" return $?

} function readFlavour { ask "Do you want to change the kernel flavour" if [ $? -ne 0 ]; then readValue "Type the flavour that will be used on the recompiled kernel/modules" "KNEWFLAVOUR"; return $? else KNEWFLAVOUR=$KFLAVOUR fi return 1; } function readKernelInstallation { ask "Do you want to install the kernel ater compiling?" KERNEL_INSTALL=$?; } function readModules { echo echo "To recompile the linux-ubuntu-modules and linux-restriced-modules, this script will need to install the new kernel image and the new kernel hearde rs" ask "Do you want to recompile the modules ?" return $? } function readModulesInstallation { ask "Do you want to install the modules ater compiling?" return $? } function readValue { echo; echo $1 ; read -p "---> " $2; } function confirm { echo; read -p "$1 (y|[n]|q)? " OK; case "$OK" in [qQ]) echo echo "Aborted." exit 1; ;; [nN]) $2 return $?; ;; esac } function ask { echo; read -p "$1 (y|[n]|q)? " OK; case "$OK" in

[qQ]) echo echo "Aborted." exit 1; ;; [yY]) return 1; ;; else) return 0; ;; esac } function downloadFiles { apt-get build-dep linux-image-$KNAME if [ $MODULES -eq 1 ]; then apt-get build-dep linux-ubuntu-modules-$KRELEASE-generic apt-get build-dep linux-restricted-modules-$KRELEASE-generic fi apt-get source linux-image-$KNAME if [ $MODULES -eq 1 ]; then apt-get source linux-ubuntu-modules-$KRELEASE-generic apt-get source linux-restricted-modules-$KRELEASE-generic fi apt-get install libqt3-mt-dev

# }

function changeKernelFlavour { cd /usr/src/linux-$KVERSION #mv debian/config/i386/config.generic debian/config/i386/config.$KNEWFLA VOUR find debian/abi -name $KFLAVOUR -execdir mv $KFLAVOUR $KNEWFLAVOUR \; find debian/abi -name $KFLAVOUR.modules -execdir mv $KFLAVOUR.modules $K NEWFLAVOUR.modules \; mv debian/control debian/control.orig mv debian/control.stub debian/control.stub.orig sed s/-$KRELEASE-generic/-$KNEWNAME/ debian/control.orig > debian/contro l sed s/-$KRELEASE-generic/-$KNEWNAME/ debian/control.stub.orig > debian/c ontrol.stub } function changeUbuntuModulesFlavour { cd /usr/src/linux-ubuntu-modules-$KVERSION-$KVERSION mv debian/control debian/control.orig mv debian/control.stub debian/control.stub.orig sed s/-$KRELEASE-generic/-$KNEWNAME/ debian/control.orig > debian/contro l sed s/-$KRELEASE-generic/-$KNEWNAME/ debian/control.stub.orig > debian/c ontrol.stub } function changeRestrictedModulesFlavour { cd /usr/src/linux-restricted-modules-$KVERSION mv debian/control.stub.in debian/control.stub.in.orig mv debian/d-i/kernel-versions.in debian/d-i/kernel-versions.in.orig

mv debian/rules debian/rules.orig sed s/-@@ABIVER@@-generic/-@@ABIVER@@-$KNEWFLAVOUR/ debian/control.stub. in.orig > debian/control.stub.in sed s/generic/$KNEWFLAVOUR/ debian/d-i/kernel-versions.in.orig > debian/ d-i/kernel-versions.in sed "s/\(flavours := .*\)generic.*/\1$KNEWFLAVOUR)/" debian/rules.orig > debian/rules chmod +x debian/rules debian/rules debian/control } function groupStuff { BUILDDIR=/usr/src/build-$KNEWNAME mkdir -p $BUILDDIR if [ $KERNEL -eq 1 ]; then mv linux-image-$KNEWNAME*.deb linux-image-debug-$KNEWNAME*.deb linux-headers-*$KNEWNAME*.deb $BUILDDIR fi if [ $MODULES -eq 1 ]; then mv linux-ubuntu-modules-$KNEWNAME*.deb *-restricted-*-$KNEWNAME* .*deb $BUILDDIR fi } function cleanUp { rm -rf linux-restricted-modules-* rm -rf linux-ubuntu-modules-* rm -rf linux[_-]$(uname -r | sed 's/\(.*\)-[0-9]*-generic/\1/')* rm *.udeb mv *.deb build-$KNEWNAME/other } KNAME=$(uname -r) KNAME="2.6.28-14-generic" KFLAVOUR=$(echo $KNAME | sed -r 's/.+\-([^-]+)$/\1/') KRELEASE=$(echo $KNAME | sed -r 's/(\-[^-]+)$//') KVERSION=$(echo $KRELEASE | sed -r 's/(\-[^-]+)$//') # Step 01 readArgs KNEWNAME=$KRELEASE-$KNEWFLAVOUR # Step 02 cd /usr/src # Step 03 downloadFiles # Step 04 if [ $KNEWFLAVOUR != $KFLAVOUR ] ; then changeKernelFlavour fi if [ $KERNEL -eq 1 ]; then # Step 05 rm -rf debian/config/i386/* sed 's/\# CONFIG_HIGHMEM64G is not set/CONFIG_HIGHMEM64G=y/' /boot/confi g-$KNAME | sed 's/CONFIG_HIGHMEM4G=y/\# CONFIG_HIGHMEM4G is not set/' > debian/c

onfig/i386/config.$KNEWFLAVOUR # Step 06 chmod +x debian/scripts/misc/splitconfig.pl chmod +x debian/scripts/misc/oldconfig debian/rules updateconfigs # Step 07 #backupNewKernel # Step 08 #CONCURRENCY_LEVEL=4 AUTOBUILD=1 NOEXTRAS=1 debian/rules binary-$KNEWFLA VOUR CONCURRENCY_LEVEL=4 AUTOBUILD=1 NOEXTRAS=1 skipabi=true skipmodule=true debian/rules binary-$KNEWFLAVOUR # Step 09 if [ $KERNEL_INSTALL -eq 1 ]; then dpkg -i ../linux-image-$KNEWNAME*.deb linux-headers-$KNEWNAME*.d eb fi fi if [ $MODULES -eq 1 ]; then # # Step 10 # if [ $KNEWFLAVOUR != "generic" ] ; then # changeUbuntuModulesFlavour # fi # # # Step 11 # CONCURRENCY_LEVEL=4 AUTOBUILD=1 NOEXTRAS=1 debian/rules binary-debs flav ours=$KNEWFLAVOUR # # if [ $MODULES_INSTALL -eq 1 ]; then # # Step 12 # dpkg -i ../linux-ubuntu-modules-$KNEWNAME*.deb # fi # Step 13 if [ $KNEWFLAVOUR != "generic" ] ; then changeRestrictedModulesFlavour fi # Step 14 CONCURRENCY_LEVEL=4 AUTOBUILD=1 NOEXTRAS=1 debian/rules binary-debs flav ours=$KNEWNAME if [ $MODULES_INSTALL -eq 1 ]; then # Step 15 dpkg -i ../*-restricted-*-$KNEWNAME*.deb fi fi # Step 16 groupStuff

# Step 17 #cleanUp

You might also like