aboutsummaryrefslogtreecommitdiff
path: root/undopatch
blob: e46bc54e68ef81a5057aaec632b172eed87d1e85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

case "$PWD" in
/usr/pkgsrc/*/*) ;;
*) echo not in package directory 1>&2; exit 1 ;;
esac

w=/usr/pkgsrc/distfiles/$(sed -n '/.*(\(.*\)).*/{s//\1/;p;q}' distinfo)

done=$(dirname $w)/.$(basename $w).done

if [ ! -e "$done" ]; then
	echo extracting archive... 1>&2
	cd $(dirname $w)
	tar xf $w
	touch $done
	cd -
fi

echo undoing patches... 1>&2
cmd=echo\ cp
[ x"$1" = x"-x" ] && cmd=cp || echo '(preview, no -x)' 1>&2
find . -name '*.orig' | while read f; do
	f=${f%.orig}
	$cmd $(dirname $w)/${f#./work/} $f
done