<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf8">
<title>/usr/web/sources/contrib/rsc/makemail - Plan 9 from Bell Labs</title>
<!-- THIS FILE IS AUTOMATICALLY GENERATED. -->
<!-- EDIT sources.tr INSTEAD. -->
</meta>
</head>
<body>
<p style="margin-top: 0; margin-bottom: 0.17in"></p>
<p style="line-height: 1.2em; margin-left: 1.00in; text-indent: 0.00in; margin-right: 1.00in; margin-top: 0; margin-bottom: 0; text-align: center;">
<span style="font-size: 10pt"><a href="/plan9/">Plan 9 from Bell Labs</a>&rsquo;s /usr/web/sources/contrib/rsc/makemail</span></p>
<p style="margin-top: 0; margin-bottom: 0.17in"></p>
<p style="margin-top: 0; margin-bottom: 0.17in"></p>
<center><font size=-1>
Copyright © 2009 Alcatel-Lucent.<br />
Distributed under the
<a href="/plan9/license.html">Lucent Public License version 1.02</a>.
<br />
<a href="/plan9/download.html">Download the Plan 9 distribution.</a>
</font>
</center>
<p style="margin-top: 0; margin-bottom: 0.17in"></p>
<table width="100%" cellspacing=0 border=0><tr><td align="center">
<table cellspacing=0 cellpadding=5 bgcolor="#eeeeff"><tr><td align="left">
<pre>
<!-- END HEADER -->
#!/bin/rc

rfork ne
ramfs
if(! test -f /bin/bincmp)
	bind -a /usr/rsc/bin/rc /bin
if(! test -f /bin/binhash)
	bind -a /usr/rsc/bin/$cputype /bin

cd /sys/lib/dist/changes
9fs sourcesdump
9fs sources
if(~ $#* 1 &amp;&amp; ~ $1 now){
	*=(`{yesterday /n/sources/plan9 | sed 's;/plan9;;'} /n/sources)
}
switch($#*){
case 0
	y=`{date |awk '{print $NF}'}
	x=`{ls /n/sourcesdump/$y | tail -2}
	if(~ $#x 1){
		ly=`{echo $y^-1 | hoc}
		x=(`{ls /n/sourcesdump/$ly | tail -1} $x)
	}
	old=$x(1)
	new=$x(2)
case 2
	old=$1
	new=$2
}
# group changes to common files
fn group {
	switch($4){
	case sys/src/9/*
		echo kernel
	case sys/src/boot/*
		echo 9load
	case 386/*
		echo binaries
	case sys/man/*/*
		echo $4 | sed 's;sys/man/[0-9]+/;;'
	case sys/src/lib*/*
		echo $4 | sed 's;sys/src/;;; s;/.*;;'
	case sys/src/cmd/disk/prep/*
		echo $4 | sed 's;sys/src/cmd/disk/prep/;;; s;/.*;;; s;\.[cy]$;;'
	case sys/src/cmd/ip/*
		echo $4 | sed 's;sys/src/cmd/ip/;;; s;/.*;;; s;\.[cy]$;;'
	case sys/src/cmd/aux/*
		echo $4 | sed 's;sys/src/cmd/aux/;;; s;/.*;;; s;\.[cy]$;;'
	case sys/src/cmd/*/*
		echo $4 | sed 's;sys/src/cmd/;;; s;/.*;;'
	case sys/src/cmd/*
		echo $4 | sed 's;sys/src/cmd/;;; s;\.[cy]$;;'
	case sys/src/games/*/*
		echo $4 | sed 's;sys/src/games/;;; s;/.*;;'
	case sys/lib/kbmap/*
		echo kbmap
	case *
		echo $4
	} | tr '/' '_'	
}

fn summarize {
	# time n a|c|d|m name name mode uid gid mtime size
	switch($3){
	case c
		if(! ~ $4 $didsum){
			didsum=($didsum $4)
			switch($4){
			case 386/9load*
				;
			case 386/* */386/*
				bincmp $old/plan9/$4 $new/plan9/$4 | sed 's/^/	/'
			case *
				diff -c $old/plan9/$4 $new/plan9/$4 |
					sed 's!(^/.*) - !\1 - \
!' |
					sed 's/^/	/' &gt;/tmp/a
				if(test `{wc -l &lt;/tmp/a} -gt 100){
					echo '	[diffs elided - too long]'&gt;/tmp/a
					echo '	['diff -c $old/plan9/$4 $new/plan9/$4']' &gt;&gt;/tmp/a
				}
				cat /tmp/a
			}
		}
	}	
}

fn x {
	# time n a|c|d|m name name mode uid gid mtime size
	base=$1.$2
	echo '#' $*
	if(! test -f $base.sum)
		summarize $* &gt;$base.sum
	grp=`{group $*}
	xbase=$base
	if(test -f grp.$grp &amp;&amp; ! test -s $base.txt){
		xbase=`{cat grp.$grp}
		echo '@'$xbase &gt;$base.txt
	}
	nnn=1
	while(test -s $xbase.txt &amp;&amp; sed 1q $xbase.txt |grep -s '^@' &amp;&amp; ! ~ $nnn 100){
		xbase=`{sed 1q $xbase.txt | sed 's/^@//'}
		nnn=`{echo 1+$nnn|hoc}
	}
	if(! test -f grp.$grp)
		echo $xbase &gt;grp.$grp
	if(! test -s $xbase.txt){
		&gt;$xbase.txt
	}
	# Header starts with annotations.
	if(! test -s $xbase.txt.0){
		if(test -s $xbase.txt){
			echo '#RSC# cat &gt;/sys/lib/dist/changes/'$xbase.txt' &lt;&lt; EOF' &gt;$xbase.txt.0
			cat $xbase.txt &gt;&gt;$xbase.txt.0
			echo '#RSC# EOF' &gt;&gt;$xbase.txt.0
		}
		if not{
			{
				echo '% cat &gt;/sys/lib/dist/changes/'$xbase.txt' &lt;&lt; EOF'
				echo Your text here.
				echo EOF
			} &gt;$xbase.txt.0
		}
	}
	# Next come the ls lines and change summaries.
	if(test -f $xbase.txt.1 &amp;&amp; ! cmp -s $base.sum $xbase.txt.1){
		cat $xbase.txt.1 &gt;&gt;$xbase.txt.0
		rm $xbase.txt.1
	}
	echo '#RSC#' $base $* &gt;&gt;$xbase.txt.0
	@{cd $new/plan9; ls -lmd $4 | sed 's/^/ /'} &gt;&gt;$xbase.txt.0
	cp $base.sum $xbase.txt.1
}

rm -f *.sum
rm -f *.txt.[01] grp.* sum.all
whatis old new
diff $old/plan9/dist/replica/plan9.log $new/plan9/dist/replica/plan9.log | 
	sed -n 's/^&gt; //p' | 
	sed '/^[0-9]+ [0-9]+ . (386\/(9pc|9load|init|bin\/|lib\/)|rc\/bin\/stock|acme\/bin\/386|sys\/games\/lib\/fortunes|lib\/face\/)/d' |
	sed 's; ;'' '';g; s;^;'';; s;$;'';; s;^;x ;' |
	rc

for(i in `{ls *.txt.0 &gt;[2]/dev/null}){
	x=`{echo $i | sed 's/0$/1/'}
	if(test -s $x)
		cat $x &gt;&gt;$i
	echo &gt;&gt;$i
}

cat *.txt.0 &gt;sum.all.local
if(grep -s '^% cat &gt;' sum.all.local)
	echo NEED SOME FILES &gt;&gt;sum.all.local
echo ',s/\n\n\n+/\n\n/g
	w
	q' | sam -d sum.all.local &gt;[2]/dev/null

grep -v '^#RSC#' sum.all.local &gt;sum.all
<!-- BEGIN TAIL -->
</pre>
</td></tr></table>
</td></tr></table>
<p style="margin-top: 0; margin-bottom: 0.17in"></p>
<p style="line-height: 1.2em; margin-left: 1.00in; text-indent: 0.00in; margin-right: 1.00in; margin-top: 0; margin-bottom: 0; text-align: center;">
<span style="font-size: 10pt"></span></p>
<p style="margin-top: 0; margin-bottom: 0.50in"></p>
<p style="margin-top: 0; margin-bottom: 0.33in"></p>
<center><table border="0"><tr>
<td valign="middle"><a href="http://www.alcatel-lucent.com/"><img border="0" src="/plan9/img/logo_ft.gif" alt="Bell Labs" />
</a></td>
<td valign="middle"><a href="http://www.opensource.org"><img border="0" alt="OSI certified" src="/plan9/img/osi-certified-60x50.gif" />
</a></td>
<td><img style="padding-right: 45px;" alt="Powered by Plan 9" src="/plan9/img/power36.gif" />
</td>
</tr></table></center>
<p style="margin-top: 0; margin-bottom: 0.17in"></p>
<center>
<span style="font-size: 10pt">(<a href="/plan9/">Return to Plan 9 Home Page</a>)</span>
</center>
<p style="margin-top: 0; margin-bottom: 0.17in"></p>
<center><font size=-1>
<span style="font-size: 10pt"><a href="http://www.lucent.com/copyright.html">Copyright</a></span>
<span style="font-size: 10pt">© 2009 Alcatel-Lucent.</span>
<span style="font-size: 10pt">All Rights Reserved.</span>
<br />
<span style="font-size: 10pt">Comments to</span>
<span style="font-size: 10pt"><a href="mailto:webmaster@plan9.bell-labs.com">webmaster@plan9.bell-labs.com</a>.</span>
</font></center>
</body>
</html>

