Advertisement
Rnery

Compilar o Kernel..

May 17th, 2022 (edited)
758
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.58 KB | None | 1 0
  1. #!/usr/bin/env bash
  2.  
  3. # Exibir mensagens informativas e aguardar a confirmação do usuário
  4. function display_information_and_wait_for_user_confirmation() {
  5.   echo -e "$1\nPressione qualquer tecla para continuar, ou <ctrl+c> para cancelar."
  6.   read -r
  7. }
  8.  
  9. # Limpar artefatos de compilação
  10. function cleanup() {
  11.   rm /usr/src/linux-upstream* || true
  12.   rm /usr/src/*.deb || true
  13.   make clean
  14.   make mrproper
  15.   make distclean
  16. }
  17.  
  18. # Instalar dependências
  19. function install_dependencies() {
  20.   apt update && apt upgrade && apt autoremove && apt autoclean && apt install zstd libncurses-dev flex bison libssl-dev libelf-dev python3-dev dwarves build-essential
  21. }
  22.  
  23. # Compilar o kernel
  24. function compile_kernel() {
  25.   cp /usr/src/.config "$(pwd)"
  26.   nice -n 15 make -j "$(nproc)" deb-pkg
  27. }
  28.  
  29. # Instalar o kernel compilado e realizar a limpeza
  30. function install_and_cleanup() {
  31.   cd /usr/src || exit 0
  32.   dpkg -i -- *.deb
  33.   sleep 300
  34.   cleanup
  35.   sleep 10
  36.   echo -e '\nFinalizado.'
  37.   sleep 10
  38.   reboot
  39. }
  40.  
  41. # Início do script
  42.  
  43. clear
  44. echo -e 'Auxiliar de Compilação Kernel Linux Debian e Derivados\nMarcelo Marchi Negreira\n'
  45.  
  46. # Instalar dependências
  47. install_dependencies
  48.  
  49. clear
  50. nproc="$(nproc)"
  51. echo -e "Trabalharei com $nproc cores.\n"
  52.  
  53. # Limpeza inicial
  54. display_information_and_wait_for_user_confirmation "Iniciando limpeza"
  55. cleanup
  56.  
  57. # Compilação
  58. display_information_and_wait_for_user_confirmation "Iniciando compilação"
  59. compile_kernel
  60.  
  61. # Instalação e limpeza final
  62. display_information_and_wait_for_user_confirmation "Iniciando Instalação e limpeza."
  63. install_and_cleanup
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement