~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/scripts/patch-kernel

Version: ~ [ 2.2.5 ] ~ [ 2.4.1 ] ~ [ 2.4.9 ] ~ [ 2.6.17.10 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #! /bin/sh
  2 # Script to apply kernel patches.
  3 #   usage: patch-kernel [ sourcedir [ patchdir [ stopversion ] ] ]
  4 #     The source directory defaults to /usr/src/linux, and the patch
  5 #     directory defaults to the current directory.
  6 #
  7 # It determines the current kernel version from the top-level Makefile.
  8 # It then looks for patches for the next sublevel in the patch directory.
  9 # This is applied using "patch -p1 -s" from within the kernel directory.
 10 # A check is then made for "*.rej" files to see if the patch was
 11 # successful.  If it is, then all of the "*.orig" files are removed.
 12 #
 13 #       Nick Holloway <Nick.Holloway@alfie.demon.co.uk>, 2nd January 1995.
 14 #
 15 # Added support for handling multiple types of compression. What includes
 16 # gzip, bzip, bzip2, zip, compress, and plaintext. 
 17 #
 18 #       Adam Sulmicki <adam@cfar.umd.edu>, 1st January 1997.
 19 #
 20 # Added ability to stop at a given version number
 21 # Put the full version number (i.e. 2.3.31) as the last parameter
 22 #       Dave Gilbert <linux@treblig.org>, 11th December 1999.
 23 
 24 # Set directories from arguments, or use defaults.
 25 sourcedir=${1-/usr/src/linux}
 26 patchdir=${2-.}
 27 stopvers=${3-imnotaversion}
 28 
 29 # set current VERSION, PATCHLEVEL, SUBLEVEL
 30 eval `sed -n 's/^\([A-Z]*\) = \([0-9]*\)$/\1=\2/p' $sourcedir/Makefile`
 31 if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ]
 32 then
 33     echo "unable to determine current kernel version" >&2
 34     exit 1
 35 fi
 36 
 37 echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL"
 38 
 39 while :
 40 do
 41     SUBLEVEL=`expr $SUBLEVEL + 1`
 42     FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
 43 
 44     patch=patch-$FULLVERSION
 45     if [ -r $patchdir/${patch}.gz ]; then
 46         ext=".gz"
 47         name="gzip"
 48         uncomp="gunzip -dc"
 49     elif [ -r $patchdir/${patch}.bz  ]; then
 50         ext=".bz"
 51         name="bzip"
 52         uncomp="bunzip -dc"
 53     elif [ -r $patchdir/${patch}.bz2 ]; then
 54         ext=".bz2"
 55         name="bzip2"
 56         uncomp="bunzip2 -dc"
 57     elif [ -r $patchdir/${patch}.zip ]; then
 58         ext=".zip"
 59         name="zip"
 60         uncomp="unzip -d"
 61     elif [ -r $patchdir/${patch}.Z ]; then
 62         ext=".Z"
 63         name="uncompress"
 64         uncomp="uncompress -c"
 65     elif [ -r $patchdir/${patch}     ]; then
 66         ext=""
 67         name="plaintext"
 68         uncomp="cat"
 69     else
 70         break
 71     fi
 72 
 73     echo -n "Applying ${patch} (${name})... "
 74     if $uncomp ${patchdir}/${patch}${ext} | patch -p1 -s -N -E -d $sourcedir
 75     then
 76         echo "done."
 77     else
 78         echo "failed.  Clean up yourself."
 79         break
 80     fi
 81     if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ]
 82     then
 83         echo "Aborting.  Reject files found."
 84         break
 85     fi
 86     # Remove backup files
 87     find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
 88 
 89     if [ $stopvers = $FULLVERSION ]
 90     then
 91         echo "Stoping at $FULLVERSION as requested. Enjoy."
 92         break
 93     fi
 94 done

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.