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 }13 function clearstatus( noflush, i)14 {15 if(!updates)16 return17 for(i=0; i<statuslen; i++)18 printf("\b \b") >updates19 statuslen = 020 if(!noflush)21 fflush(updates)22 }24 function status(s)25 {26 if(!updates)27 return28 clearstatus(1)29 printf(" %s ", s) >updates30 statuslen = length(s)+531 fflush(updates)32 }34 debug!=0 { print "# " $0 }36 /^$/ { next }38 /^echo cd / { next }39 /^\+\+ pwd/ { next }41 /^\* /{42 clearstatus()43 if(debug) print "% mark"44 print >out45 fflush(out)46 if(copy){47 print >copy48 fflush(copy)49 }50 cmd = ""51 printtabs = 1 # print indented lines immediately following52 errors = 053 next54 }56 /^ / && printtabs!=0 {57 clearstatus()58 print >out59 fflush(out)60 if(copy){61 print >copy62 fflush(copy)63 }64 next65 }67 { printtabs = 0 }69 /^(9a|9c|9l|9ar|9?install|cp|rm|mv|mk|9 yacc|9 lex|9 rc|do|for i|if|mk|gcc|cpp|cp|sh|cmp|rc|\.\/o)($|[^:])/ {70 if(debug) print "% start"71 errors = 072 cmd = ""73 if(!verbose)74 cmd = cmd cd75 cmd = cmd $0 "\n"76 next77 }79 /^cd .+; mk .+/ && !verbose {80 dir = $281 sub(/;$/, "", dir)82 status(dir " mk " $4)83 }85 /^cd / {86 if(debug) print "% cd"87 errors = 088 if(verbose){89 print >out90 fflush(out)91 if(copy){92 print >copy93 fflush(copy)94 }95 }96 cd = $0 "\n"97 cmd = ""98 next99 }101 {102 cmd = cmd $0 "\n"103 }105 errors != 0 {106 clearstatus()107 if(debug) print "% errors"108 printf "%s", cmd >out109 fflush(out)110 if(copy){111 printf "%s", cmd >copy112 fflush(copy)113 }114 cmd = ""115 next116 }118 /^( |then|else|fi|done|[ar] - [^ ]*\.o$)/ {119 next120 }122 /^(conflicts:)/ {123 if(debug) print "% skip1"124 next125 }127 /(up to date|nothing to see|assuming it will be|loop not entered)/ {128 next129 }131 /(nodes\(%e\)|packed transitions)/ {132 if(debug) print "% skip2"133 next134 }136 {137 # unexpected line138 clearstatus()139 if(debug) print "% errors1"140 errors = 1141 printf ">>> %s", cmd >out142 fflush(out)143 if(copy){144 printf ">>> %s", cmd >copy145 fflush(copy)146 }147 cmd = ""148 }