blob: 55e659a00062cb46b25f2be1a2176e011e9575f4 (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
|