2 # A little script I whipped up to make it easy to
3 # patch source trees and have sane error handling
6 # (c) 2002 Erik Andersen <andersen@codepoet.org>
8 # Set directories from arguments, or use defaults.
10 patchdir
=${2-../kernel-patches}
13 if [ ! -d "${targetdir}" ] ; then
14 echo "Aborting. '${targetdir}' is not a directory."
17 if [ ! -d "${patchdir}" ] ; then
18 echo "Aborting. '${patchdir}' is not a directory."
22 for i
in ${patchdir}/${patchpattern} ; do
25 type="gzip"; uncomp
="gunzip -dc"; ;;
27 type="bzip"; uncomp
="bunzip -dc"; ;;
29 type="bzip2"; uncomp
="bunzip2 -dc"; ;;
31 type="zip"; uncomp
="unzip -d"; ;;
33 type="compress"; uncomp
="uncompress -c"; ;;
35 type="plaintext"; uncomp
="cat"; ;;
37 echo "Ignoring unknown ${i}"; continue; ;;
39 [ -d "${i}" ] && echo "Ignoring subdirectory ${i}" && continue
41 echo "Applying ${i} using ${type}: "
42 ${uncomp} ${i} | patch -p1 -E -d ${targetdir}
44 echo "Patch failed! Please fix $i!"
49 # Check for rejects...
50 if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
51 echo "Aborting. Reject files found."
56 find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \
;