Compilação automática do kernel Linux-libre 3.14.16

Publicado por Mário RPG (última atualização em 15/08/2014)

[ Hits: 2.447 ]

Homepage: www.fsfla.org

Download scriptkernel-libre-3.14.16.sh




Script em bash para compilação automática do kernel Linux-libre 3.14.16 no Ubuntu/Debian 32 bits para PC/notebooks que tenham no mínimo 2 GB de memória RAM. Ele baixa e compila tudo automaticamente usando "CFLAGS -MARCH=NATIVE + -Ofast", só sendo necessário escolher a arquitetura exata do seu processador no menuconfig.

Como executar no terminal:

$ time sudo bash scritpkernel-libre-3.14.16.sh

Página do projeto:

http://sourceforge.net/projects/scriptkernel/

  



Esconder código-fonte

#!/bin/bash

# Licensa GPL3
#
# DEBIAN LIKE
#
# NECESSARIO versão GCC-4.7.3 ou superior
#
# Tamanho final da pasta /usr/src/linux-3.14.xx = 9.6 GB
#
# Tempo de compilação ~150 min.
#
###########################################################

#versão do kernel a ser compilado
kernel=3.14

#path de atualização
patchkernel=3.14.16

#patch BFQ
#bfq=3.4.0-v4

#patch do kernel ubuntu: 0001... 0002... 0003... 0004... site: http://kernel.ubuntu.com/~kernel-ppa/mainline/
P1=0001-base-packaging.patch
P2=0002-debian-changelog.patch
P3=0003-configs-based-on-Ubuntu-3.13.0-8.27.patch
#P4=0004-configs-based-on-Ubuntu-3.4.0-5.11.patch


#apelido do kernel ubuntu
apelido=utopic

#patch ck
#patchck=3.4-ck3

#sufixo
ckk=amd


#.config antigo
kernelantigo=atual

############################################

# não precisa mexer em mais nada aqui

##################################
#arquitetura: amd64 ou i386 # criado por Stivekx - forum ubuntu-br #######
arqt=$(dpkg --print-architecture)


#CL=CONCURRENCY_LEVEL do processador # criado por Stivekx  ############
CL=$(grep -c processor /proc/cpuinfo)
##################################

########baixando compiladores e dependencias########################################################
sudo apt-get update
sudo apt-get install kernel-package libncurses5 libncurses5-dev build-essential patch gcc make gzip bzip2 lzip lzma lzop lrzip lrzsz xz-utils -y
sudo apt-get install gcc-4.7 -y
####################################################################################################



######  deletando patchs antigos  #############
#sudo rm /usr/src/patch-$patchkernel
#sudo rm /usr/src/patch-$patchck
#sudo rm /usr/src/*.patch
#sudo rm /usr/src/0002-debian-changelog.patch
#sudo rm /usr/src/0003-default-configs.patch
#sudo rm /usr/src/0001-block-cgroups-kconfig-build-bits-for-BFQ-v4-$kernel.patch
#sudo rm /usr/src/0002-block-introduce-the-BFQ-v4-I-O-sched-for-$kernel.patch
############################################

#######
sudo mkdir /usr/src/bkpatch
sudo mv /usr/src/*.patch /usr/src/bkpatch
#######

cd /usr/src
wget -c http://www.linux-libre.fsfla.org/pub/linux-libre/releases/$kernel-gnu/linux-libre-$kernel-gnu.tar.bz2
#wget -c http://www.kernel.org/pub/linux/kernel/v3.x/linux-$kernel.tar.bz2


sudo tar -jxpvf /usr/src/linux-libre-$kernel-gnu.tar.bz2
sudo mv /usr/src/linux-$kernel /usr/src/linux-libre-$patchkernel-$ckk


wget -c http://www.linux-libre.fsfla.org/pub/linux-libre/releases/$patchkernel-gnu/patch-$kernel-gnu-$patchkernel-gnu.xz
#wget -c http://www.kernel.org/pub/linux/kernel/v3.x/patch-$patchkernel.xzy
#wget -c http://ck.kolivas.org/patches/3.0/$kernel/$patchck/patch-$patchck.bz2
#wget -c http://algo.ing.unimo.it/people/paolo/disk_sched/patches/$bfq/0001-block-cgroups-kconfig-build-bits-for-BFQ-v4-$kernel.patch
#wget -c http://algo.ing.unimo.it/people/paolo/disk_sched/patches/$bfq/0002-block-introduce-the-BFQ-v4-I-O-sched-for-$kernel.patch



#ubuntu patch
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v$patchkernel-$apelido/$P1
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v$patchkernel-$apelido/$P2
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v$patchkernel-$apelido/$P3
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v$patchkernel-$apelido/$P4




sudo xz -d /usr/src/patch-$kernel-gnu-$patchkernel-gnu.xz
#sudo bunzip2 /usr/src/patch-libre-$patchck.bz2


cd /usr/src/linux-libre-$patchkernel-$ckk

sudo patch -p1 < /usr/src/patch-$kernel-gnu-$patchkernel-gnu
#sudo patch -p1 < /usr/src/patch-$patchck
#sudo patch -p1 < /usr/src/0001-block-cgroups-kconfig-build-bits-for-BFQ-v4-$kernel.patch
#sudo patch -p1 < /usr/src/0002-block-introduce-the-BFQ-v4-I-O-sched-for-$kernel.patch
sudo patch -p1 < /usr/src/$P1
sudo patch -p1 < /usr/src/$P2
sudo patch -p1 < /usr/src/$P3
sudo patch -p1 < /usr/src/$P4

######################
sleep 2

sudo rm /boot/download
cd /boot

sudo wget -c http://sourceforge.net/projects/scriptkernel/files/config-14-x86/download

#sudo wget -c http://sourceforge.net/projects/scriptkernel/files/config-14-atom32/download

#sudo wget -c http://sourceforge.net/projects/scriptkernel/files/config-kernel-12/download

sudo cp /boot/download /usr/src/linux-libre-$patchkernel-$ckk/.config


#### criado por Stivekx #############
#config_file=$(locate /boot/config-* | sort -r | head -1)

#sudo cp $config_file /usr/src/linux-$patchkernel-$ckk

#########################

############# Editando o Makefile ######################

sudo sed -e 's/EXTRAVERSION\([ = ]\+\)/EXTRAVERSION = -amd/g' /usr/src/linux-libre-$patchkernel-$ckk/Makefile  > /usr/src/linux-libre-$patchkernel-$ckk/mk && mv /usr/src/linux-libre-$patchkernel-$ckk/mk /usr/src/linux-libre-$patchkernel-$ckk/Makefile

cd /usr/src/linux-libre-$patchkernel-$ckk

#sudo gedit Makefile

sleep 3

sudo make menuconfig




######## Retirando Modulos Problematicos  ############

sudo sed 's/CONFIG_RTS5139=m/# CONFIG_RTS5139 is not set/g' /usr/src/linux-libre-$patchkernel-$ckk/.config > /usr/src/linux-libre-$patchkernel-$ckk/aa && mv /usr/src/linux-libre-$patchkernel-$ckk/aa /usr/src/linux-libre-$patchkernel-$ckk/.config

sleep 2

sudo sed 's/CONFIG_IGB=m/# CONFIG_IGB is not set/g' /usr/src/linux-libre-$patchkernel-$ckk/.config > /usr/src/linux-libre-$patchkernel-$ckk/bb && mv /usr/src/linux-libre-$patchkernel-$ckk/bb /usr/src/linux-libre-$patchkernel-$ckk/.config

sleep 2

sudo sed 's/CONFIG_IGB_DCA=y/# CONFIG_IGB_DCA is not set/g' /usr/src/linux-libre-$patchkernel-$ckk/.config > /usr/src/linux-libre-$patchkernel-$ckk/cc && mv /usr/src/linux-libre-$patchkernel-$ckk/cc /usr/src/linux-libre-$patchkernel-$ckk/.config

sleep 2

sudo sed 's/CONFIG_IGBVF=m/# CONFIG_IGBVF is not set/g' /usr/src/linux-libre-$patchkernel-$ckk/.config > /usr/src/linux-libre-$patchkernel-$ckk/dd && mv /usr/src/linux-libre-$patchkernel-$ckk/dd /usr/src/linux-libre-$patchkernel-$ckk/.config

sleep 2

sudo sed 's/CONFIG_E1000E=m/# CONFIG_E1000E is not set/g' /usr/src/linux-libre-$patchkernel-$ckk/.config > /usr/src/linux-libre-$patchkernel-$ckk/ee && mv /usr/src/linux-libre-$patchkernel-$ckk/ee /usr/src/linux-libre-$patchkernel-$ckk/.config




sleep 3

######################################################


############ script criado por Stivekx #######################

#!/bin/bash

#Script para automatizar a mudança das flags na hora de compilar o kernel.
#Mais informações sobre como compilar o kernel para seu processador:
#http://ubuntuforum-br.org/index.php/topic,81718.0.html

#Modo de usar:
#Após baixar o kernel, descompactar, criar um link simbólico para ele no /usr/src/linux:
# cd /usr/src/linux
# sudo su
# chmod +x script.sh
# ./script.sh
#O script deve ser executado como root. Recomendo que use sudo su - e rode o script ao invés de sudo sh script.sh


#Script criado por André Steinn

#Aqui é a lista de arquivos que ele vai dar replace no -march= por -march=native. Você pode mudar essa lista de arquivos passando a lista pela opção a e separados pro virgula
#e.g.: ./script.sh -a arch/x86/boot/compressed/Makefile,arch/x86/boot/Makefile,arquivo1,arquivo2,arquivo3

arquivos=( "arch/x86/boot/compressed/Makefile" "arch/x86/boot/Makefile" "arch/x86/kernel/acpi/realmode/Makefile" "arch/x86/Kconfig.cpu" "arch/x86/Makefile" "arch/x86/Makefile_32.cpu")

#Aqui eu verifico se a pessoa passou algum argumento na hora de executar o script
while getopts ":a:c" opt; do
  case $opt in
    a)
      echo "Você setou uma lista de arquivos personalizada: $OPTARG" >&2
    IFS=',' read -ra arquivos <<< "$OPTARG"
      ;;
    \?)
      echo "Opção inválida: -$OPTARG" >&2
      exit 1
      ;;
  esac
done

#Aqui eu faço um loop e altero os arquivos, removendo o -march=() por -march=native
for i in "${arquivos[@]}"
do
    echo "Path no arquivo:"$i
    sed -e 's/-march=\([A-Z0-9a-z]\+\)/-march=native -Ofast /g'  $i > "$i.file_changed"
    mv "$i.file_changed" $i
done



################

sleep 3


#time sudo CONCURRENCY_LEVEL=2 make-kpkg --initrd kernel_image kernel_headers modules_image

#time sudo CONCURRENCY_LEVEL=$CL make-kpkg --initrd kernel_image kernel_headers modules_image

#cd /usr/src
#sudo dpkg -i linux-image-$patchkernel-$ckk\_$patchkernel-$ckk-10.00.Custom_$arqt.deb linux-headers-$patchkernel-$ckk\_$patchkernel-$ckk-10.00.Custom_$arqt.deb

cd /usr/src/linux-libre-$patchkernel-$ckk

time sudo make -j2
time sudo make modules_install
time sudo make install


sleep 3

cd /lib/modules
ls

#sudo mkinitramfs -o /boot/initrd.img-$patchkernel-$ckk $patchkernel-$ckk
sudo update-grub

sleep 5
echo 'tudo belezinha'

Scripts recomendados

Dia Anterior

Scanner de portas abertas

Converter arquivos CBR para PDF

IPv6 fácil e rápido

Validador mac-address em shell script


  

Comentários
[1] Comentário enviado por mariojuniorjp em 24/10/2014 - 07:25h

Pô cara, muitíssimo obrigado por compartilhar esse script. Era disto que eu estava precisando! \o


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner
Linux banner
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts