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