plan9port/dist/isum.awk

158 lines
2.2 KiB
Awk
Raw Normal View History

2005-11-26 15:36:47 +00:00
# Summarize the installation log, printing errors along with
# enough context to make sense of them.
BEGIN {
# print verbose
cd = ""
2005-12-15 03:31:07 +00:00
out = "/dev/stdout"
2006-07-23 14:36:05 +00:00
statuslen = 0
2005-12-15 03:31:07 +00:00
debug = 0
2006-07-23 14:36:05 +00:00
updates = "/dev/stderr"
if(ENVIRON["winid"] != "") # running in acme window
updates = ""
2006-07-23 14:36:05 +00:00
}
function myflush(f)
{
# fflush is not available on sun, but system("") appears to work everywhere
system("")
}
function clearstatus(noflush, i)
2006-07-23 14:36:05 +00:00
{
if(!updates)
return
for(i=0; i<statuslen; i++)
printf("\b \b") >updates
statuslen = 0
2006-07-23 14:41:55 +00:00
if(!noflush)
myflush(updates)
2006-07-23 14:36:05 +00:00
}
function status(s)
{
if(!updates)
return
2006-07-23 14:41:55 +00:00
clearstatus(1)
2006-07-23 14:36:05 +00:00
printf(" %s ", s) >updates
statuslen = length(s)+5
myflush(updates)
2005-11-26 15:36:47 +00:00
}
2005-12-15 03:31:07 +00:00
debug!=0 { print "# " $0 }
2005-11-26 15:36:47 +00:00
/^$/ { next }
2005-11-28 21:14:44 +00:00
/^echo cd / { next }
/^\+\+ pwd/ { next }
2005-11-26 15:36:47 +00:00
/^\* /{
2006-07-23 14:36:05 +00:00
clearstatus()
2005-11-26 15:36:47 +00:00
if(debug) print "% mark"
print >out
myflush(out)
2006-07-23 14:36:05 +00:00
if(copy){
print >copy
myflush(copy)
2006-07-23 14:36:05 +00:00
}
2005-11-26 15:36:47 +00:00
cmd = ""
printtabs = 1 # print indented lines immediately following
errors = 0
next
}
2005-12-15 03:31:07 +00:00
/^ / && printtabs!=0 {
2006-07-23 14:36:05 +00:00
clearstatus()
2005-11-26 15:36:47 +00:00
print >out
myflush(out)
2006-07-23 14:36:05 +00:00
if(copy){
print >copy
myflush(copy)
2006-07-23 14:36:05 +00:00
}
2005-11-26 15:36:47 +00:00
next
}
{ printtabs = 0 }
/^(9a|9c|9l|9ar|9?install|cat pdf|cp|rm|mv|mk|9 yacc|9 lex|9 rc|do|for i|if|mk|gcc|cpp|cp|sh|cmp|rc|\.\/o)($|[^:])/ {
2005-11-26 15:36:47 +00:00
if(debug) print "% start"
errors = 0
cmd = ""
if(!verbose)
cmd = cmd cd
cmd = cmd $0 "\n"
next
}
2006-07-23 14:41:55 +00:00
/^cd .+; mk .+/ && !verbose {
dir = $2
sub(/;$/, "", dir)
status(dir " mk " $4)
}
2005-11-26 15:36:47 +00:00
/^cd / {
if(debug) print "% cd"
errors = 0
if(verbose){
print >out
myflush(out)
2006-07-23 14:36:05 +00:00
if(copy){
print >copy
myflush(copy)
2006-07-23 14:36:05 +00:00
}
}
2005-11-26 15:36:47 +00:00
cd = $0 "\n"
cmd = ""
next
}
{
cmd = cmd $0 "\n"
}
2005-12-15 03:31:07 +00:00
errors != 0 {
2006-07-23 14:36:05 +00:00
clearstatus()
2005-11-26 15:36:47 +00:00
if(debug) print "% errors"
printf "%s", cmd >out
myflush(out)
2006-07-23 14:36:05 +00:00
if(copy){
printf "%s", cmd >copy
myflush(copy)
2006-07-23 14:36:05 +00:00
}
2005-11-26 15:36:47 +00:00
cmd = ""
next
}
/^( |then|else|fi|done|[ar] - [^ ]*\.o$)/ {
next
}
2005-12-15 03:31:07 +00:00
/^(conflicts:)/ {
2005-11-26 15:36:47 +00:00
if(debug) print "% skip1"
next
}
/(up to date|nothing to see|assuming it will be|loop not entered|# WSYSTYPE)/ {
2005-11-26 15:36:47 +00:00
next
}
/(nodes\(%e\)|packed transitions)/ {
if(debug) print "% skip2"
next
}
{
# unexpected line
2006-07-23 14:36:05 +00:00
clearstatus()
2005-11-26 15:36:47 +00:00
if(debug) print "% errors1"
errors = 1
printf ">>> %s", cmd >out
myflush(out)
2006-07-23 14:36:05 +00:00
if(copy){
printf ">>> %s", cmd >copy
myflush(copy)
2006-07-23 14:36:05 +00:00
}
2005-11-26 15:36:47 +00:00
cmd = ""
}