cookutils annotate lighttpd/index.cgi @ rev 929

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