Kernel Build Script
Das Kernelkompilieren ist inzwischen recht einfach geworden, aber trotzdem 
gibt es noch eine Reihe von Schritten auzuführen, bis sich der Erfolg einstellt.
Aber Unix wäre nicht Unix, wenn es nicht auch dafür noch ein handliches Script
gäbe, das einem nochmal etwas Arbeit abnimmt. Dieser Beitrag ist von Raphael, und
er meint dazu: "... hat mir nicht viel Spass gemacht jedesmal
die ganze make-Kette einzugeben beim Kernel-compile, so hab ich
das ganze unter Optionen gesetzt und in ein Script gepackt. Erklärung
und Beispiele hab ich ins Script geschrieben, und da es wirklich
sooooo simpel ist, dürfte es jedem leicht fallen, weitere make-Steps
einzubauen." 
build - Kernel compile script
#!/bin/bash 
# 
# build - a handy script to build the linux kernel 
# 
# options: 
#     -f     full, means it compiles the whole kernel including 
#        the modules and installs them. 
# 
#    -o     only, means it compiles ONLY this steps you 
#        you specify (see expl. of modifiers below) 
# 
#    -s    skip, means it compiles the whole kernel but SKIPS 
#        the steps you specify (see expl. of modifiers below) 
# 
#    -h    this help ;) 
# 
# modifiers: 
#     d    dependents (or 'make dep') 
#    c    clean (or 'make clean') 
#    z    zImage (or 'make zImage') 
#    b    bzImage (or 'make bzImage') 
#    m    modules (or 'make modules') 
#    i    modules_install (or 'make modules_install') 
#        to be continued.... 
# 
# examples: 
#    to build the kernel but not the modules nor install them: 
#    ./build -s mi 
# 
#    to build just the deps and bzImage: 
#    ./build -m db 
# 
# 
# for any questions, send your email to: milosh@plexus.shacknet.nu 
# 
 
 
SRCDIR=/usr/src/linux 
PARAM=$1 
OPTSTR=$@ 
 
die() 
{ 
   echo "-- sorry, failed to make $1 :("; 
   exit 1 
} 
 
valid() 
{ 
   for i in $OPTSTR ; do 
       echo "$i" | grep "$1" > /dev/null &&  return 0 
   done 
   return 1 
} 
 
cddir() 
{ 
   if [ -d $1 ] ; then 
       cd $1 
   else 
       echo "-- sorry, dir $1 not found" 
       exit 1; 
   fi 
} 
 
case "$PARAM" in "-s" ) 
   cddir $SRCDIR 
   valid "d" || (echo "making dep" && make dep || die "dep") 
   valid "c" || (echo "making clean" && make clean || die "clean") 
   valid "z" || (echo "making zImage" && make zImage || die "zImage") 
   valid "b" || (echo "making bzImage" && make bzImage || die "bzImage") 
   valid "m" || (echo "making modules" && make modules || die "modules") 
   valid "i" || (echo "making mod_inst" && make modules_install \ 
                       || die "modules_install") 
   exit 0 
   ;; 
 
"-o" ) 
   cddir $SRCDIR 
   valid "d" && echo "making dep" && (make dep || die "dep") 
   valid "c" && echo "making clean" && (make clean || die "clean") 
   valid "z" && echo "making zImage" && (make zImage || die "zImage") 
   valid "b" && echo "making bzImage" && (make bzImage || die "bzImage") 
   valid "m" && echo "making modules" && (make modules || die "modules") 
   valid "i" && echo "making mod_inst" && (make modules_install \ 
                       || die "modules_install") 
   exit 0 
   ;; 
 
"-f" )    cddir $SRCDIR 
   make dep && \ 
   make clean && \ 
   make bzImage && \ 
   make modules && \ 
   make modules_install && \ 
   echo "finished.... ;)" 
   exit 0 
   ;; 
 
"-h" ) 
   head -31 $0|tail -29 
   exit 0 
   ;; 
 
*  )     echo "build - kernel building script" 
          echo "usage: build [-h] [-f] [-m|-s] (d|c|z|b|m|i)" 
   exit 0 
   ;; 
esac 
exit 1 
  
	     
	    Webmaster at lugbe.ch 
	Die Artikel dieser Seite stehen unter Copyleft ihrer jeweiligen Autoren.
Ihre Nutzung, Wiedergabe etc. untersteht den Bedingungen der GNU Free Documentation License (http://www.gnu.org/copyleft/fdl.html), wo nicht explizit anders vermerkt.
	   |