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