summaryrefslogtreecommitdiffstats
path: root/scripts/apply_patch_series.sh
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2006-01-25 16:57:53 +0000
committerSascha Hauer <s.hauer@pengutronix.de>2006-01-25 16:57:53 +0000
commitd1bb4b02db15abb3bba8812f498583d80348fe68 (patch)
tree998994a5f5170c1c6bc56efeb54964842f8d2ae4 /scripts/apply_patch_series.sh
parented75d0fbe0f8c12b659eca22a72a2e193844fe65 (diff)
downloadptxdist-d1bb4b02db15abb3bba8812f498583d80348fe68.tar.gz
ptxdist-d1bb4b02db15abb3bba8812f498583d80348fe68.tar.xz
add script to apply a patchstack
git-svn-id: https://svn.pengutronix.de/svn/ptxdist/trunks/ptxdist-0.9-trunk@4416 33e552b5-05e3-0310-8538-816dae2090ed
Diffstat (limited to 'scripts/apply_patch_series.sh')
-rwxr-xr-xscripts/apply_patch_series.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/scripts/apply_patch_series.sh b/scripts/apply_patch_series.sh
new file mode 100755
index 000000000..fd83c3efb
--- /dev/null
+++ b/scripts/apply_patch_series.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+#
+# apply_patch_series: apply a patch series to a directory
+#
+
+. `dirname $0`/libptxdist.sh
+
+usage() {
+ echo
+ [ -n "$1" ] && echo -e "${PREFIX} error: $1\n"
+ echo "usage: $0 <args>"
+ echo
+ echo " Arguments:"
+ echo
+ echo " -s <file> series file to use"
+ echo " -d <directory> target directory"
+ exit 1
+}
+
+#
+# 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
+done
+
+#
+# Sanity checks
+#
+[ -z "$SERIES" ] && usage "${PREFIX} error: specify a series file with -s"
+[ -z "$TARGET" ] && usage "${PREFIX} error: specify a target directory with -d"
+
+pushd "$TARGET" || exit 1
+
+cat "$SERIES" | egrep -v "^[[:space:]]*#" | egrep -v "^[[:space:]]*$" | while read patchfile unused; do
+ abspatch=`dirname $SERIES`/"$patchfile"
+ if [ ! -e "$abspatch" ]; then
+ echo "patch $abspatch does not exist. aborting"
+ exit 1
+ fi
+ echo "applying $abspatch"
+ cat "$abspatch" | patch -p1 || exit 1
+done
+
+if [ "$?" != 0 ]; then
+ exit 1;
+fi
+
+popd
+