cookutils annotate web/cooker.cgi @ rev 15
Add debug info if cook error
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Thu May 05 05:04:15 2011 +0200 (2011-05-05) |
parents | 01dfc1ed1e0e |
children | dcf50aa1bb76 |
rev | line source |
---|---|
pankso@5 | 1 #!/bin/sh |
pankso@5 | 2 # |
pankso@5 | 3 # SliTaz Cooker CGI/web interface. |
pankso@5 | 4 # |
pankso@5 | 5 echo "Content-Type: text/html" |
pankso@5 | 6 echo "" |
pankso@5 | 7 |
pankso@5 | 8 [ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf |
pankso@5 | 9 [ -f "cook.conf" ] && . ./cook.conf |
pankso@5 | 10 |
pankso@5 | 11 # The same wok as cook. |
pankso@5 | 12 wok="$WOK" |
pankso@5 | 13 |
pankso@5 | 14 # Cooker DB files. |
pankso@5 | 15 activity="$CACHE/activity" |
pankso@5 | 16 commits="$CACHE/commits" |
pankso@5 | 17 cooklist="$CACHE/cooklist" |
pankso@5 | 18 cookorder="$CACHE/cookorder" |
pankso@14 | 19 command="$CACHE/command" |
pankso@5 | 20 blocked="$CACHE/blocked" |
pankso@5 | 21 broken="$CACHE/broken" |
pankso@5 | 22 |
pankso@5 | 23 # |
pankso@5 | 24 # Functions |
pankso@5 | 25 # |
pankso@5 | 26 |
pankso@5 | 27 # Put some colors in log and DB files. |
pankso@5 | 28 syntax_highlighter() { |
pankso@5 | 29 sed -e 's#OK$#<span class="span-ok">OK</span>#g' \ |
pankso@5 | 30 -e 's#yes$#<span class="span-ok">yes</span>#g' \ |
pankso@5 | 31 -e 's#no$#<span class="span-no">no</span>#g' \ |
pankso@5 | 32 -e 's#error$#<span class="span-error">error</span>#g' \ |
pankso@15 | 33 -e 's#ERROR:#<span class="span-error">ERROR:</span>#g' \ |
pankso@5 | 34 -e s"#^Executing:\([^']*\).#<span class='span-sky'>\0</span>#"g \ |
pankso@15 | 35 -e s"#^====\([^']*\).#<span class='span-line'>\0</span>#"g \ |
pankso@15 | 36 -e s"#http://\([^']*\).*#<a href='\0'>\1</a>#"g |
pankso@5 | 37 } |
pankso@5 | 38 |
pankso@5 | 39 # Latest build pkgs. |
pankso@5 | 40 list_packages() { |
pankso@5 | 41 cd $PKGS |
pankso@5 | 42 ls -1t *.tazpkg | head -20 | \ |
pankso@5 | 43 while read file |
pankso@5 | 44 do |
pankso@5 | 45 echo -n $(stat -c '%y' $PKGS/$file | cut -d . -f 1 | sed s/:[0-9]*$//) |
pankso@5 | 46 echo " : $file" |
pankso@5 | 47 done |
pankso@5 | 48 } |
pankso@5 | 49 |
pankso@5 | 50 # xHTML header |
pankso@5 | 51 cat << EOT |
pankso@5 | 52 <!DOCTYPE html> |
pankso@5 | 53 <html xmlns="http://www.w3.org/1999/xhtml"> |
pankso@5 | 54 <head> |
pankso@5 | 55 <title>SliTaz Cooker</title> |
pankso@5 | 56 <meta charset="utf-8" /> |
pankso@5 | 57 <link rel="stylesheet" type="text/css" href="style.css" /> |
pankso@5 | 58 </head> |
pankso@5 | 59 <body> |
pankso@5 | 60 |
pankso@5 | 61 <div id="header"> |
pankso@5 | 62 <h1><a href="cooker.cgi">SliTaz Cooker</a></h1> |
pankso@5 | 63 </div> |
pankso@5 | 64 |
pankso@5 | 65 <!-- Content --> |
pankso@5 | 66 <div id="content"> |
pankso@5 | 67 EOT |
pankso@5 | 68 |
pankso@5 | 69 # |
pankso@5 | 70 # Load requested page |
pankso@5 | 71 # |
pankso@5 | 72 |
pankso@5 | 73 case "${QUERY_STRING}" in |
pankso@5 | 74 log=*) |
pankso@5 | 75 pkg=${QUERY_STRING#log=} |
pankso@5 | 76 if [ -f "$LOGS/$pkg.log" ]; then |
pankso@14 | 77 echo "<h2>Log for: $pkg</h2>" |
pankso@15 | 78 if fgrep -q "Summary " $LOGS/$pkg.log; then |
pankso@15 | 79 echo '<pre>' |
pankso@15 | 80 grep -A 8 "^Summary " $LOGS/$pkg.log | sed /^$/d | \ |
pankso@15 | 81 syntax_highlighter |
pankso@15 | 82 echo '</pre>' |
pankso@15 | 83 echo '<pre>' |
pankso@15 | 84 cat $LOGS/$pkg.log | syntax_highlighter |
pankso@15 | 85 echo '</pre>' |
pankso@15 | 86 else |
pankso@15 | 87 if fgrep -q "cook:$pkg$" $command; then |
pankso@15 | 88 echo "<pre>The Cooker is currently cooking: $pkg</pre>" |
pankso@15 | 89 fi |
pankso@14 | 90 echo '<pre>' && cat $LOGS/$pkg.log | syntax_highlighter |
pankso@15 | 91 echo '</pre>' |
pankso@14 | 92 fi |
pankso@5 | 93 else |
pankso@5 | 94 echo "<pre>No log file found for: $pkg</pre>" |
pankso@5 | 95 fi ;; |
pankso@5 | 96 *) |
pankso@5 | 97 cat << EOT |
pankso@5 | 98 <div style="float: right;"> |
pankso@5 | 99 <form method="get" action="$SCRIPT_NAME"> |
pankso@5 | 100 Show log: |
pankso@5 | 101 <input type="text" name="log" /> |
pankso@5 | 102 </form> |
pankso@5 | 103 </div> |
pankso@5 | 104 |
pankso@5 | 105 <h2>Summary</h2> |
pankso@5 | 106 <pre> |
pankso@5 | 107 Cooked packages : $(ls $PKGS/*.tazpkg | wc -l) |
pankso@5 | 108 Packages in wok : $(ls $WOK | wc -l) |
pankso@5 | 109 Wok revision : <a href="http://hg.slitaz.org/wok">$(cd $WOK && hg head --template '{rev}\n')</a> |
pankso@5 | 110 Commits to cook : $(cat $commits | wc -l) |
pankso@5 | 111 Broken packages : $(cat $broken | wc -l) |
pankso@5 | 112 </pre> |
pankso@5 | 113 |
pankso@14 | 114 <div> |
pankso@14 | 115 Latest logs: <a href="cooker.cgi?log=cookorder">cookorder</a> |
pankso@14 | 116 <a href="cooker.cgi?log=commits">commits</a> |
pankso@14 | 117 </div> |
pankso@14 | 118 |
pankso@5 | 119 <h2>Activity</h2> |
pankso@5 | 120 <pre> |
pankso@5 | 121 $(tac $CACHE/activity | sed s"#^\([^']* : \)#<span class='span-date'>\0</span>#"g) |
pankso@5 | 122 </pre> |
pankso@5 | 123 |
pankso@5 | 124 <h2>Commits</h2> |
pankso@5 | 125 <pre> |
pankso@5 | 126 $(cat $commits) |
pankso@5 | 127 </pre> |
pankso@5 | 128 |
pankso@5 | 129 <h2>Broken</h2> |
pankso@5 | 130 <pre> |
pankso@5 | 131 $(cat $broken | sed s"#^[^']*#<a href='cooker.cgi?log=\0'>\0</a>#"g) |
pankso@5 | 132 </pre> |
pankso@5 | 133 |
pankso@14 | 134 <h2>Bloked</h2> |
pankso@14 | 135 <pre> |
pankso@14 | 136 $(cat $blocked | sed s"#^[^']*#<a href='cooker.cgi?log=\0'>\0</a>#"g) |
pankso@14 | 137 </pre> |
pankso@14 | 138 |
pankso@5 | 139 <h2>Latest cook</h2> |
pankso@5 | 140 <pre> |
pankso@5 | 141 $(list_packages | sed s"#^\([^']* \)#<span class='span-date'>\0</span>#"g) |
pankso@5 | 142 </pre> |
pankso@5 | 143 EOT |
pankso@5 | 144 ;; |
pankso@5 | 145 esac |
pankso@5 | 146 |
pankso@5 | 147 # Close xHTML page |
pankso@5 | 148 cat << EOT |
pankso@5 | 149 </div> |
pankso@5 | 150 |
pankso@5 | 151 <div id="footer"> |
pankso@15 | 152 <a href="cooker.cgi">SliTaz Cooker</a> |
pankso@5 | 153 </div> |
pankso@5 | 154 |
pankso@5 | 155 </body> |
pankso@5 | 156 </html> |
pankso@5 | 157 EOT |
pankso@5 | 158 |
pankso@5 | 159 exit 0 |