Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_posix/rc/bin/patch/create – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#!/bin/rc
2
rfork e
3
 
4
fn xchmod { 
5
	chmod $* >[2]/dev/null
6
}
7
 
8
if(~ $#* 0 1 2){
9
	echo 'usage: patch/create name email file... [< description]' >[1=2]
10
	exit usage
11
}
12
 
13
if(! echo $1 | grep -s '^[a-z_0-9.\-]+$'){
14
	echo 'bad name: [a-z0-9._\-]+ only' >[1=2]
15
	exit usage
16
}
17
if(! echo $2 | grep -s '^(-|[A-Za-z0-9.\-+]+@[A-Za-z0-9.\-+]+)$'){
18
	echo 'bad email: [a-z0-9.-+] only; use ''-'' to not leave an email address.' >[1=2]
19
	exit usage
20
}
21
 
22
if(! test -d /n/sources/patch){
23
	rfork n
24
	9fs sources
25
}
26
 
27
patch=$1
28
email=$2
29
shift
30
shift
31
d=/n/sources/patch/$patch
32
if(! mkdir $d){
33
	echo mkdir $d failed >[1=2]
34
	exit mkdir
35
}
36
if(! ~ $email -){
37
	echo $email >$d/email
38
}
39
 
40
xchmod o-w $d
41
>$d/readme
42
>$d/files
43
>$d/notes
44
for(i in $*){
45
	i=`{cleanname -d `{pwd} $i}
46
	if(! test -f $i){
47
		echo error: cannot find $i >[1=2]
48
		rm -rf $d
49
		exit oops
50
	}
51
	short=`{basename $i}
52
	uniq=$short
53
	n=0
54
	while(test -f $d/$uniq){
55
		uniq=$short.$n
56
		n=`{echo 1+$n | hoc}
57
	}
58
	cp $i $d/$uniq
59
	if(test -f /n/sources/plan9/$i){
60
		if(cmp -s /n/sources/plan9/$i $i)
61
			echo warning: new file $i does not differ from sources >[1=2]
62
		cp /n/sources/plan9/$i $d/$uniq.orig
63
	}
64
	if not
65
		echo warning: new file $i not on sources >[1=2]
66
	echo $i $uniq >>$d/files
67
}
68
@{builtin cd $d && xchmod ug+rw * && xchmod a+r *}
69
 
70
if(~ `{cat /proc/$pid/fd | awk 'NR==2{print $NF}'} */dev/cons && test -w /dev/consctl){
71
	>/dev/consctl {
72
		echo holdon
73
		cat >$d/readme
74
	}
75
}
76
if not
77
	cat >$d/readme
78
 
79
if(! test -s $d/readme){
80
	echo 'no description given; aborting' >[1=2]
81
	rm -rf $d
82
	exit oops
83
}
84
 
85
echo $d