Professional Documents
Culture Documents
Kernel CK Ubuntu
Kernel CK Ubuntu
/usr/bin/env bash
#http://viajemotu.wordpress.com/2012/08/13/kernel-ck-for-ubuntu-precise/
#https://github.com/chilicuil/learn/blob/master/sh/is/kernel-ck-ubuntu
# $ time bash kernel-ck-ubuntu
#####################################
#kernel version base
kernel=3.11
#kernel specific version
patchkernel=3.11.7
#BFQ patch
bfq=3.11.0-v6r2
vbfq=v6r2
#CK patch
patchck=3.11-ck1
#sufix
ckk=ck1
#arch
arqt=$(dpkg --print-architecture)
#####################################
################################################################################
####################################################
##############################################DO NOT EDIT BELOW UNLESS YOU KNOW
WHAT YOU'RE DOING###################################
################################################################################
####################################################
#the /tmp partitions usually have noexec
tmp_path="$HOME/.tmp/kernel-ck-ubuntu-$patchkernel"
curr_path=$PWD
apps_default="kernel-package gcc-4.6 libncurses5 libncurses5-dev build-essential
patch fakeroot bc"
CL=$(printf "%s\\n" "$(expr $(grep -c processor /proc/cpuinfo) + 1 )")
trap _cleanup SIGINT SIGTERM #trap ctrl-c
_header()
{
clear
printf "%b\\n" "\033[1m-------------------------------\033[7m $0 $patchkerne
l \033[0m\033[1m------------------------------\033[0m"
printf "%b\\n" "\033[1m Original:\033[0m
http://sourceforge.net/projects
/scriptkernel/"
printf "%b\\n" "\033[1m Inspired by:\033[0m http://omicron.homeip.net/proje
cts/#easy_e17.sh"
printf "%b\\n" "\033[1m Updates:\033[0m
https://github.com/chilicuil/le
arn/blob/master/sh/is/kernel-ck-ubuntu"
printf "%s\\n"
"
send your push request!"
printf "\\n"
printf "%b\\n" "\033[1m Patches:\033[0m
-bfq, -ck, -ubuntu"
printf "%b\\n" "\033[1m Config:\033[0m
http://repo-ck.com/"
printf "\\n"
printf "%b\\n" "\033[1m----------------\033[7m Current Configuration: edit t
he script to change them \033[0m\033[1m--------------\033[0m"
printf "%s\\n" " build path:
$tmp_path"
printf "%s\\n" " kernel:
$patchkernel"
printf "%s\\n" " -bfq patchset:
$bfq"
$ $@"
status=$?
[ X"$status" != X"0" ] && exit $status || return
}
_cmdsudo()
{ #print && execute a command, exits if command fails
[ -z "$1" ] && return 1
_cmdsudo_var_serr=$$
printf "%s " "
$ $@"
printf "\\n"
printf "%s\\n" "$sudopwd" | $sudocmd eval "$@" > /tmp/"$_cmdsudo_var_serr".o
ut 2>&1
_cmdsudo_var_status=$?
[ X"$_cmdsudo_var_status" != X"0" ] && { cat /tmp/"$_cmdsudo_var_serr".out;
\
rm -rf /tmp/"$_cmdsudo_var_serr".out; exit $_cmdsudo_var_status; } \
|| { rm -rf /tmp/"$_cmdsudo_var_serr".out; return $_cmdsudo_var_status;
}
}
_handscui()
{
[ -z $1 ] && { printf "%5s\n" ""; return 1; }
pid=$1
animation_state=1
if [ ! "$(ps -p $pid -o comm=)" ]; then
printf "%5s\n" ""
return
fi
printf "%s" "
"
= X"root" ]; then
"Detecting user $LOGNAME (non-root) ..."
"Checking if sudo is available ..."
sudo >/dev/null 2>/dev/null; printf "%s\\n" "$?"`
else
printf "%s\\n" "You're not root and sudo isn't available. Please run
this script as root!"
exit
fi
fi
}
_cleanup()
{
stty echo
printf "%b\\n" "\033[1m-------------------\033[7m Cleanup \033[0m\033[1m------------------\033[0m"
printf "%s\\n" "[+] deleting files at $tmp_path ..."
#printf "%s\\n" "$sudopwd" | $sudocmd rm -v $tmp_path/patch*
#printf "%s\\n" "$sudopwd" | $sudocmd rm -v $tmp_path/*.patch
printf "%s\\n" "$sudopwd" | _cmd $sudocmd rm -rf $tmp_path/linux-$patchkerne
l-$ckk
#printf "%s\\n" "$sudopwd" | $sudocmd mount -o remount /tmp
#rm -rf $tmp_path 2>/dev/null
if [ -z "$1" ]; then
exit
fi
}
_waitfor()
{
[ -z "$1" ] && return 1
printf "%s " "
$ $@ ..."
eval "$@" > /dev/null 2>&1 &
sleep 1s
_handscui $(pidof $1)
}
_waitforsudo()
{
[ -z "$1" ] && return 1
printf "%s " "
$ sudo $@ ..."
printf "%s" "$sudopwd" | $sudocmd $@ > /dev/null 2>&1 &
sleep 1s
_handscui $(pidof $1)
}
_header
_getroot
printf "%b\\n" "\033[1m--------------------------------\033[7m Fixing dependenci
es \033[0m\033[1m--------------------------------\033[0m"
_waitforsudo apt-get update
_waitforsudo apt-get install --no-install-recommends -y $apps_default
printf "%b\\n" "\033[1m--------------------------------\033[7m Downloading archi
ves \033[0m\033[1m-------------------------------\033[0m"
printf "%s\\n" "[+] downloading main vanilla kernel tree ..."
##TODO 05-11-2013 20:30 >> liquorix.net current configuration breaks -ck kernel
#
starting in >= 3.10, check from time to time if it ca
n be reused
#for now use config mirrored from http://repo-ck.com/
_waitfor wget "http://javier.io/mirror/3.11/config.$arqt"
_cmd cp "config.$arqt" .config
##tmp fix for bug #663474, disable lguest hypervisor, http://lguest.ozlabs.org/l
guest.txt
##http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=663474
if [ X"$arqt" = X"i386" ]; then
sed -i "/CONFIG_LGUEST_GUEST/d" .config
sed -i "/CONFIG_LGUEST/d" .config
elif [ X"$arqt" = X"amd64" ]; then
if [ ! -d ./arch/amd64 ]; then
cd arch
ln -s x86 amd64
cd fi
fi
##thanks to StefanescuCristian: https://github.com/chilicuil/learn/commit/c2d445
5
printf "%s\\n" "[+] making sure BFS and BFQ are enabled in config"
sed -i "/CONFIG_SCHED_CFS=y/d" .config
sed -i "s/# CONFIG_SCHED_BFS is not set/CONFIG_SCHED_BFS=y/g" .config
sed -i "s/# CONFIG_IOSCHED_BFQ is not set/CONFIG_IOSCHED_BFQ=y/g" .config
sed -i "s/CONFIG_DEFAULT_CFQ=y/# CONFIG_DEFAULT_CFQ is not set/g" .config
sed -i "s/CONFIG_DEFAULT_DEADLINE=y/# CONFIG_DEFAULT_DEADLINE is not set/g" .con
fig
sed -i "s/CONFIG_DEFAULT_NOOP=y/# CONFIG_DEFAULT_NOOP is not set/g" .config
sed -i "s/CONFIG_DEFAULT_IOSCHED="cfq"/CONFIG_DEFAULT_IOSCHED="bfq"/g" .config
sed -i "s/CONFIG_DEFAULT_IOSCHED="deadline"/CONFIG_DEFAULT_IOSCHED="bfq"/g" .con
fig
sed -i "s/CONFIG_DEFAULT_IOSCHED="noop"/CONFIG_DEFAULT_IOSCHED="bfq"/g" .config
sed -i "s/# CONFIG_DEFAULT_BFQ is not set/CONFIG_DEFAULT_BFQ=y/g" .config
printf "%s\\n" "[+] making sure CONFIG_HZ is set to 1000, better performance + f
ixes in resume|suspending issues"
sed -i -e 's/^CONFIG_HZ_300=y/# CONFIG_HZ_300 is not set/' \
-i -e 's/^# CONFIG_HZ_1000 is not set/CONFIG_HZ_1000=y/' \
-i -e 's/^CONFIG_HZ=300/CONFIG_HZ=1000/' .config
##printf "%s\\n" "[+] optimizying even more, using streamline_config.pl ...
"
##chmod +x ./scripts/kconfig/streamline_config.pl && ./scripts/kconfig/streamlin
e_config.pl > config_strip
###make localmodconfig
##mv config_strip .config
##printf "%s\\n" "[+] running menuconfig ...
##make menuconfig
"