summaryrefslogtreecommitdiffstats
path: root/scripts/apply_patch_series.sh
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2006-05-22 10:08:03 +0000
committerSascha Hauer <s.hauer@pengutronix.de>2006-05-22 10:08:03 +0000
commit427dd19fc1e05db07f54e3fd876cb089de12b842 (patch)
treecd500e69ad3d6e6d85e074d41c42210751685e75 /scripts/apply_patch_series.sh
parentcdfc3d0f70fb63b0e67df7747e49e9db865f7582 (diff)
downloadptxdist-427dd19fc1e05db07f54e3fd876cb089de12b842.tar.gz
ptxdist-427dd19fc1e05db07f54e3fd876cb089de12b842.tar.xz
add -p option: apply all patches from a directory
git-svn-id: https://svn.pengutronix.de/svn/ptxdist/trunks/ptxdist-0.10-trunk@5533 33e552b5-05e3-0310-8538-816dae2090ed
Diffstat (limited to 'scripts/apply_patch_series.sh')
-rwxr-xr-xscripts/apply_patch_series.sh43
1 files changed, 31 insertions, 12 deletions
diff --git a/scripts/apply_patch_series.sh b/scripts/apply_patch_series.sh
index cb50027de..62360c65e 100755
--- a/scripts/apply_patch_series.sh
+++ b/scripts/apply_patch_series.sh
@@ -1,6 +1,7 @@
#!/bin/bash
#
-# apply_patch_series: apply a patch series to a directory
+# apply_patch_series: either apply a patch series to a directory or
+# apply all patches from a given directory
#
. `dirname $0`/libptxdist.sh
@@ -13,6 +14,7 @@ usage() {
echo " Arguments:"
echo
echo " -s <file> series file to use"
+ echo " -p <path> apply all patches from <path>"
echo " -d <directory> target directory"
exit 1
}
@@ -20,29 +22,46 @@ usage() {
#
# Option parser
#
-while [ $# -gt 0 ]; do
- case "$1" in
- -s) SERIES=`ptxd_abspath $2`; shift 2 ;;
- -d) TARGET=`ptxd_abspath $2`; shift 2 ;;
- *) usage "unknown option $1" ;;
- esac
+while getopts "hs:d:p:" OPT
+do
+ case "$OPT" in
+ h) usage
+ exit 1
+ ;;
+ s) SERIES=`ptxd_abspath $OPTARG`;
+ ;;
+ d) TARGET=`ptxd_abspath $OPTARG`;
+ ;;
+ p) PATCHESPATH=`ptxd_abspath $OPTARG`;
+ esac
done
+shift `expr $OPTIND - 1`
#
# Sanity checks
#
-[ -z "$SERIES" ] && usage "${PREFIX} error: specify a series file with -s"
-[ -z "$TARGET" ] && usage "${PREFIX} error: specify a target directory with -d"
+[ -z "$SERIES" ] && [ -z "$PATCHESPATH" ] && usage "${PREFIX} error: specify a series file with -s or a patches directory with -p"
+[ -n "$SERIES" ] && [ -n "$PATCHESPATH" ] && usage "${PREFIX} error: the -s and -p option may not be used together"
+[ -z "$TARGET" ] && usage "${PREFIX} error: specify a target directory with -d"
+
+[ -n "$SERIES" ] && PATCHESPATH=`dirname $SERIES`
pushd "$TARGET" || exit 1
-cat "$SERIES" | egrep -v "^[[:space:]]*#" | egrep -v "^[[:space:]]*$" | while read patchfile unused; do
- abspatch=`dirname $SERIES`/"$patchfile"
+{
+ if [ -f "$SERIES" ]; then
+ cat "$SERIES"
+ else
+ cd $PATCHESPATH && find -name "*.patch" -or -name "*.diff" -or -name "*.gz" -or -name "*.bz2"
+ fi
+} |
+egrep -v "^[[:space:]]*#" | egrep -v "^[[:space:]]*$" | while read patchfile unused; do
+ abspatch="$PATCHESPATH"/"$patchfile"
if [ ! -e "$abspatch" ]; then
echo "patch $abspatch does not exist. aborting"
exit 1
fi
- case `basename $abspatch` in
+ case "$patchfile" in
*.gz)
CAT=zcat
;;