source: freewrt/scripts/patch-kernel.sh@ fdd4f59

freewrt_1_0 freewrt_2_0
Last change on this file since fdd4f59 was 86ea442, checked in by Thorsten Glaser <tg@…>, 19 years ago

allow patchpattern to be a braceexpand expression

git-svn-id: svn://www.freewrt.org/trunk/freewrt@408 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100755
File size: 1.4 KB
Line 
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}
11patchpattern=${3-*}
12
13if [ ! -d "${targetdir}" ] ; then
14 echo "Aborting. '${targetdir}' is not a directory."
15 exit 1
16fi
17if [ ! -d "${patchdir}" ] ; then
18 echo "Aborting. '${patchdir}' is not a directory."
19 exit 1
20fi
21
22wd=$(pwd)
23cd $patchdir
24for i in ${patchpattern} ; do
25 test -e "$i" || continue
26 i=$patchdir/$i
27 cd $wd
28 case "$i" in
29 *.gz)
30 type="gzip"; uncomp="gunzip -dc"; ;;
31 *.bz)
32 type="bzip"; uncomp="bunzip -dc"; ;;
33 *.bz2)
34 type="bzip2"; uncomp="bunzip2 -dc"; ;;
35 *.zip)
36 type="zip"; uncomp="unzip -d"; ;;
37 *.Z)
38 type="compress"; uncomp="uncompress -c"; ;;
39 *)
40 type="plaintext"; uncomp="cat"; ;;
41 esac
42 [ -d "${i}" ] && echo "Ignoring subdirectory ${i}" && continue
43 echo ""
44 echo "Applying ${i} using ${type}: "
45 ${uncomp} ${i} | patch -p1 -E -d ${targetdir}
46 if [ $? != 0 ] ; then
47 echo "Patch failed! Please fix $i!"
48 exit 1
49 fi
50 cd $patchdir
51done
52
53# Check for rejects...
54if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
55 echo "Aborting. Reject files found."
56 exit 1
57fi
58
59# Remove backup files
60find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
Note: See TracBrowser for help on using the repository browser.