]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/uClibc/sources/patch-kernel.sh
uClibc-Update.
[people/pmueller/ipfire-2.x.git] / src / uClibc / sources / patch-kernel.sh
CommitLineData
a52153e7
MT
1#! /bin/sh
2# A little script I whipped up to make it easy to
3# patch source trees and have sane error handling
4# -Erik
5#
6# (c) 2002 Erik Andersen <andersen@codepoet.org>
7
8# Set directories from arguments, or use defaults.
9targetdir=${1-.}
10patchdir=${2-../kernel-patches}
1d4ec104
MT
11shift 2
12patchpattern=${@-*}
a52153e7
MT
13
14if [ ! -d "${targetdir}" ] ; then
15 echo "Aborting. '${targetdir}' is not a directory."
16 exit 1
17fi
18if [ ! -d "${patchdir}" ] ; then
19 echo "Aborting. '${patchdir}' is not a directory."
20 exit 1
21fi
22
1d4ec104 23for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
a52153e7
MT
24 case "$i" in
25 *.gz)
26 type="gzip"; uncomp="gunzip -dc"; ;;
27 *.bz)
28 type="bzip"; uncomp="bunzip -dc"; ;;
29 *.bz2)
30 type="bzip2"; uncomp="bunzip2 -dc"; ;;
31 *.zip)
32 type="zip"; uncomp="unzip -d"; ;;
33 *.Z)
34 type="compress"; uncomp="uncompress -c"; ;;
35 *)
36 type="plaintext"; uncomp="cat"; ;;
37 esac
38 echo ""
39 echo "Applying ${i} using ${type}: "
1d4ec104 40 ${uncomp} ${patchdir}/${i} | patch -p1 -E -d ${targetdir}
a52153e7
MT
41 if [ $? != 0 ] ; then
42 echo "Patch failed! Please fix $i!"
43 exit 1
44 fi
45done
46
47# Check for rejects...
48if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
49 echo "Aborting. Reject files found."
50 exit 1
51fi
52
53# Remove backup files
54find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;