make menuconfig
Dieses Script führt den Nutzer automatisch durch die verschiedenen Schritte, die zum Konfigurieren und Kompilieren eines Kernels notwendig sind.
#!/bin/sh clear version="0.3" echo "kernel compile script v$version" echo echo # check for root if [ "$UID" != "0" ] then echo "You have to be root to run this script!" exit 1 fi # check for bootloader bootloader() { echo echo echo -n "checking for bootloader..." # GRUB if test -e "/boot/grub/menu.lst" then bolo="grub" fi # LILO if test -e "/etc/lilo.conf" then bolo="$(echo $bolo)lilo" # assign $bolo, so that we know if both bootloaders exist fi # assigning path to bootloder config case "$bolo" in lilo) echo "lilo" bolo_config="/etc/lilo.conf" ;; grub) echo "grub" bolo_config="/boot/grub/menu.lst" ;; grublilo) # found both bootloaders, let user decide echo "found grub and lilo" echo "which bootloader do you use?" echo "[0] grub (default)" echo "[1] lilo" echo -n "choice: " read choice case "$choice" in 0|"") bolo_config="/boot/grub/menu.lst" echo "using grub as bootloader" ;; 1) bolo="lilo" # needed later bec. we have to run lilo after kernel update bolo_config="/etc/lilo.conf" echo "using lilo as bootloader" ;; *) # user not able to type 0 or 1 or wants to exit echo "wrong input. exiting." exit 2 esac ;; *) # whether lilo nor grub could be found echo "none found" ;; esac } # check for bootloader end # print avaible kernel print_kernel_versions() { echo echo echo "searching for kernel source directories" # search for kernel.org-like source directories ls -1 -d /usr/src/linux-2.6* 2>/dev/null | egrep -v "(tar|bz2|gz)" | cut -d "-" -f 2- # search for debian-package-like source directories (new variant) ls -1 -d /usr/src/linux-source-2.6* 2>/dev/null | egrep -v "(tar|bz2|gz)" | cut -d "-" -f 3- # search for debian-package-like source directories (old variant, untested!) ls -1 -d /usr/src/kernel-source-2.6* 2>/dev/null | egrep -v "(tar|bz2|gz)" | cut -d "-" -f 3- } # print avaible kernel end # configure the kernel configure() { echo echo echo -n "Do you want to configure the kernel? (Y/n) " read choice case $choice in y|Y|"") echo "running 'make menuconfig'" make menuconfig ;; *) ;; esac echo "running 'make clean'" make clean } # configure end # build kernel build_kernel() { echo echo echo -n "Do you want to build the kernel? (Y/n) " read choice case $choice in y|Y|"") new_kernel="1" # needed later to know whether we have to install the kernel stuff or not echo "running 'make bzImage'" make bzImage ;; *) ;; esac } # build kernel end # build modules build_modules() { echo echo echo -n "Do you want to build the modules? (Y/n) " read choice case $choice in y|Y|"") echo "running 'make modules'" make modules echo "running 'make modules_install'" make modules_install ;; *) ;; esac } # build modules end # install the kernel install_kernel() { echo echo echo "copying bzImage and System.map" cp -v arch/i386/boot/bzImage /boot/bzImage-$kern_version cp -v System.map /boot/System.map-$kern_version echo "making new System.map the default one" mv -v /boot/System.map /boot/System.map.old # backup old System.map ln -v -s /boot/System.map-$kern_version /boot/System.map } # install kernel end # edit bootloader config edit_config() { echo echo echo -n "Do you want to edit the config of your bootloader? (Y/n) " read choice case $choice in y|Y|"") echo "editing config" editor "$bolo_config" ;; *) ;; esac } # edit bootloader config end # we want to configure, build and install a kernel new_kernel() { bootloader # check for bootloader print_kernel_versions # print avaible kernel echo "Now simply type in one of the kernels listed above." echo "If your kernel source directory isn't listed above, please" echo " specify the full path where you extracted it." echo "Note: everything behind the first '-' will be used as the kernel version!" echo echo -n "version or path: " read choice # assigning path to kernel source # first character = "/"? if [ "$(echo "$choice" | cut -b 1)" == "/" ] && test -e "$choice" then src_path="$choice" choice=$(echo $choice | cut -d "-" -f 2-) # version is everything behind first '-' echo "using $src_path as source directory and $choice as version" elif test -e /usr/src/linux-$choice # kernel.org-like source directory then src_path="/usr/src/linux-$choice" echo "using kernel.org like source directory" echo "$src_path" elif test -e /usr/src/linux-source-$choice # debian-package-like source directory (new variant) then src_path="/usr/src/linux-source-$choice" echo "using new debian-package-like source directory" echo "$src_path" elif test -e /usr/src/kernel-source-$choice # debian-package-like source directory (old variant, untested!) then src_path="/usr/src/kernel-source-$choice" echo "using old debian-package-like source directory" echo "$src_path" else echo "wrong kernel source directory. exiting." exit 3 fi kern_version="$choice" cd "$src_path" configure # do we want to configure the kernel? build_kernel # do we want to build the kernel? build_modules # do we want to build the modules? if [ "$new_kernel" == "1" ] then install_kernel # install the kernel edit_config # edit bootloader config fi if [ "$bolo" == "lilo" ] then echo echo echo "running lilo" lilo fi echo "running 'make clean'" make clean } # new kernel end # print removable kernels print_removable_versions() { echo echo echo "searching for removable kernels" # search for removable kernels in /boot ls -1 /boot/bzImage-2.6* | cut -d "-" -f 2- } # print removable kernels end # delete an installed kernel delete_kernel() { echo echo echo -n "Do you really want to remove that kernel (y/N) " read choice case $choice in y|Y) echo "removing kernel $kern_version" rm -v -R /lib/modules/$kern_version rm -v /boot/System.map-$kern_version rm -v /boot/bzImage-$kern_version ;; *) echo "exiting" exit ;; esac } # delete an installed kernel end # remove an installed kernel rem_kernel() { echo echo echo "Warning: it is only safe to remove kernels installed with this script." print_removable_versions # print found kernel versions echo echo "Now simply type in one of the kernels listed above." echo "It is not possible to remove any other installed kernels with this script." read kern_version if test -e /boot/bzImage-$kern_version \ && test -e /boot/System.map-$kern_version \ && test -e /lib/modules/$kern_version then delete_kernel # if everything exists, delete kernel elif [ "$kern_version" == "" ] then # empty version, maybe user wants to abort echo "exiting" exit 4 else echo # warn user echo "It seems that kernel $kern_version has not been installed with this script" echo " or something other is wrong." delete_kernel # call delete_kernel bec. user has still the chance to abort fi } # remove kernel end # download a kernel from kernel.org download_kernel() { echo echo # get latest version latest=$(finger @kernel.org | grep "latest stable" | awk '{ print $10 }') if [ "$latest" == "" ] then echo "It seems that you are not connected to the internet" echo " or kernel.org suffers from problems." exit 5 fi echo "According to kernel.org, the latest kernel-version is $latest" echo -n "Which version do you want to download? (type enter for $latest) " read kern_version if [ "$kern_version" == "" ] then kern_version=$latest fi # change directory cd /usr/src # and download kernel wget ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$kern_version.tar.bz2 # simple check if kernel has been downloaded (but maybe only partly) # fixme: we need to check if kernel has been downloaded successfully! if ! test -e /usr/src/linux-$kern_version.tar.bz2 then echo "Something went wrong while downloading the kernel!" exit 6 fi echo echo echo -n "Do you want to unpack the kernel? (Y/n) " read choice case $choice in y|Y|"") echo "unpacking kernel" # unpack the kernel tar xjvf linux-$kern_version.tar.bz2 ;; *) echo "exiting" exit esac echo echo echo -n "Do you want to install the new kernel? (Y/n) " read choice case $choice in y|Y|"") echo "configuring kernel" new_kernel # run kernel configuration ;; *) echo "exiting" ;; esac } # download kernel end # what do you want to do today? echo "[0] configure and install new kernel (default)" echo "[1] remove installed kernel" echo "[2] download kernel from kernel.org" echo "[3] exit" echo -n "choice: " read choice case "$choice" in 0|"") # 0 and enter (=nothing) echo "configuring kernel" new_kernel ;; 1) echo "removing kernel" rem_kernel ;; 2) echo "downloading kernel" download_kernel ;; *) echo "exiting." exit ;; esac echo echo echo "finished." exit
v0.3 2006-01-05
v0.2 2006-01-05
v0.1 2006-01-04
make menuconfig