S.A.K.C. - SUSE Automated Kernel Compiler - Version 2.60

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 …

The Linux Kernel Archives

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,

another fine tool which i won’t be able to try for awhile, but much appreciated (i want TRIM :p).

your contributions have been helpful to many and time consuming on your part i’m sure.

kudos.

Wow James version 2.0 looks really amazing I will try it out soon

Thanks a lot :slight_smile:

Thanks ah7013 & j_xavier for your kind words. I have been working on the new interface for a couple of weeks, but the last three nights, it is practically all I have been doing. If there is one things for sure, any computer within my reach has a new kernel installed on it. lol!

Thank You,

first of all, thanks jdmcdaniel3 for ur work.
i used yesterday 1.3 version on suse 11.3 64 bits, and every thing went smooth. today i wanted to do the same thing for exact/similar pc, and wanted to try version 2.0 but i got errors and it was hard to see what it was saying, coz the line were mixed. so i tried 1.3 the it stated more clear what was going on. i also noticed that in the folder where i downloaded the kernel (~/Doenloads) after decompressing, the decompressed folder was deleted automatically and 1.3 version display “…file does not exist”. but i noticed that the decompressed folder was created (or maybe moved to) in ~. so i just moved it back to ~/Downloads and run 1.3 again and every thing seems to be fine now (still compiling). its really weird, coz it worked for another pc like charm. just wanted to let know, in case some one is having the same problem.

Version 1.30:

 S.A.K.C. - SUSE Automated Kernel Compiler - Version 1.30 

 Converting Kernel bz2 file to a tar file.  Please wait. 

  /home/nastea/Downloads/linux-2.6.37-rc5.tar.bz2: done

 Extracting Kernel Tar Files.       Please wait....      
/home/nastea/bin/sakc_1.3: line 241: cd: /home/nastea/Downloads/linux-2.6.37-rc5: No such file or directory

 Kernel Configuration Process for Kernel file name: /home/nastea/Downloads/linux-2.6.37-rc5.tar.bz2

 You may be required to press <enter> more than once to accept a (NEW) Kernel  
 option default. Any new Kernel hardware detection modules added from your     
 existing Kernel, will ask if they should be included.  The options are y=yes, 
 n=no, m=Module (create a module for possible loading, if present) ?=Help with 
 the default shown as a capital letter and just pressing <enter> will select.  

When you are ready, Press the <enter> key to continue ..... (CTRL-C to abort)

Version 2.0:

12/11/10                                 /home/nastea/Downloads/linux-2.6.37-rc5
                                  --------------------------------------------------------------------------------
                                              S.A.K.C. - SUSE Automated Kernel Compiler - Version 2.00            
                                  --------------------------------------------------------------------------------
                                                Your Kernel file has been Compiled Successfully!             /home/nastea/bin/sakc_2.0: line 395: /usr/bin/play: No such file or directory----------------------------------------------------------------------------
                                   Num          Function                    Status                      Exit Code 
                                  --------------------------------------------------------------------------------

                                    1.  Kernel File Decompression:         Completed!                       0     

                                    2.  Kernel File Configuration:         Completed!                       2     

                                    3.  Kernel File Compile Process:       Completed!    0   minute(s) /home1nastea/bin/sakc_2.0: line 356: /home/nastea/Documents//home/nastea/Downloads/linux-2.6.37-rc5.101211.133837.txt: No such file or directory
/home/nastea/bin/sakc_2.0: line 357: /home/nastea/Documents//home/nastea/Doroot's password:6.37-rc5.101211.133837.txt: No such file or directory
/home/nastea/bin/sakc_2.0: line 358: /home/nastea/Documents//home/nastea/Downloads/linux-2.6.37-rc5.101211.133837.txt: No such file or directory
/home/nastea/bin/sakc_2.0: line 360: /home/nastea/Documents//home/nastea/Downloads/linux-2.6.37-rc5.101211.133837.txt: No such file or directory
                                                                                                        
                                  --------------------------------------------------------------------------------

Here is how I normally use S.A.K.C on openSUSE 11.3 Before you start, I would delete any kernel compile folder for a version I am compiling that already existed. I would do this if I was just testing a kernel I compiled again or if I had a problem with the previous compile.

  1. I download the latest kernel source file from: The Linux Kernel Archives.
  2. By default the files go into my home area Downloads folder (~/Downloads).
  3. I open a terminal session and change to the Downloads folder and run the command:
james@linux-ew60:~/Downloads> sakc linux-2.6.37-rc5.tar.bz2

S.A.K.C. by default creates a Log file in your ~/Documents folder and any folder name specified in S.A.K.C. should not have a back slash added to the end of its name. That is ~/Documents is good and ~/Documents/ is bad and should not be used.

In S.A.K.C., if the Exit Code is not “0” for one of the four functions, then that function has failed and going on will most likely not work properly for you.

Here are some others things to note:

  1. Keep all Kernel Source Compile folders as long as you use that kernel version. Having the source to the loaded kernel is imported for many operations like loading a proprietary video driver.

  2. Kernel Source Compile folders can take up a lot of room. Between 6 and 7 GB each! If you have upgraded to a newer kernel (like going from kernel-2.6.37-rc4 to kernel-2.6.37-rc5, then DELETE the older kernel compile folder called kernel-2.6.37-rc4 and remove the kernel loads lines from your grub menu.lst file and save some room. Any kernel you want an option to use, keep the compile folder and its load option in your menu.lst file.

Thank You,

oh, stupid me… i just noticed my mistake, i did not inclide the path to Downloads in my command, thats why every thing was saving to home folder and not in Downloads. even though, i tried again, and with version 2.0 but it is finishing in a few seconds, saying every thing went ok. version 1.3 is working fine. thats is the output, pay atention to start and end time:

12/11/10                                      /home/stasik/test/linux-2.6.37-rc5
                                                    --------------------------------------------------------------------------------
                                                                S.A.K.C. - SUSE Automated Kernel Compiler - Version 2.00            
                                                    --------------------------------------------------------------------------------
                                                                    Your Kernel file Has Been Installed Successfully                /stasik/test/sakc_2.0: line 405: /home/stasik/Documents//home/stasik/test/linux-2.6.37-rc5.101211.145019.txt: No such file or directory-------------------------------------------------
/home/stasik/test/sakc_2.0: line 406: /home/stasik/Documents//home/stasik/test/linux-2.6.37-rc5.101211.145019.txt: No such file or directory
/home/stasik/test/sakc_2.0: line 407: /home/stasik/Documents//home/stasik/test/linux-2.6.37-rc5.101211.145019.txt: No such file or directory
/home/stasik/test/sakc_2.0: line 409: /home/stasik/Documents//home/stasik/test/linux-2.6.37-rc5.101211.145019.txt: No such file or directory
/home/stasik/test/sakc_2.0: line 319: /home/stasik/Documents//home/stasik/test/linux-2.6.37-rCompleted!   019.txt: No such fil0 or directory
/home/stasik/test/sakc_2.0: line 320: /home/stasik/Documents//home/stasik/test/linux-2.6.37-rc5.101211.145019.txt: No such file or directory
/home/stasik/test/sakc_2.0: line 321: /home/stasik/Documents//home/stasik/test/linux-2.6.37-rCompleted!   019.txt: No such fil1 or directory
/home/stasik/test/sakc_2.0: line 323: /home/stasik/Documents//home/stasik/test/linux-2.6.37-rc5.101211.145019.txt: No such file or directory
                                                      3.  Kernel File Compile Process:       Completed!    0   minute(s) /home1stasik/test/sakc_2.0: line 356: /home/stasik/Documents//home/stasik/test/linux-2.6.37-rc5.101211.145019.txt: No such file or directory
/home/stasik/test/sakc_2.0: line 357: /home/stasik/Documents//home/stasik/test/linux-2.6.37-rCompleted!      .txt: No such fil1 or directory
/home/stasik/test/sakc_2.0: line 358: /home/stasik/Documents//home/stasik/test/linux-2.6.37-rc5.101211.145019.txt: No such file or directory
/home/stasik/test/sakc_2.0: line 420: /home/stasik/D Compile Start: 12/11/10-14:50:43             Compile Finish: 12/11/10-14:50:43 irectory
/home/stasik/test/sakc_2.0: line 421: /home/stasik/Documents//                                                             file or directory
/home/stasik/test/sakc_2.0: line 422: /home/stasik/D  Script Start: 12/11/10-14:50:19              Script Finish: 12/11/10-14:50:58 irectory
/home/stasik/test/sakc_2.0: line 423: /home/stasik/Documents//home/stasik/test/linux-2.6.37-rc5.101211.145019.txt: No such file or directory
/home/stasik/test/sakc_2.0: line 424: /home/stasik/Documents//home/stasik/test/linux-2.6.37-rc5.101211.145019.txt: No such file or directory

So my intent was to run S.A.K.C. from the downloads folder, or which ever folder contains the kernel source file. So again, if we downloaded kernel linux-2.6.36.2.tar.bz2 in to my home area ~/Downloads folder I would open a terminal session and do the following commands:

james@linux-ew60:~> cd Downloads
james@linux-ew60:~/Downloads> sakc linux-2.6.36.2.tar.bz2

Why not try running S.A.K.C. this way and see if it works OK for you? Don’t include the folder name with the kernel name, but rather BE in the folder with the kernel when you start S.A.K.C.

Thank You,

i do not change any thing in ur script. i do the same things fo both 1.3 and 2.0. this is what i do:
-place both script and kernel in one folder
-open shell and cd to that folder
-drag-n-drop script onto shell, “space”, drag-n-drop kernel to shell, “enter”
i get this:
stasik@adsl-99-99-99-101:~> cd /home/stasik/test/
stasik@adsl-99-99-99-101:~/test> /home/stasik/test/sakc_2.0 /home/stasik/test/linux-2.6.37-rc5.tar.bz2

i do not change any thing in ur script. i do the same things fo both 1.3 and 2.0. this is what i do:
-place both script and kernel in one folder
-open shell and cd to that folder
-drag-n-drop script onto shell, “space”, drag-n-drop kernel to shell, “enter”
i get this:
stasik@adsl-99-99-99-101:~> cd /home/stasik/test/
stasik@adsl-99-99-99-101:~/test> /home/stasik/test/sakc_2.0 /home/stasik/test/linux-2.6.37-rc5.tar.bz2

So I don’t know what you mean when you say ‘-drag-n-drop script onto shell, “space”, drag-n-drop kernel to shell, “enter”’.

Here is how I would do the same thing I think you are saying…

  1. Copy both files sakc_2.00 (script is marked executable) and *linux-2.6.37-rc5.tar.bz2 to the */home/stasik/test folder using Dolphin or other file manager.

  2. Open a Terminal session

  3. *cd /home/stasik/test folder (notice you do not need that last backslash)

  4. *I can just type “sack_2.0 *linux-2.6.37-rc5.tar.bz2” *since both files are already in the same folder.There is no need to include the folder names for the default folder you are in when running sakc if all of the files are loaded in the default folder.

Further, the intent on S.A.K.C. was to be placed it in your /home/yourname/bin folder so it does not need to be loaded anywhere else and you do not need to specify its location or copy it to the same folder as your kernel source file. When you type the name sakc, it just runs without being in the same folder or specifying its location.

*Thank You,

by drag-and-drop, i mean i grab the file, from the folder, and move it over shell/terminal, this way the path appear, i dont type it. i know that script should be in the bin and u could run without full path, but writing the path should not do any harm.
anyway, version 1.3 is working fine for me. maybe i just do something wrong with 2.0, i am not expert, so sh*t may happen). thanks for ur work!

stasiuneaat in the new S.A.K.C. script change the function called folder_name to read:

#
# Extract Kernel Folder Name from bz2 File Name
#
function folder_name {
  shortname=$(basename $1)
  NUM=${#shortname}
  folder="${shortname:0:$(($NUM-8))}"
}

This change allows the CD $folder command to work properly.

The reason for this is the tar command will untar a file that is somewhere else if you include the path, but the file will be untared in the present default folder. When sakc tries to change to the new kernel folder where the bz2 file existed, it is not there, but rather in the default folder (not in the folder where the source bz2 file existed) and thus the error.

The original sakc first converted the file from bz2 to tar and then from tar to its root folder name. The tar file would exist in the default folder and so that worked OK as done originally. This then dealt with the default folder in a different way. While I have ran sakc version 2 many times, I always did it the same way and not the way you are doing it.

The fix above should make it work OK for you. I ask of you can give it a try to see if it will work alright.

Thank You,

i renamed “folder_name” to “read” and now the output looks much better. how long should it take before i have to input root password? mine took a few seconds, and the linux folder is only 300 mb but not 7gb like the previous installation. did the compilation failed? or the compilation starts when i input the pass?? thats the output of the execution of the script just in a few seconds:

--------------------------------------------------------------------------------
1.  Kernel File Decompression:         Completed!                       0     
2.  Kernel File Configuration:         Completed!                       2     
3.  Kernel File Compile Process:       Completed!    0   minute(s)      2     
4.  Kernel File Installation:          root's password:                       
 --------------------------------------------------------------------------------

what is the story with: line 395: /usr/bin/play: No such file or directory ?? always appear in v2.0

The following code in S.A.K.C. allows you to turn on or off sound after the compile is complete. I added one new comment line about sox.

#
# Do You Wish SAKC to play a Sound When the Compile is complete? (true / false)
# **play** is included with the --> sox <-- application found in YaST
#

Play_Sound=true
wav_Player=/usr/bin/play
wav_File=/usr/share/sounds/alsa/test.wav

You can set Play_Sound=true or Play_Sound=false. If true, then it expects to use the program called play to play a wav file from your alsa folder. The program play can be found in the package called sox in YaST / Software Management. Open up Software Management, search on sox and install the application, then this will work for you.

Thank You,

#
# Extract the base Kernel Folder Name from .tar.bz2 File Name
#
function folder_name {
  shortname=$(basename $FILE)
  NUM=${#shortname}
  folder="${shortname:0:$(($NUM-8))}"
}

OK, try this code section. I forgot that $1 has to do with just this function and so it must refer to the $FILE I set at the start of S.A.K.C. Sorry about that.

Thank You,

so i replaced

function folder_name {
  NUM=${#FILE}
  folder="${FILE:0:$(($NUM-8))}"
  NUM=${#folder}
}

from the original 2.0 version code with

function folder_name {
  shortname=$(basename $FILE)
  NUM=${#shortname}
  folder="${shortname:0:$(($NUM-8))}"
}

and every thing seems to be fine now. i didnt proceed with the installation, but compilation completed successfully. i ll find out at the next kernel release, but i am sure every thing will be ok.
thanks again:good::good::good:

Following is version 2.10 of S.A.K.C. which fixes the folder issue that can occur if you extract an archive located in another folder that is not in the default folder. I have changed the sound player so that it does not run if the play program is not found. I setup S.A.K.C. so that any of the four functions fail, the program just exits. There are other changes as well. Hopefully this will work better for you.

http://thumbnails30.imagebam.com/11046/83ee2a110459117.jpg](http://www.imagebam.com/image/83ee2a110459117)

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   : Sat Dec 11 13:47:00 CST 2010
#: Author      : J. McDaniel
#: Version     : 2.10
#: Description : Kernel Compile Script for openSUSE
#: Options     : sakc kernel_file_name.bz2

TITLE="            S.A.K.C. - SUSE Automated Kernel Compiler - Version 2.10            "

FILE=$1

script_start=$(date +%m/%d/%y-%H:%M:%S)

#
# Written for the openSUSE forums on Saturday December 11, 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 is included with the --> sox <-- application found in YaST
#
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 Elapsed 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 the base Kernel Folder Name from .tar.bz2 File Name
#
function folder_name {
  shortname=$(basename $FILE)
  NUM=${#shortname}
  folder="${shortname: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) ON_LINE=10
     Exit_Code=$uncompress_exit ;;
      2) ON_LINE=12
     Exit_Code=$configure_exit ;;
      3) ON_LINE=14
     Exit_Code=$compile_exit ;;
      4) ON_LINE=16
         Exit_Code=$install_exit ;;
      *) ;;
    esac
    print_color $(( ON_LINE )) 74 7 0 1 "$Exit_Code"
    if  $(( Exit_Code )) -ge 1 ] ; then
      print_color $(( ON_LINE )) 41 4 0 1 "Failed!   "
      exit $Exit_Code
    else
      print_color $(( ON_LINE )) 41 7 0 1 "Completed!   "
    fi
  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
# 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
}

function log_heading {
echo " " >> $log_file_name
echo "*********** Command: $1 *********************" >> $log_file_name
echo " " >> $log_file_name
}

function log_complete {
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
}

#
# 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

#
# S.A.K.C. Kernel Decompression ***********************************************
#

# Your Kernel file is now being uncompressed.  Please Wait ...
status_display 1

tar -vxjf $FILE > /dev/null 2>&1
uncompress_exit=$?

progress_display 1

cd $folder

#
# S.A.K.C. Kernel Configuration ***********************************************
#

# Your Kernel file is now being Configured.    Please Wait ...
status_display 2

log_heading "make mrproper"

# Fix any left over compile issues before we start again

make mrproper >> $log_file_name 2>&1

# Get the Configuration for the running kernel

zcat /proc/config.gz >.config 

log_heading "make oldconfig"

# Take the defaults for all new kernel module configurations

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

#
# S.A.K.C. 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 $show_time ; then
  time_display
fi

if  $Jobs -ge 2 ] ; then

  log_heading "make -j$Jobs"
  
  make -j$Jobs >> $log_file_name 2>&1
  compile_exit=$?

else

  log_heading "make"

  make >> $log_file_name 2>&1
  compile_exit=$?
fi

# Kill Background Elasped Time Display shown during 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
#

which $wav_Player > /dev/null 2>&1
error_code1=$?

which $wav_File > /dev/null 2>&1
error_code2=$?

if $Play_Sound ; then
  if  $(( error_code1 )) -eq 0 ] ||  $(( error_code2 )) -eq 0 ] ; then
    $wav_Player -q $wav_File
  fi
fi

#
# S.A.K.C. Kernel Install *****************************************************
# 

get_password
status_display 6

log_heading "make modules_install install"

sudo make modules_install install >> $log_file_name 2>&1
install_exit=$?

progress_display 4

#
# S.A.K.C. is Complete ********************************************************
#

script_stops=$(date +%m/%d/%y-%H:%M:%S)

log_complete

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 …

The Linux Kernel Archives

Into your downloads folder. Open up a terminal session, change to your downloads folder and run the command:

sakc kernel_name

If you have any comments, problems or requests, please let me know.

Thank You,

Following is a companion file to S.A.K.C. and its purpose is to do the following:

  1. List all kernel source files in your default ~/Downloads Folder
  2. Allow you to select the kernel to compile from a list without knowing the exact name
  3. Change to the default kernel compile folder ~/Kernel
  4. Start S.A.K.C. with the name and path to the kernel source file you selected.

For this to work, first you already have downloaded and made active the S.A.K.C. script file, second you must make sure the following three lines in klist are correct. Change to match your setup and/or create the required folders. The three lines you must make sure are correct read:


#
# Please Make Sure these names are correct - Do not include a "/" at the end...
#
kernel_folder=~/Downloads
compile_folder=~/Kernel
sakc_name=~/bin/sakc

Copy and Paste the text of this script into a text editor and save it as the file klist in your home area bin folder (~/bin/klist).

#!/bin/bash

#: Title       : klist - Kernel Lister/Selector
#: Date Created: Sun Dec 19 17:39:18 CST 2010
#: Last Edit   : Sun Dec 19 21:12:00 CST 2010
#: Author      : J. McDaniel
#: Version     : 1.00
#: Description : run sakc compiler & list kernel source files
#: Options     : klist [kerenl_source_file.tar.bz2]

#
# Written for the openSUSE forums on Sunday December 19, 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/klist).
# This script must be marked executable to be used.  Please run 
# the following Terminal command: chmod +x ~/bin/klist
# To use klist, 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: klist

#
# klist requires that the S.A.K.C. script file is already loaded on your computer
#

#
# Please Make Sure these names are correct - Do not include a "/" at the end...
#

kernel_folder=~/Downloads
compile_folder=~/Kernel
sakc_name=~/bin/sakc


# Check to make sure klist was not started as Root

if  $UID -eq 0 ] ; then
  echo "Please Do Not Run $0 as a Root User!"
  exit 1
fi

# Make sure the sakc file exists in the folder specified

if  ! -e $sakc_name ] ; then
  echo "The Kernel Compiler $sakc_name was not found!"
  exit 1
fi 

# Determine if a kernel file name was given at start

if  $# -eq 0 ] ; then

  tput clear
  echo "S.A.K.C. Kernel Selection Menu"
  echo

# Determine if the compile_folder exists

  if  -d $compile_folder ]] ; then
    cd $compile_folder
  else
    echo "The Folder $compile_folder does not exist!"
    echo "Please create this folder and start $0 again."
    exit 1
  fi

# Determine if the kernel_folder Exists

  if  -d $kernel_folder ]] ; then

    declare -a kernels

# Find and display all files that start with linux and end with .bz2

    for i in $kernel_folder/linux*.bz2 ; do 
      let counter=counter+1
      kernels$counter]=$i 
      echo "$counter) ${kernels$counter]}"
    done

    echo
    echo -n "Please Select the Kernel You wish to use: "
    read CHOICE

    $sakc_name ${kernels$CHOICE]}
    exit 0
  else
    echo "Folder $kernel_folder does not exist"
    exit 1
  fi

else

# For this to be used, you suplied the full name/path to the kernel 
# and just switched to your kernel compile folder

  $sakc_name %1

fi

exit 0

# End Of Script


This script must be marked executable to be used. Please run the following Terminal command:

chmod +x ~/bin/klist

To use klist, download the latest kernel source files from …

The Linux Kernel Archives

Into your downloads folder. Open up a terminal session, change to your downloads folder and run the command:

klist

Again, you must already have the S.A.K.C. script file on your computer before you can use klist. If you have any comments, problems or requests, please let me know.

Thank You,

Into your downloads folder. Open up a terminal session, change to your downloads folder and run the command:
The above statement is not exactly true when you use klist in that you no longer need to change to your downloads folder. klist will change to the kernel compile folder as you modified klist to say/do. This error in directions is just what you get when you copy text from one message to another. Sorry for this error.

Thank You,

Hi there,
great program - i just love it. Although I do not really post here in the forum very often I do read along alot here :slight_smile:

Just one suggestion/question: Wouldn’t it be good to put the code of the latest version in the start-post of this thread? Or maybe a hint in which post one will find the latest version?

I think it would make it easier to keep people up-to-date on the latest version; especially when they have just found the threads about the s.a.k.c. :slight_smile:

Best regards,

(and sorry for my english)