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}
14 if [ ! -d "${targetdir}" ] ; then
15 echo "Aborting. '${targetdir}' is not a directory."
18 if [ ! -d "${patchdir}" ] ; then
19 echo "Aborting. '${patchdir}' is not a directory."
23 for i
in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
26 type="gzip"; uncomp
="gunzip -dc"; ;;
28 type="bzip"; uncomp
="bunzip -dc"; ;;
30 type="bzip2"; uncomp
="bunzip2 -dc"; ;;
32 type="zip"; uncomp
="unzip -d"; ;;
34 type="compress"; uncomp
="uncompress -c"; ;;
36 type="plaintext"; uncomp
="cat"; ;;
39 echo "Applying ${i} using ${type}: "
40 ${uncomp} ${patchdir}/${i} | patch -p1 -E -d ${targetdir}
42 echo "Patch failed! Please fix ${patchdir}/$i!"
47 # Check for rejects...
48 if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
49 echo "Aborting. Reject files found."
54 find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \
;