1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #!/bin/rc
- rfork e
- if(~ $#* 0 1){
- echo 'usage: patch/create name file... [< description]' >[1=2]
- exit usage
- }
- if(! echo $1 | grep -s '^[a-z_0-9.\-]+$'){
- echo bad name
- exit usage
- }
- if(! test -d /n/sources/patch){
- rfork n
- 9fs sources
- }
- patch=$1
- d=/n/sources/patch/$patch
- if(! mkdir $d){
- echo mkdir $d failed >[1=2]
- exit mkdir
- }
- chmod o-w $d
- >$d/readme
- >$d/files
- >$d/notes
- shift
- 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
- chmod ug+rw $d/*
- chmod a+r $d/*
- }
- 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 >[1=2] please run patch/email $patch your-email-address
- echo >[1=2] so that 9trouble can mail you if there are questions. thanks.
- echo >[1=2] the email address will not be readable by other sources users.
- echo >[1=2]
- echo $d
|