rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 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 = "" |
rsc | 5348a60 | 2005-12-15 03:31:07 +0000 | [diff] [blame] | 7 | out = "/dev/stdout" |
rsc | 32a580f | 2006-07-23 14:36:05 +0000 | [diff] [blame^] | 8 | statuslen = 0 |
rsc | 5348a60 | 2005-12-15 03:31:07 +0000 | [diff] [blame] | 9 | debug = 0 |
rsc | 32a580f | 2006-07-23 14:36:05 +0000 | [diff] [blame^] | 10 | updates = "/dev/stderr" |
| 11 | } |
| 12 | |
| 13 | function clearstatus( i) |
| 14 | { |
| 15 | if(!updates) |
| 16 | return |
| 17 | for(i=0; i<statuslen; i++) |
| 18 | printf("\b \b") >updates |
| 19 | statuslen = 0 |
| 20 | fflush(updates) |
| 21 | } |
| 22 | |
| 23 | function status(s) |
| 24 | { |
| 25 | if(!updates) |
| 26 | return |
| 27 | clearstatus() |
| 28 | printf(" %s ", s) >updates |
| 29 | statuslen = length(s)+5 |
| 30 | fflush(updates) |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 31 | } |
| 32 | |
rsc | 5348a60 | 2005-12-15 03:31:07 +0000 | [diff] [blame] | 33 | debug!=0 { print "# " $0 } |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 34 | |
| 35 | /^$/ { next } |
| 36 | |
rsc | 6637b80 | 2005-11-28 21:14:44 +0000 | [diff] [blame] | 37 | /^echo cd / { next } |
| 38 | /^\+\+ pwd/ { next } |
| 39 | |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 40 | /^\* /{ |
rsc | 32a580f | 2006-07-23 14:36:05 +0000 | [diff] [blame^] | 41 | clearstatus() |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 42 | if(debug) print "% mark" |
| 43 | print >out |
| 44 | fflush(out) |
rsc | 32a580f | 2006-07-23 14:36:05 +0000 | [diff] [blame^] | 45 | if(copy){ |
| 46 | print >copy |
| 47 | fflush(copy) |
| 48 | } |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 49 | cmd = "" |
| 50 | printtabs = 1 # print indented lines immediately following |
| 51 | errors = 0 |
| 52 | next |
| 53 | } |
| 54 | |
rsc | 5348a60 | 2005-12-15 03:31:07 +0000 | [diff] [blame] | 55 | /^ / && printtabs!=0 { |
rsc | 32a580f | 2006-07-23 14:36:05 +0000 | [diff] [blame^] | 56 | clearstatus() |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 57 | print >out |
| 58 | fflush(out) |
rsc | 32a580f | 2006-07-23 14:36:05 +0000 | [diff] [blame^] | 59 | if(copy){ |
| 60 | print >copy |
| 61 | fflush(copy) |
| 62 | } |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 63 | next |
| 64 | } |
| 65 | |
| 66 | { printtabs = 0 } |
| 67 | |
| 68 | /^(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)($|[^:])/ { |
| 69 | if(debug) print "% start" |
| 70 | errors = 0 |
| 71 | cmd = "" |
| 72 | if(!verbose) |
| 73 | cmd = cmd cd |
| 74 | cmd = cmd $0 "\n" |
| 75 | next |
| 76 | } |
| 77 | |
| 78 | /^cd / { |
| 79 | if(debug) print "% cd" |
| 80 | errors = 0 |
| 81 | if(verbose){ |
| 82 | print >out |
| 83 | fflush(out) |
rsc | 32a580f | 2006-07-23 14:36:05 +0000 | [diff] [blame^] | 84 | if(copy){ |
| 85 | print >copy |
| 86 | fflush(copy) |
| 87 | } |
| 88 | } |
| 89 | else{ |
| 90 | dir = $2 |
| 91 | sub(/;$/, "", dir) |
| 92 | status(dir) |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 93 | } |
| 94 | cd = $0 "\n" |
| 95 | cmd = "" |
| 96 | next |
| 97 | } |
| 98 | |
| 99 | { |
| 100 | cmd = cmd $0 "\n" |
| 101 | } |
| 102 | |
rsc | 5348a60 | 2005-12-15 03:31:07 +0000 | [diff] [blame] | 103 | errors != 0 { |
rsc | 32a580f | 2006-07-23 14:36:05 +0000 | [diff] [blame^] | 104 | clearstatus() |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 105 | if(debug) print "% errors" |
| 106 | printf "%s", cmd >out |
| 107 | fflush(out) |
rsc | 32a580f | 2006-07-23 14:36:05 +0000 | [diff] [blame^] | 108 | if(copy){ |
| 109 | printf "%s", cmd >copy |
| 110 | fflush(copy) |
| 111 | } |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 112 | cmd = "" |
| 113 | next |
| 114 | } |
| 115 | |
| 116 | /^( |then|else|fi|done|[ar] - [^ ]*\.o$)/ { |
| 117 | next |
| 118 | } |
| 119 | |
rsc | 5348a60 | 2005-12-15 03:31:07 +0000 | [diff] [blame] | 120 | /^(conflicts:)/ { |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 121 | if(debug) print "% skip1" |
| 122 | next |
| 123 | } |
| 124 | |
rsc | 5348a60 | 2005-12-15 03:31:07 +0000 | [diff] [blame] | 125 | /(up to date|nothing to see|assuming it will be|loop not entered)/ { |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 126 | next |
| 127 | } |
| 128 | |
| 129 | /(nodes\(%e\)|packed transitions)/ { |
| 130 | if(debug) print "% skip2" |
| 131 | next |
| 132 | } |
| 133 | |
| 134 | { |
| 135 | # unexpected line |
rsc | 32a580f | 2006-07-23 14:36:05 +0000 | [diff] [blame^] | 136 | clearstatus() |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 137 | if(debug) print "% errors1" |
| 138 | errors = 1 |
| 139 | printf ">>> %s", cmd >out |
| 140 | fflush(out) |
rsc | 32a580f | 2006-07-23 14:36:05 +0000 | [diff] [blame^] | 141 | if(copy){ |
| 142 | printf ">>> %s", cmd >copy |
| 143 | fflush(copy) |
| 144 | } |
rsc | dc794ed | 2005-11-26 15:36:47 +0000 | [diff] [blame] | 145 | cmd = "" |
| 146 | } |
| 147 | |