summaryrefslogtreecommitdiffstats
path: root/bin/patch-wrapper.in
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2006-02-06 05:31:10 +0000
committerAndreas Gruenbacher <agruen@suse.de>2006-02-06 05:31:10 +0000
commit2a02ce16ee3f20d46dc500bf08b47e10187a28f9 (patch)
tree61ae675308fa015dfd47c474581b2d6f6a80d6c8 /bin/patch-wrapper.in
parent1c56918eee78602861b04188394895dfd9a1876b (diff)
downloadquilt-2a02ce16ee3f20d46dc500bf08b47e10187a28f9.tar.gz
- bin/patch-wrapper.in: Add hack to follow pipes via /proc on
Linux (zcat patch.diff.gz | patch -p0, etc.).
Diffstat (limited to 'bin/patch-wrapper.in')
-rwxr-xr-xbin/patch-wrapper.in21
1 files changed, 17 insertions, 4 deletions
diff --git a/bin/patch-wrapper.in b/bin/patch-wrapper.in
index 46ef8ae..5f2f107 100755
--- a/bin/patch-wrapper.in
+++ b/bin/patch-wrapper.in
@@ -149,6 +149,18 @@ else
fi
fi
+find_pipe_patch() {
+ declare patch=$1
+ patch=${patch//\[/\\[}
+ patch=${patch//\]/\\]}
+ set -- $(stat -c $'%a %N\n' /proc/*/fd/* 2>/dev/null \
+ | sed -nre "s,^300 \`(/proc/.*/fd)/.*' -> \`$patch'$,\\1,p")
+ set -- $(stat -c $'%a %N\n' $1/* 2>/dev/null \
+ | sed -nre "s,^500 \`.*' -> \`(.*)',\\1,p")
+ [ $# -eq 1 ] || set -- "$patch"
+ echo "$1"
+}
+
if [ -n "$cannot_handle" ]
then
$PATCH "${original_options[@]}"
@@ -160,9 +172,10 @@ then
patch=$opt_input
else
patch=$(readlink /proc/self/fd/0)
- # FIXME: try to recognize pipes, find the other end of a pipe
- # in /proc, and for gzip and bzip2 processes, use the file
- # that the process is reading from.
+ if [[ "$patch" =~ "^pipe:" ]]
+ then
+ patch=$(find_pipe_patch "$patch")
+ fi
fi
patch=${patch#$PWD/}
@@ -173,8 +186,8 @@ if [ -e "$patch" ]
then
if [ "${patch:0:1}" = / ]
then
+ ln -s "$patch" "$quilt_patches$patch"
patch=${patch#/}
- ln -s "$patch" "$quilt_patches/$patch"
else
while ! [ "$dir/$updir$patch" -ef "$patch" ]
do