|
Revision 2585, 1.7 kB
(checked in by tg, 2 years ago)
|
these shall not be executable nor use absolute pathnames,
since perl doesn't always live in /usr/bin (e.g. NetBSDĀ®)
|
| Line | |
|---|
| 1 |
#!/usr/bin/env bash |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
[[ -n $BASH_VERSION ]] && shopt -s extglob |
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
targetdir=${1-.} |
|---|
| 13 |
patchdir=${2-../kernel-patches} |
|---|
| 14 |
patchpattern=${3-*} |
|---|
| 15 |
|
|---|
| 16 |
if [ ! -d "${targetdir}" ] ; then |
|---|
| 17 |
echo "Aborting. '${targetdir}' is not a directory." |
|---|
| 18 |
exit 1 |
|---|
| 19 |
fi |
|---|
| 20 |
if [ ! -d "${patchdir}" ] ; then |
|---|
| 21 |
echo "Aborting. '${patchdir}' is not a directory." |
|---|
| 22 |
exit 1 |
|---|
| 23 |
fi |
|---|
| 24 |
|
|---|
| 25 |
wd=$(pwd) |
|---|
| 26 |
cd $patchdir |
|---|
| 27 |
rm -f $targetdir/.patch.tmp |
|---|
| 28 |
for i in $(eval echo ${patchpattern}); do |
|---|
| 29 |
test -e "$i" || continue |
|---|
| 30 |
i=$patchdir/$i |
|---|
| 31 |
cd $wd |
|---|
| 32 |
case $i in |
|---|
| 33 |
*.gz) |
|---|
| 34 |
type="gzip"; uncomp="gunzip -dc"; ;; |
|---|
| 35 |
*.bz) |
|---|
| 36 |
type="bzip"; uncomp="bunzip -dc"; ;; |
|---|
| 37 |
*.bz2) |
|---|
| 38 |
type="bzip2"; uncomp="bunzip2 -dc"; ;; |
|---|
| 39 |
*.zip) |
|---|
| 40 |
type="zip"; uncomp="unzip -d"; ;; |
|---|
| 41 |
*.Z) |
|---|
| 42 |
type="compress"; uncomp="uncompress -c"; ;; |
|---|
| 43 |
*) |
|---|
| 44 |
type="plaintext"; uncomp="cat"; ;; |
|---|
| 45 |
esac |
|---|
| 46 |
[ -d "${i}" ] && echo "Ignoring subdirectory ${i}" && continue |
|---|
| 47 |
echo "" |
|---|
| 48 |
echo "Applying ${i} using ${type}: " |
|---|
| 49 |
${uncomp} ${i} | tee $targetdir/.patch.tmp | patch -p1 -E -d ${targetdir} |
|---|
| 50 |
fgrep '@@ -0,0 ' $targetdir/.patch.tmp >/dev/null 2>&1 && \ |
|---|
| 51 |
touch $targetdir/.patched-newfiles |
|---|
| 52 |
rm -f $targetdir/.patch.tmp |
|---|
| 53 |
if [ $? != 0 ] ; then |
|---|
| 54 |
echo "Patch failed! Please fix $i!" |
|---|
| 55 |
exit 1 |
|---|
| 56 |
fi |
|---|
| 57 |
cd $patchdir |
|---|
| 58 |
done |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then |
|---|
| 62 |
echo "Aborting. Reject files found." |
|---|
| 63 |
exit 1 |
|---|
| 64 |
fi |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \; |
|---|