Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 01/08/2014, à 00:37

Iito

[Script] Compilation et installation du kernel de votre choix ;)

Salut salut,

J'ai fais un petit script afin de compiler le kernel que vous souhaitez (version 3 minimum)
Le script est bilingue pour les moins doués d'entre nous en anglais ^^
il télécharge puis compile et enfin installe le kernel voulu et mettant à jour grub jettez y un oeil ,)

#!/bin/bash
# Shell script for One Click Kernel Compile and Installation
# Programmed by Mansa Camara
# Copyright (C) 2014, Mansa Camara <mansa.camara@yahoo.fr>
# 
# NOTE:
# THIS SCRIPT WILL ONLY WORK WHEN QT LIBRARY IS THERE , IF IT IS NOT THERE IT WOULD BE DOWNLOADED AUTOMATICALLY USING APT
# Tested on UBUNTU,FEDORA

#HOW TO RUN THIS
# step 1:  You can dowmload the latest stable kernel version from kernel.org in and copy to any directory.  
# step 2: place this script to that directory and run it...
#    OR
#step 1 : run the script and chose the version you want, it will do all rest.

# ./kernel_install_by_mansa.sh	


# thats all! :-)  ... do look at the code to understand,,,


#NOTE: IF YOU ARE COMPILING THIS FOR SECOND TIME ... NOTIFY IT WHEN IT WILL BE ASKED


clear
echo "				Lang ? (EN or FR)"
read lang
if [[ $lang == "FR" ]] || [[ $lang == "fr" ]] || [[ $lang == "Fr" ]];then
	echo "		        	Auto compilation du noyau et installaton"
	echo "		        	========================================="
	echo
	echo "Ce programme va télécharger, compiler puis installer le kernel souhaité sur votre ordinateur"
	echo "Ce programme nécessite l'utilisation de la librairie QT4, si elle n'est pas présente elle sera téléchargée automatiquement, donc vous avez besoin d'une connexion internet afin que ce programme fonctionne correctement..." 
	echo
	echo
	lang="FR"
	echo "Quelle version souhaitez-vous ? Plusieurs choix sont disponibles @ www.kernel.org"
else
	echo "		        	Auto Kernel Compile and Install"
	echo "		        	================================="
	echo
	echo "This program will compile and install a new kernel in your system"
	echo "This program will need QT4 Library , if it is not present it will be downloaded automatically , so You need a Internet connection  for this program to work correctly..." 
	echo
	echo
	lang="EN"
	echo "Which version do you want ? Choices are available @ www.kernel.org"
fi
read version
if [[ $lang == "FR" ]];then
	echo "Téléchargement en cours"
else	
	echo "Download in progress"
fi
KERNEL_URL=https://www.kernel.org/pub/linux/kernel/v3.x/linux-$version.tar.xz
wget $KERNEL_URL
echo
if [[ $lang == "FR" ]];then
	echo "Voulez-vous voir le changelog de ce kernel $version ? [O/N]"
else
	echo "Do you want to see the changelog of the $version kernel ? [Y/N]"
fi
read rep
if [[ $rep == "Yes" ]] || [[ $rep == "YES" ]] || [[ $rep == "yes" ]] || [[ $rep == "Y" ]] || [[ $rep == "y" ]] || [[ $rep == "Oui" ]] || [[ $rep == "OUI" ]] || [[ $rep == "O" ]] || [[ $rep == "o" ]] || [[ $rep == "oui" ]];then
curl  https://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-$version > changelog-$version.txt && cat -s changelog-$version.txt | more && rm changelog-$version.txt
fi
if [[ $lang == "FR" ]];then
	echo  "Commencement de la compilation et de l'installation...."
else
	echo  "Starting Auto Kernel Compile and Install..."
	echo
	echo
	echo
fi
ls linux-*.xz 
k_found=$(eval ls linux-*.xz | wc -l)

if [[ $lang == "FR" ]];then
	echo "les kernels suivant ont été trouvé $k_found"
else
	echo "found the above $k_found kernels"
fi
echo
if  [ $k_found  -eq  0  ]
then
	if [[ $lang == "FR" ]];then
		echo "Aucun kernels n'a été trouvé... le kernel ainsi que le script doivent se trouver dans le même répertoire..."
	else
		echo "No kernels found.... both the kernel file  and this script will have to be in the same directory..."
	fi
	echo
	echo
	if [[ $lang == "FR" ]];then
		echo "Fermeture du programme..."
	else
		echo "exiting now..."
	fi
	exit
fi

#find and choose the kernel with latest version
k0=$( ls linux-*.xz  | sort | tail -1)
if [[ $lang == "FR" ]];then
	echo " J'ai trouvé la dernière version du kernel $k0"
else
	echo " i have found latest kernel version file as $k0"
fi
echo
if [[ $lang == "FR" ]];then
	echo "Entrez quelle kernel vous souhaitez compiler et installer ?"
	echo
	echo "par ex. si vous avez le kernel linux-3.12.25.tar.xz alors votre version est 3.12.25, donc entrez 3.12.25 ci-contre "
	echo
	echo "Entrez la version du kernel, nombre uniquement ?"
else
	echo "Enter which kernel version number to compile and install ? "
	echo
	echo "for eg. if you have downloaded linux-2.6.39.1.tar.xz then your version number is 2.6.39.1 , then enter 2.6.39.1 below "
	echo
	echo " Enter kernel version number only ?  "
fi
read k
echo 
echo
if [[ $lang == "FR" ]];then
	echo "Entrez le nombres de processeurs que votre ordinateur possède ?"
	echo
	echo "Aide :"
	echo "Si vous avez un dual core avec 2 threads , entrez 2"
	echo "Si vous avez un dual core avec 4 threads , entrez 4"
	echo "Si vous avez un quad core avec 4 threads , entrez 4"
	echo "Si vous avez un quad core avec 8 threads , entrez 8"
	echo "En général, si vous avez un processeur à n threads , entrez n"
else
	echo "Enter number of processors your computer has ?"
	echo
	echo "HINT:"
	echo "If you have dual core with 2 threads , enter 2"
	echo "If you have dual core with 4 threads , enter 4"
	echo "If you have quad core with 4 threads , enter 4" 
	echo "If you have quad core with 8 threads , enter 8"
	echo "In general , If you processor with  h threads , enter h"
fi
read n


# p =no of proc + 1 // i read it from one site... it's recommended to put one more than how many processors you have. For example: on a dual core machine you could compile the kernel with make -j3.
 
p=`expr $n +  1 `


echo 
echo
if [[ $lang == "FR" ]];then
	echo "Je vérifie les dépendences..."
	echo "Afin d'installer les librairies qt4, si elles ne sont pas déjà installées..."
	echo
	echo "Veuillez rentrer votre mot de passe sudo"
else
	echo  "Checking Dependencies...."
	echo "Now to install qt4 library if it is not already installed there.."
	echo
	echo Enter password to go into supervisor mode...
fi
if [[ $lang == "FR" ]];then
	echo "MUHAHAHAHAHAHAHAHA à moi le pouvoir !!! --\' (c'est une boutade(blague))"
else
	echo "MUHAHAHAHAHAHAHA now it's my turn to do what i want !!! \o/ (in case of, it's a joke ;-) )"
fi
sudo apt-get install libqt4-dev
echo
echo
if [[ $lang == "FR" ]];then
	echo "Vous avez entré que votre ordinateur possède $n processeurs "
else
	echo "You have entered that your system has $n processors "
fi



#to go into supervisor mode,,,
sudo ls
VER=$k
cur=$(eval pwd)
tar -xJvf linux-$VER.tar.xz


#now linux-2.6.38.2 directory will get created..
cd linux-$VER

#HOW TO CONFIGURE KERNEL .... READ THE OPTION DESCRIPTORS AND CONFIGURE KERNEL...AND SAVE .CONFIG FILE IN DEFAULT DIRECTORY ITSELF
#lets configure the kernel...

echo
echo
if [[ $lang == "FR" ]];then
	echo "La prochaine instruction ne fonctionnera que si vous avez les librairies QT4 ou QT3 d'installé... si ce n'est pas le cas installez-les..."
else
	echo " the next command wont work , unless you have  QT4 or QT3 library installed... if not install it..  "
fi


#now to copy your previous latest configuration from your kernel list
con_file=$(ls /boot/config-* | sort | tail -1)
sudo cp  $con_file .config



#now to run graphical configurator...
make xconfig

echo
if [[ $lang == "FR" ]];then
	echo "Si vous avez vu un menu graphique précédement c'est que qt3 ou qt4 sont installées... si vous n'avez rien vu, appuyez sur ctrl+c pour quitter et installez manuellement qt4"
	echo "vous pouvez executer la commande suivante \" sudo apt-get install libqt4-dev\" afin d'installer qt4 mais vous devez être connecté à internet..."
	echo
	echo
	echo "Appuyez sue Entrer pour continuer"
else
	echo "if you had seen a graphical menu earlier then qt3 or qt4 was installed... if you have not seen the graphical menu then  press ctrl+c to exit and install qt4...."
	echo "you can run   \" sudo apt-get install libqt4-dev to install qt4.... ,you need to be online to download QT4...\"   "
	echo 
	echo
	echo "press Enter to continue"
fi
	echo



read a



#uncomment this line if you are running kernel compilation again...
if [[ $lang == "FR" ]];then
	echo "Executez-vous ce script pour la seconde fois au motif d'une compilation à échoué ? [O/N]"
else
	echp "Are you running compilation for second time because of compilation faill ? [Y/N]"
fi
read rep
if [[ $rep == "Yes" ]] || [[ $rep == "YES" ]] || [[ $rep == "yes" ]] || [[ $rep == "Y" ]] || [[ $rep == "y" ]] || [[ $rep == "Oui" ]] || [[ $rep == "OUI" ]] || [[ $rep == "O" ]] || [[ $rep == "o" ]] || [[ $rep == "oui" ]];then
make clean
fi

if [[ $lang == "FR" ]];then
	echo "Cette étape risque de prendre du temps en fonction de votre configuration"
else
	echo "This step will take a long time.. based on your configuration options..."
fi

#now compile... takes a long time...
make -j$p


# ’make modules’ will built the various components which we chose to build as modules
sudo make modules


# ’make modules_install’, which must be run as root, ivileges) will create /lib/modules/‘uname -r‘ and copy the modules there.
sudo make modules_install


# Copy the kernel image and the System.map file to the /boot directory.

sudo cp System.map /boot/System.map-$VER
sudo cp arch/x86/boot/bzImage /boot/vmlinuz-$VER

# it seems config is needed ... added this now
sudo cp .config /boot/config-$VER

# Create the initramfs image.
cd /boot
sudo mkinitramfs -o initrd.img-$VER $VER


#and finally update the grub loader... if you use linux uses lilo check out how that works...
sudo update-grub

if [[ $lang == "FR" ]];then
	echo "Si vous vouyez \'grub update successful\' avec votre nouveau kernel, vous pouvez redemarrer"
	echo "Vous verrez le nouveau kernel apparaître dans la list grub de démarrage.. ça, c'est fait!"
else
	echo "If you see grub update successful with ur new kernel image ... then go ahead and reboot the system..."
	echo "it will show the new kernel in the list... yipee! its done"

Si vous voulez y apporter des modifs ne vous genez pas :-D

Dernière modification par Iito (Le 01/08/2014, à 14:32)

Hors ligne

#2 Le 01/08/2014, à 11:29

Lork Scorguar

Re : [Script] Compilation et installation du kernel de votre choix ;)

Salut,

Pas mal ce script mais il me semble qu'il y a une erreur. Tu ne lances la commande d'install de qt (sudo apt-get install libqt4-dev) que si la langue est l'anglais.


Kubuntu 14.10
rMacBook Pro

Hors ligne

#3 Le 01/08/2014, à 14:31

Iito

Re : [Script] Compilation et installation du kernel de votre choix ;)

ah oui il me manque un fi wink

Hors ligne

#4 Le 27/08/2014, à 19:03

linuxm@c

Re : [Script] Compilation et installation du kernel de votre choix ;)

dans l`etape : Voulez-vous voir le changelog de ce kernel 3.14 ? [O/N]   --> le choix o

en a un texte partiellement illisible  ( voir ci dessous )

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   234  100   234    0     0    135      0  0:00:01  0:00:01 --:--:--   135
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /pub/linux/kernel/v3.x/ChangeLog-3.14 was not found on this server.</p>
</body></html>
Commencement de la compilation et de l'installation....
linux-3.14.tar.xz
les kernels suivant ont été trouvé 1

Hors ligne