summaryrefslogtreecommitdiff
path: root/patch/patch-create-i
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-01-28 21:33:30 +0000
committerJohn Ankarström <john@ankarstrom.se>2021-01-28 21:33:30 +0000
commit51b5b02f52cc6f314029f3f2fe97afdc26ba0f25 (patch)
tree711d1efadeb78ad9b2d9f7b629350358838bc626 /patch/patch-create-i
parentf3fd330cddade1c66d0f101d5cc6f657c4cd1bb6 (diff)
downloadplan9-51b5b02f52cc6f314029f3f2fe97afdc26ba0f25.tar.gz
Add various patches
Diffstat (limited to 'patch/patch-create-i')
-rw-r--r--patch/patch-create-i/create98
-rwxr-xr-xpatch/patch-create-i/create.orig85
-rw-r--r--patch/patch-create-i/email1
-rw-r--r--patch/patch-create-i/files1
-rw-r--r--patch/patch-create-i/notes0
-rw-r--r--patch/patch-create-i/readme1
6 files changed, 186 insertions, 0 deletions
diff --git a/patch/patch-create-i/create b/patch/patch-create-i/create
new file mode 100644
index 0000000..c9fcf24
--- /dev/null
+++ b/patch/patch-create-i/create
@@ -0,0 +1,98 @@
+#!/bin/rc
+rfork e
+
+fn xchmod {
+ chmod $* >[2]/dev/null
+}
+
+flagfmt='i'
+args='name email file... [< description]'
+
+if(! ifs=() eval `{aux/getflags $*} || ~ $#* 0 1 2){
+ aux/usage
+ exit usage
+}
+
+if(! echo $1 | grep -s '^[a-z_0-9.\-]+$'){
+ echo 'bad name: [a-z0-9._\-]+ only' >[1=2]
+ exit usage
+}
+if(! echo $2 | grep -s '^(-|[A-Za-z0-9.\-+]+@[A-Za-z0-9.\-+]+)$'){
+ echo 'bad email: [a-z0-9.-+] only; use ''-'' to not leave an email address.' >[1=2]
+ exit usage
+}
+
+if(! test -d /n/sources/patch){
+ rfork n
+ 9fs sources
+}
+
+patch=$1
+email=$2
+shift
+shift
+d=/n/sources/patch/$patch
+if(! mkdir $d){
+ echo mkdir $d failed >[1=2]
+ exit mkdir
+}
+if(! ~ $email -){
+ echo $email >$d/email
+}
+
+xchmod o-w $d
+>$d/readme
+>$d/files
+>$d/notes
+for(i in $*){
+ i=`{cleanname -d `{pwd} $i}
+ if(! test -f $i){
+ echo error: cannot find $i >[1=2]
+ rm -rf $d
+ exit oops
+ }
+ short=`{basename $i}
+ uniq=$short
+ n=0
+ while(test -f $d/$uniq){
+ uniq=$short.$n
+ n=`{echo 1+$n | hoc}
+ }
+ if(test -f /n/sources/plan9/$i){
+ cp /n/sources/plan9/$i $d/$uniq.orig
+ if(~ $flagi 1)
+ idiff $d/$uniq.orig $i > $d/$uniq
+ if not
+ cp $i $d/$uniq
+ if(~ $status ''){
+ echo $i $uniq >>$d/files
+ if(cmp -s /n/sources/plan9/$i $i)
+ echo warning: new file $i does not differ from sources >[1=2]
+ }
+ if not
+ echo warning: skipping file $i >[1=2]
+ }
+ if not{
+ echo warning: new file $i not on sources >[1=2]
+ cp $i $d/$uniq
+ echo $i $uniq >>$d/files
+ }
+}
+@{builtin cd $d && xchmod ug+rw * && xchmod a+r *}
+
+if(~ `{cat /proc/$pid/fd | awk 'NR==2{print $NF}'} */dev/cons && test -w /dev/consctl){
+ >/dev/consctl {
+ echo holdon
+ cat >$d/readme
+ }
+}
+if not
+ cat >$d/readme
+
+if(! test -s $d/readme){
+ echo 'no description given; aborting' >[1=2]
+ rm -rf $d
+ exit oops
+}
+
+echo $d
diff --git a/patch/patch-create-i/create.orig b/patch/patch-create-i/create.orig
new file mode 100755
index 0000000..55e659a
--- /dev/null
+++ b/patch/patch-create-i/create.orig
@@ -0,0 +1,85 @@
+#!/bin/rc
+rfork e
+
+fn xchmod {
+ chmod $* >[2]/dev/null
+}
+
+if(~ $#* 0 1 2){
+ echo 'usage: patch/create name email file... [< description]' >[1=2]
+ exit usage
+}
+
+if(! echo $1 | grep -s '^[a-z_0-9.\-]+$'){
+ echo 'bad name: [a-z0-9._\-]+ only' >[1=2]
+ exit usage
+}
+if(! echo $2 | grep -s '^(-|[A-Za-z0-9.\-+]+@[A-Za-z0-9.\-+]+)$'){
+ echo 'bad email: [a-z0-9.-+] only; use ''-'' to not leave an email address.' >[1=2]
+ exit usage
+}
+
+if(! test -d /n/sources/patch){
+ rfork n
+ 9fs sources
+}
+
+patch=$1
+email=$2
+shift
+shift
+d=/n/sources/patch/$patch
+if(! mkdir $d){
+ echo mkdir $d failed >[1=2]
+ exit mkdir
+}
+if(! ~ $email -){
+ echo $email >$d/email
+}
+
+xchmod o-w $d
+>$d/readme
+>$d/files
+>$d/notes
+for(i in $*){
+ i=`{cleanname -d `{pwd} $i}
+ if(! test -f $i){
+ echo error: cannot find $i >[1=2]
+ rm -rf $d
+ exit oops
+ }
+ short=`{basename $i}
+ uniq=$short
+ n=0
+ while(test -f $d/$uniq){
+ uniq=$short.$n
+ n=`{echo 1+$n | hoc}
+ }
+ cp $i $d/$uniq
+ if(test -f /n/sources/plan9/$i){
+ if(cmp -s /n/sources/plan9/$i $i)
+ echo warning: new file $i does not differ from sources >[1=2]
+ cp /n/sources/plan9/$i $d/$uniq.orig
+ }
+ if not
+ echo warning: new file $i not on sources >[1=2]
+ echo $i $uniq >>$d/files
+}
+@{builtin cd $d && xchmod ug+rw * && xchmod a+r *}
+
+if(~ `{cat /proc/$pid/fd | awk 'NR==2{print $NF}'} */dev/cons && test -w /dev/consctl){
+ >/dev/consctl {
+ echo holdon
+ cat >$d/readme
+ }
+}
+if not
+ cat >$d/readme
+
+if(! test -s $d/readme){
+ echo 'no description given; aborting' >[1=2]
+ rm -rf $d
+ exit oops
+}
+
+echo $d
diff --git a/patch/patch-create-i/email b/patch/patch-create-i/email
new file mode 100644
index 0000000..191feb6
--- /dev/null
+++ b/patch/patch-create-i/email
@@ -0,0 +1 @@
+john@ankarstrom.se
diff --git a/patch/patch-create-i/files b/patch/patch-create-i/files
new file mode 100644
index 0000000..5d6e99c
--- /dev/null
+++ b/patch/patch-create-i/files
@@ -0,0 +1 @@
+/rc/bin/patch/create create
diff --git a/patch/patch-create-i/notes b/patch/patch-create-i/notes
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/patch/patch-create-i/notes
diff --git a/patch/patch-create-i/readme b/patch/patch-create-i/readme
new file mode 100644
index 0000000..01147b0
--- /dev/null
+++ b/patch/patch-create-i/readme
@@ -0,0 +1 @@
+patch/create -i creates patch interactively with idiff