summaryrefslogtreecommitdiff
path: root/patch/patch-update/update
diff options
context:
space:
mode:
Diffstat (limited to 'patch/patch-update/update')
-rwxr-xr-xpatch/patch-update/update35
1 files changed, 35 insertions, 0 deletions
diff --git a/patch/patch-update/update b/patch/patch-update/update
new file mode 100755
index 0000000..6d7f2bf
--- /dev/null
+++ b/patch/patch-update/update
@@ -0,0 +1,35 @@
+#!/bin/rc -e
+
+# patch/update -- update file(s) in patch
+
+flagfmt=a
+args='name file...'
+if(! ifs=() eval `{aux/getflags $*} || test $#* -lt 2){
+ aux/usage
+ exit usage
+}
+
+if(! test -d /n/sources/patch){
+ rfork n
+ 9fs sources
+}
+
+d=/n/sources/patch/$1
+shift
+if(! test -d $d){
+ echo 'no such patch' $d >[1=2]
+ exit nopatch
+}
+
+for(file in $*){
+ src=`{cleanname -d `{pwd} $file}
+ dst=`{awk '$1 == ENVIRON["src"] { print $2 }' $d/files}
+ if (~ $dst ''){
+ echo $src not found in $d/files -- wrong patch? >[1=2]
+ exit 'nofile'
+ }
+ echo cp $src $d/$dst
+ cp $src $d/$dst
+ chmod ug+rw $d/$dst >[2]/dev/null
+ chmod a+r $d/$dst >[2]/dev/null
+}