Info:
By James D. McDaniel, 1 Year ago, written in Bash. This post will never expire.
- #!/bin/bash
- #: Title : S.A.K.C. - SUSE Automated Kernel Compiler
- #: Date Created: Wed Dec 8 19:10:59 CST 2010
- #: Last Edit : Sun Apr 22 16:53:00 CST 2012
- #: Author : J. McDaniel
- #: Version : 2.71
- #: Description : Kernel Compile Script for openSUSE
- #: Options : sakc [-h --help] [kernel_file_name.bz2]
- TITLE=" S.A.K.C. - SUSE Automated Kernel Compiler - Version 2.71 "
- Dash1="----------------------------------------------------------"
- FILE=$1
- declare -a configs
- declare -a kernels
- #
- # Written for the openSUSE forums on Sunday April 22, 2012
- #
- #
- # 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
- #
- #
- # Make Sure the Following Folder/File names are correct and exist!!!
- #
- #
- # Where do you Keep/Download Your Kernel Source Files? This Folder Name Must Exist!
- #
- kernel_folder=$HOME/Downloads
- #
- # Where do you want to place your Compiled Kernels? This Folder Name Must Exist!
- #
- compile_folder=$HOME/Kernel
- # Where do you want to place your Saved Configs? To be inside of compile_folder above
- # As in $compile_folder/$config_folder OR /home/username/Kernel/Configs by default
- #
- config_folder=Configs
- # Where is SAKC located and what is it called (folder/name)
- # Don't Like the name sakc? Save it as anything you like,
- # but make sure this is the name/location that you used!
- sakc_name=$HOME/bin/sakc
- #
- # Kernel Compile/Configuration Log File. Do you wish to save all information for viewing later?
- #
- log_file=true
- log_file_location=$HOME/Documents
- #
- # 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
- #
- # Turbo Mode Default; false or ask (Don't use true!) ******************************
- #
- turbomode=ask
- #
- # Do you want to see SAKC in color? ******************************************
- # The default is true, but can be set to false ********************************
- #
- use_color=true
- #
- # Time Display Function. Do you want the Elasped time displayed while your compile is running?
- #
- show_time=true
- # GPL Statement Output
- function show_gpl {
- echo "S.A.K.C. is designed to compile a kernel source file in openSUSE."
- echo "Copyright (C) 2011-2012 by James D. McDaniel, jmcdaniel3@austin.rr.com"
- echo
- echo "This program is free software; you can redistribute it and/or modify"
- echo "it under the terms of the GNU General Public License as published by"
- echo "the Free Software Foundation; either version 2 of the License, or"
- echo "(at your option) any later version."
- echo
- echo "This program is distributed in the hope that it will be useful,"
- echo "but WITHOUT ANY WARRANTY; without even the implied warranty of"
- echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
- echo "GNU General Public License for more details."
- echo
- echo "You should have received a copy of the GNU General Public License"
- echo "along with this program; if not, write to the Free Software"
- echo "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"
- echo
- }
- #
- # Produced using figlet *******************************************************
- #
- function banner {
- cat << "EOFBANNER"
- ____ _ _ __ ____
- / ___| / \ | |/ / / ___|
- \___ \ / _ \ | ' / | |
- ___) | / ___ \ _| . \ | |___ _
- |____(_)_/ \_(_)_|\_(_)____(_)
- ____ _ _ ____ _____
- ___ _ __ ___ _ __ / ___|| | | / ___|| ____|
- / _ \| '_ \ / _ \ '_ \\___ \| | | \___ \| _|
- | (_) | |_) | __/ | | |___) | |_| |___) | |___
- \___/| .__/ \___|_| |_|____/ \___/|____/|_____|
- |_|
- EOFBANNER
- }
- script_start=$(date +%m/%d/%y-%H:%M:%S)
- #
- # Set Number of Compile Jobs based on number of CPU's times two ***************
- #
- Number_CPUS=$(getconf _NPROCESSORS_ONLN)
- Jobs=$(($Number_CPUS+$Number_CPUS))
- #
- # S.A.K.C. Function Blocks ****************************************************
- #
- #
- # Determine file size *********************************************************
- # $2 is kB (1000), K (1024), mB (1000*1000), M (1024*1024), and so on for G, T, P, E, Z, Y.
- #
- function file_size {
- if [ -f "$1" ] ; then
- filesize=$(ls -l --block-size=$2 $1 | awk -F " " '{ print $5 }')
- else
- let filesize=0
- fi
- }
- #
- # Color Display Request - color forground background [b/n] ********************
- #
- # 0:Black 1:Blue 2:Green 3:Cyan 4:Red 5:Magenta 6:Yellow 7:White
- function color {
- if [[ $3 == [Bb] ]] ; then
- tput bold
- fi
- if [[ $3 == [Nn] ]] ; then
- tput sgr0
- fi
- if $use_color ; then
- tput setf $(( $1 ))
- tput setb $(( $2 ))
- else
- tput setf 7
- tput setb 0
- fi
- return 0
- }
- #
- # Set .config editor based on desktop *****************************************
- #
- function set_editor {
- #
- # Determine which desktop that we are using ***********************************
- #
- ps nc -C plasma-desktop >/dev/null && de=1 # For kde
- ps nc -C xfce4-panel >/dev/null && de=2 # For xfce
- ps nc -C gnome-panel >/dev/null && de=3 # For gnome2
- ps nc -C gnome-shell >/dev/null && de=4 # For gnome3
- ps nc -C lxsession >/dev/null && de=5 # lxde
- #
- # Insert the Name Of your Favorite KDE or GNOME File Editor *******************
- #
- case "$de" in
- "1") EDITOR="kwrite" ;; # For KDE
- "2") EDITOR="mousepad" ;; # For xfce
- "3") EDITOR="gedit" ;; # For gnome2
- "4") EDITOR="gedit" ;; # For gnome3
- "5") EDITOR="leafpad" ;; # For lxde
- *) exit 1 ;;
- esac
- #
- # Set Editor to what you want or prefer here just add the name and remove remark
- #
- # EDITOR="kwrite"
- return 0
- }
- #
- # 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
- if [ $(($WIDTH)) -le 80 ] ; then
- col_os=0
- else
- col_os=$((($WIDTH - 80) / 2 ))
- fi
- fgrd=${3}
- bgrd=${4}
- s_line=${1}
- s_col=${2}
- maxnum=${5}
- counter=0
- while [ $(( counter )) -lt $(( maxnum + 1 )) ] ; do
- tput cup $(( s_line + counter + line_os)) $(( s_col + col_os ))
- color $((fgrd)) $((bgrd)) B
- 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 "
- if $turbomode ; then
- print_color 1 34 4 0 1 "TURBO MODE"
- fi
- 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 +%m%d%y.%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
- }
- #
- # Common Text to Display When an Error is Detected ****************************
- #
- function error_message {
- tput clear
- color 2 0 B
- echo $Dash1
- color 7 2 B
- echo "$TITLE"
- color 2 0 B
- echo $Dash1
- color 7 0 B
- echo
- color 7 4 B
- echo "$1"
- color 7 0 B
- echo
- }
- #
- # Kernel Configuration Selector ***********************************************
- #
- function config_slection {
- config_menu=true
- delete_config=false
- edit_config=false
- while $config_menu ; do
- if $delete_config ; then
- error_message "You have elected to manually Delete a kernel config file!"
- else
- if $edit_config ; then
- error_message "You have elected to manually Edit a kernel config file!"
- else
- error_message "You have elected to manually Select the kernel config file!"
- fi
- fi
- color 6 1 B
- echo "Active Config uses your Config from your running Kernel."
- echo "Configs < 100kB in size suggest they are for Turbo Mode."
- echo "Configs from a Turbo Compile will always Compile Fast. "
- color 7 0 B
- echo
- echo "Please select the configuration file from this list:"
- echo
- let counter=0
- for i in $compile_folder/$config_folder/c* ; do
- if [ -f $i ] ; then
- let counter=counter+1
- configs[$counter]=$(basename $i)
- file_size $compile_folder/$config_folder/${configs[$counter]} KB
- color 7 0 B
- echo -n " $counter) "
- color 3 0 B
- echo -n "${configs[$counter]}, "
- color 7 0 B
- echo -n "filesize="
- color 3 0 B
- echo -n "$filesize"
- color 7 0 B
- if [ $counter -eq 1 ] ; then
- echo ", Original Default Config"
- else
- echo -n ", Ext="
- color 3 0 B
- echo "Date.Time"
- color 7 0 B
- fi
- fi
- done
- if [[ $counter -eq 0 ]]; then
- echo
- color 7 4 B
- echo "No Kernel Config Files were found in $compile_folder/$config_folder!"
- color 7 0 B
- echo
- exit 1
- fi
- echo
- if [ $delete_config == false ] && [ $edit_config == false ] ; then
- echo "Commands: S=Save, D=Delete, E=Edit or A=Active Config & Q=Quit"
- else
- echo "Commands: B=Back to Config Select or Q=Quit"
- fi
- echo
- color 7 1 B
- if $delete_config ; then
- echo -n "Please Select Kernel Config File # [1-$counter] or (Q/B): "
- else
- if $edit_config ; then
- echo -n "Please Select Kernel Config File # [1-$counter] or (Q/B): "
- else
- echo -n "Please Select Kernel Config File # [1-$counter] or (S/D/E/A/Q): "
- fi
- fi
- color 7 0 B
- read CHOICE
- if [[ $CHOICE =~ ^[0-9]+$ ]] ; then
- if [[ $CHOICE -le $counter ]] && [[ $CHOICE -gt 0 ]]; then
- if $delete_config ; then
- if [ -f "$compile_folder/$config_folder/${configs[$CHOICE]}" ] ; then
- echo
- read -p "Are You Sure you want to remove: ${configs[$CHOICE]}? (y/N): " something
- if [[ $something == [yY] ]] ; then
- rm "$compile_folder/$config_folder/${configs[$CHOICE]}"
- fi
- fi
- else
- if $edit_config ; then
- $EDITOR "$compile_folder/$config_folder/${configs[$CHOICE]}"
- else
- config_menu=false
- config_name=${configs[$CHOICE]}
- fi
- fi
- else
- config_name="config.sav"
- fi
- else
- if [[ $CHOICE == [sS] ]] ; then
- ext=$(date +%y%m%d.%H%M%S)
- echo "# Created on $ext by $TITLE" > "$compile_folder/$config_folder/config_sav.$ext"
- zcat /proc/config.gz >> "$compile_folder/$config_folder/config_sav.$ext"
- fi
- if [[ $CHOICE == [dD] ]] ; then
- delete_config=true
- fi
- if [[ $CHOICE == [eE] ]] ; then
- edit_config=true
- fi
- if [[ $CHOICE == [bB] ]] ; then
- delete_config=false
- edit_config=false
- fi
- if [[ $CHOICE == [aA] ]] ; then
- if [ $delete_config == false ] ; then
- use_active_config=true
- config_menu=false
- fi
- fi
- if [[ $CHOICE == [Qq] ]] ; then
- clear
- banner
- show_gpl
- exit 0
- fi
- fi
- done
- }
- #
- # Allow new Compile option that can speed up the Compile time *****************
- #
- function use_turbo_mode {
- # We Must save a copy of your config file before you EVER use Turbo Mode
- if [ "$turbomode" == "ask" ] ; then
- error_message "Do you wish to Enable the Turbo Mode Compiler? (Y=Yes/N=No)"
- color 7 0 B
- echo -n "On Your Last Compile You: "
- color 3 0 B
- if [ -f "$compile_folder/$config_folder/turbomode" ] ; then
- echo "Used the Turbo Compile Mode"
- else
- echo "Did Not Use Turbo Compile Mode"
- fi
- echo
- color 7 1 B
- echo "Using Turbo Mode can reduce the compile time up to 25% of "
- echo "normal. Before using Turbo Mode, All hardware you expect "
- echo "to use with this kernel should be connected now and turned "
- echo "on. Failure to do so might cause them to not work. If "
- echo "you have issues using this option, just recompile and don't"
- echo "use the Turbo Mode Compile Mode option. If you want to use"
- echo "the new Turbo Mode Compiler and you are not sure everything"
- echo "is connected turned on and working, then Quit now and make "
- echo "sure it is on! Please see the C=Config menu for more kernel"
- echo "configuration options. Using Active Config from the Config"
- echo "menu preserves all installed Turbo Compile Modules from a "
- echo "previous successful Turbo Mode Compile and will be as fast."
- echo
- color 7 4 B
- read -s -n1 -p "Wish to Use the fast Turbo Mode Compiler? (y/N) Q=Quit: " CHOICE
- color 7 0 B
- if [[ $CHOICE == [qQ] ]] ; then
- clear
- banner
- show_gpl
- exit 0
- fi
- if [[ $CHOICE == [yY] ]] ; then
- turbomode=true
- echo "true" > $compile_folder/$config_folder/turbomode
- else
- turbomode=false
- fi
- else
- if [ $turbomode != true ] ; then
- if [ $turbomode != false ] ; then
- turbomode=false
- fi
- fi
- fi
- }
- #
- # 2nd Menu to be displayed ****************************************************
- #
- function menu_two {
- manual_config=false
- use_active_config=false
- if [ ! -f "$compile_folder/$config_folder/config.sav" ] ; then
- cp /boot/config-*-desktop "$compile_folder/$config_folder/config.sav" 2>&1
- fi
- if [ ! -f "$compile_folder/$config_folder/config.sav" ] ; then
- cp /boot/config-*-default "$compile_folder/$config_folder/config.sav" 2>&1
- fi
- if [ ! -f "$compile_folder/$config_folder/config.sav" ] ; then
- zcat /proc/config.gz >"$compile_folder/$config_folder/config.sav"
- fi
- error_message "Kernel Source File: $FILE"
- color 3 0 B
- echo -n "1) "
- color 7 0 B
- echo "Standand Kernel Compile (All Users)"
- color 3 0 B
- echo
- echo -n "2) "
- color 7 0 B
- echo "Turbo Mode Selection Menu (Advanced Users Only)"
- echo
- color 3 0 B
- echo -n "3) "
- color 7 0 B
- echo "Kernel Configuration Selection Menu (Advanced Users Only)"
- echo
- color 3 0 B
- echo -n "Q) "
- color 7 0 B
- echo "Quit SAKC Compiler Selection Menu"
- echo
- color 7 2 B
- echo -n "Please Select From these SAKC Compiler Options [1-3] Q=Quit"
- color 7 0 B
- while [ "$CHOICE" == "" ] ; do
- read -s -n1 CHOICE
- if [[ $CHOICE == [qQ] ]] ; then
- clear
- banner
- show_gpl
- exit 0
- fi
- if [[ $CHOICE == [123] ]] ; then
- if [ $CHOICE -eq 1 ] ; then
- turbomode=false
- fi
- if [ $CHOICE -eq 2 ] ; then
- use_turbo_mode
- fi
- if [ $CHOICE -eq 3 ] ; then
- config_slection
- turbomode=false
- manual_config=true
- if $use_active_config ; then
- manual_config=false
- else
- echo
- echo -n "Your Config Selection was: "
- color 3 0 B
- echo -n "$config_name"
- color 7 0 B
- read -p ", Press Enter to Continue ..." something
- fi
- fi
- else
- CHOICE=""
- fi
- done
- return 0
- }
- #
- # Help is Displayed from here *************************************************
- #
- function help {
- cat << EOFHELP
- $TITLE
- Your S.A.K.C. Startup and help options are:
- $0 -h --help :to show this help
- OR
- $0 [kernel_file_name.bz2]
- The kernel_file_name.bz2 name is optional and will be requested if not supplied.
- EOFHELP
- show_gpl
- exit 0
- }
- #
- # Display Help if requested. Example from Findgrub ***************************
- #
- case "$1" in
- -h|--help) help ;;
- esac
- #
- # S.A.K.C. Display Error Messages *********************************************
- #
- tput clear
- #
- # Make sure script was not started as root ************************************
- #
- 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
- #
- # Determine if the compile_folder exists **************************************
- #
- if [[ -d "$compile_folder" ]] ; then
- cd "$compile_folder"
- if [[ ! -d "$config_folder" ]] ; then
- mkdir "$config_folder"
- fi
- else
- error_message "The Kernel Compile Folder: $compile_folder, does not exist!"
- echo "Please create or change this folder name and start $(basename $0) again."
- echo
- exit 1
- fi
- #
- # Make sure the sakc script file exists in the folder specified ***************
- #
- if [ ! -e "$sakc_name" ] ; then
- error_message "The S.A.K.C. Kernel Source File Compiler: $sakc_name, was not found!"
- exit 1
- fi
- #
- # Determine if a kernel file name was given at start **************************
- #
- if [ $# -eq 0 ] ; then
- #
- # Determine if the kernel_folder (default is ~/Downloads) Exists **************
- #
- if [[ -d "$kernel_folder" ]] ; then
- menu=true
- delete_kernel=false
- while $menu ; do
- tput clear
- color 2 0 B
- echo $Dash1
- color 7 2 B
- echo "$TITLE"
- color 2 0 B
- echo $Dash1
- color 7 0 B
- echo
- echo -n "S.A.K.C. Location/Name: "
- color 3 0 B
- echo "$sakc_name"
- color 7 0 B
- echo
- echo -n " Kernel Compile Folder: "
- color 3 0 B
- echo "$compile_folder"
- color 7 0 B
- echo -n " Kernel Config Folder: "
- color 3 0 B
- echo "$compile_folder/$config_folder"
- color 7 0 B
- echo -n " Kernel Source Folder: "
- color 3 0 B
- echo "$kernel_folder"
- color 7 0 B
- echo
- echo -n " "
- color 7 6 B
- echo " Kernel Source File Tar Ball Listing "
- color 7 0 B
- echo
- counter=0
- declare -a kernels
- #
- # Find and display all files that start with linux* and end with .tar.bz2
- #
- for i in "$kernel_folder"/linux*.tar.bz2 ; do
- #
- # Determine if the kernel source file exists **********************************
- #
- if [ -f $i ] ; then
- let counter=counter+1
- kernels[$counter]=$i
- color 7 0 B
- echo -n " $counter) "
- color 3 0 B
- echo "$(basename ${kernels[$counter]})"
- fi
- done
- #
- # Determine if any Kernel Source Files were found *****************************
- #
- if [[ $counter -eq 0 ]]; then
- echo
- color 7 4 B
- echo "No Kernel Source Files were found in $kernel_folder!"
- color 7 0 B
- echo
- exit 1
- fi
- #
- # Main Program Prompt Displayed Here ******************************************
- #
- echo
- color 7 1 B
- if $delete_kernel ; then
- echo -n "Enter Kernel Source File # to Delete (Q=Quit,B=Back): "
- else
- echo -n "Enter Kernel Source File # to Compile (Q=Quit,D=Delete): "
- fi
- color 7 0 B
- read CHOICE
- #
- # Determine if input ($CHOICE) is an integer number and in range, look for Q to
- # Quit. If menu is not set to false, the menu will just be redisplayed as you
- # did not enter a valid menu option number for a kernel source file to compile.
- #
- if [[ $CHOICE =~ ^[0-9]+$ ]] ; then
- if [[ $CHOICE -le $counter ]] && [[ $CHOICE -gt 0 ]]; then
- if $delete_kernel ; then
- echo
- read -p "Are You Sure you want to remove: $(basename ${kernels[$CHOICE]})? (y/N): " something
- if [[ $something == [yY] ]] ; then
- rm "${kernels[$CHOICE]}"
- fi
- else
- menu=false
- fi
- fi
- else
- if [[ $CHOICE == [Qq] ]] ; then
- clear
- banner
- show_gpl
- exit 0
- fi
- if [[ $CHOICE == [dD] ]] ; then
- delete_kernel=true
- fi
- if [[ $CHOICE == [bB] ]] ; then
- delete_kernel=false
- fi
- fi
- done
- $sakc_name ${kernels[$CHOICE]}
- else
- #
- # The Kernel Source File Folder (default=~/Downloads) was not found ***********
- #
- error_message "The Kernel Source File Folder: $kernel_folder, does not exist!"
- exit 1
- fi
- exit 0
- else
- #
- # 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 *******************************************
- #
- set_editor
- menu_two
- 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=$?
- #
- # 1. Kernel File Decompression: Completed! ***********************************
- #
- progress_display 1
- if [ -d "$folder" ] ; then
- cd $folder
- else
- error_message "Kernel Source Folder $folder Does Not Exist!"
- read -p "Press Any Key to Exit S.A.K.C." CHOICE
- exit 1
- fi
- #
- # 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 2>&1 >> $log_file_name
- #
- # Get the Configuration for the running kernel ********************************
- #
- log_heading "make oldconfig"
- #
- # What kernel config file are you using? **************************************
- #
- if $manual_config ; then
- cp "$compile_folder/$config_folder/$config_name" .config
- echo "**** Manual Config file was selected ****" >> $log_file_name
- else
- if $turbomode ; then
- chmod +x ./scripts/kconfig/streamline_config.pl
- text=$(./scripts/kconfig/streamline_config.pl 2>&1 > ./config_strip)
- mv ./config_strip ./.config
- echo "**** Turbo Compile Mode is Enabled ****" >> $log_file_name
- else
- if $use_active_config ; then
- zcat /proc/config.gz >.config
- echo "**** Using Last Kernel Configuration ****" >> $log_file_name
- else
- echo "**** Turbo Compile Mode is Disabled ****" >> $log_file_name
- if [ -f "$compile_folder/$config_folder/turbomode" ] ; then
- if [ -f "$compile_folder/$config_folder/config.sav" ] ; then
- cp "$compile_folder/$config_folder/config.sav" .config
- else
- zcat /proc/config.gz >.config
- fi
- else
- zcat /proc/config.gz >.config
- fi
- fi
- fi
- fi
- #
- # Lets save a copy of every config file that was used. ************************
- #
- ext=$(date +%y%m%d.%H%M%S)
- if $turbomode ; then
- echo "# Created on $ext by $TITLE in TURBO MODE" > "$compile_folder/$config_folder/config_sav.$ext"
- cat .config >> "$compile_folder/$config_folder/config_sav.$ext"
- else
- echo "# Created on $ext by $TITLE" > "$compile_folder/$config_folder/config_sav.$ext"
- cat .config >> "$compile_folder/$config_folder/config_sav.$ext"
- fi
- #
- # 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=$?
- if [ $configure_exit -gt 0 ] ; then
- make xconfig
- configure_exit=$?
- fi
- display_header
- fi
- #
- # 2. Kernel File Configuration: Completed! ***********************************
- #
- 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
- #
- # 3. Kernel File Compile Process: Completed! *********************************
- #
- progress_display 3
- end_of_compile=$(date +%m/%d/%y-%H:%M:%S)
- #
- # Your Kernel file has been Compiled Successfully! ****************************
- #
- 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 > /dev/null 2>&1
- fi
- fi
- #
- # S.A.K.C. Kernel Install *****************************************************
- #
- get_password
- # Your Kernel file is now being Installed. Please Wait ...
- status_display 6
- log_heading "make modules_install install"
- sudo make modules_install install >> $log_file_name 2>&1
- install_exit=$?
- # 4. Kernel File Installation: Completed!
- 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 19 0 7 1 1 " Script Start: $script_start Script Finish: $script_stops "
- tput cup 24 0
- read something
- tput clear
- banner
- show_gpl
- if [ $turbomode != true ] || [ $manual_config == true ] ; then
- if [ -f "$compile_folder/$config_folder/turbomode" ] ; then
- rm "$compile_folder/$config_folder/turbomode"
- fi
- fi
- fi
- exit 0
- # End Of Script
