#!/bin/ksh
#obtain archives from apache site
perl geturl.perl

#process mail folders
#cat together cvs messages 
for i in $(ls mail/cvs*.gz | sort);do gunzip -c $i; done > cvsmail
for i in $(ls mail/cvs*[0-9] | sort);do cat $i; done >> cvsmail

#cat together bugdb messages 
for i in $(ls mail/bug*.gz | sort);do gunzip -c $i; done > bugmail
for i in $(ls mail/bug*[0-9] | sort);do cat $i; done >> bugmail

#cat together developer mailing list messages 
for i in $(ls mail/nh*.gz | sort);do gunzip -c $i; done > nhmail
for i in $(ls mail/nh*[0-9] | sort);do cat $i; done >> nhmail

#create table summarizing discussion messages
perl -Iblib/lib procnhmail.perl > nh

#produce two tables mailmrs and maildelta
perl -Iblib/lib proccvsmail.perl

#produce bug list table (mailbugs)
perl -Iblib/lib procbugmail.perl | sort -u > bugs
#extract info from abstract on who submitted the MR (contributed to it)
perl -Iblib/lib getSubmitted.perl > mailfixmrs


#how much does it takes to close a bug
#first get all PR numbers associated with changes in changepr
cut -d\; -f11 mailfixmrs | \
awk -F\: '{for(i=1;i<=NF;i++)print $i;}'| \
sort -u> changepr
#produce start/end status/date for each PR
perl fixbugs.perl < bugs > fixbugs
#produce the type of bug inf (core, module, etc.)
cut -d\; -f1-7,9,10 fixbugs | perl cleanbugs.perl > cleanbugs


#Who wrote patches?
cut -d\; -f3,4,5,7 nh1 | grep -v ';yes;' | grep 1$ | perl fixNames.perl | sort | uniq -c | sort -n | awk '{print i+=$1,$1,$2,$3,$4;}'

#################################################
#look at who is who in terms of delta:
#################################################

perl countChanges.perl > changes






