rev |
line source |
al@898
|
1 #!/bin/sh
|
al@898
|
2 #
|
al@898
|
3 # SliTaz Cooker CGI + Lighttpd web interface.
|
al@898
|
4 #
|
al@898
|
5
|
al@898
|
6 # Make request URI relative to the script name
|
al@898
|
7 base="$(dirname "$SCRIPT_NAME")"; [ "$base" == '/' ] && base=''
|
al@898
|
8 REQUEST_URI=$(echo "$REQUEST_URI" | sed "s|^$base/*|/|; s|\?.*||")
|
al@898
|
9
|
al@898
|
10 # Split the URI request to /pkg/cmd/arg
|
al@898
|
11 export pkg=$(echo "$REQUEST_URI" | cut -d/ -f2)
|
al@898
|
12 export cmd=$(echo "$REQUEST_URI" | cut -d/ -f3)
|
al@898
|
13 export arg=$(echo "$REQUEST_URI" | sed 's|^/[^/]*/[^/]*/||')
|
al@898
|
14
|
al@898
|
15
|
al@898
|
16 . /usr/lib/slitaz/httphelper.sh
|
al@898
|
17
|
al@898
|
18 [ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf
|
al@898
|
19 [ -f "./cook.conf" ] && . ./cook.conf
|
al@898
|
20 wok="$WOK"
|
al@898
|
21 title=${title:-SliTaz Cooker}
|
al@898
|
22 # Cooker DB files.
|
al@898
|
23 activity="$CACHE/activity"
|
al@898
|
24 commits="$CACHE/commits"
|
al@898
|
25 cooklist="$CACHE/cooklist"
|
al@898
|
26 cookorder="$CACHE/cookorder"
|
al@898
|
27 command="$CACHE/command"; touch $command
|
al@898
|
28 blocked="$CACHE/blocked"
|
al@898
|
29 broken="$CACHE/broken"
|
al@898
|
30 cooknotes="$CACHE/cooknotes"
|
al@898
|
31 cooktime="$CACHE/cooktime"
|
al@898
|
32 wokrev="$CACHE/wokrev"
|
al@933
|
33 webstat="$CACHE/webstat"
|
al@940
|
34 splitdb="$CACHE/split.db"
|
al@898
|
35
|
al@898
|
36 # Path to markdown to html convertor
|
al@898
|
37 cmark_opts='--smart -e table -e strikethrough -e autolink -e tagfilter'
|
al@898
|
38 if [ -n "$(which cmark 2>/dev/null)" ]; then
|
al@898
|
39 md2html="$(which cmark) $cmark_opts"
|
al@898
|
40 elif [ -x "./cmark" ]; then
|
al@898
|
41 md2html="./cmark $cmark_opts"
|
al@898
|
42 elif [ -n "$(which sundown 2>/dev/null)" ]; then
|
al@898
|
43 md2html=$(which sundown)
|
al@898
|
44 elif [ -x "./sundown" ]; then
|
al@898
|
45 md2html="./sundown"
|
al@898
|
46 fi
|
al@898
|
47
|
al@898
|
48
|
al@898
|
49
|
al@898
|
50
|
al@898
|
51 # Search form redirection
|
al@898
|
52 if [ -n "$(GET search)" ]; then
|
al@898
|
53 echo -e "HTTP/1.1 301 Moved Permanently\nLocation: $base/$(GET q)\n\n"
|
al@898
|
54 exit 0
|
al@898
|
55 fi
|
al@898
|
56
|
al@898
|
57
|
al@898
|
58 # Show the running command and it's progression
|
al@898
|
59
|
al@898
|
60 running_command() {
|
al@898
|
61 state="$(cat $command)"
|
al@923
|
62 local pct=''
|
al@898
|
63 if [ -n "$state" ];then
|
al@898
|
64 echo -n "$state</td></tr><tr><td>Completion</td>"
|
al@898
|
65 set -- $(grep "^$state" $cooktime)
|
al@898
|
66 [ -n "$1" -a $2 -ne 0 ] && pct=$((($(date +%s)-$3)*100/$2))
|
al@898
|
67 [ -n "$pct" ] && max="max='100'"
|
al@898
|
68 echo -n "<td><progress id='gauge' $max value='$pct' title='Click to stop updating' onclick='stopUpdating()'>"
|
al@898
|
69 echo -n "</progress> <span id='pct'>${pct:-?}%</span>"
|
al@898
|
70 [ "$2" -gt 60 ] &&
|
al@898
|
71 echo -n "</td></tr><tr><td>Estimated end time</td><td>$(date +%H:%M -ud @$(($2+$3)))"
|
al@898
|
72 else
|
al@898
|
73 echo 'not running'
|
al@898
|
74 fi
|
al@898
|
75 }
|
al@898
|
76
|
al@898
|
77
|
al@898
|
78 # HTML page header
|
al@898
|
79
|
al@898
|
80 page_header() {
|
al@898
|
81 local theme t='' css
|
al@898
|
82 theme=$(COOKIE theme)
|
al@898
|
83 [ "$theme" == 'default' ] && theme=''
|
al@898
|
84 [ -n "$theme" ] && theme="-$theme"
|
al@898
|
85 css="cooker$theme.css"
|
al@898
|
86
|
al@898
|
87 echo -e 'Content-Type: text/html; charset=UTF-8\n'
|
al@898
|
88
|
al@898
|
89 cat <<EOT
|
al@898
|
90 <!DOCTYPE html>
|
al@898
|
91 <html lang="en">
|
al@898
|
92 <head>
|
al@898
|
93 <title>$([ -n "$pkg" ] && echo "$pkg - ")$title</title>
|
al@898
|
94 <link rel="stylesheet" href="/$css">
|
al@898
|
95 <link rel="icon" type="image/png" href="/slitaz-cooker.png">
|
al@903
|
96 <link rel="search" href="$base/os.xml" title="$title" type="application/opensearchdescription+xml">
|
al@898
|
97 <!-- mobile -->
|
al@898
|
98 <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
al@898
|
99 <meta name="theme-color" content="#222">
|
al@898
|
100 <!-- rss -->
|
al@898
|
101 <link rel="alternate" type="application/rss+xml" title="$title Feed" href="?rss">
|
al@898
|
102 </head>
|
al@898
|
103 <body>
|
al@898
|
104 <div id="container">
|
al@898
|
105 <header>
|
al@898
|
106 <h1><a href="$base/">$title</a></h1>
|
al@898
|
107 <div class="network">
|
al@898
|
108 <a href="http://www.slitaz.org/">Home</a>
|
al@898
|
109 <a href="http://bugs.slitaz.org/">Bugs</a>
|
al@898
|
110 <a href="http://hg.slitaz.org/wok-next/">Hg</a>
|
al@898
|
111 <a href="http://roadmap.slitaz.org/">Roadmap</a>
|
al@898
|
112 <a href="http://pizza.slitaz.me/">Pizza</a>
|
al@898
|
113 <a href="http://tank.slitaz.org/">Tank</a>
|
al@898
|
114 |
|
al@947
|
115 <a href="/cross/">Cross</a>
|
al@947
|
116 <a href="/i486.cgi">i486</a>
|
al@898
|
117 <a href="$base/cookiso.cgi">ISO</a>
|
al@898
|
118 <select onChange="window.location.href=this.value" style="display: none">
|
al@898
|
119 <option value=".">Go to…</option>
|
al@898
|
120 <option value="http://www.slitaz.org/">Home</option>
|
al@898
|
121 <option value="http://bugs.slitaz.org/">Bug tracker</option>
|
al@898
|
122 <option value="http://hg.slitaz.org/wok/">Hg wok</option>
|
al@898
|
123 <option value="http://roadmap.slitaz.org/">Roadmap</option>
|
al@898
|
124 <option value="http://pizza.slitaz.me/">Pizza</option>
|
al@898
|
125 <option value="http://tank.slitaz.org/">Tank</option>
|
al@898
|
126 <option disabled>---------</option>
|
al@898
|
127 <option value="cross/">Cross</option>
|
al@898
|
128 <option value="i486.cgi">i486</option>
|
al@898
|
129 <option value="cookiso.cgi">ISO</option>
|
al@898
|
130 </select>
|
al@898
|
131 </div>
|
al@898
|
132 </header>
|
al@898
|
133
|
al@898
|
134 <main>
|
al@898
|
135 EOT
|
al@898
|
136
|
al@898
|
137 [ -n "$(GET debug)" ] && echo "<pre><code class='language-ini'>$(env | sort)</code></pre>"
|
al@898
|
138 }
|
al@898
|
139
|
al@898
|
140
|
al@898
|
141 # HTML page footer
|
al@898
|
142
|
al@898
|
143 page_footer() {
|
al@898
|
144 date_now=$(date +%s)
|
al@898
|
145 sec_now=$(date +%S); sec_now=${sec_now#0} # remove one leading zero
|
al@898
|
146 wait_sec=$(( 60 - $sec_now ))
|
al@898
|
147 cat <<EOT
|
al@898
|
148 </main>
|
al@898
|
149
|
al@898
|
150 <footer>
|
al@898
|
151 <a href="http://www.slitaz.org/">SliTaz Website</a>
|
al@898
|
152 <a href="$base/">Cooker</a>
|
al@898
|
153 <a href="$base/doc/cookutils/cookutils.html">Documentation</a>
|
al@898
|
154 <a href="$base/?theme">Theme</a>
|
al@898
|
155 </footer>
|
al@898
|
156 </div>
|
al@898
|
157 <script src="/cooker.js"></script>
|
al@898
|
158 <script>refreshDate(${wait_sec}000, ${date_now}000)</script>
|
al@898
|
159 </body>
|
al@898
|
160 </html>
|
al@898
|
161 EOT
|
al@898
|
162 }
|
al@898
|
163
|
al@898
|
164
|
al@898
|
165 show_note() {
|
al@898
|
166 echo "<div class='bigicon-$1'>$2</div>"
|
al@898
|
167 }
|
al@898
|
168
|
al@898
|
169
|
al@898
|
170 not_found() {
|
al@898
|
171 local file="${1#$PKGS/}"; file="${file#$LOGS/}"; file="${file#$WOK/}"
|
al@898
|
172 echo "HTTP/1.1 404 Not Found"
|
al@898
|
173 page_header
|
al@898
|
174 echo "<h2>Not Found</h2>"
|
al@898
|
175 case $2 in
|
al@898
|
176 pkg)
|
al@898
|
177 show_note e "The requested package “$(basename "$(dirname "$file")")” was not found." ;;
|
al@898
|
178 *)
|
al@898
|
179 show_note e "The requested file “$file” was not found." ;;
|
al@898
|
180 esac
|
al@898
|
181 page_footer
|
al@898
|
182 }
|
al@898
|
183
|
al@898
|
184
|
al@898
|
185 manage_modified() {
|
al@898
|
186 local file="$1" option="$2" nul day mon year time hh mm ss date_s
|
al@898
|
187 if [ ! -f "$file" ]; then
|
al@898
|
188 if [ "$option" == 'silently-absent' ]; then
|
al@898
|
189 echo "HTTP/1.1 404 Not Found"
|
al@898
|
190 return
|
al@898
|
191 else
|
al@898
|
192 not_found "$file" "$2"
|
al@898
|
193 exit
|
al@898
|
194 fi
|
al@898
|
195 fi
|
al@898
|
196 [ "$option" == 'no-last-modified' ] && return
|
al@898
|
197 if [ -n "$HTTP_IF_MODIFIED_SINCE" ]; then
|
al@898
|
198 echo "$HTTP_IF_MODIFIED_SINCE" | \
|
al@898
|
199 while read nul day mon year time nul; do
|
al@898
|
200 case $mon in
|
al@898
|
201 Jan) mon='01';; Feb) mon='02';; Mar) mon='03';; Apr) mon='04';;
|
al@898
|
202 May) mon='05';; Jun) mon='06';; Jul) mon='07';; Aug) mon='08';;
|
al@898
|
203 Sep) mon='09';; Oct) mon='10';; Nov) mon='11';; Dec) mon='12';;
|
al@898
|
204 esac
|
al@898
|
205 hh=$(echo $time | cut -d: -f1)
|
al@898
|
206 mm=$(echo $time | cut -d: -f2)
|
al@898
|
207 ss=$(echo $time | cut -d: -f3)
|
al@898
|
208 date_s=$(date -ud "$year$mon$day$hh$mm.$ss" +%s)
|
al@898
|
209 # if [ "$date_s" -ge "$(date -ur "$file" +%s)" ]; then
|
al@898
|
210 # echo -e 'HTTP/1.1 304 Not Modified\n'
|
al@898
|
211 # exit
|
al@898
|
212 # fi
|
al@898
|
213 # TODO: improve caching control
|
al@898
|
214 done
|
al@898
|
215 fi
|
al@898
|
216 echo "Last-Modified: $(date -Rur "$file" | sed 's|UTC|GMT|')"
|
al@898
|
217 echo "Cache-Control: public, max-age=3600"
|
al@898
|
218 }
|
al@898
|
219
|
al@898
|
220
|
al@898
|
221 # Query '?pct=<package>': update percentage
|
al@898
|
222
|
al@898
|
223 if [ -n "$(GET pct)" ]; then
|
al@898
|
224 pkg="$(GET pct)"
|
al@898
|
225 state="$(cat $command)"
|
al@898
|
226 if [ "$state" == "cook:$pkg" ]; then
|
al@898
|
227 set -- $(grep "^$state" $cooktime)
|
al@898
|
228 [ -n "$1" ] && pct=$(( ($(date +%s) - $3) * 100 / $2 ))
|
al@898
|
229 echo "${pct:-?}"
|
al@898
|
230 else
|
al@898
|
231 echo 'reload'
|
al@898
|
232 fi
|
al@898
|
233 exit 0
|
al@898
|
234 fi
|
al@898
|
235
|
al@898
|
236
|
al@898
|
237 # Query '?poke': poke cooker
|
al@898
|
238
|
al@898
|
239 if [ -n "$(GET poke)" ]; then
|
al@898
|
240 touch $CACHE/cooker-request
|
al@898
|
241 echo -e "Location: ${HTTP_REFERER:-${REQUEST_URI%\?*}}\n"
|
al@898
|
242 exit
|
al@898
|
243 fi
|
al@898
|
244
|
al@898
|
245
|
al@898
|
246 # Query '?recook=<package>': query to recook package
|
al@898
|
247
|
al@898
|
248 if [ -n "$(GET recook)" ]; then
|
al@898
|
249 pkg="$(GET recook)"
|
al@898
|
250 case "$HTTP_USER_AGENT" in
|
al@898
|
251 *SliTaz*)
|
al@898
|
252 grep -qs "^$pkg$" $CACHE/recook-packages ||
|
al@898
|
253 echo "$pkg" >> $CACHE/recook-packages
|
al@898
|
254 esac
|
al@898
|
255 echo -e "Location: ${HTTP_REFERER:-${REQUEST_URI%\?*}}\n"
|
al@898
|
256 exit
|
al@898
|
257 fi
|
al@898
|
258
|
al@898
|
259
|
al@898
|
260 # Query '/i/<log>/<pkg>': show indicator icon
|
al@898
|
261 # Can't use ?query - not able to change '+' to '%2B' in the sed rules (see log handler)
|
al@898
|
262
|
al@898
|
263 if [ "$pkg" == 'i' ]; then
|
al@898
|
264 echo -en "Content-Type: image/svg+xml\n\n<svg xmlns='http://www.w3.org/2000/svg' height='12' width='8'><path d='"
|
al@898
|
265 if [ $LOGS/$cmd -nt $PKGS/$arg.tazpkg ]; then
|
al@898
|
266 echo "m1 2-1 1v8l1 1h6l1-1v-8l-1-1z' fill='#090'/></svg>"
|
al@898
|
267 else
|
al@898
|
268 echo "m0 3v8l1 1h6l1-1v-8l-1-1h-6zm3 0h2v5h-2zm0 6h2v2h-2z' fill='#d00'/></svg>"
|
al@898
|
269 fi
|
al@898
|
270 exit
|
al@898
|
271 fi
|
al@898
|
272
|
al@898
|
273
|
al@982
|
274 # Query '/s/<pkg>': show status indicator icon
|
al@982
|
275 # Can't use ?query - not able to change '+' to '%2B' in the sed rules (see log handler)
|
al@982
|
276
|
al@982
|
277 if [ "$pkg" == 's' ]; then
|
al@982
|
278 # argument <pkg> is in $cmd variable
|
al@982
|
279
|
al@982
|
280 # find main package
|
al@982
|
281 main=$(awk -F$'\t' -vpkg=" $cmd " '{
|
al@982
|
282 if (index(" " $2 " ", pkg)) {print $1; exit}
|
al@982
|
283 }' $splitdb)
|
al@982
|
284 # get version
|
al@982
|
285 ver="$(. $wok/$main/receipt; echo "$VERSION")"
|
al@982
|
286
|
al@982
|
287 echo -en "Content-Type: image/svg+xml\n\n<svg xmlns='http://www.w3.org/2000/svg' height='12' width='8'><path d='"
|
al@982
|
288 if [ -e $PKGS/$cmd-$ver.tazpkg ]; then
|
al@982
|
289 echo "m1 2-1 1v8l1 1h6l1-1v-8l-1-1z' fill='#090'/></svg>"
|
al@982
|
290 else
|
al@982
|
291 echo "m0 3v8l1 1h6l1-1v-8l-1-1h-6zm3 0h2v5h-2zm0 6h2v2h-2z' fill='#d00'/></svg>"
|
al@982
|
292 fi
|
al@982
|
293 exit
|
al@982
|
294 fi
|
al@982
|
295
|
al@982
|
296
|
al@898
|
297 # Query '?theme[=<theme>]': change UI theme
|
al@898
|
298
|
al@898
|
299 if [ -n "$(GET theme)" ]; then
|
al@898
|
300 theme="$(GET theme)"
|
al@924
|
301 ref="$(echo "$HTTP_REFERER" | sed 's|:|%3A|g; s|/|%2F|g; s|\?|%3F|g; s|\+|%2B|g;')"
|
al@898
|
302 case $theme in
|
al@898
|
303 theme)
|
al@898
|
304 current=$(COOKIE theme)
|
al@898
|
305 page_header
|
al@898
|
306 cat <<EOT
|
al@898
|
307 <section>
|
al@898
|
308 <h2>Change theme</h2>
|
al@898
|
309 <p>Current theme: “${current:-default}”. Select other:</p>
|
al@898
|
310 <ul>
|
al@898
|
311 $(
|
al@903
|
312 for i in default emerald sky goldenrod midnight like2016 terminal; do
|
al@924
|
313 [ "$i" == "${current:-default}" ] || echo "<li><a href=\"$base/?theme=$i&ref=$ref\">$i</a></li>"
|
al@898
|
314 done
|
al@898
|
315 )
|
al@898
|
316 </ul>
|
al@898
|
317 </section>
|
al@898
|
318 EOT
|
al@898
|
319 page_footer
|
al@898
|
320 exit 0
|
al@898
|
321 ;;
|
al@903
|
322 default|emerald|sky|goldenrod|midnight|like2016|terminal)
|
al@924
|
323 ref="$(GET ref)"
|
al@924
|
324 [ -n "$ref" ] || ref="$base/"
|
al@898
|
325 # Expires in a year
|
al@898
|
326 expires=$(date -uRd @$(($(date +%s)+31536000)) | sed 's|UTC|GMT|')
|
al@924
|
327 echo -e "HTTP/1.1 302 Found\nLocation: $ref\nCache-Control: no-cache\nSet-Cookie: theme=$theme; expires=$expires\n\n"
|
al@898
|
328 exit 0
|
al@898
|
329 ;;
|
al@898
|
330 esac
|
al@898
|
331 fi
|
al@898
|
332
|
al@898
|
333
|
al@898
|
334 #case "$QUERY_STRING" in
|
al@898
|
335 # stuff*)
|
al@898
|
336 # file="$wok/$(GET stuff)"
|
al@898
|
337 # manage_modified "$file"
|
al@898
|
338 # ;;
|
al@898
|
339 #
|
al@898
|
340 # pkg=*|receipt=*|description=*|files=*|log=*|man=*|doc=*|info=*)
|
al@898
|
341 # type=${QUERY_STRING%%=*}
|
al@898
|
342 # pkg=$(GET $type)
|
al@898
|
343 # case "$type" in
|
al@898
|
344 # description)
|
al@898
|
345 # manage_modified "$wok/$pkg/receipt" 'no-last-modified'
|
al@898
|
346 # manage_modified "$wok/$pkg/description.txt" 'silently-absent'
|
al@898
|
347 # ;;
|
al@898
|
348 # log)
|
al@898
|
349 # manage_modified "$wok/${pkg%%.log*}/receipt" 'no-last-modified'
|
al@898
|
350 # manage_modified "$LOGS/$pkg"
|
al@898
|
351 # ;;
|
al@898
|
352 # *)
|
al@898
|
353 # manage_modified "$wok/$pkg/receipt" pkg
|
al@898
|
354 # ;;
|
al@898
|
355 # esac
|
al@898
|
356 # ;;
|
al@898
|
357 #esac
|
al@898
|
358
|
al@898
|
359
|
al@898
|
360 # RSS feed generator
|
al@898
|
361 # URI: ?rss[&limit={1..100}]
|
al@898
|
362
|
al@898
|
363 if [ -n "$(GET rss)" ]; then
|
al@898
|
364 limit=$(GET limit); limit="${limit:-12}"; [ "$limit" -gt 100 ] && limit='100'
|
al@898
|
365 pubdate=$(date -Rur$(ls -t $FEEDS/*.xml | head -n1) | sed 's|UTC|GMT|')
|
al@898
|
366 cooker_url="http://$HTTP_HOST$base/"
|
al@898
|
367 cat <<EOT
|
al@898
|
368 Content-Type: application/rss+xml
|
al@898
|
369
|
al@898
|
370 <?xml version="1.0" encoding="utf-8" ?>
|
al@898
|
371 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
al@898
|
372 <channel>
|
al@898
|
373 <title>$title</title>
|
al@898
|
374 <description>The SliTaz packages cooker feed</description>
|
al@898
|
375 <link>$cooker_url</link>
|
al@898
|
376 <lastBuildDate>$pubdate</lastBuildDate>
|
al@898
|
377 <pubDate>$pubdate</pubDate>
|
al@898
|
378 <atom:link href="$cooker_url?rss" rel="self" type="application/rss+xml" />
|
al@898
|
379 EOT
|
al@898
|
380 for rss in $(ls -t $FEEDS/*.xml | head -n$limit); do
|
al@898
|
381 sed "s|http[^=]*=|$cooker_url|; s|<guid|& isPermaLink=\"false\"|g; s|</pubDate| GMT&|g" $rss
|
al@898
|
382 done
|
al@898
|
383 cat <<EOT
|
al@898
|
384 </channel>
|
al@898
|
385 </rss>
|
al@898
|
386 EOT
|
al@898
|
387 exit 0
|
al@898
|
388 fi
|
al@898
|
389
|
al@898
|
390
|
al@903
|
391 ### OpenSearch ###
|
al@903
|
392
|
al@903
|
393 # Query '/os.xml': get OpenSearch Description
|
al@903
|
394
|
al@903
|
395 if [ "$pkg" == 'os.xml' ]; then
|
al@903
|
396 cat <<EOT
|
al@903
|
397 Content-Type: application/xml; charset=UTF-8
|
al@903
|
398
|
al@903
|
399 <?xml version="1.0" encoding="UTF-8"?>
|
al@903
|
400 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
|
al@903
|
401 <ShortName>$title</ShortName>
|
al@903
|
402 <Description>SliTaz packages search</Description>
|
al@903
|
403 <Image width="16" height="16" type="image/png">http://$HTTP_HOST/images/logo.png</Image>
|
al@903
|
404 <Url type="text/html" method="GET" template="http://$HTTP_HOST$base/{searchTerms}"/>
|
al@903
|
405 <Url type="application/x-suggestions+json" method="GET" template="http://$HTTP_HOST$base/">
|
al@903
|
406 <Param name="oss" value="{searchTerms}"/>
|
al@903
|
407 </Url>
|
al@903
|
408 <SearchForm>http://$HTTP_HOST$base/</SearchForm>
|
al@903
|
409 <InputEncoding>UTF-8</InputEncoding>
|
al@903
|
410 </OpenSearchDescription>
|
al@903
|
411 EOT
|
al@903
|
412 exit 0
|
al@903
|
413 fi
|
al@903
|
414
|
al@903
|
415 # Query '?oss[=<term>]': OpenSearch suggestions
|
al@903
|
416
|
al@903
|
417 if [ -n "$(GET oss)" ]; then
|
al@903
|
418 term="$(GET oss | tr -cd '[:alnum:]+-')"
|
al@903
|
419 echo -e 'Content-Type: application/x-suggestions+json; charset=UTF-8\n'
|
al@903
|
420 cd $wok
|
al@903
|
421 ls | fgrep "$term" | head -n10 | awk -vterm="$term" '
|
al@903
|
422 BEGIN{printf("[\"%s\",[", term)}
|
al@903
|
423 {printf("%s\"%s\"", NR != 1 ? "," : "", $0)}
|
al@903
|
424 END {printf("]]")}
|
al@903
|
425 '
|
al@903
|
426 exit 0
|
al@903
|
427 fi
|
al@903
|
428
|
al@903
|
429
|
al@898
|
430
|
al@898
|
431
|
al@898
|
432 #
|
al@898
|
433 # Functions
|
al@898
|
434 #
|
al@898
|
435
|
al@898
|
436
|
al@898
|
437 # Unpack to stdout
|
al@898
|
438
|
al@898
|
439 docat() {
|
al@898
|
440 case "$1" in
|
al@898
|
441 *gz) zcat ;;
|
al@898
|
442 *bz2) bzcat ;;
|
al@898
|
443 *xz) xzcat ;;
|
al@898
|
444 *) cat
|
al@898
|
445 esac < $1
|
al@898
|
446 }
|
al@898
|
447
|
al@898
|
448
|
al@898
|
449 # Tiny texinfo converter
|
al@898
|
450
|
al@898
|
451 info2html() {
|
al@898
|
452 sed \
|
al@898
|
453 -e 's|&|\&|g; s|<|\<|g; s|>|\>|g' \
|
al@898
|
454 -e 's|^\* \(.*\)::|* <a href="#\1">\1</a> |' \
|
al@898
|
455 -e 's|\*note \(.*\)::|<a href="#\1">\1</a>|' \
|
al@898
|
456 -e '/^File: / s|(dir)|Top|g' \
|
al@898
|
457 -e '/^File: / s|Next: \([^,]*\)|<a class="button" href="#\1">Next: \1</a>|' \
|
al@898
|
458 -e '/^File: / s|Prev: \([^,]*\)|<a class="button" href="#\1">Prev: \1</a>|' \
|
al@898
|
459 -e '/^File: / s|Up: \([^,]*\)|<a class="button" href="#\1">Up: \1</a>|' \
|
al@898
|
460 -e '/^File: / s|^.* Node: \([^,]*\), *\(.*\)$|<pre id="\1">\2|' \
|
al@898
|
461 -e '/^<pre id=/ s|^\([^>]*>\)\(<a[^>]*>Next: [^,]*\), *\(<a[^>]*>Prev: [^,]*\), *\(<a[^>]*>Up: .*\)|\1 \3 \4 \2|' \
|
al@898
|
462 -e '/^Tag Table:$/,/^End Tag Table$/d' \
|
al@898
|
463 -e '/INFO-DIR/,/^END-INFO-DIR/d' \
|
al@898
|
464 -e "s|https*://[^>),'\"\`’ ]*|<a href=\"&\">&</a>|g" \
|
al@898
|
465 -e "s|ftp://[^>),\"\` ]*|<a href=\"&\">&</a>|g" \
|
al@898
|
466 -e 's|^\* Menu:|<b>Menu:</b>|' \
|
al@898
|
467 -e "s|^|</pre>|"
|
al@898
|
468 }
|
al@898
|
469
|
al@898
|
470
|
al@898
|
471 # Put some colors into log and DB files.
|
al@898
|
472
|
al@898
|
473 syntax_highlighter() {
|
al@898
|
474 case $1 in
|
al@898
|
475 log)
|
al@898
|
476 # If variables not defined - define them with some rare values
|
al@898
|
477 : ${_src=#_#_#}
|
al@898
|
478 : ${_install=#_#_#}
|
al@898
|
479 : ${_fs=#_#_#}
|
al@898
|
480 : ${_stuff=#_#_#}
|
al@898
|
481 # Use one-letter html tags to save some bytes :)
|
al@898
|
482 # <b>is error (red)</b> <u>is warning (orange)</u> <i>is informal (green)</i>
|
al@898
|
483 sed -e 's/&/\&/g; s/</\</g; s/>/\>/g' \
|
al@898
|
484 -e 's#OK$#<i>OK</i>#' \
|
al@898
|
485 -e 's#\([Dd]one\)$#<i>\1</i>#' \
|
al@898
|
486 -e 's#Success$#<i>Success</i>#' \
|
al@898
|
487 -e 's#\([^a-z]\)ok$#\1<i>ok</i>#' \
|
al@898
|
488 -e 's#\([^a-z]\)yes$#\1<i>yes</i>#' \
|
al@912
|
489 -e 's#\([^a-z]\)ON$#\1<i>ON</i>#' \
|
al@898
|
490 -e 's#\([^a-z]\)no$#\1<u>no</u>#' \
|
al@898
|
491 -e 's#\([^a-z]\)none$#\1<u>none</u>#' \
|
al@898
|
492 -e 's#\([^a-z]\)false$#\1<u>false</u>#' \
|
al@912
|
493 -e 's#\([^a-z]\)OFF$#\1<u>OFF</u>#' \
|
al@898
|
494 -e 's#\(^checking .*\.\.\. \)\(.*\)$#\1<i>\2</i>#' \
|
al@898
|
495 \
|
al@898
|
496 -e 's#\( \[Y[nm/]\?\] n\)$# <u>\1</u>#' \
|
al@898
|
497 -e 's#\( \[N[ym/]\?\] y\)$# <i>\1</i>#' \
|
al@898
|
498 -e 's# y$# <i>y</i>#' \
|
al@898
|
499 -e 's# n$# <u>n</u>#' \
|
al@898
|
500 -e 's#(NEW) *$#<b>(NEW)</b>#' \
|
al@898
|
501 \
|
al@898
|
502 -e 's#.*(pkg/local).*#<i>\0</i>#' \
|
al@898
|
503 -e 's#.*(web/cache).*#<u>\0</u>#' \
|
al@898
|
504 \
|
al@898
|
505 -e 's#\([^a-zA-Z]\)\([Ee]rror\)$#\1<b>\2</b>#' \
|
al@898
|
506 -e 's#ERROR:#<b>ERROR:</b>#g' \
|
al@898
|
507 \
|
al@909
|
508 -e 's#^.*[Ff][Aa][Ii][Ll][Ee][Dd].*#<b>\0</b>#' \
|
al@898
|
509 -e 's#^.*[Ff]atal.*#<b>\0</b>#' \
|
al@989
|
510 -e '/non-fatal/ s|</*b>||g' \
|
al@898
|
511 -e 's#^.*[Nn]ot found.*#<b>\0</b>#' \
|
al@898
|
512 -e 's#^.*[Nn]o such file.*#<b>\0</b>#' \
|
al@898
|
513 -e 's#^.*No package .* found.*#<b>\0</b>#' \
|
al@898
|
514 -e 's#^.*Unable to find.*#<b>\0</b>#' \
|
al@938
|
515 -e 's#[^a-zA-Z-][Ii]nvalid.*#<b>\0</b>#' \
|
al@914
|
516 -e 's#\([Nn][Oo][Tt] found\.*\)$#<b>\1</b>#' \
|
al@914
|
517 -e 's#\(found\.*\)$#<i>\1</i>#' \
|
al@898
|
518 \
|
al@898
|
519 -e 's#^.*WARNING:.*#<u>\0</u>#' \
|
al@898
|
520 -e 's#^.*warning:.*#<u>\0</u>#' \
|
al@898
|
521 -e 's#^.* [Ee]rror:* .*#<b>\0</b>#' \
|
al@898
|
522 -e 's#^.*terminated.*#<b>\0</b>#' \
|
al@898
|
523 -e 's#\(missing\)#<b>\1</b>#g' \
|
al@898
|
524 -e 's#^.*[Cc]annot find.*#<b>\0</b>#' \
|
al@898
|
525 -e 's#^.*unrecognized options.*#<u>\0</u>#' \
|
al@898
|
526 -e 's#^.*does not.*#<u>\0</u>#' \
|
al@898
|
527 -e 's#^.*[Ii]gnoring.*#<u>\0</u>#' \
|
al@898
|
528 -e 's#^.*note:.*#<u>\0</u>#' \
|
al@898
|
529 \
|
al@898
|
530 -e 's#^.* will not .*#<u>\0</u>#' \
|
al@898
|
531 -e 's!^Hunk .* succeeded at .*!<u>\0</u>!' \
|
al@898
|
532 -e 's#^.* Warning: .*#<u>\0</u>#' \
|
al@898
|
533 \
|
al@898
|
534 -e "s#^Executing:\([^']*\).#<em>\0</em>#" \
|
al@898
|
535 -e "s#^Making.*#<em>\0</em>#" \
|
al@898
|
536 -e "s#^Scanning dependencies of target .*#<em>\0</em>#" \
|
al@898
|
537 -e "s#^====\([^']*\).#<span class='span-line'>\0</span>#g" \
|
al@898
|
538 -e "s#^[a-zA-Z0-9]\([^']*\) :: #<span class='span-sky'>\0</span>#g" \
|
al@898
|
539 -e "s#[fh]tt*ps*://[^ '\"]*#<a href='\0'>\0</a>#g" \
|
al@898
|
540 \
|
al@941
|
541 -e 's|^<u>\(.*libtool: warning: relinking.*\)</u>|\1|' \
|
al@941
|
542 -e 's|^<u>\(.*libtool: warning: .* has not been installed in .*\)</u>|\1|' \
|
al@941
|
543 -e 's|^<u>\(.*checking for a sed.*\)</u>|\1|' \
|
al@941
|
544 \
|
al@941
|
545 -e "s|$_src|<var>\${src}</var>|g;
|
al@941
|
546 s|$_install|<var>\${install}</var>|g;
|
al@941
|
547 s|$_fs|<var>\${fs}</var>|g;
|
al@941
|
548 s|$_stuff|<var>\${stuff}</var>|g" \
|
al@913
|
549 -e "s|\[9\([1-6]\)m|<span class='c\10'>|;
|
al@942
|
550 s|\[39m|</span>|;
|
al@989
|
551 s|\[1m|<strong>|g; s|\[0m|</strong>|g" \
|
al@989
|
552 -e "s|^+.*|<i>\0</i>|;
|
al@992
|
553 s|^-.*|<b>\0</b>|; /----/s|</*b>||; /^<b>--[^-]/s|</*b>||;"
|
al@898
|
554 ;;
|
al@898
|
555
|
al@898
|
556 files)
|
al@898
|
557 # Highlight the Busybox's `ls` output
|
al@898
|
558 awk '{
|
al@898
|
559 part1 = substr($0, 0, 16);
|
al@898
|
560 part2 = substr($0, 17, 9);
|
al@898
|
561 part3 = substr($0, 26, 9);
|
al@898
|
562 part4 = substr($0, 35);
|
al@898
|
563 if (part2 != "root ") part2 = "<span class=\"c11\">" part2 "</span>";
|
al@898
|
564 if (part3 != "root ") part3 = "<span class=\"c11\">" part3 "</span>";
|
al@898
|
565 print part1 part2 part3 part4;
|
al@898
|
566 }' | \
|
al@924
|
567 sed "s|\[0m/|/\[0m|g;
|
al@924
|
568 s|\[\([01]\);3\([1-7]\)m|<a class='c\2\1'>|g;
|
al@898
|
569 s|\[\([01]\);0m|<a class='c0\1'>|g;
|
al@898
|
570 s|\[0m|</a>|g;
|
al@898
|
571 s|^\(lrwxrwxrwx\)|<span class='c61'>\1</span>|;
|
al@898
|
572 s|^\(-rwxr-xr-x\)|<span class='c21'>\1</span>|;
|
al@898
|
573 s|^\(-rw-r--r--\)|<span class='c31'>\1</span>|;
|
al@924
|
574 s|^\(drwxr-xr-x\)|<span class='c41'>\1</span>|;
|
al@902
|
575 s|^\([lrwxs-]*\)|<span class='c11'>\1</span>|;
|
al@898
|
576 "
|
al@898
|
577 ;;
|
al@898
|
578 esac
|
al@898
|
579 }
|
al@898
|
580
|
al@898
|
581
|
al@898
|
582 show_code() {
|
al@898
|
583 echo -n "<pre><code class=\"language-$1\">"
|
al@898
|
584 sed 's|&|\&|g; s|<|\<|g; s|>|\>|g'
|
al@898
|
585 echo '</code></pre>'
|
al@898
|
586 }
|
al@898
|
587
|
al@898
|
588
|
al@898
|
589 datalist() {
|
al@940
|
590 cut -d$'\t' -f2 $splitdb | tr ' ' '\n' | sort -u | awk '
|
al@898
|
591 BEGIN{printf("<datalist id=\"packages\">")}
|
al@940
|
592 {printf("<option>%s",$1)}
|
al@898
|
593 END {printf("</datalist>")}
|
al@898
|
594 '
|
al@898
|
595 }
|
al@898
|
596
|
al@898
|
597
|
al@898
|
598 mklog() {
|
al@898
|
599 awk '
|
al@898
|
600 BEGIN { printf("<pre class=\"log dog\">\n") }
|
al@898
|
601 { print }
|
al@898
|
602 END { print "</pre>" }'
|
al@898
|
603 }
|
al@898
|
604
|
al@898
|
605
|
al@898
|
606 summary() {
|
al@898
|
607 log="$1"
|
al@898
|
608 pkg="$(basename ${log%%.log*})"
|
al@898
|
609
|
al@898
|
610 if [ -f "$log" ]; then
|
al@898
|
611 if grep -q "cook:$pkg$" $command; then
|
al@898
|
612 show_note i "The Cooker is currently building $pkg"
|
al@898
|
613 elif fgrep -q "Summary for:" $log; then
|
al@904
|
614 sed '/^Summary for:/,$!d' $log | awk '
|
al@898
|
615 BEGIN { print "<section>" }
|
al@904
|
616 function row(line) {
|
al@904
|
617 split(line, s, " : ");
|
al@904
|
618 printf("\t<tr><td>%s</td><td>%s</td></tr>\n", s[1], s[2]);
|
al@904
|
619 }
|
al@904
|
620 function row2(line, rowNum) {
|
al@904
|
621 split(line, s, " : ");
|
al@938
|
622 if (rowNum == 1) {
|
al@938
|
623 print "<thead>";
|
al@904
|
624 printf("\t<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>\n", s[1], s[2], s[3], s[4], s[5]);
|
al@938
|
625 print "</thead><tbody>";
|
al@938
|
626 }
|
al@904
|
627 else
|
al@904
|
628 printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", s[1], s[2], s[3], s[4], s[5]);
|
al@904
|
629 }
|
al@898
|
630 {
|
al@904
|
631 if (NR==1) { printf("<h3>%s</h3>\n<table>\n", $0); next }
|
al@904
|
632 if ($0 ~ "===") { seen++; if (seen == 1) next; else exit; }
|
al@904
|
633 if ($0 ~ "---") {
|
al@904
|
634 seen2++;
|
al@938
|
635 if (seen2 == 1) print "</table>\n\n<table class=\"pkgslist\">"
|
al@904
|
636 next
|
al@898
|
637 }
|
al@904
|
638 if (seen2) row2($0, seen2); else row($0);
|
al@898
|
639 }
|
al@938
|
640 END { print "</tbody></table></section>" }
|
al@898
|
641 '
|
al@898
|
642 elif fgrep -q "Debug information" $log; then
|
al@898
|
643 echo -e '<section>\n<h3>Debug information</h3>'
|
al@898
|
644 sed -e '/^Debug information/,$!d; /^===/d; /^$/d' $log | sed -n '1!p' | \
|
al@898
|
645 if [ -n "$2" ]; then
|
al@979
|
646 syntax_highlighter log | sed 's|\([^0-9 ]\)\([0-9][0-9]*\):|\1<a href="#l\2">\2</a>:|'
|
al@898
|
647 else
|
al@898
|
648 sed 's|^[0-9][0-9]*:||' | syntax_highlighter log
|
al@898
|
649 fi | mklog
|
al@898
|
650 echo '</section>'
|
al@898
|
651 fi
|
al@898
|
652 else
|
al@898
|
653 [ -n "$pkg" -a -d "$wok/$pkg" ] && show_note e "No log for $pkg"
|
al@898
|
654 fi
|
al@898
|
655 }
|
al@898
|
656
|
al@898
|
657
|
al@898
|
658 active() {
|
al@898
|
659 [ "$cmd" == "$1" -o "$cmd" == "${2:-$1}" ] && echo -n ' active'
|
al@898
|
660 }
|
al@898
|
661
|
al@898
|
662
|
al@898
|
663 pkg_info() {
|
al@898
|
664 local log active bpkg
|
al@898
|
665 log="$LOGS/$pkg.log"
|
al@898
|
666
|
al@989
|
667 echo "<h2><a href=\"$base/$pkg\">$pkg</a>$(. $wok/$pkg/receipt; [ -n "$SHORT_DESC" ] && echo ": $SHORT_DESC")</h2>"
|
al@898
|
668 echo '<div id="info">'
|
al@898
|
669 echo "<a class='button icon receipt$(active receipt stuff)' href='$base/$pkg/receipt'>receipt & stuff</a>"
|
al@898
|
670
|
al@898
|
671 unset WEB_SITE WANTED
|
al@898
|
672 . $wok/$pkg/receipt
|
al@898
|
673
|
al@898
|
674 [ -n "$WEB_SITE" ] &&
|
al@898
|
675 echo "<a class='button icon website' href='$WEB_SITE' target='_blank' rel='noopener noreferrer'>web site</a>"
|
al@898
|
676
|
al@925
|
677 [ -f "$wok/$pkg/taz/$PACKAGE-$VERSION/receipt" ] &&
|
al@898
|
678 echo "<a class='button icon files$(active files)' href='$base/$pkg/files'>files</a>"
|
al@898
|
679
|
al@925
|
680 [ -n "$(ls $wok/$pkg/description*.txt)" ] &&
|
al@925
|
681 echo "<a class='button icon desc$(active description)' href='$base/$pkg/description'>description</a>"
|
al@898
|
682
|
al@925
|
683 [ -n "$TARBALL" -a -s "$SRC/$TARBALL" -o -d "$wok/$pkg/taz" ] &&
|
al@925
|
684 echo "<a class='button icon download' href='$base/$pkg/download'>download</a>"
|
al@898
|
685
|
al@898
|
686 echo "<a class='button icon browse' href='$base/$pkg/browse/'>browse</a>"
|
al@898
|
687
|
al@898
|
688 [ -x ./man2html -a -d "$wok/$pkg/install/usr/share/man" ] &&
|
al@898
|
689 echo "<a class='button icon doc$(active man)' href='$base/$pkg/man/'>man</a>"
|
al@898
|
690
|
al@898
|
691 [ -d "$wok/$pkg/install/usr/share/doc" -o -d "$wok/$pkg/install/usr/share/gtk-doc" ] &&
|
al@898
|
692 echo "<a class='button icon doc$(active doc)' href='$base/$pkg/doc/'>doc</a>"
|
al@898
|
693
|
al@898
|
694 [ -d "$wok/$pkg/install/usr/share/info" ] &&
|
al@898
|
695 echo "<a class='button icon doc$(active info)' href='$base/$pkg/info/#Top'>info</a>"
|
al@898
|
696
|
al@989
|
697 if [ -n "$LFS" ]; then
|
al@989
|
698 printf "<a class='button icon doc' href='%s' target='_blank' rel='noopener noreferrer'>" "$LFS"
|
al@989
|
699 [ "${LFS/blfs/}" != "$LFS" ] && printf "B"
|
al@989
|
700 printf "LFS</a>\n"
|
al@989
|
701 fi
|
al@981
|
702
|
al@898
|
703 [ -s "$log" ] &&
|
al@898
|
704 echo "<a class='button icon log$(active log)' href='$base/$pkg/log/'>logs</a>"
|
al@898
|
705
|
al@898
|
706 echo '</div>'
|
al@898
|
707 }
|
al@898
|
708
|
al@898
|
709
|
al@898
|
710 mktable() {
|
al@898
|
711 sed 's# : #|#' | awk -vc="$1" '
|
al@898
|
712 BEGIN { printf("<table class=\"%s\">\n", c); FS="|" }
|
al@898
|
713 { printf("<tr><td>%s</td>", $1);
|
al@898
|
714 if (NF == 2) printf("<td>%s</td>", $2);
|
al@898
|
715 printf("</tr>\n", $2) }
|
al@898
|
716 END { print "</table>" }'
|
al@898
|
717 }
|
al@898
|
718
|
al@898
|
719
|
al@898
|
720 section() {
|
al@898
|
721 local i=$(basename "$1")
|
al@898
|
722 echo -e '\n\n<section>'
|
al@898
|
723 [ $(wc -l < $1) -gt $2 ] && echo "<a class='button icon more r' href='?$i'>${3#*|}</a>"
|
al@898
|
724 echo "<h2>${3%|*}</h2>"
|
al@898
|
725 mktable "$i"
|
al@898
|
726 echo '</section>'
|
al@898
|
727 }
|
al@898
|
728
|
al@898
|
729
|
al@908
|
730 show_desc() {
|
al@908
|
731 echo "<section><h3>Description of “$1”</h3>"
|
al@908
|
732 if [ -n "$md2html" ]; then
|
al@908
|
733 $md2html $2
|
al@908
|
734 else
|
al@908
|
735 show_code markdown < $2
|
al@908
|
736 fi
|
al@908
|
737 echo "</section>"
|
al@908
|
738 }
|
al@908
|
739
|
al@908
|
740
|
al@924
|
741 # Return all the names of packages bundled in this receipt
|
al@924
|
742
|
al@924
|
743 all_names() {
|
al@924
|
744 local split=" $SPLIT "
|
al@924
|
745 if [ "${split/ $PACKAGE /}" != "$split" ]; then
|
al@924
|
746 # $PACKAGE included somewhere in $SPLIT (probably in the end).
|
al@924
|
747 # We should build packages in the order defined in the $SPLIT.
|
al@924
|
748 echo $SPLIT
|
al@924
|
749 else
|
al@924
|
750 # We'll build the $PACKAGE, then all defined in the $SPLIT.
|
al@924
|
751 echo $PACKAGE $SPLIT
|
al@924
|
752 fi
|
al@924
|
753 }
|
al@924
|
754
|
al@924
|
755
|
al@924
|
756 toolchain_version() {
|
al@924
|
757 echo "<tr><td><a href='$base/$1'>$1</a></td><td>"
|
al@924
|
758 if [ -e "$WOK/$1/receipt" ]; then
|
al@924
|
759 grep ^VERSION $WOK/$1/receipt | cut -d '"' -f2
|
al@924
|
760 echo '</td><td>'
|
al@924
|
761 grep ^SHORT_DESC $WOK/$1/receipt | cut -d '"' -f2
|
al@924
|
762 else
|
al@924
|
763 echo -n '---</td><td>---'
|
al@924
|
764 fi
|
al@924
|
765 echo "</td></tr>"
|
al@924
|
766 }
|
al@924
|
767
|
al@924
|
768
|
al@924
|
769 files_header() {
|
al@924
|
770 echo '<section><h3>Available downloads:</h3>'
|
al@924
|
771 echo '<table><thead><tr><th>File</th><th>Size</th><th>Description</th></tr></thead><tbody>'
|
al@924
|
772 }
|
al@924
|
773
|
al@924
|
774
|
al@933
|
775 # Update statistics used in web interface.
|
al@933
|
776 # There is no need to recalculate the statistics every time the page is displayed.
|
al@940
|
777 # Note, $webstat file must be owned by www, otherwise this function will not be able to do the job.
|
al@933
|
778
|
al@933
|
779 update_webstat() {
|
al@938
|
780 echo '<div id="waitme">'
|
al@938
|
781 show_note i 'Please wait while statistics are being collected.'
|
al@938
|
782 echo "</div>"
|
al@938
|
783
|
al@933
|
784 # for receipts:
|
al@933
|
785 rtotal=$(ls $WOK/*/arch.$ARCH | wc -l)
|
al@933
|
786 rcooked=$(ls -d $WOK/*/taz | wc -l)
|
al@933
|
787 runbuilt=$(($rtotal - $rcooked))
|
al@933
|
788 rblocked=$(wc -l < $blocked)
|
al@933
|
789 rbroken=$(wc -l < $broken)
|
al@933
|
790
|
al@933
|
791 # for packages:
|
al@936
|
792 ptotal=$(cut -d$'\t' -f2 $CACHE/split.db | tr ' ' '\n' | sort -u | wc -l)
|
al@933
|
793 pcooked=$(ls $PKGS/*.tazpkg | wc -l)
|
al@933
|
794 punbuilt=$(($ptotal - $pcooked))
|
al@933
|
795 pblocked=$(
|
al@933
|
796 while read i; do
|
al@933
|
797 sed "/^$i\t/!d" $CACHE/split.db
|
al@933
|
798 done < $blocked | cut -d$'\t' -f2 | tr ' ' '\n' | wc -l)
|
al@933
|
799 pbroken=$(
|
al@933
|
800 while read i; do
|
al@933
|
801 sed "/^$i\t/!d" $CACHE/split.db
|
al@933
|
802 done < $broken | cut -d$'\t' -f2 | tr ' ' '\n' | wc -l)
|
al@933
|
803
|
al@933
|
804 cat > $webstat <<EOT
|
al@933
|
805 rtotal="$rtotal"; rcooked="$rcooked"; runbuilt="$runbuilt"; rblocked="$rblocked"; rbroken="$rbroken"
|
al@933
|
806 ptotal="$ptotal"; pcooked="$pcooked"; punbuilt="$punbuilt"; pblocked="$pblocked"; pbroken="$pbroken"
|
al@933
|
807 EOT
|
al@938
|
808
|
al@938
|
809 echo '<script>document.getElementById("waitme").remove();</script>'
|
al@933
|
810 }
|
al@933
|
811
|
al@933
|
812
|
al@898
|
813
|
al@898
|
814
|
al@898
|
815 #
|
al@898
|
816 # Load requested page
|
al@898
|
817 #
|
al@898
|
818
|
al@898
|
819 if [ -z "$pkg" ]; then
|
al@898
|
820
|
al@898
|
821 page_header
|
al@898
|
822 if [ -n "$QUERY_STRING" -a "$QUERY_STRING" != 'debug' ]; then
|
al@898
|
823
|
al@898
|
824 for list in activity cooknotes cooklist; do
|
al@898
|
825 [ -n "$(GET $list)" ] || continue
|
al@898
|
826 [ "$list" == 'cooklist' ] && nb="- Packages: $(wc -l < $cooklist)"
|
al@898
|
827 echo '<section id="content2">'
|
al@898
|
828 echo "<h2>DB: $list $nb</h2>"
|
al@905
|
829 tac $CACHE/$list | sed 's|cooker.cgi?pkg=||; s|%2B|+|g;
|
al@898
|
830 s|\[ Done|<span class="r c20">Done|;
|
al@898
|
831 s|\[ Failed|<span class="r c10">Failed|;
|
al@898
|
832 s| \]|</span>|' | mktable $list
|
al@898
|
833 echo '</section>'
|
al@898
|
834 done
|
al@898
|
835
|
al@898
|
836 if [ -n "$(GET broken)" ]; then
|
al@938
|
837 echo '<section id="content2">'
|
al@898
|
838 echo "<h2>DB: broken - Packages: $(wc -l < $broken)</h2>"
|
al@898
|
839 sort $CACHE/broken | sed "s|^[^']*|<a href='$base/\0'>\0</a>|g" | mktable
|
al@938
|
840 echo '</section>'
|
al@898
|
841 fi
|
al@898
|
842
|
al@898
|
843 case "$QUERY_STRING" in
|
al@898
|
844 *.log)
|
al@898
|
845 log=$LOGS/$QUERY_STRING
|
al@898
|
846 name=$(basename $log)
|
al@898
|
847 if [ -f "$log" ]; then
|
al@898
|
848 echo "<h2>Log for: ${name%.log}</h2>"
|
al@898
|
849 if fgrep -q "Summary" $log; then
|
al@898
|
850 echo '<pre class="log">'
|
al@942
|
851 grep -A 20 'Summary' $log | syntax_highlighter log
|
al@898
|
852 echo '</pre>'
|
al@898
|
853 fi
|
al@898
|
854 echo '<pre class="log">'
|
al@898
|
855 syntax_highlighter log < $log
|
al@898
|
856 echo '</pre>'
|
al@986
|
857 if [ "$QUERY_STRING" == 'pkgdb.log' ]; then
|
al@985
|
858 # Display button only for SliTaz web browser
|
al@985
|
859 case "$HTTP_USER_AGENT" in
|
al@985
|
860 *SliTaz*)
|
al@985
|
861 if [ -f $CACHE/cooker-request -a -n "$HTTP_REFERER" ]; then
|
al@985
|
862 if grep -qs '^pkgdb$' $CACHE/recook-packages; then
|
al@985
|
863 show_note i "The package database has been requested for re-creation"
|
al@985
|
864 else
|
al@985
|
865 echo "<a class='button' href='$base/?recook=pkgdb'>Re-create the DB</a>"
|
al@985
|
866 fi
|
al@985
|
867 fi
|
al@985
|
868 ;;
|
al@985
|
869 esac
|
al@985
|
870 fi
|
al@898
|
871 else
|
al@898
|
872 show_note e "No log file: $log"
|
al@898
|
873 fi
|
al@898
|
874 ;;
|
al@924
|
875 toolchain)
|
al@924
|
876 cat <<EOT
|
al@924
|
877 <div id="content2">
|
al@924
|
878 <section>
|
al@924
|
879 <h2>SliTaz GNU/Linux toolchain</h2>
|
al@924
|
880
|
al@924
|
881 <table>
|
al@924
|
882 <tr><td>Build date</td> <td colspan="2">$(sed -n '/^Cook date/s|[^:]*: \(.*\)|\1|p' $LOGS/slitaz-toolchain.log)</td></tr>
|
al@924
|
883 <tr><td>Build duration</td> <td colspan="2">$(sed -n '/^Cook time/s|[^:]*: \(.*\)|\1|p' $LOGS/slitaz-toolchain.log)</td></tr>
|
al@924
|
884 <tr><td>Architecture</td> <td colspan="2">$ARCH</td></tr>
|
al@924
|
885 <tr><td>Build system</td> <td colspan="2">$BUILD_SYSTEM</td></tr>
|
al@924
|
886 <tr><td>Host system</td> <td colspan="2">$HOST_SYSTEM</td></tr>
|
al@924
|
887 <tr><th>Package</th><th>Version</th><th>Description</th></tr>
|
al@924
|
888 $(toolchain_version slitaz-toolchain)
|
al@924
|
889 $(toolchain_version binutils)
|
al@924
|
890 $(toolchain_version linux-api-headers)
|
al@924
|
891 $(toolchain_version gcc)
|
al@924
|
892 $(toolchain_version glibc)
|
al@924
|
893 </table>
|
al@924
|
894
|
al@924
|
895 <p>Toolchain documentation: <a target="_blank" rel="noopener noreferrer"
|
al@924
|
896 href="http://doc.slitaz.org/en:cookbook:toolchain">http://doc.slitaz.org/en:cookbook:toolchain</a>
|
al@924
|
897 </p>
|
al@924
|
898
|
al@924
|
899 </section>
|
al@924
|
900 </div>
|
al@924
|
901 EOT
|
al@924
|
902 ;;
|
al@898
|
903 esac
|
al@898
|
904 page_footer
|
al@898
|
905 exit 0
|
al@898
|
906 fi
|
al@898
|
907
|
al@898
|
908
|
al@898
|
909 # We may have a toolchain.cgi script for cross cooker's
|
al@898
|
910 if [ -f "toolchain.cgi" ]; then
|
al@898
|
911 toolchain="toolchain.cgi"
|
al@898
|
912 else
|
al@924
|
913 toolchain="?toolchain"
|
al@898
|
914 fi
|
al@933
|
915
|
paul@900
|
916 # Main page with summary. Count only packages included in ARCH,
|
al@898
|
917 # use 'cooker arch-db' to manually create arch.$ARCH files.
|
al@933
|
918
|
al@898
|
919 cat <<EOT
|
al@898
|
920 <div id="content2">
|
al@898
|
921
|
al@898
|
922 <section>
|
al@898
|
923 <form method="get" action="" class="search r">
|
al@898
|
924 <input type="hidden" name="search" value="pkg"/>
|
al@898
|
925 <button type="submit" title="Search">Search</button>
|
al@898
|
926 <input type="search" name="q" placeholder="Package" list="packages" autocorrect="off" autocapitalize="off"/>
|
al@898
|
927 </form>
|
al@898
|
928
|
al@898
|
929 <h2>Summary</h2>
|
al@898
|
930 EOT
|
al@898
|
931
|
al@898
|
932 mktable <<EOT
|
al@898
|
933 Cooker state : $(running_command)
|
al@898
|
934 Wok revision : <a href='$WOK_URL' target='_blank' rel='noopener noreferrer'>$(cat $wokrev)</a>
|
al@898
|
935 Commits to cook : $(wc -l < $commits)
|
al@898
|
936 Current cooklist : $(wc -l < $cooklist)
|
al@898
|
937 Architecture : $ARCH, <a href="$toolchain">toolchain</a>
|
al@898
|
938 Server date : <span id='date'>$(date -u '+%F %R %Z')</span>
|
al@898
|
939 EOT
|
al@898
|
940
|
al@898
|
941 # If command is "cook:*", update gauge and percentage periodically.
|
al@898
|
942 # If different package is cooking, reload the page (with new settings)
|
al@898
|
943 cmd="$(cat $command)"
|
al@898
|
944 case "$cmd" in
|
al@898
|
945 cook:*)
|
al@898
|
946 pkg=${cmd#*:}
|
al@898
|
947 echo "<script>updatePkg = '${pkg//+/%2B}';</script>"
|
al@898
|
948 ;;
|
al@898
|
949 esac
|
al@898
|
950
|
al@933
|
951 # Do we need to update the statistics?
|
al@933
|
952 [ "$webstat" -nt "$activity" ] || update_webstat
|
al@933
|
953 . $webstat
|
al@933
|
954
|
al@933
|
955 pct=0; [ "$rtotal" -gt 0 ] && pct=$(( ($rcooked * 100) / $rtotal ))
|
al@933
|
956
|
al@933
|
957 cat <<EOT
|
al@933
|
958 <div class="meter"><progress max="100" value="$pct">${pct}%</progress><span>${pct}%</span></div>
|
al@933
|
959
|
al@933
|
960 <table class="webstat"><thead>
|
al@933
|
961 <tr><th> </th><th>Total </th><th>Cooked </th><th>Unbuilt </th><th>Blocked </th><th>Broken </th></tr>
|
al@933
|
962 </thead><tbody>
|
al@933
|
963 <tr><td>Receipts</td><td>$rtotal</td><td>$rcooked</td><td>$runbuilt</td><td>$rblocked</td><td>$rbroken</td></tr>
|
al@933
|
964 <tr><td>Packages</td><td>$ptotal</td><td>$pcooked</td><td>$punbuilt</td><td>$pblocked</td><td>$pbroken</td></tr>
|
al@933
|
965 </tbody></table>
|
al@933
|
966 EOT
|
al@933
|
967
|
al@898
|
968 if [ -e "$CACHE/cooker-request" -a ! -s $command ]; then
|
al@898
|
969 if [ "$activity" -nt "$CACHE/cooker-request" ]; then
|
al@898
|
970 echo '<a class="button icon bell r" href="?poke">Wake up</a>'
|
al@898
|
971 else
|
al@898
|
972 show_note i 'Cooker will be launched in the next 5 minutes.'
|
al@898
|
973 fi
|
al@898
|
974 fi
|
al@898
|
975
|
al@898
|
976 cat <<EOT
|
al@898
|
977 <p>
|
al@898
|
978 Service logs:
|
al@898
|
979 <a href="?cookorder.log">cookorder</a> ·
|
al@898
|
980 <a href="?commits.log">commits</a> ·
|
al@898
|
981 <a href="?pkgdb.log">pkgdb</a>
|
al@898
|
982 </p>
|
al@898
|
983 </section>
|
al@898
|
984 EOT
|
al@898
|
985
|
al@898
|
986 tac $activity | head -n12 | sed 's|cooker.cgi?pkg=||;
|
al@898
|
987 s|\[ Done|<span class="r c20">Done|;
|
al@898
|
988 s|\[ Failed|<span class="r c10">Failed|;
|
al@898
|
989 s| \]|</span>|;
|
al@898
|
990 s|%2B|\+|g' | \
|
al@898
|
991 section $activity 12 "Activity|More activity"
|
al@898
|
992
|
al@898
|
993 [ -s "$cooknotes" ] && tac $cooknotes | head -n12 | \
|
al@898
|
994 section $cooknotes 12 "Cooknotes|More notes"
|
al@898
|
995
|
al@898
|
996 [ -s "$commits" ] &&
|
al@898
|
997 section $commits 20 "Commits|More commits" < $commits
|
al@898
|
998
|
al@898
|
999 [ -s "$cooklist" ] && head -n 20 $cooklist | \
|
al@898
|
1000 section $cooklist 20 "Cooklist|Full cooklist"
|
al@898
|
1001
|
al@898
|
1002 [ -s "$broken" ] && head -n20 $broken | sed "s|^[^']*|<a href='\0'>\0</a>|g" | \
|
al@898
|
1003 section $broken 20 "Broken|All broken packages"
|
al@898
|
1004
|
al@898
|
1005 [ -s "$blocked" ] && sed "s|^[^']*|<a href='\0'>\0</a>|g" $blocked | \
|
al@898
|
1006 section $blocked 12 "Blocked|All blocked packages"
|
al@898
|
1007
|
al@898
|
1008 cd $PKGS
|
al@898
|
1009 ls -let *.tazpkg | awk '
|
al@898
|
1010 (NR<=20){
|
al@898
|
1011 sub(/:[0-9][0-9]$/, "", $9);
|
al@898
|
1012 mon = index(" JanFebMarAprMayJunJulAugSepOctNovDec", $7) / 3;
|
al@898
|
1013 printf("%d-%02d-%02d %s : <a href=\"get/%s\">%s</a>\n", $10, mon, $8, $9, $11, $11);
|
al@898
|
1014 }' | \
|
al@898
|
1015 section $activity 1000 "Latest cook"
|
al@898
|
1016
|
al@898
|
1017 echo '</div>'
|
al@898
|
1018 datalist
|
al@898
|
1019 page_footer
|
al@898
|
1020 exit 0
|
al@898
|
1021 fi
|
al@898
|
1022
|
al@898
|
1023
|
al@898
|
1024 case "$cmd" in
|
al@898
|
1025 '')
|
al@898
|
1026 page_header
|
al@898
|
1027
|
al@989
|
1028 requested_pkg="$pkg"
|
al@898
|
1029 # Package info.
|
al@940
|
1030 if [ ! -f "$wok/$pkg/receipt" ]; then
|
al@940
|
1031 # Let's look at the cases when the package was not found
|
al@940
|
1032
|
al@940
|
1033 # Maybe query is the exact name of split package? -> proceed to main package
|
al@940
|
1034 mainpkg=$(awk -F$'\t' -vpkg=" $pkg " '{
|
al@940
|
1035 if (index(" " $2 " ", pkg)) {print $1; exit}
|
al@940
|
1036 }' $splitdb)
|
al@940
|
1037
|
al@940
|
1038 # No, so let's find any matches among packages names (both main and split)
|
al@940
|
1039 if [ -z "$mainpkg" ]; then
|
al@940
|
1040 pkgs=$(cut -d$'\t' -f2 $splitdb | tr ' ' '\n' | fgrep "$pkg")
|
al@940
|
1041 # Nothing matched
|
al@940
|
1042 if [ -z "$pkgs" ]; then
|
al@940
|
1043 echo "<h2>Not Found</h2>"
|
al@940
|
1044 show_note e "The requested package <b>$pkg</b> was not found on this server."
|
al@940
|
1045 page_footer; exit 0
|
al@940
|
1046 fi
|
al@940
|
1047 # Search results page
|
al@898
|
1048 echo "<section><h2>Package names matching “$pkg”</h2>"
|
al@898
|
1049 echo "<table><thead><tr><th>Name</th><th>Description</th><th>Category</th></tr></thead><tbody>"
|
al@940
|
1050 query="$pkg"
|
al@940
|
1051 for pkg in $pkgs; do
|
al@940
|
1052 # Find main package
|
al@940
|
1053 mainpkg=$(awk -F$'\t' -vpkg=" $pkg " '{
|
al@940
|
1054 if (index(" " $2 " ", pkg)) {print $1; exit}
|
al@940
|
1055 }' $splitdb)
|
al@940
|
1056 unset SHORT_DESC CATEGORY; . $wok/$mainpkg/receipt
|
al@940
|
1057
|
al@898
|
1058 unset SHORT_DESC CATEGORY
|
al@940
|
1059 [ -e "$wok/$mainpkg/taz/$PACKAGE-$VERSION/receipt" ] &&
|
al@940
|
1060 . $wok/$mainpkg/taz/$PACKAGE-$VERSION/receipt
|
al@940
|
1061
|
al@940
|
1062 echo -n "<tr><td><a href="$base/$pkg">${pkg//$query/<mark>$query</mark>}</a>"
|
al@940
|
1063 [ "$pkg" == "$mainpkg" ] || echo -n " (${mainpkg//$query/<mark>$query</mark>})"
|
al@940
|
1064 echo -n "</td><td>$SHORT_DESC</td><td>$CATEGORY</td></tr>"
|
al@898
|
1065 done
|
al@898
|
1066 echo '</tbody></table></section>'
|
al@940
|
1067 page_footer; exit 0
|
al@898
|
1068 fi
|
al@940
|
1069 pkg="$mainpkg"
|
al@898
|
1070 fi
|
al@898
|
1071
|
al@940
|
1072 log=$LOGS/$pkg.log
|
al@940
|
1073 pkg_info
|
al@940
|
1074
|
al@898
|
1075 # Check for a log file and display summary if it exists.
|
al@898
|
1076 summary "$log"
|
al@898
|
1077
|
al@982
|
1078 # Informal table with dependencies
|
al@989
|
1079 pkg="$requested_pkg"
|
al@982
|
1080 cat <<EOT
|
al@982
|
1081 <section>
|
al@989
|
1082 <h3>Related packages</h3>
|
al@989
|
1083 <table class="third">
|
al@982
|
1084 <thead>
|
al@982
|
1085 <tr>
|
al@982
|
1086 <th>Build dependencies</th>
|
al@989
|
1087 <th>Runtime dependencies</th>
|
al@982
|
1088 <th>Required by</th>
|
al@982
|
1089 </tr>
|
al@982
|
1090 </thead>
|
al@982
|
1091 <tbody>
|
al@982
|
1092 <tr>
|
al@982
|
1093 <td>
|
al@982
|
1094 <table>
|
al@982
|
1095 EOT
|
al@983
|
1096 for i in $WANTED $BUILD_DEPENDS; do
|
al@982
|
1097 echo "<tr><td><img src='$base/s/$i'> <a href='$base/$i'>$i</a></td></tr>"
|
al@982
|
1098 done
|
al@982
|
1099 cat <<EOT
|
al@982
|
1100 </table>
|
al@982
|
1101 </td>
|
al@982
|
1102 <td>
|
al@982
|
1103 <table>
|
al@982
|
1104 EOT
|
al@982
|
1105 {
|
al@989
|
1106 [ -s "$PKGS/packages.info" ] &&
|
al@989
|
1107 awk -F$'\t' -vp="$pkg" '{
|
al@989
|
1108 if ($1 == p) print $8
|
al@989
|
1109 }' "$PKGS/packages.info"
|
al@989
|
1110 } | tr ' ' '\n' | sort -u | \
|
al@989
|
1111 while read i; do
|
al@989
|
1112 [ -n "$i" ] &&
|
al@989
|
1113 echo "<tr><td><img src='$base/s/$i'> <a href='$base/$i'>$i</a></td></tr>"
|
al@989
|
1114 done
|
al@989
|
1115 cat <<EOT
|
al@989
|
1116 </table>
|
al@989
|
1117 </td>
|
al@989
|
1118 <td>
|
al@989
|
1119 <table>
|
al@989
|
1120 EOT
|
al@989
|
1121
|
al@989
|
1122 {
|
al@982
|
1123 for i in $(awk -F$'\t' -vp="$pkg" '{if($1==p)print $2}' $splitdb); do
|
al@982
|
1124
|
al@982
|
1125 [ -s "$PKGS/packages.info" ] &&
|
al@982
|
1126 awk -F$'\t' -vp=" $i " '{
|
al@982
|
1127 if (index(" " $8 " ", p)) print $1
|
al@982
|
1128 }' "$PKGS/packages.info"
|
al@982
|
1129
|
al@982
|
1130 [ -s "$PKGS/bdeps.txt" ] &&
|
al@982
|
1131 awk -F$'\t' -vp=" $i " '{
|
al@982
|
1132 if (index(" " $2 " ", p)) print $1
|
al@982
|
1133 }' $PKGS/bdeps.txt
|
al@982
|
1134 done
|
al@982
|
1135 } | sort -u | \
|
al@982
|
1136 while read i; do
|
al@982
|
1137 echo "<tr><td><img src='$base/s/$i'> <a href='$base/$i'>$i</a></td></tr>"
|
al@982
|
1138 done
|
al@982
|
1139 cat <<EOT
|
al@982
|
1140 </table>
|
al@982
|
1141 </td>
|
al@982
|
1142 </tr>
|
al@982
|
1143 </tbody>
|
al@982
|
1144 </table>
|
al@982
|
1145 </section>
|
al@982
|
1146 EOT
|
al@982
|
1147
|
al@898
|
1148 # Display <Recook> button only for SliTaz web browser
|
al@971
|
1149 case "$HTTP_USER_AGENT" in
|
al@971
|
1150 *SliTaz*)
|
al@971
|
1151 if [ -f $CACHE/cooker-request -a -n "$HTTP_REFERER" ]; then
|
al@971
|
1152 if grep -qs "^$pkg$" $CACHE/recook-packages; then
|
al@971
|
1153 show_note i "The package “$pkg” has been requested for recook"
|
al@971
|
1154 else
|
al@971
|
1155 echo "<a class='button' href='$base/?recook=${pkg//+/%2B}'>Recook $pkg</a>"
|
al@898
|
1156 fi
|
al@971
|
1157 fi
|
al@971
|
1158 ;;
|
al@971
|
1159 esac
|
al@898
|
1160 ;;
|
al@898
|
1161
|
al@898
|
1162 receipt)
|
al@898
|
1163 page_header
|
al@898
|
1164 pkg_info
|
al@898
|
1165 echo "<a class='button receipt' href='$base/$pkg/receipt'>receipt</a>"
|
al@898
|
1166 ( cd $wok/$pkg; find stuff -type f 2>/dev/null ) | sort | \
|
al@898
|
1167 awk -vb="$base/$pkg" '{printf("<a class=\"button\" href=\"%s/%s\">%s</a>\n", b, $0, $0)}'
|
al@898
|
1168
|
al@898
|
1169 show_code bash < $wok/$pkg/receipt
|
al@898
|
1170 ;;
|
al@898
|
1171
|
al@898
|
1172 stuff)
|
al@898
|
1173 page_header
|
al@898
|
1174 pkg_info
|
al@898
|
1175 file="$pkg/stuff/$arg"
|
al@898
|
1176 echo "<a class='button' href='$base/$pkg/receipt'>receipt</a>"
|
al@898
|
1177 ( cd $wok/$pkg; find stuff -type f 2>/dev/null ) | sort | \
|
al@898
|
1178 awk -vb="$base/$pkg" -va="stuff/$arg" '{
|
al@898
|
1179 printf("<a class=\"button%s\" href=\"%s/%s\">%s</a>\n", a==$0 ? " receipt" : "", b, $0, $0)
|
al@898
|
1180 }'
|
al@898
|
1181
|
al@898
|
1182 if [ -f "$wok/$file" ]; then
|
al@898
|
1183 case $file in
|
al@898
|
1184 *.desktop|*.theme) class="ini" ;;
|
al@898
|
1185 *.patch|*.diff|*.u) class="diff" ;;
|
al@898
|
1186 *.sh) class="bash" ;;
|
al@898
|
1187 *.conf*|*.ini)
|
al@898
|
1188 class="bash"
|
al@898
|
1189 [ -n "$(cut -c1 < $wok/$file | fgrep '[')" ] && class="ini"
|
al@898
|
1190 ;;
|
al@898
|
1191 *.pl) class="perl" ;;
|
al@898
|
1192 *.c|*.h|*.awk) class="clike" ;;
|
al@898
|
1193 *.svg) class="svg" ;;
|
al@898
|
1194 *Makefile*) class="makefile" ;;
|
al@898
|
1195 *.po|*.pot) class="bash" ;;
|
al@898
|
1196 *.css) class="css" ;;
|
al@898
|
1197 *.htm|*.html) class="html" ;;
|
al@898
|
1198 *.js) class="js" ;;
|
al@898
|
1199 *.txt) class="asciidoc" ;;
|
al@898
|
1200 *)
|
al@898
|
1201 case $(head -n1 $wok/$file) in
|
al@898
|
1202 *!/bin/sh*|*!/bin/bash*) class="bash" ;;
|
al@898
|
1203 esac
|
al@898
|
1204 if [ -z "$class" -a "$(head -n1 $wok/$file | cut -b1)" == '#' ]; then
|
al@898
|
1205 class="bash"
|
al@898
|
1206 fi
|
al@898
|
1207 if [ -z "$class" ]; then
|
al@898
|
1208 # Follow Busybox restrictions. Search for non-printable chars
|
al@898
|
1209 if [ $(tr -d '[:alnum:][:punct:][:blank:][:cntrl:]' < "$wok/$file" | wc -c) -gt 0 ]; then
|
al@898
|
1210 raw="true"
|
al@898
|
1211 fi
|
al@898
|
1212 fi
|
al@898
|
1213 ;;
|
al@898
|
1214 esac
|
al@898
|
1215
|
al@898
|
1216 # Display image
|
al@898
|
1217 case $file in
|
al@898
|
1218 *.png|*.svg|*.jpg|*.jpeg|*.ico)
|
al@898
|
1219 echo "<img src='$base/$pkg/browse/stuff/$arg' style='display: block; max-width: 100%; margin: auto'/>"
|
al@898
|
1220 ;;
|
al@898
|
1221 esac
|
al@898
|
1222
|
al@898
|
1223 # Display colored listing for all text-based documents (also for *.svg)
|
al@898
|
1224 case $file in
|
al@898
|
1225 *.png|*.jpg|*.jpeg|*.ico) ;;
|
al@898
|
1226 *)
|
al@898
|
1227 if [ -z "$raw" ]; then
|
al@898
|
1228 cat $wok/$file | show_code $class
|
al@898
|
1229 fi
|
al@898
|
1230 ;;
|
al@898
|
1231 esac
|
al@898
|
1232
|
al@898
|
1233 # Display hex dump for binary files
|
al@898
|
1234 if [ -n "$raw" ]; then
|
al@898
|
1235 hexdump -C $wok/$file | show_code #| sed 's|^\([0-9a-f][0-9a-f]*\)|<span class="c2">\1</span>|'
|
al@898
|
1236 fi
|
al@898
|
1237 else
|
al@898
|
1238 show_note e "File “$file” absent!"
|
al@898
|
1239 fi
|
al@898
|
1240 ;;
|
al@898
|
1241
|
al@898
|
1242 files)
|
al@898
|
1243 page_header
|
al@898
|
1244 pkg_info
|
al@898
|
1245
|
al@898
|
1246 packaged=$(mktemp)
|
al@898
|
1247
|
al@898
|
1248 # find main package
|
al@898
|
1249 wanted=$(. $wok/$pkg/receipt; echo $WANTED)
|
al@898
|
1250 main=${wanted:-$pkg}
|
al@915
|
1251
|
paul@900
|
1252 # identify split packages
|
al@898
|
1253 split="$main $(. $wok/$main/receipt; echo $SPLIT)"
|
al@898
|
1254 [ -d "$wok/$main-dev" ] && split="$split $main-dev"
|
al@898
|
1255 split="$(echo $split | tr ' ' '\n' | sort -u)"
|
al@915
|
1256
|
al@898
|
1257 # finally we need the version
|
al@915
|
1258 if [ -f "$WOK/linux/receipt" ]; then
|
al@915
|
1259 kvers=$(. $WOK/linux/receipt; echo $VERSION)
|
al@915
|
1260 kbasevers=$(echo $kvers | cut -d. -f1,2)
|
al@915
|
1261 elif [ -f "$INSTALLED/linux-api-headers/receipt" ]; then
|
al@915
|
1262 kvers=$(. $INSTALLED/linux-api-headers/receipt; echo $VERSION)
|
al@915
|
1263 kbasevers=$(echo $kvers | cut -d. -f1,2)
|
al@915
|
1264 fi
|
al@898
|
1265 ver=$(. $wok/$main/receipt; echo $VERSION$EXTRAVERSION)
|
al@898
|
1266
|
al@924
|
1267
|
al@924
|
1268 echo "<section><h3>Quick jump:</h3><ul>"
|
al@940
|
1269 echo "$split" | sed 'p' | xargs printf "<li><a href='#%s'>%s</a></li>\n"
|
al@940
|
1270 echo "<li id='li-repeats' style='display:none'><a href='#repeats'>repeatedly packaged files</a></li>"
|
al@964
|
1271 echo "<li id='li-empty' style='display:none'><a href='#empty'>unpackaged empty folders</a></li>"
|
al@946
|
1272 echo "<li id='li-orphans' style='display:none'><a href='#orphans'>unpackaged files</a>"
|
al@946
|
1273 echo "<span id='orphansTypes'></span></li>"
|
al@924
|
1274 echo "</ul></section>"
|
al@924
|
1275
|
al@898
|
1276 for p in $split; do
|
al@898
|
1277 namever="$p-$ver"
|
al@898
|
1278 if [ -d "$wok/$p/taz/$p-$ver" ]; then
|
al@898
|
1279 indir=$p
|
al@898
|
1280 elif [ -d "$wok/$main/taz/$p-$ver" ]; then
|
al@898
|
1281 indir=$main
|
al@898
|
1282 fi
|
al@898
|
1283 dir="$wok/$indir/taz/$p-$ver/fs"
|
al@898
|
1284
|
al@898
|
1285 size=$(du -hs $dir | awk '{ sub(/\.0/, ""); print $1 }')
|
al@898
|
1286
|
al@940
|
1287 echo "<section><h3 id='$p'>Contents of package “$namever” (${size:-empty}):</h3>"
|
al@912
|
1288 echo '<pre class="files">'
|
al@912
|
1289 if [ -s "$wok/$indir/taz/$p-$ver/files.list" ]; then
|
al@912
|
1290 echo -n '<span class="underline">permissions·lnk·user ·'
|
al@924
|
1291 echo -en 'group · size·date & time ·name\n</span>'
|
al@912
|
1292 cd $dir
|
al@924
|
1293 find . -print0 | sort -z | xargs -0 ls -ldp --color=always | \
|
al@912
|
1294 syntax_highlighter files | \
|
al@924
|
1295 sed "s|\([^>]*\)>\.\([^<]*\)\(<.*\)$|\1 href='$base/$indir/browse/taz/$p-$ver/fs\2'>\2\3|;" | \
|
al@912
|
1296 awk 'BEGIN { FS="\""; }
|
al@912
|
1297 { gsub("+", "%2B", $2); print; }'
|
al@912
|
1298 else
|
al@912
|
1299 echo 'No files'
|
al@912
|
1300 fi
|
al@898
|
1301 echo '</pre></section>'
|
al@898
|
1302 cat $wok/$indir/taz/$p-$ver/files.list >> $packaged
|
al@898
|
1303 done
|
al@898
|
1304
|
al@898
|
1305 # find repeatedly packaged files
|
al@898
|
1306 repeats="$(sort $packaged | uniq -d)"
|
al@898
|
1307 if [ -n "$repeats" ]; then
|
al@928
|
1308 echo '<script>document.getElementById("li-repeats").style.display = "list-item"</script>'
|
al@940
|
1309 echo -n '<section><h3 id="repeats">Repeatedly packaged files:</h3><pre class="files">'
|
al@898
|
1310 echo "$repeats" | sed 's|^|<span class="c11">!!!</span> |'
|
al@898
|
1311 echo "</pre></section>"
|
al@898
|
1312 fi
|
al@898
|
1313
|
al@964
|
1314 # find unpackaged empty folders
|
al@964
|
1315 emptydirs="$(
|
al@964
|
1316 cd $wok/$main/install
|
al@964
|
1317 find -type d | sed 's|\.||' | \
|
al@964
|
1318 while read d; do
|
al@964
|
1319 [ -z "$(ls "$wok/$main/install$d")" ] || continue
|
al@964
|
1320 echo $d
|
al@964
|
1321 done | \
|
al@964
|
1322 while read d; do
|
al@964
|
1323 notfound='yes'
|
al@964
|
1324 for p in $(cd $wok/$main/taz; ls); do
|
al@964
|
1325 if [ -d "$wok/$main/taz/$p/fs$d" ]; then
|
al@964
|
1326 notfound=''
|
al@964
|
1327 break
|
al@964
|
1328 fi
|
al@964
|
1329 done
|
al@964
|
1330 [ -n "$notfound" ] &&
|
al@964
|
1331 ls -ldp --color=always .$d | syntax_highlighter files | sed 's|>\./|>/|'
|
al@964
|
1332 done
|
al@964
|
1333 )"
|
al@964
|
1334 if [ -n "$emptydirs" ]; then
|
al@964
|
1335 echo '<script>document.getElementById("li-empty").style.display = "list-item"</script>'
|
al@964
|
1336 echo -n '<section><h3 id="empty">Unpackaged empty folders:</h3><pre class="files">'
|
al@964
|
1337 echo "$emptydirs"
|
al@964
|
1338 echo "</pre></section>"
|
al@964
|
1339 fi
|
al@964
|
1340
|
al@898
|
1341 # find unpackaged files
|
al@898
|
1342 all_files=$(mktemp)
|
al@898
|
1343 cd $wok/$main/install; find ! -type d | sed 's|\.||' > $all_files
|
al@898
|
1344 orphans="$(sort $all_files $packaged | uniq -u)"
|
al@912
|
1345 if [ -d "$wok/$main/install" -a -n "$orphans" ]; then
|
al@928
|
1346 echo '<script>document.getElementById("li-orphans").style.display = "list-item"</script>'
|
al@940
|
1347 echo '<section><h3 id="orphans">Unpackaged files:</h3>'
|
al@912
|
1348 table=$(mktemp)
|
al@924
|
1349 echo "$orphans" | awk -vi="$base/$indir/browse/install" '
|
al@924
|
1350 function tag(text, color) {
|
al@924
|
1351 printf("<span class=\"c%s1\">%s</span> ", color, text);
|
al@924
|
1352 printf("<a class=\"c00\" href=\"%s\">%s</a>\n", i $0, $0);
|
al@924
|
1353 }
|
al@912
|
1354 /\/perllocal.pod$/ || /\/\.packlist$/ || /\/share\/bash-completion\// ||
|
al@945
|
1355 /\/lib\/systemd\// || /\.pyc$/ || /\.pyo$/ || /\/fonts\.scale$/ || /\/fonts\.dir$/ {
|
al@945
|
1356 tag("---", 0); next }
|
al@898
|
1357 /\.pod$/ { tag("pod", 5); next }
|
al@898
|
1358 /\/share\/man\// { tag("man", 5); next }
|
al@912
|
1359 /\/share\/doc\// || /\/share\/gtk-doc\// || /\/share\/info\// ||
|
al@912
|
1360 /\/share\/devhelp\// { tag("doc", 5); next }
|
al@898
|
1361 /\/share\/icons\// { tag("ico", 2); next }
|
al@898
|
1362 /\/share\/locale\// { tag("loc", 4); next }
|
al@924
|
1363 /\.h$/ || /\.a$/ || /\.la$/ || /\.pc$/ || /\/bin\/.*-config$/ ||
|
al@924
|
1364 /\/Makefile.*$/ { tag("dev", 3); next }
|
al@989
|
1365 /\/share\/help\// || /\/share\/appdata\// { tag("gnm", 6); next }
|
al@898
|
1366 { tag("???", 1) }
|
al@912
|
1367 ' > $table
|
al@912
|
1368
|
al@912
|
1369 # Summary table
|
al@946
|
1370 orphans_types='()'
|
al@912
|
1371 for i in head body; do
|
al@912
|
1372 case $i in
|
al@912
|
1373 head) echo -n '<table class="summary"><tr>';;
|
al@912
|
1374 body) echo -n '<th> </th></tr><tr>';;
|
al@912
|
1375 esac
|
al@989
|
1376 for j in '???1' dev3 loc4 ico2 doc5 man5 pod5 gnm6 '---0'; do
|
al@912
|
1377 tag=${j:0:3}; class="c${j:3:1}0"; [ "$class" == 'c00' ] && class='c01'
|
al@912
|
1378 case $i in
|
al@912
|
1379 head) echo -n "<th class='$class'>$tag</th>";;
|
al@946
|
1380 body)
|
al@946
|
1381 tagscount="$(grep ">$tag<" $table | wc -l)"
|
al@946
|
1382 printf '<td>%s</td>' "$tagscount"
|
al@946
|
1383 [ "$tagscount" -gt 0 ] && orphans_types="${orphans_types/)/ $tag)}"
|
al@946
|
1384 ;;
|
al@912
|
1385 esac
|
al@912
|
1386 done
|
al@912
|
1387 done
|
al@912
|
1388 echo '<td> </td></tr></table>'
|
al@946
|
1389 orphans_types="${orphans_types/( /(}"
|
al@946
|
1390 [ "$orphans_types" != '()' ] &&
|
al@946
|
1391 echo "<script>document.getElementById('orphansTypes').innerText = '${orphans_types// /, }';</script>"
|
al@912
|
1392
|
al@912
|
1393 echo -n '<pre class="files">'
|
al@912
|
1394 cat $table
|
al@898
|
1395 echo '</pre></section>'
|
al@912
|
1396 rm $table
|
al@898
|
1397 fi
|
al@912
|
1398 rm $packaged $all_files
|
al@898
|
1399 ;;
|
al@898
|
1400
|
al@898
|
1401 description)
|
al@898
|
1402 page_header
|
al@898
|
1403 pkg_info
|
al@908
|
1404 descs="$(ls $WOK/$pkg/description*.txt)"
|
al@908
|
1405 if [ -n "$descs" ]; then
|
al@898
|
1406 echo '<div id="content2">'
|
al@908
|
1407 [ -f "$WOK/$pkg/description.txt" ] && show_desc "$pkg" "$WOK/$pkg/description.txt"
|
al@908
|
1408 for i in $descs; do
|
al@908
|
1409 case $i in
|
al@908
|
1410 */description.txt) continue ;;
|
al@908
|
1411 *) package=$(echo $i | cut -d. -f2) ;;
|
al@908
|
1412 esac
|
al@908
|
1413 show_desc "$package" "$i"
|
al@908
|
1414 done
|
al@898
|
1415 echo '</div>'
|
al@898
|
1416 else
|
al@898
|
1417 show_note w "No description of $pkg"
|
al@898
|
1418 fi
|
al@898
|
1419 ;;
|
al@898
|
1420
|
al@898
|
1421 log)
|
al@898
|
1422 page_header
|
al@898
|
1423 pkg_info
|
al@898
|
1424 [ -z "$arg" ] && arg=$(stat -c %Y $LOGS/$pkg.log)
|
al@898
|
1425
|
al@898
|
1426 echo '<div class="btnList">'
|
al@924
|
1427 acc='l' # access key for the latest log is 'L'
|
al@898
|
1428 while read log; do
|
al@924
|
1429 # for all $pkg.log, $pkg.log.0 .. $pkg.log.9, $pkg-pack.log (if any)
|
al@898
|
1430 timestamp=$(stat -c %Y $log)
|
al@898
|
1431 class=''
|
al@898
|
1432 if [ "$arg" == "$timestamp" ]; then
|
al@898
|
1433 class=' log'
|
al@898
|
1434 logfile="$log"
|
al@898
|
1435 fi
|
al@924
|
1436 case $log in *-pack.log) acc='p';; esac # access key for the packing log is 'P'
|
al@898
|
1437 echo -n "<a class='button$class' data-acc='$acc' accesskey='$acc' href='$base/$pkg/log/$timestamp'>"
|
al@898
|
1438 echo "$(stat -c %y $log | cut -d: -f1,2)</a>"
|
al@898
|
1439 case $acc in
|
al@898
|
1440 l) acc=0;;
|
al@898
|
1441 *) acc=$((acc+1));;
|
al@898
|
1442 esac
|
al@898
|
1443 done <<EOT
|
al@898
|
1444 $(find $LOGS -name "$pkg.log*" | sort)
|
al@924
|
1445 $(find $LOGS -name "$pkg-pack.log")
|
al@898
|
1446 EOT
|
al@898
|
1447 echo '</div>'
|
al@898
|
1448
|
al@898
|
1449 if [ -z "$logfile" ]; then
|
al@898
|
1450 show_note e "Requested log is absent"
|
al@898
|
1451 page_footer
|
al@898
|
1452 exit 0
|
al@898
|
1453 fi
|
al@898
|
1454
|
al@898
|
1455 # Define cook variables for syntax highlighter
|
al@898
|
1456 if [ -s "$WOK/$pkg/receipt" ]; then
|
al@898
|
1457 . "$WOK/$pkg/receipt"
|
al@898
|
1458 _wok='/home/slitaz/wok'
|
al@898
|
1459 _src="$_wok/$pkg/source/$PACKAGE-$VERSION"
|
al@898
|
1460 _install="$_wok/$pkg/install"
|
al@898
|
1461 _fs="$_wok/$pkg/taz/$PACKAGE-$VERSION/fs"
|
al@898
|
1462 _stuff="$_wok/$pkg/stuff"
|
al@898
|
1463 fi
|
al@898
|
1464
|
al@898
|
1465 # if [ ! -f "gzlog/$pkg.$arg" ]; then
|
al@898
|
1466 # {
|
al@898
|
1467 # summary "$logfile" links
|
al@898
|
1468 #
|
al@898
|
1469 # syntax_highlighter log < $logfile | awk '
|
al@898
|
1470 # BEGIN { print "<pre class=\"log\">"; }
|
al@898
|
1471 # { printf("<a name=\"l%d\" href=\"#l%d\">%5d</a> %s\n", NR, NR, NR, $0); }
|
al@898
|
1472 # END { print "</pre>"; }
|
al@898
|
1473 # '
|
al@898
|
1474 #
|
al@898
|
1475 # page_footer
|
al@898
|
1476 # } | gzip > gzlog/$pkg.$arg
|
al@898
|
1477 # fi
|
al@898
|
1478
|
al@898
|
1479 blog=$(basename $logfile)
|
al@898
|
1480 summary "$logfile" links
|
al@898
|
1481
|
al@898
|
1482 # disable next `sed` for the 'like2016' theme
|
al@898
|
1483 theme=$(COOKIE theme); theme=${theme:-default}; [ "$theme" != 'like2016' ] && theme=''
|
al@898
|
1484 cat $logfile | syntax_highlighter log | \
|
al@898
|
1485 sed -e "/(pkg\/local$theme):/ s|: \([^<]*\)|<img src='$base/i/$blog/\1'> \1|" | \
|
al@898
|
1486 awk '
|
al@898
|
1487 BEGIN { print "<pre class=\"log\">"; }
|
al@972
|
1488 { printf("<span id=\"l%d\">%s</span><a href=\"#l%d\"></a>\n", NR, $0, NR); }
|
al@898
|
1489 END { print "</pre>"; }
|
al@898
|
1490 '
|
al@898
|
1491 ;;
|
al@898
|
1492
|
al@898
|
1493
|
al@898
|
1494 man|doc|info)
|
al@898
|
1495 page_header
|
al@898
|
1496 pkg_info
|
al@898
|
1497 echo '<div style="max-height: 6.4em; overflow: auto; padding: 0 4px">'
|
al@898
|
1498
|
al@898
|
1499 dir="wok/$pkg/install/usr/share/$cmd"
|
al@898
|
1500 [ "$cmd" == 'doc' ] && dir="$dir wok/$pkg/install/usr/share/gtk-doc"
|
al@898
|
1501 if [ "$cmd" == 'doc' -a -z "$arg" ]; then
|
al@898
|
1502 try=$(for i in $dir; do find $i -name 'index.htm*'; done | sed q)
|
al@898
|
1503 [ -n "$try" ] && arg="$try"
|
al@898
|
1504 fi
|
al@898
|
1505 while read i; do
|
al@898
|
1506 [ -s "$i" ] || continue
|
al@898
|
1507 case "$i" in
|
al@898
|
1508 *.jp*g|*.png|*.gif|*.svg|*.css) continue
|
al@898
|
1509 esac
|
al@898
|
1510 i=${i#$dir/}
|
al@898
|
1511 [ -n "$arg" ] || arg="$i"
|
al@898
|
1512 class=''; [ "$arg" == "$i" ] && class=" doc"
|
al@898
|
1513 case "$cmd" in
|
al@898
|
1514 man)
|
al@898
|
1515 case $i in
|
al@898
|
1516 man*) lang='';;
|
al@898
|
1517 *) lang="${i%%/*}: ";;
|
al@898
|
1518 esac
|
al@898
|
1519 man=$(basename $i .gz)
|
al@898
|
1520 echo "<a class='button$class' href='$base/$pkg/man/$i'>$lang${man%.*} (${man##*.})</a>"
|
al@898
|
1521 ;;
|
al@898
|
1522 doc)
|
al@898
|
1523 echo "<a class='button$class' href='$base/$pkg/doc/$i'>$(basename $i .gz)</a>"
|
al@898
|
1524 ;;
|
al@898
|
1525 info)
|
al@898
|
1526 info=$(basename $i)
|
al@898
|
1527 echo "<a class='button$class' href='$base/$pkg/info/$i#Top'>${info/.info/}</a>"
|
al@898
|
1528 ;;
|
al@898
|
1529 esac
|
al@898
|
1530 done <<EOT
|
al@898
|
1531 $(for i in $dir; do find $i -type f; done | sort)
|
al@898
|
1532 EOT
|
al@898
|
1533 echo '</div>'
|
al@898
|
1534
|
al@898
|
1535 [ -f "$arg" ] || arg="$dir/$arg"
|
al@898
|
1536 if [ -f "$arg" ]; then
|
al@898
|
1537 tmp="$(mktemp)"
|
al@898
|
1538 docat "$arg" > $tmp
|
al@898
|
1539 [ -s "$tmp" ] &&
|
al@898
|
1540 case "$cmd" in
|
al@898
|
1541 info)
|
al@898
|
1542 echo '<div id="content2" class="texinfo"><pre class="first">'
|
al@898
|
1543 info2html < "$tmp"
|
al@898
|
1544 echo '</pre></div>'
|
al@898
|
1545 ;;
|
al@898
|
1546 doc)
|
al@898
|
1547 case "$arg" in
|
al@898
|
1548 *.sgml|*.devhelp2) class='xml';;
|
al@898
|
1549 *.py) class='python';; # pycurl package
|
al@898
|
1550 *.css) class='css';;
|
al@976
|
1551 *.sh) class='bash';;
|
al@976
|
1552 *)
|
al@976
|
1553 first=$(head -n1 "$tmp")
|
al@976
|
1554 if [ "${first:0:1}" == '#' ]; then
|
al@976
|
1555 class='bash' # first line begins with '#'
|
al@976
|
1556 else
|
al@976
|
1557 class='asciidoc'
|
al@976
|
1558 fi;;
|
al@898
|
1559 esac
|
al@898
|
1560 case "$arg" in
|
al@898
|
1561 *.htm*)
|
al@898
|
1562 case $arg in
|
al@898
|
1563 wok/*) page="${arg#wok/}"; page="$base/$pkg/browse/${page#*/}";;
|
al@898
|
1564 *) page="$base/$pkg/browse/install/usr/share/$cmd/$arg";;
|
al@898
|
1565 esac
|
paul@929
|
1566 # make the iframe height so long to contain its contents without scrollbar
|
al@898
|
1567 echo "<iframe id='idoc' src='$page' width='100%' onload='resizeIframe(this)'></iframe>"
|
al@898
|
1568 ;;
|
al@898
|
1569 *.pdf)
|
al@898
|
1570 case $arg in
|
al@898
|
1571 wok/*) page="${arg#wok/}"; page="$base/$pkg/browse/${page#*/}";;
|
al@898
|
1572 *) page="$base/$pkg/browse/install/usr/share/$cmd/$arg";;
|
al@898
|
1573 esac
|
al@898
|
1574 cat <<EOT
|
al@898
|
1575 <object id="idoc" data="$page" width="100%" height="100%" type="application/pdf" style="min-height: 600px">
|
al@898
|
1576 $(show_note w "Missing PDF plugin.<br/>Get the file <a href="$page">$(basename "$page")</a>.")
|
al@898
|
1577 </object>
|
al@898
|
1578 EOT
|
al@898
|
1579 ;;
|
al@958
|
1580 *.md|*.markdown)
|
al@958
|
1581 echo '<section>'
|
al@958
|
1582 $md2html "$tmp"
|
al@958
|
1583 echo '</section>'
|
al@958
|
1584 ;;
|
al@898
|
1585 *)
|
al@898
|
1586 show_code $class < "$tmp"
|
al@898
|
1587 ;;
|
al@898
|
1588 esac
|
al@898
|
1589 ;;
|
al@898
|
1590 man)
|
al@898
|
1591 #export TEXTDOMAIN='man2html'
|
al@898
|
1592 echo "<div id='content2'>"
|
al@898
|
1593
|
al@898
|
1594 html=$(./man2html "$tmp" | sed -e '1,/<header>/d' -e '/<footer>/,$d' \
|
al@898
|
1595 -e 's|<a href="file:///[^>]*>\([^<]*\)</a>|\1|g' \
|
al@898
|
1596 -e 's|<a href="?[1-9]\+[^>]*>\([^<]*\)</a>|\1|g')
|
al@898
|
1597
|
al@898
|
1598 if [ -n "$(echo "$html" | fgrep 'The requested file /tmp/tmp.')" ]; then
|
al@898
|
1599 # Process the pre-formatted man-cat page
|
al@912
|
1600 # (for example see sudo package without groff in build dependencies)
|
al@912
|
1601 sed -i '
|
al@898
|
1602 s|M-bM-^@M-^S|—|g;
|
al@898
|
1603 s|M-bM-^@M-^\\|<b>|g;
|
al@898
|
1604 s|M-bM-^@M-^]|</b>|g
|
al@898
|
1605 s|M-bM-^@M-^X|<u>|g;
|
al@898
|
1606 s|M-bM-^@M-^Y|</u>|g;
|
al@898
|
1607 s|M-BM-||g;
|
al@912
|
1608 s|++oo|•|g;
|
al@912
|
1609 s|&|\&|g; s|<|\<|g; s|>|\>|g;
|
al@898
|
1610 ' "$tmp"
|
al@912
|
1611 for i in a b c d e f g h i j k l m n o p q r s t u v w x y z \
|
al@912
|
1612 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \
|
al@912
|
1613 0 1 2 3 4 5 6 7 8 9 _ - '\\+' '\.' /; do
|
al@912
|
1614 sed -i "s|$i$i|<b>$i</b>|g; s|_$i|<u>$i</u>|g" "$tmp"
|
al@912
|
1615 done
|
al@912
|
1616 echo '<pre class="catman">'
|
al@912
|
1617 sed 's|</b><b>||g; s|</u><u>||g; s|</u><b>_</b><u>|_|g; s|</b> <b>| |g;' "$tmp"
|
al@898
|
1618 echo '</pre>'
|
al@898
|
1619 else
|
al@898
|
1620 echo "$html"
|
al@898
|
1621 fi
|
al@898
|
1622 echo "</div>"
|
al@898
|
1623 ;;
|
al@898
|
1624 esac
|
al@898
|
1625 rm -f $tmp
|
al@898
|
1626 else
|
al@898
|
1627 show_note e "File “$arg” not exists!"
|
al@898
|
1628 fi
|
al@898
|
1629 ;;
|
al@898
|
1630
|
al@924
|
1631 download)
|
al@924
|
1632 page_header
|
al@924
|
1633 pkg_info
|
al@924
|
1634 show=0
|
al@924
|
1635
|
al@924
|
1636 . $wok/$pkg/receipt
|
al@924
|
1637
|
al@924
|
1638 if [ -n "$TARBALL" -a -s "$SRC/$TARBALL" ]; then
|
al@924
|
1639 files_header
|
al@924
|
1640 echo "<tr><td><a href='$base/src/$TARBALL'>$TARBALL</a></td>"
|
al@924
|
1641 ls -lh "$SRC/$TARBALL" | awk '{printf("<td>%sB</td>", $5)}'
|
al@924
|
1642 echo "<td>Sources for building the package “$pkg”</td></tr>"
|
al@924
|
1643 show=1
|
al@924
|
1644 fi
|
al@924
|
1645
|
al@924
|
1646 if [ -d "$wok/$pkg/taz" ]; then
|
al@924
|
1647 [ "$show" -eq 1 ] || files_header
|
al@924
|
1648
|
al@924
|
1649 for i in $(all_names); do
|
al@924
|
1650 [ -e "$wok/$pkg/taz/$i-$VERSION$EXTRAVERSION/receipt" ] || continue
|
al@924
|
1651 . $wok/$pkg/taz/$i-$VERSION$EXTRAVERSION/receipt
|
al@924
|
1652
|
al@924
|
1653 for filename in "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" "$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg"; do
|
al@924
|
1654 [ -f "$PKGS/$filename" ] &&
|
al@924
|
1655 cat <<EOT
|
al@924
|
1656 <tr>
|
al@924
|
1657 <td><a href="$base/get/$filename">$filename</a></td>
|
al@924
|
1658 <td>$(ls -lh ./packages/$filename | awk '{printf("%sB", $5)}')</td>
|
al@924
|
1659 <td>$SHORT_DESC</td>
|
al@924
|
1660 </tr>
|
al@924
|
1661 EOT
|
al@924
|
1662 done
|
al@924
|
1663 done
|
al@924
|
1664 show=1
|
al@924
|
1665 fi
|
al@924
|
1666
|
al@924
|
1667 if [ "$show" -eq 1 ]; then
|
al@924
|
1668 echo '</tbody></table></section>'
|
al@924
|
1669 else
|
al@924
|
1670 show_note w "Sorry, there's nothing to download…"
|
al@924
|
1671 fi
|
al@924
|
1672 ;;
|
al@924
|
1673
|
al@898
|
1674 esac
|
al@898
|
1675
|
al@898
|
1676
|
al@898
|
1677 page_footer
|
al@898
|
1678 exit 0
|