freewrt_1_0
freewrt_2_0
| 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.
|
|---|
| 9 | targetdir=${1-.}
|
|---|
| 10 | patchdir=${2-../kernel-patches}
|
|---|
| 11 | patchpattern=${3-*}
|
|---|
| 12 |
|
|---|
| 13 | if [ ! -d "${targetdir}" ] ; then
|
|---|
| 14 | echo "Aborting. '${targetdir}' is not a directory."
|
|---|
| 15 | exit 1
|
|---|
| 16 | fi
|
|---|
| 17 | if [ ! -d "${patchdir}" ] ; then
|
|---|
| 18 | echo "Aborting. '${patchdir}' is not a directory."
|
|---|
| 19 | exit 1
|
|---|
| 20 | fi
|
|---|
| 21 |
|
|---|
| 22 | wd=$(pwd)
|
|---|
| 23 | cd $patchdir
|
|---|
| 24 | for 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
|
|---|
| 51 | done
|
|---|
| 52 |
|
|---|
| 53 | # Check for rejects...
|
|---|
| 54 | if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
|
|---|
| 55 | echo "Aborting. Reject files found."
|
|---|
| 56 | exit 1
|
|---|
| 57 | fi
|
|---|
| 58 |
|
|---|
| 59 | # Remove backup files
|
|---|
| 60 | find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.