isum.awk (2260B)
1 # Summarize the installation log, printing errors along with 2 # enough context to make sense of them. 3 4 BEGIN { 5 # print verbose 6 cd = "" 7 out = "/dev/stdout" 8 statuslen = 0 9 debug = 0 10 updates = "/dev/stderr" 11 if(ENVIRON["winid"] != "") # running in acme window 12 updates = "" 13 } 14 15 function myflush(f) 16 { 17 # fflush is not available on sun, but system("") appears to work everywhere 18 system("") 19 } 20 21 function clearstatus(noflush, i) 22 { 23 if(!updates) 24 return 25 for(i=0; i<statuslen; i++) 26 printf("\b \b") >updates 27 statuslen = 0 28 if(!noflush) 29 myflush(updates) 30 } 31 32 function status(s) 33 { 34 if(!updates) 35 return 36 clearstatus(1) 37 printf(" %s ", s) >updates 38 statuslen = length(s)+5 39 myflush(updates) 40 } 41 42 debug!=0 { print "# " $0 } 43 44 /^$/ { next } 45 46 /^echo cd / { next } 47 /^\+\+ pwd/ { next } 48 49 /^\* /{ 50 clearstatus() 51 if(debug) print "% mark" 52 print >out 53 myflush(out) 54 if(copy){ 55 print >copy 56 myflush(copy) 57 } 58 cmd = "" 59 printtabs = 1 # print indented lines immediately following 60 errors = 0 61 next 62 } 63 64 /^ / && printtabs!=0 { 65 clearstatus() 66 print >out 67 myflush(out) 68 if(copy){ 69 print >copy 70 myflush(copy) 71 } 72 next 73 } 74 75 { printtabs = 0 } 76 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 = 0 80 cmd = "" 81 if(!verbose) 82 cmd = cmd cd 83 cmd = cmd $0 "\n" 84 next 85 } 86 87 /^cd .+; mk .+/ && !verbose { 88 dir = $2 89 sub(/;$/, "", dir) 90 status(dir " mk " $4) 91 } 92 93 /^cd / { 94 if(debug) print "% cd" 95 errors = 0 96 if(verbose){ 97 print >out 98 myflush(out) 99 if(copy){ 100 print >copy 101 myflush(copy) 102 } 103 } 104 cd = $0 "\n" 105 cmd = "" 106 next 107 } 108 109 { 110 cmd = cmd $0 "\n" 111 } 112 113 errors != 0 { 114 clearstatus() 115 if(debug) print "% errors" 116 printf "%s", cmd >out 117 myflush(out) 118 if(copy){ 119 printf "%s", cmd >copy 120 myflush(copy) 121 } 122 cmd = "" 123 next 124 } 125 126 /^( |then|else|fi|done|[ar] - [^ ]*\.o$)/ { 127 next 128 } 129 130 /^(conflicts:)/ { 131 if(debug) print "% skip1" 132 next 133 } 134 135 /(up to date|nothing to see|assuming it will be|loop not entered|# WSYSTYPE)/ { 136 next 137 } 138 139 /(nodes\(%e\)|packed transitions)/ { 140 if(debug) print "% skip2" 141 next 142 } 143 144 { 145 # unexpected line 146 clearstatus() 147 if(debug) print "% errors1" 148 errors = 1 149 printf ">>> %s", cmd >out 150 myflush(out) 151 if(copy){ 152 printf ">>> %s", cmd >copy 153 myflush(copy) 154 } 155 cmd = "" 156 } 157