Blob
1 # Summarize the installation log, printing errors along with2 # enough context to make sense of them.4 BEGIN {5 # print verbose6 cd = ""7 out = "/dev/stdout"8 statuslen = 09 debug = 010 updates = "/dev/stderr"11 if(ENVIRON["winid"] != "") # running in acme window12 updates = ""13 }15 function myflush(f)16 {17 # fflush is not available on sun, but system("") appears to work everywhere18 system("")19 }21 function clearstatus(noflush, i)22 {23 if(!updates)24 return25 for(i=0; i<statuslen; i++)26 printf("\b \b") >updates27 statuslen = 028 if(!noflush)29 myflush(updates)30 }32 function status(s)33 {34 if(!updates)35 return36 clearstatus(1)37 printf(" %s ", s) >updates38 statuslen = length(s)+539 myflush(updates)40 }42 debug!=0 { print "# " $0 }44 /^$/ { next }46 /^echo cd / { next }47 /^\+\+ pwd/ { next }49 /^\* /{50 clearstatus()51 if(debug) print "% mark"52 print >out53 myflush(out)54 if(copy){55 print >copy56 myflush(copy)57 }58 cmd = ""59 printtabs = 1 # print indented lines immediately following60 errors = 061 next62 }64 /^ / && printtabs!=0 {65 clearstatus()66 print >out67 myflush(out)68 if(copy){69 print >copy70 myflush(copy)71 }72 next73 }75 { printtabs = 0 }77 /^(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)($|[^:])/ {78 if(debug) print "% start"79 errors = 080 cmd = ""81 if(!verbose)82 cmd = cmd cd83 cmd = cmd $0 "\n"84 next85 }87 /^cd .+; mk .+/ && !verbose {88 dir = $289 sub(/;$/, "", dir)90 status(dir " mk " $4)91 }93 /^cd / {94 if(debug) print "% cd"95 errors = 096 if(verbose){97 print >out98 myflush(out)99 if(copy){100 print >copy101 myflush(copy)102 }103 }104 cd = $0 "\n"105 cmd = ""106 next107 }109 {110 cmd = cmd $0 "\n"111 }113 errors != 0 {114 clearstatus()115 if(debug) print "% errors"116 printf "%s", cmd >out117 myflush(out)118 if(copy){119 printf "%s", cmd >copy120 myflush(copy)121 }122 cmd = ""123 next124 }126 /^( |then|else|fi|done|[ar] - [^ ]*\.o$)/ {127 next128 }130 /^(conflicts:)/ {131 if(debug) print "% skip1"132 next133 }135 /(up to date|nothing to see|assuming it will be|loop not entered)/ {136 next137 }139 /(nodes\(%e\)|packed transitions)/ {140 if(debug) print "% skip2"141 next142 }144 {145 # unexpected line146 clearstatus()147 if(debug) print "% errors1"148 errors = 1149 printf ">>> %s", cmd >out150 myflush(out)151 if(copy){152 printf ">>> %s", cmd >copy153 myflush(copy)154 }155 cmd = ""156 }