I am Happy To announce S.A.K.C. Version 2.00 with a brand new user interface. Here is what you are in store for:
http://thumbnails9.imagebam.com/11035/0116e9110340010.jpg](http://www.imagebam.com/image/0116e9110340010)
S.A.K.C. Version 2.00 includes all of the features of the previous version plus all text output from your Kernel Configuration, Compiling and Installation are saved to a text file for viewing right after the new Kernel is installed and later as well. You no longer need to press enter to take the many defaults for your new kernel configuration. As your new Kernel compiles, the minutes tick off for you to see. Please download and enjoy S.A.K.C. Version 2.00. I welcome your comments…
Copy and Paste the text of this script into a text editor and save it as the file sakc in your home area bin folder (~/bin/sakc).
#!/bin/bash
#: Title : S.A.K.C. - SUSE Automated Kernel Compiler
#: Date Created: Wed Dec 8 19:10:59 CST 2010
#: Last Edit : Fri Dec 10 16:51:00 CST 2010
#: Author : J. McDaniel
#: Version : 2.00
#: Description : Kernel Compile Script for openSUSE
#: Options : sakc kernel_file_name.bz2
TITLE=" S.A.K.C. - SUSE Automated Kernel Compiler - Version 2.00 "
FILE=$1
script_start=$(date +%m/%d/%y-%H:%M:%S)
#
# Written for the openSUSE forums on Friday December 10, 2010
#
#
# Copy and Paste the text of this script into a text editor and save
# it as the file sakc in your home area bin folder (~/bin/sakc).
# This script must be marked executable to be used. Please run
# the following Terminal command: chmod +x ~/bin/sakc
# To use sakc, download the latest kernel source files from ...
# http://www.kernel.org/ into your download(s) folder.
# Open up a terminal session, change to your download(s) folder
# and run the command: sakc kernel_name
#
#
# Set Number of Compile Jobs based on number of CPU's times two
#
Number_CPUS=$(grep "processor" /proc/cpuinfo | wc -l)
Jobs=$(($Number_CPUS+$Number_CPUS))
#
# Do You Wish SAKC to play a Sound When the Compile is complete? (true / false)
#
Play_Sound=true
wav_Player=/usr/bin/play
wav_File=/usr/share/sounds/alsa/test.wav
#
# Time Display Function. Do you want the Elasped time displayed while your compile is running?
#
show_time=true
#
# Kernel Compile/Configuration Log File . Do you wish to save all information for viewing later?
#
log_file=true
log_file_location=~/Documents
#
# S.A.K.C. Function Blocks ****************************************************
#
#
# Display All Text in Color as requested
#
# syntax: print_color line col fgrd_color bgrd_color #lines "text"...
#
# 0: Black 1: Blue 2: Green 3: Cyan 4: Red 5: Magenta 6: Yellow 7: White
#
function print_color {
WIDTH=`tput cols`
HEIGHT=`tput lines`
line_os=0
col_os=$((( $WIDTH - 80) / 2 ))
s_line=$1
s_col=$2
fgrd=$3
bgrd=$4
maxnum=$5
counter=0
while $(( counter )) -lt $(( maxnum + 1 )) ] ; do
tput cup $(( s_line + counter + line_os)) $(( s_col + col_os ))
tput bold
tput setf $(( fgrd ))
tput setb $(( bgrd ))
echo "$6$(tput sgr0)"
let counter=counter+1
shift
done
}
#
# Display Active Time While doing the compile / This runs in the background
#
function time_display {
tput cup $(( 14 + line_os)) $(( 41 + col_os ))
echo -n "Elapsed Time: 0 minute(s) "
while true ; do let comp_time=comp_time+1 && sleep 60 && tput cup $(( 14 + line_os)) $(( 55 + col_os )) && echo -n "$comp_time$(tput sgr0)" ; done &
PID1=$!
}
#
# Extract Kernel Folder Name from bz2 File Name
#
function folder_name {
NUM=${#FILE}
folder="${FILE:0:$(($NUM-8))}"
NUM=${#folder}
}
#
# S.A.K.C. Main Header Display
#
function display_header {
tput clear
print_color 1 0 7 0 1 "$(date +%m/%d/%y)"
print_color 1 $((80-NUM)) 7 0 1 "$folder"
print_color 3 0 7 2 1 "$TITLE"
l1="--------------------------------------------------------------------------------"
l2=""
l3="--------------------------------------------------------------------------------"
l4=""
l5="--------------------------------------------------------------------------------"
l6=" Num Function Status Exit Code "
l7="--------------------------------------------------------------------------------"
print_color 2 0 3 0 7 "$l1" "$l2" "$l3" "$l4" "$l5" "$l6" "$l7"
l1=" 1. Kernel File Decompression: "
l2=""
l3=" 2. Kernel File Configuration: "
l4=""
l5=" 3. Kernel File Compile Process: "
l6=""
l7=" 4. Kernel File Installation: "
print_color 10 0 7 0 7 "$l1" "$l2" "$l3" "$l4" "$l5" "$l6" "$l7"
l1="--------------------------------------------------------------------------------"
l2=""
l3="--------------------------------------------------------------------------------"
print_color 18 0 3 0 3 "$l1" "$l2" "$l3"
}
#
# S.A.K.C. top status display
#
function status_display {
case $1 in
1) print_color 5 0 7 1 1 " Your Kernel file is now being uncompressed. Please Wait ... " ;;
2) print_color 5 0 6 1 1 " Your Kernel file is now being Configured. Please Wait ... " ;;
3) print_color 5 0 7 4 1 " Would you like to modify your Kernel configurations in a GUI? " ;;
4) print_color 5 0 7 1 1 " Your Kernel file is now being Compiled. Please Wait ... " ;;
5) print_color 5 0 7 4 1 " Your Kernel file has been Compiled Successfully! " ;;
6) print_color 5 0 6 1 1 " Your Kernel file is now being Installed. Please Wait ... " ;;
7) print_color 5 0 7 4 1 " Would you like to view your Kernel Config/Compile/Install Log File? " ;;
8) print_color 5 0 7 1 1 " Your Kernel file Has Been Installed Successfully " ;;
*) ;;
esac
tput cup $(( 5 + line_os)) $(( 75 + col_os ))
}
#
# S.A.K.C. Kernel Function progress display
#
function progress_display {
for ((i=1;i<=$1;++i)) ; do
case $i in
1) print_color 10 41 7 0 1 "Completed! "
print_color 10 74 7 0 1 "$uncompress_exit" ;;
2) print_color 12 41 7 0 1 "Completed! "
print_color 12 74 7 0 1 $configure_exit ;;
3) print_color 14 41 7 0 1 "Completed! "
print_color 14 74 7 0 1 $compile_exit ;;
4) print_color 16 41 7 0 1 "Completed! "
print_color 16 74 7 0 1 $install_exit ;;
*) ;;
esac
done
}
#
# Get User Input Display
#
function get_input {
print_color 19 10 7 0 1 " Please make your selection and press <enter> (Y=Yes/N=No): "
tput cup $(( 19 + line_os)) $(( 69 + col_os ))
read CHOICE
print_color 19 10 7 0 1 " "
}
#
# Get User Input & password Display
#
function get_password {
print_color 19 9 7 0 1 " Press the <enter> key to proceed to your Kernel Instalation "
tput cup $(( 19 + line_os)) $(( 69 + col_os ))
read CHOICE
print_color 19 9 7 0 1 " "
tput cup $(( 16 + line_os)) $(( 41 + col_os ))
sudo dir > /dev/null
tput cup $(( 16 + line_os)) $(( 41 + col_os ))
echo " "
}
#
# Prompt for user input in bold while, for startup error messages
#
function enter_prompt {
echo
tput bold
tput setf 7
tput cup $(( 4 + line_os)) $(( 0 + col_os ))
echo -n "$1$(tput sgr0)"
read CHOICE
echo
}
#
# Setup Name and Location of your Log File
#
function start_log {
ext=$(date +%y%m%d.%H%M%S)
if $log_file ; then
log_file_name=$log_file_location"/"$folder"."$ext".txt"
else
log_file_name="/dev/null"
fi
}
#
# S.A.K.C. Display Error MEssages *********************************************
#
# Make sure script was not started as root
tput clear
if $UID -eq 0 ] ; then
l1=""
l2=" Do Not Start $(basename $0) as a root user! Your password will be "
l3=" requested later when needed to install your new Kernel. "
print_color 0 0 7 4 4 "$TITLE" "$l1" "$l2" "$l3"
enter_prompt "Press <enter> to exit..."
exit 2
fi
# Make sure we got kernel source file name as a command line argument
if $# -eq 0 ] ; then
l1=""
l2=" Command Syntax is: $(basename $0) kernel_source_file_name.tar.bz2 "
l3=""
print_color 0 0 7 4 4 "$TITLE" "$l1" "$l2" "$l3"
enter_prompt "Press <enter> to exit..."
exit 1
fi
# Determine if kernel file-name is present
if ! -e $FILE ] ; then
l1=""
l2=" The Kernel Source file: --> $1 <-- was not Found! "
l3=""
print_color 0 0 7 4 4 "$TITLE" "$l1" "$l2" "$l3"
enter_prompt "Press <enter> to exit..."
exit 10
fi
#
# S.A.K.C. Main Program Starts Here *******************************************
#
folder_name
start_log
display_header
#
# Kernel Uncompression ********************************************************
#
# Your Kernel file is now being uncompressed. Please Wait ...
status_display 1
# Start The Log File Output if Selected
echo "$TITLE" > $log_file_name
echo " " >> $log_file_name
echo " S.A.C.K. Start: $script_start of kernel: $folder " >> $log_file_name
echo " " >> $log_file_name
tar -vxjf $FILE > /dev/null 2>&1
uncompress_exit=$?
progress_display 1
cd $folder
#
# Kernel Configuration ********************************************************
#
# Your Kernel file is now being Configured. Please Wait ...
status_display 2
# Log File Header for make mrproper
echo " " >> $log_file_name
echo "*********** Command: make mrproper *********************" >> $log_file_name
echo " " >> $log_file_name
make mrproper >> $log_file_name 2>&1
# Get the Configuration for the running kernel
zcat /proc/config.gz >.config
# Take the defaults for all new kernel module configurations
# Log File Output for ALL Kernel Hardware Modules
echo " " >> $log_file_name
echo "*********** Command: make oldconfig *********************" >> $log_file_name
echo " " >> $log_file_name
yes "" | make oldconfig >> $log_file_name 2>&1
configure_exit=$?
# Would you like to modify your Kernel configurations in a GUI?
status_display 3
get_input
if $CHOICE == [Yy] ]] ; then
tput clear
make menuconfig
configure_exit=$?
display_header
fi
progress_display 2
#
# Kernel Compile **************************************************************
#
start_of_compile=$(date +%m/%d/%y-%H:%M:%S)
# Your Kernel file is now being Compiled. Please Wait ...
status_display 4
if $Jobs -ge 2 ] ; then
if $show_time ; then
time_display
fi
# Kernel Log File Entry for Compiling with Jobs set
echo " " >> $log_file_name
echo "*********** Command: make -j$Jobs *********************" >> $log_file_name
echo " " >> $log_file_name
make -j$Jobs >> $log_file_name 2>&1
compile_exit=$?
else
if $show_time ; then
time_display
fi
# Kernel Log File Entry for Compiling without Jobs set
echo " " >> $log_file_name
echo "*********** Command: make *********************" >> $log_file_name
echo " " >> $log_file_name
make >> $log_file_name 2>&1
compile_exit=$?
fi
# Kill Background Elasped Time Display while doing the compile
if $show_time ; then
disown $PID1
kill -9 $PID1
fi
progress_display 3
end_of_compile=$(date +%m/%d/%y-%H:%M:%S)
status_display 5
#
# Play a Sound file When the Compile is Complete
#
if $Play_Sound ; then
$wav_Player -q $wav_File
fi
#
# Kernel Install **************************************************************
#
get_password
status_display 6
echo " " >> $log_file_name
echo "*********** Command: make modules_install install *********************" >> $log_file_name
echo " " >> $log_file_name
sudo make modules_install install >> $log_file_name 2>&1
install_exit=$?
progress_display 4
#
# SAKC is Complete ************************************************************
#
script_stops=$(date +%m/%d/%y-%H:%M:%S)
echo " " >> $log_file_name
echo " Compile Start: $start_of_compile Compile Finish: $end_of_compile " >> $log_file_name
echo " Script Start: $script_start Script Finish: $script_stops " >> $log_file_name
echo " " >> $log_file_name
echo "$TITLE" >> $log_file_name
if $log_file ; then
# Would you like to view your Kernel Config/Compile Log File?
status_display 7
get_input
if $CHOICE == [Yy] ]] ; then
less $log_file_name
fi
fi
# Your Kernel file Has Been Installed Successfully
status_display 8
print_color 18 0 7 1 1 " Compile Start: $start_of_compile Compile Finish: $end_of_compile "
print_color 20 0 7 1 1 " Script Start: $script_start Script Finish: $script_stops "
tput cup 24 0
exit 0
# End Of Script
This script must be marked executable to be used. Please run the following Terminal command:
chmod +x ~/bin/sakc
To use sakc, download the latest kernel source files from …
Into your downloads folder. Open up a terminal session, change to your downloads folder and run the command:
sakc kernel_name
You can always find the most recent compiler in my blog here: http://forums.opensuse.org/blogs/jdmcdaniel3/s-k-c-suse-automated-kernel-compiler-version-2-50-34/
If you are looking to download ANY kernel version back to 2.6.11 (2005) look at my SGTB bash script here: http://forums.opensuse.org/blogs/jdmcdaniel3/sgtb-suse-git-kernel-tarball-creator-version-1-31-53/
If you have any comments, problems or requests, please let me know.
Thank You,