cookutils annotate lighttpd/index.cgi @ rev 1106

Typos (again)
author Paul Issott <paul@slitaz.org>
date Sat Dec 01 10:48:06 2018 +0000 (2018-12-01)
parents 5dcdc6015a2d
children 7fdea1dfb4e2
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@1076 18 case $QUERY_STRING in
al@1076 19 *debug*)
al@1076 20 debug='yes'
al@1076 21 QUERY_STRING="$(echo "$QUERY_STRING" | sed 's|debug||; s|^&||; s|&&|\&|; s|&$||')"
al@1076 22 ;;
al@1076 23 esac
al@1076 24
al@898 25 [ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf
al@898 26 [ -f "./cook.conf" ] && . ./cook.conf
al@898 27 wok="$WOK"
al@898 28 title=${title:-SliTaz Cooker}
al@898 29 # Cooker DB files.
al@898 30 activity="$CACHE/activity"
al@898 31 commits="$CACHE/commits"
al@898 32 cooklist="$CACHE/cooklist"
al@898 33 cookorder="$CACHE/cookorder"
al@898 34 command="$CACHE/command"; touch $command
al@898 35 blocked="$CACHE/blocked"
al@898 36 broken="$CACHE/broken"
al@898 37 cooknotes="$CACHE/cooknotes"
al@898 38 cooktime="$CACHE/cooktime"
al@898 39 wokrev="$CACHE/wokrev"
al@1082 40 webstat="$CACHE/webstat" # note, file should be previously created with write permissions for www
al@940 41 splitdb="$CACHE/split.db"
al@1081 42 maintdb="$CACHE/maint.db"
al@1082 43 repologydb="$CACHE/repology.db" # note, file should be previously created with write permissions for www
al@898 44
al@898 45 # Path to markdown to html convertor
al@898 46 cmark_opts='--smart -e table -e strikethrough -e autolink -e tagfilter'
al@898 47 if [ -n "$(which cmark 2>/dev/null)" ]; then
al@898 48 md2html="$(which cmark) $cmark_opts"
al@898 49 elif [ -x "./cmark" ]; then
al@898 50 md2html="./cmark $cmark_opts"
al@898 51 elif [ -n "$(which sundown 2>/dev/null)" ]; then
al@898 52 md2html=$(which sundown)
al@898 53 elif [ -x "./sundown" ]; then
al@898 54 md2html="./sundown"
al@898 55 fi
al@898 56
al@898 57
al@898 58
al@898 59
al@898 60 # Search form redirection
al@898 61 if [ -n "$(GET search)" ]; then
al@898 62 echo -e "HTTP/1.1 301 Moved Permanently\nLocation: $base/$(GET q)\n\n"
al@898 63 exit 0
al@898 64 fi
al@898 65
al@898 66
paul@1084 67 # Show the running command and its progression
al@898 68
al@898 69 running_command() {
al@898 70 state="$(cat $command)"
al@923 71 local pct=''
al@898 72 if [ -n "$state" ];then
al@898 73 echo -n "$state</td></tr><tr><td>Completion</td>"
al@898 74 set -- $(grep "^$state" $cooktime)
al@898 75 [ -n "$1" -a $2 -ne 0 ] && pct=$((($(date +%s)-$3)*100/$2))
al@898 76 [ -n "$pct" ] && max="max='100'"
al@898 77 echo -n "<td><progress id='gauge' $max value='$pct' title='Click to stop updating' onclick='stopUpdating()'>"
al@898 78 echo -n "</progress> <span id='pct'>${pct:-?}%</span>"
al@898 79 [ "$2" -gt 60 ] &&
al@898 80 echo -n "</td></tr><tr><td>Estimated end time</td><td>$(date +%H:%M -ud @$(($2+$3)))"
al@898 81 else
al@898 82 echo 'not running'
al@898 83 fi
al@898 84 }
al@898 85
al@898 86
al@898 87 # HTML page header
al@898 88
al@898 89 page_header() {
al@1029 90 local theme t='' css pretitle='' command
al@898 91 theme=$(COOKIE theme)
al@898 92 [ "$theme" == 'default' ] && theme=''
al@898 93 [ -n "$theme" ] && theme="-$theme"
al@898 94 css="cooker$theme.css"
al@898 95
al@1012 96 if [ -n "$pkg" ]; then
al@1029 97 case "$pkg" in
al@1090 98 ~) if [ -z "$cmd" ]; then pretitle="Tag cloud - "; else pretitle="Tag \"$cmd\" - "; fi;;
al@1091 99 =) if [ -z "$cmd" ]; then pretitle="Badges - "; else pretitle="Badge \"$cmd\" - "; fi;;
al@1029 100 *) pretitle="$pkg - ";;
al@1029 101 esac
al@1012 102 else
al@1029 103 command="$(cat $command)"
al@1029 104 [ -n "$command" ] && pretitle="$command - "
al@1012 105 fi
al@1043 106 [ -z "$favicon" ] && favicon='/slitaz-cooker.png'
al@1012 107
al@898 108 echo -e 'Content-Type: text/html; charset=UTF-8\n'
al@898 109
al@898 110 cat <<EOT
al@898 111 <!DOCTYPE html>
al@898 112 <html lang="en">
al@898 113 <head>
al@1012 114 <title>$pretitle$title</title>
al@898 115 <link rel="stylesheet" href="/$css">
al@1043 116 <link rel="icon" type="image/png" href="$favicon">
al@903 117 <link rel="search" href="$base/os.xml" title="$title" type="application/opensearchdescription+xml">
al@898 118 <!-- mobile -->
al@898 119 <meta name="viewport" content="width=device-width, initial-scale=1.0">
al@898 120 <meta name="theme-color" content="#222">
al@898 121 <!-- rss -->
al@898 122 <link rel="alternate" type="application/rss+xml" title="$title Feed" href="?rss">
al@1063 123 <script>
al@1063 124 // Get part of the main page
al@1063 125 function getPart(part) {
al@1063 126 var partRequest = new XMLHttpRequest();
al@1063 127 partRequest.onreadystatechange = function() {
al@1063 128 if (this.readyState == 4 && this.status == 200) {
al@1063 129 response = this.responseText;
al@1063 130 var partElement = document.getElementById(part);
al@1063 131 if (response !== null) partElement.innerHTML = response;
al@1063 132 }
al@1063 133 };
al@1063 134 partRequest.open('GET', '?part=' + part, true);
al@1063 135 partRequest.responseType = '';
al@1063 136 partRequest.send();
al@1063 137 }
al@1063 138 </script>
al@898 139 </head>
al@898 140 <body>
al@898 141 <div id="container">
al@898 142 <header>
al@898 143 <h1><a href="$base/">$title</a></h1>
al@898 144 <div class="network">
al@898 145 <a href="http://www.slitaz.org/">Home</a>
al@898 146 <a href="http://bugs.slitaz.org/">Bugs</a>
al@898 147 <a href="http://hg.slitaz.org/wok-next/">Hg</a>
al@898 148 <a href="http://roadmap.slitaz.org/">Roadmap</a>
al@898 149 <a href="http://pizza.slitaz.me/">Pizza</a>
al@898 150 <a href="http://tank.slitaz.org/">Tank</a>
al@898 151 |
al@947 152 <a href="/cross/">Cross</a>
al@947 153 <a href="/i486.cgi">i486</a>
al@898 154 <a href="$base/cookiso.cgi">ISO</a>
al@898 155 <select onChange="window.location.href=this.value" style="display: none">
al@898 156 <option value=".">Go to…</option>
al@898 157 <option value="http://www.slitaz.org/">Home</option>
al@898 158 <option value="http://bugs.slitaz.org/">Bug tracker</option>
al@898 159 <option value="http://hg.slitaz.org/wok/">Hg wok</option>
al@898 160 <option value="http://roadmap.slitaz.org/">Roadmap</option>
al@898 161 <option value="http://pizza.slitaz.me/">Pizza</option>
al@898 162 <option value="http://tank.slitaz.org/">Tank</option>
al@898 163 <option disabled>---------</option>
al@898 164 <option value="cross/">Cross</option>
al@898 165 <option value="i486.cgi">i486</option>
al@898 166 <option value="cookiso.cgi">ISO</option>
al@898 167 </select>
al@898 168 </div>
al@898 169 </header>
al@898 170
al@898 171 <main>
al@898 172 EOT
al@898 173
al@1076 174 [ -n "$debug" ] && echo "<pre><code class='language-ini'>$(env | sort)</code></pre>"
al@898 175 }
al@898 176
al@898 177
al@898 178 # HTML page footer
al@898 179
al@898 180 page_footer() {
al@898 181 date_now=$(date +%s)
al@898 182 sec_now=$(date +%S); sec_now=${sec_now#0} # remove one leading zero
al@898 183 wait_sec=$(( 60 - $sec_now ))
al@1090 184 cat <<-EOT
al@1090 185 </main>
al@898 186
al@1090 187 <footer>
al@1090 188 <a href="http://www.slitaz.org/">SliTaz Website</a>
al@1090 189 <a href="http://tank.slitaz.org/graphs.php">Server status</a>
al@1090 190 <a href="$base/doc/cookutils/cookutils.html">Documentation</a>
al@1090 191 <a href="$base/?theme">Theme</a>
al@1090 192 </footer>
al@1090 193 </div>
al@1090 194 <script src="/cooker.js"></script>
al@1090 195 <script>refreshDate(${wait_sec}000, ${date_now}000)</script>
al@1090 196 </body>
al@1090 197 </html>
al@1090 198 EOT
al@898 199 }
al@898 200
al@898 201
al@898 202 show_note() {
al@898 203 echo "<div class='bigicon-$1'>$2</div>"
al@898 204 }
al@898 205
al@898 206
al@898 207 not_found() {
al@898 208 local file="${1#$PKGS/}"; file="${file#$LOGS/}"; file="${file#$WOK/}"
al@898 209 echo "HTTP/1.1 404 Not Found"
al@898 210 page_header
al@898 211 echo "<h2>Not Found</h2>"
al@898 212 case $2 in
al@898 213 pkg)
al@898 214 show_note e "The requested package “$(basename "$(dirname "$file")")” was not found." ;;
al@898 215 *)
al@898 216 show_note e "The requested file “$file” was not found." ;;
al@898 217 esac
al@898 218 page_footer
al@898 219 }
al@898 220
al@898 221
al@898 222 manage_modified() {
al@898 223 local file="$1" option="$2" nul day mon year time hh mm ss date_s
al@898 224 if [ ! -f "$file" ]; then
al@898 225 if [ "$option" == 'silently-absent' ]; then
al@898 226 echo "HTTP/1.1 404 Not Found"
al@898 227 return
al@898 228 else
al@898 229 not_found "$file" "$2"
al@898 230 exit
al@898 231 fi
al@898 232 fi
al@898 233 [ "$option" == 'no-last-modified' ] && return
al@898 234 if [ -n "$HTTP_IF_MODIFIED_SINCE" ]; then
al@898 235 echo "$HTTP_IF_MODIFIED_SINCE" | \
al@898 236 while read nul day mon year time nul; do
al@898 237 case $mon in
al@898 238 Jan) mon='01';; Feb) mon='02';; Mar) mon='03';; Apr) mon='04';;
al@898 239 May) mon='05';; Jun) mon='06';; Jul) mon='07';; Aug) mon='08';;
al@898 240 Sep) mon='09';; Oct) mon='10';; Nov) mon='11';; Dec) mon='12';;
al@898 241 esac
al@898 242 hh=$(echo $time | cut -d: -f1)
al@898 243 mm=$(echo $time | cut -d: -f2)
al@898 244 ss=$(echo $time | cut -d: -f3)
al@898 245 date_s=$(date -ud "$year$mon$day$hh$mm.$ss" +%s)
al@898 246 # if [ "$date_s" -ge "$(date -ur "$file" +%s)" ]; then
al@898 247 # echo -e 'HTTP/1.1 304 Not Modified\n'
al@898 248 # exit
al@898 249 # fi
al@898 250 # TODO: improve caching control
al@898 251 done
al@898 252 fi
al@898 253 echo "Last-Modified: $(date -Rur "$file" | sed 's|UTC|GMT|')"
al@898 254 echo "Cache-Control: public, max-age=3600"
al@898 255 }
al@898 256
al@898 257
al@1082 258 # Proxy to the Repology
al@1082 259 # Problems:
paul@1084 260 # 1. Function "latest packaged version" widely used here and it has no JSON API, but only SVG badge.
paul@1084 261 # 2. So, all version comparisons can be only visual and not automated.
paul@1104 262 # 3. Of the thousands of badges present on the web page, many of them are broken (maybe server
al@1082 263 # drops requests), while our server displays status icons well.
al@1082 264 # 4. Default badges are wide and not customizable.
al@1082 265 # Solution:
paul@1084 266 # 1. Make local cache. Update it on demand, but no more than once a day (Repology caches info
al@1082 267 # on a hourly basis). Use cached values when they are not expired.
al@1082 268 # 2. Extract and save version(s) from the SVG badges. Values can be compared in the scripts as well
paul@1084 269 # as custom badges that may also be provided.
al@1082 270
al@1082 271 repology_get() {
al@1082 272 local found versions day=$(date +%j) # %j is the number of the day in the year
al@1082 273 found=$(awk -F$'\t' -vpkg="$1" -vday="$day" '{
al@1082 274 if ($1 == pkg && $2 == day) { print $3; exit; }
al@1082 275 }' $repologydb)
al@1082 276 if [ -n "$found" ]; then
al@1082 277 echo "$found"
al@1082 278 else
al@1088 279 # set HOST_WGET in cook.conf
al@1088 280 versions=$($HOST_WGET -q -T 20 -O- https://repology.org/badge/latest-versions/$1.svg \
al@1082 281 | sed '/<text /!d; /fill/d; /latest/d; s|.*>\(.*\)<.*|\1|; s|, | |g') # space separated list
al@1082 282 if [ -n "$versions" ]; then
al@1082 283 sed -i "/^$1 /d" $repologydb
al@1082 284 echo -e "$1\t$day\t$versions" >> $repologydb
al@1082 285 echo $versions
al@1082 286 fi
al@1082 287 fi
al@1082 288 }
al@1082 289
al@1082 290
al@898 291 # Query '?pct=<package>': update percentage
al@898 292
al@898 293 if [ -n "$(GET pct)" ]; then
al@898 294 pkg="$(GET pct)"
al@898 295 state="$(cat $command)"
al@898 296 if [ "$state" == "cook:$pkg" ]; then
al@898 297 set -- $(grep "^$state" $cooktime)
al@898 298 [ -n "$1" ] && pct=$(( ($(date +%s) - $3) * 100 / $2 ))
al@898 299 echo "${pct:-?}"
al@898 300 else
al@898 301 echo 'reload'
al@898 302 fi
al@898 303 exit 0
al@898 304 fi
al@898 305
al@898 306
al@898 307 # Query '?poke': poke cooker
al@898 308
al@898 309 if [ -n "$(GET poke)" ]; then
al@898 310 touch $CACHE/cooker-request
al@898 311 echo -e "Location: ${HTTP_REFERER:-${REQUEST_URI%\?*}}\n"
al@898 312 exit
al@898 313 fi
al@898 314
al@898 315
al@898 316 # Query '?recook=<package>': query to recook package
al@898 317
al@898 318 if [ -n "$(GET recook)" ]; then
al@898 319 pkg="$(GET recook)"
al@898 320 case "$HTTP_USER_AGENT" in
al@898 321 *SliTaz*)
al@898 322 grep -qs "^$pkg$" $CACHE/recook-packages ||
al@898 323 echo "$pkg" >> $CACHE/recook-packages
al@898 324 esac
al@898 325 echo -e "Location: ${HTTP_REFERER:-${REQUEST_URI%\?*}}\n"
al@898 326 exit
al@898 327 fi
al@898 328
al@898 329
al@898 330 # Query '/i/<log>/<pkg>': show indicator icon
al@898 331 # Can't use ?query - not able to change '+' to '%2B' in the sed rules (see log handler)
al@898 332
al@898 333 if [ "$pkg" == 'i' ]; then
al@898 334 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 335 if [ $LOGS/$cmd -nt $PKGS/$arg.tazpkg ]; then
al@898 336 echo "m1 2-1 1v8l1 1h6l1-1v-8l-1-1z' fill='#090'/></svg>"
al@898 337 else
al@898 338 echo "m0 3v8l1 1h6l1-1v-8l-1-1h-6zm3 0h2v5h-2zm0 6h2v2h-2z' fill='#d00'/></svg>"
al@898 339 fi
al@898 340 exit
al@898 341 fi
al@898 342
al@898 343
al@982 344 # Query '/s/<pkg>': show status indicator icon
al@982 345 # Can't use ?query - not able to change '+' to '%2B' in the sed rules (see log handler)
al@982 346
al@982 347 if [ "$pkg" == 's' ]; then
al@982 348 # argument <pkg> is in $cmd variable
al@982 349 echo -en "Content-Type: image/svg+xml\n\n<svg xmlns='http://www.w3.org/2000/svg' height='12' width='8'><path d='"
al@1005 350 # packages.info updates with each new package, so we'll find actual info here
al@1090 351 if grep -q "^$cmd"$'\t' $PKGS/packages-$ARCH.info; then
al@982 352 echo "m1 2-1 1v8l1 1h6l1-1v-8l-1-1z' fill='#090'/></svg>"
al@982 353 else
al@982 354 echo "m0 3v8l1 1h6l1-1v-8l-1-1h-6zm3 0h2v5h-2zm0 6h2v2h-2z' fill='#d00'/></svg>"
al@982 355 fi
al@982 356 exit
al@982 357 fi
al@982 358
al@982 359
al@898 360 # Query '?theme[=<theme>]': change UI theme
al@898 361
al@898 362 if [ -n "$(GET theme)" ]; then
al@898 363 theme="$(GET theme)"
al@924 364 ref="$(echo "$HTTP_REFERER" | sed 's|:|%3A|g; s|/|%2F|g; s|\?|%3F|g; s|\+|%2B|g;')"
al@898 365 case $theme in
al@898 366 theme)
al@898 367 current=$(COOKIE theme)
al@898 368 page_header
al@1090 369 cat <<-EOT
al@1090 370 <section>
al@1090 371 <h2>Change theme</h2>
al@1090 372 <p>Current theme: “${current:-default}”. Select other:</p>
al@1090 373 <ul>$(
al@1090 374 for i in default emerald sky goldenrod midnight like2016 terminal; do
al@1090 375 [ "$i" == "${current:-default}" ] || echo "<li><a href=\"$base/?theme=$i&amp;ref=$ref\">$i</a></li>"
al@1090 376 done
al@1090 377 )</ul>
al@1090 378 </section>
al@1090 379 EOT
al@898 380 page_footer
al@898 381 exit 0
al@898 382 ;;
al@903 383 default|emerald|sky|goldenrod|midnight|like2016|terminal)
al@924 384 ref="$(GET ref)"
al@924 385 [ -n "$ref" ] || ref="$base/"
al@898 386 # Expires in a year
al@898 387 expires=$(date -uRd @$(($(date +%s)+31536000)) | sed 's|UTC|GMT|')
al@924 388 echo -e "HTTP/1.1 302 Found\nLocation: $ref\nCache-Control: no-cache\nSet-Cookie: theme=$theme; expires=$expires\n\n"
al@898 389 exit 0
al@898 390 ;;
al@898 391 esac
al@898 392 fi
al@898 393
al@898 394
al@898 395 #case "$QUERY_STRING" in
al@898 396 # stuff*)
al@898 397 # file="$wok/$(GET stuff)"
al@898 398 # manage_modified "$file"
al@898 399 # ;;
al@898 400 #
al@898 401 # pkg=*|receipt=*|description=*|files=*|log=*|man=*|doc=*|info=*)
al@898 402 # type=${QUERY_STRING%%=*}
al@898 403 # pkg=$(GET $type)
al@898 404 # case "$type" in
al@898 405 # description)
al@898 406 # manage_modified "$wok/$pkg/receipt" 'no-last-modified'
al@898 407 # manage_modified "$wok/$pkg/description.txt" 'silently-absent'
al@898 408 # ;;
al@898 409 # log)
al@898 410 # manage_modified "$wok/${pkg%%.log*}/receipt" 'no-last-modified'
al@898 411 # manage_modified "$LOGS/$pkg"
al@898 412 # ;;
al@898 413 # *)
al@898 414 # manage_modified "$wok/$pkg/receipt" pkg
al@898 415 # ;;
al@898 416 # esac
al@898 417 # ;;
al@898 418 #esac
al@898 419
al@898 420
al@898 421 # RSS feed generator
al@898 422 # URI: ?rss[&limit={1..100}]
al@898 423
al@898 424 if [ -n "$(GET rss)" ]; then
al@898 425 limit=$(GET limit); limit="${limit:-12}"; [ "$limit" -gt 100 ] && limit='100'
al@898 426 pubdate=$(date -Rur$(ls -t $FEEDS/*.xml | head -n1) | sed 's|UTC|GMT|')
al@898 427 cooker_url="http://$HTTP_HOST$base/"
al@1090 428 cat <<-EOT
al@1090 429 Content-Type: application/rss+xml
al@898 430
al@1090 431 <?xml version="1.0" encoding="utf-8" ?>
al@1090 432 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
al@1090 433 <channel>
al@1090 434 <title>$title</title>
al@1090 435 <description>The SliTaz packages cooker feed</description>
al@1090 436 <link>$cooker_url</link>
al@1090 437 <lastBuildDate>$pubdate</lastBuildDate>
al@1090 438 <pubDate>$pubdate</pubDate>
al@1090 439 <atom:link href="$cooker_url?rss" rel="self" type="application/rss+xml" />
al@1090 440 EOT
al@898 441 for rss in $(ls -t $FEEDS/*.xml | head -n$limit); do
al@1090 442 sed -e "/\?pkg=/s|http[^=]*=|$cooker_url|;" \
al@1090 443 -e "s|\([0-9]\)</pubDate>|\1 GMT</pubDate>|" $rss
al@898 444 done
al@1090 445 cat <<-EOT
al@1090 446 </channel>
al@1090 447 </rss>
al@1090 448 EOT
al@898 449 exit 0
al@898 450 fi
al@898 451
al@898 452
al@903 453 ### OpenSearch ###
al@903 454
al@903 455 # Query '/os.xml': get OpenSearch Description
al@903 456
al@903 457 if [ "$pkg" == 'os.xml' ]; then
al@1090 458 cat <<-EOT
al@1090 459 Content-Type: application/xml; charset=UTF-8
al@903 460
al@1090 461 <?xml version="1.0" encoding="UTF-8"?>
al@1090 462 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
al@1090 463 <ShortName>$title</ShortName>
al@1090 464 <Description>SliTaz packages search</Description>
al@1090 465 <Image width="16" height="16" type="image/png">http://$HTTP_HOST/images/logo.png</Image>
al@1090 466 <Url type="text/html" method="GET" template="http://$HTTP_HOST$base/{searchTerms}"/>
al@1090 467 <Url type="application/x-suggestions+json" method="GET" template="http://$HTTP_HOST$base/">
al@1090 468 <Param name="oss" value="{searchTerms}"/>
al@1090 469 </Url>
al@1090 470 <SearchForm>http://$HTTP_HOST$base/</SearchForm>
al@1090 471 <InputEncoding>UTF-8</InputEncoding>
al@1090 472 </OpenSearchDescription>
al@1090 473 EOT
al@903 474 exit 0
al@903 475 fi
al@903 476
al@903 477 # Query '?oss[=<term>]': OpenSearch suggestions
al@903 478
al@903 479 if [ -n "$(GET oss)" ]; then
al@903 480 term="$(GET oss | tr -cd '[:alnum:]+-')"
al@903 481 echo -e 'Content-Type: application/x-suggestions+json; charset=UTF-8\n'
al@903 482 cd $wok
al@903 483 ls | fgrep "$term" | head -n10 | awk -vterm="$term" '
al@903 484 BEGIN{printf("[\"%s\",[", term)}
al@903 485 {printf("%s\"%s\"", NR != 1 ? "," : "", $0)}
al@903 486 END {printf("]]")}
al@903 487 '
al@903 488 exit 0
al@903 489 fi
al@903 490
al@903 491
al@898 492
al@898 493
al@898 494 #
al@898 495 # Functions
al@898 496 #
al@898 497
al@898 498
al@898 499 # Unpack to stdout
al@898 500
al@898 501 docat() {
al@898 502 case "$1" in
al@898 503 *gz) zcat ;;
al@898 504 *bz2) bzcat ;;
al@898 505 *xz) xzcat ;;
al@898 506 *) cat
al@898 507 esac < $1
al@898 508 }
al@898 509
al@898 510
al@898 511 # Tiny texinfo converter
al@898 512
al@898 513 info2html() {
al@898 514 sed \
al@1090 515 -e 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g;' \
al@1090 516 -e "s|\`\([^']*\)'|<b>\1</b>|g" \
al@1090 517 -e 's|"\([A-Za-z0-9]\)|“\1|g; s|"|”|g' \
al@898 518 -e 's|^\* \(.*\)::|* <a href="#\1">\1</a> |' \
al@898 519 -e 's|\*note \(.*\)::|<a href="#\1">\1</a>|' \
al@898 520 -e '/^File: / s|(dir)|Top|g' \
al@1088 521 -e '/^File: / s|Next: \([^,]*\)|<a class="button icon next" href="#\1">Next: \1</a>|' \
al@1088 522 -e '/^File: / s|Prev: \([^,]*\)|<a class="button icon prev" href="#\1">Prev: \1</a>|' \
al@1088 523 -e '/^File: / s|Up: \([^,]*\)|<a class="button icon up" href="#\1">Up: \1</a>|' \
al@898 524 -e '/^File: / s|^.* Node: \([^,]*\), *\(.*\)$|<pre id="\1">\2|' \
al@1090 525 -e '/^<pre id=/ s|^\([^>]*>\)\(<a[^>]*>Next: [^,]*\), *\(<a[^>]*>Prev: [^,]*\), *\(<a[^>]*>Up: .*\)|\1<div class="buttonbar">\3 \4 \2</div>|' \
al@1090 526 -e '/^<pre id=/ s|^\([^>]*>\)*\(<a[^>]*>Prev: [^,]*\), *\(<a[^>]*>Up: .*\)|\1<div class="buttonbar">\2 \3 <a class="button icon next" href="#">Next</a></div>|' \
al@898 527 -e '/^Tag Table:$/,/^End Tag Table$/d' \
al@898 528 -e '/INFO-DIR/,/^END-INFO-DIR/d' \
al@898 529 -e "s|https*://[^>),'\"\`’ ]*|<a href=\"&\">&</a>|g" \
al@898 530 -e "s|ftp://[^>),\"\` ]*|<a href=\"&\">&</a>|g" \
al@898 531 -e 's|^\* Menu:|<b>Menu:</b>|' \
al@898 532 -e "s|^|</pre>|"
al@898 533 }
al@898 534
al@898 535
al@898 536 # Put some colors into log and DB files.
al@898 537
al@898 538 syntax_highlighter() {
al@898 539 case $1 in
al@898 540 log)
al@898 541 # If variables not defined - define them with some rare values
al@898 542 : ${_src=#_#_#}
al@898 543 : ${_install=#_#_#}
al@898 544 : ${_fs=#_#_#}
al@898 545 : ${_stuff=#_#_#}
al@898 546 # Use one-letter html tags to save some bytes :)
al@998 547 # <b>is error (red)</b> <u>is warning (orange)</u> <i>is informative (green)</i>
al@1002 548 sed \
al@1002 549 -e 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g' \
al@898 550 -e 's#OK$#<i>OK</i>#' \
al@898 551 -e 's#\([Dd]one\)$#<i>\1</i>#' \
al@898 552 -e 's#Success$#<i>Success</i>#' \
al@898 553 -e 's#\([^a-z]\)ok$#\1<i>ok</i>#' \
al@898 554 -e 's#\([^a-z]\)yes$#\1<i>yes</i>#' \
al@1059 555 -e 's#: \(YES.*\)#: <i>\1</i>#' \
al@912 556 -e 's#\([^a-z]\)ON$#\1<i>ON</i>#' \
al@1062 557 -e 's#\(enabled\)$#<i>\1</i>#' \
al@898 558 -e 's#\([^a-z]\)no$#\1<u>no</u>#' \
al@1059 559 -e 's#: \(NO.*\)#: <u>\1</u>#' \
al@898 560 -e 's#\([^a-z]\)none$#\1<u>none</u>#' \
al@898 561 -e 's#\([^a-z]\)false$#\1<u>false</u>#' \
al@912 562 -e 's#\([^a-z]\)OFF$#\1<u>OFF</u>#' \
al@1062 563 -e 's#\(disabled\)$#<u>\1</u>#' \
al@898 564 -e 's#\(^checking .*\.\.\. \)\(.*\)$#\1<i>\2</i>#' \
al@898 565 \
al@898 566 -e 's#\( \[Y[nm/]\?\] n\)$# <u>\1</u>#' \
al@898 567 -e 's#\( \[N[ym/]\?\] y\)$# <i>\1</i>#' \
al@898 568 -e 's# y$# <i>y</i>#' \
al@898 569 -e 's# n$# <u>n</u>#' \
al@898 570 -e 's#(NEW) *$#<b>(NEW)</b>#' \
al@898 571 \
al@898 572 -e 's#.*(pkg/local).*#<i>\0</i>#' \
al@898 573 -e 's#.*(web/cache).*#<u>\0</u>#' \
al@898 574 \
al@898 575 -e 's#\([^a-zA-Z]\)\([Ee]rror\)$#\1<b>\2</b>#' \
al@898 576 -e 's#ERROR:#<b>ERROR:</b>#g' \
al@898 577 \
al@1063 578 -e 's#^.*multiple definition of.*#<b>\0</b>#' \
al@909 579 -e 's#^.*[Ff][Aa][Ii][Ll][Ee][Dd].*#<b>\0</b>#' \
al@1078 580 -e 's#^.*[^A-Za-z:/-][Ff]atal.*#<b>\0</b>#' \
al@989 581 -e '/non-fatal/ s|</*b>||g' \
al@898 582 -e 's#^.*[Nn]ot found.*#<b>\0</b>#' \
al@898 583 -e 's#^.*[Nn]o such file.*#<b>\0</b>#' \
al@898 584 -e 's#^.*No package .* found.*#<b>\0</b>#' \
al@898 585 -e 's#^.*Unable to find.*#<b>\0</b>#' \
al@938 586 -e 's#[^a-zA-Z-][Ii]nvalid.*#<b>\0</b>#' \
al@1064 587 -e 's#Segmentation fault#<b>\1</b>#' \
al@914 588 -e 's#\([Nn][Oo][Tt] found\.*\)$#<b>\1</b>#' \
al@914 589 -e 's#\(found\.*\)$#<i>\1</i>#' \
al@898 590 \
al@898 591 -e 's#^.*WARNING:.*#<u>\0</u>#' \
al@898 592 -e 's#^.*warning:.*#<u>\0</u>#' \
al@898 593 -e 's#^.* [Ee]rror:* .*#<b>\0</b>#' \
al@898 594 -e 's#^.*terminated.*#<b>\0</b>#' \
al@898 595 -e 's#\(missing\)#<b>\1</b>#g' \
al@898 596 -e 's#^.*[Cc]annot find.*#<b>\0</b>#' \
al@1064 597 -e 's#^.*unrecognized option.*#<u>\0</u>#' \
al@898 598 -e 's#^.*does not.*#<u>\0</u>#' \
al@898 599 -e 's#^.*[Ii]gnoring.*#<u>\0</u>#' \
al@898 600 -e 's#^.*note:.*#<u>\0</u>#' \
al@898 601 \
al@898 602 -e 's#^.* will not .*#<u>\0</u>#' \
al@898 603 -e 's!^Hunk .* succeeded at .*!<u>\0</u>!' \
al@898 604 -e 's#^.* Warning: .*#<u>\0</u>#' \
al@898 605 \
al@898 606 -e "s#^Executing:\([^']*\).#<em>\0</em>#" \
al@898 607 -e "s#^Making.*#<em>\0</em>#" \
al@898 608 -e "s#^Scanning dependencies of target .*#<em>\0</em>#" \
al@898 609 -e "s#^====\([^']*\).#<span class='span-line'>\0</span>#g" \
al@898 610 -e "s#^[a-zA-Z0-9]\([^']*\) :: #<span class='span-sky'>\0</span>#g" \
al@898 611 -e "s#[fh]tt*ps*://[^ '\"]*#<a href='\0'>\0</a>#g" \
al@1079 612 -e 's|^Switching to the .*|<span class="switch">‣‣‣ \0</span>|' \
al@898 613 \
al@941 614 -e 's|^<u>\(.*libtool: warning: relinking.*\)</u>|\1|' \
al@941 615 -e 's|^<u>\(.*libtool: warning: .* has not been installed in .*\)</u>|\1|' \
al@941 616 -e 's|^<u>\(.*checking for a sed.*\)</u>|\1|' \
al@1048 617 -e 's|^<u><b>\(.*inlining failed.*\)</b></u>|<u>\1</u>|' \
al@941 618 \
al@941 619 -e "s|$_src|<var>\${src}</var>|g;
al@941 620 s|$_install|<var>\${install}</var>|g;
al@941 621 s|$_fs|<var>\${fs}</var>|g;
al@941 622 s|$_stuff|<var>\${stuff}</var>|g" \
al@1002 623 \
al@1017 624 -e "s|\[\([01]\)m\[3\([1-7]\)m|<span class='c\2\1'>|g;
al@1017 625 s|\[\([01]\);3\([1-7]\)m|<span class='c\2\1'>|g;
al@1022 626 s|\[3\([1-7]\)m|<span class='c\10'>|g;
al@1002 627 s|\[\([01]\);0m|<span class='c0\1'>|g;
al@1016 628 s|\[0m|</span>|g;
al@1017 629 s|\[m|</span>|g;
al@1022 630 s|\[0;10m|</span>|g;
al@1022 631 s|\[K||g;" \
al@1002 632 \
al@913 633 -e "s|\[9\([1-6]\)m|<span class='c\10'>|;
al@942 634 s|\[39m|</span>|;
al@1022 635 #s|\[1m|<span class='c01'>|g;
al@1022 636 s|\[1m|<span style='font-weight:bold'>|g; s|(B|</span>|g;
al@1090 637 s|\[m||g;" \
al@1090 638 \
al@1002 639 -e "s!^|\(+.*\)!|<span class='c20'>\1</span>!;
al@1002 640 s!^|\(-.*\)!|<span class='c10'>\1</span>!;
al@1090 641 s!^|\(@@.*@@\)\$!|<span class='c30'>\1</span>!;" \
al@1002 642 \
al@1090 643 -e "s|^Successfully installed [^ ][^ ]*$|<i>\0</i>|;
al@1090 644 s|^Successfully installed .*$|<b>\0</b>|;
al@1090 645 s|^\(Requirement already satisfied: .*\) in|<i>\1</i> in|;
al@1090 646 s|^Collecting .* (from .*$|<b>\0</b>|;
al@1090 647 s|^ Could not find.*|<b>\0</b>|;
al@1090 648 s|^No matching distribution found for.*|<b>\0</b>|;"
al@1002 649
al@898 650 ;;
al@898 651
al@898 652 files)
al@898 653 # Highlight the Busybox's `ls` output
al@898 654 awk '{
al@898 655 part1 = substr($0, 0, 16);
al@898 656 part2 = substr($0, 17, 9);
al@898 657 part3 = substr($0, 26, 9);
al@898 658 part4 = substr($0, 35);
al@898 659 if (part2 != "root ") part2 = "<span class=\"c11\">" part2 "</span>";
al@898 660 if (part3 != "root ") part3 = "<span class=\"c11\">" part3 "</span>";
al@898 661 print part1 part2 part3 part4;
al@898 662 }' | \
al@924 663 sed "s|\[0m/|/\[0m|g;
al@924 664 s|\[\([01]\);3\([1-7]\)m|<a class='c\2\1'>|g;
al@898 665 s|\[\([01]\);0m|<a class='c0\1'>|g;
al@898 666 s|\[0m|</a>|g;
al@898 667 s|^\(lrwxrwxrwx\)|<span class='c61'>\1</span>|;
al@898 668 s|^\(-rwxr-xr-x\)|<span class='c21'>\1</span>|;
al@898 669 s|^\(-rw-r--r--\)|<span class='c31'>\1</span>|;
al@924 670 s|^\(drwxr-xr-x\)|<span class='c41'>\1</span>|;
al@1077 671 s|^\(-rwsr-xr-x\)|<span class='c51'>\1</span>|;
al@1010 672 s|^\([lrwxs-][lrwxs-]*\)|<span class='c11'>\1</span>|;
al@898 673 "
al@898 674 ;;
al@898 675 esac
al@898 676 }
al@898 677
al@898 678
al@898 679 show_code() {
al@898 680 echo -n "<pre><code class=\"language-$1\">"
al@898 681 sed 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g'
al@898 682 echo '</code></pre>'
al@898 683 }
al@898 684
al@898 685
al@898 686 datalist() {
al@940 687 cut -d$'\t' -f2 $splitdb | tr ' ' '\n' | sort -u | awk '
al@898 688 BEGIN{printf("<datalist id=\"packages\">")}
al@940 689 {printf("<option>%s",$1)}
al@898 690 END {printf("</datalist>")}
al@898 691 '
al@898 692 }
al@898 693
al@898 694
al@898 695 mklog() {
al@898 696 awk '
al@898 697 BEGIN { printf("<pre class=\"log dog\">\n") }
al@898 698 { print }
al@898 699 END { print "</pre>" }'
al@898 700 }
al@898 701
al@898 702
al@898 703 summary() {
al@898 704 log="$1"
al@898 705 pkg="$(basename ${log%%.log*})"
al@898 706
al@898 707 if [ -f "$log" ]; then
al@898 708 if grep -q "cook:$pkg$" $command; then
al@1090 709 show_note i "The Cooker is currently building $pkg" \
al@1090 710 | sed 's|>|&<progress id="gauge" class="meter-small" max="100" value="0"></progress> |'
al@1090 711 echo "<script>updatePkg = '${pkg//+/%2B}';</script>"
al@898 712 elif fgrep -q "Summary for:" $log; then
al@904 713 sed '/^Summary for:/,$!d' $log | awk '
al@898 714 BEGIN { print "<section>" }
al@904 715 function row(line) {
al@904 716 split(line, s, " : ");
al@904 717 printf("\t<tr><td>%s</td><td>%s</td></tr>\n", s[1], s[2]);
al@904 718 }
al@904 719 function row2(line, rowNum) {
al@904 720 split(line, s, " : ");
al@938 721 if (rowNum == 1) {
al@938 722 print "<thead>";
al@904 723 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 724 print "</thead><tbody>";
al@938 725 }
al@904 726 else
al@904 727 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 728 }
al@898 729 {
al@904 730 if (NR==1) { printf("<h3>%s</h3>\n<table>\n", $0); next }
al@904 731 if ($0 ~ "===") { seen++; if (seen == 1) next; else exit; }
al@904 732 if ($0 ~ "---") {
al@904 733 seen2++;
al@938 734 if (seen2 == 1) print "</table>\n\n<table class=\"pkgslist\">"
al@904 735 next
al@898 736 }
al@904 737 if (seen2) row2($0, seen2); else row($0);
al@898 738 }
al@938 739 END { print "</tbody></table></section>" }
al@898 740 '
al@898 741 elif fgrep -q "Debug information" $log; then
al@1090 742 # second line of log is "Cook: <package> <version>"
al@1090 743 echo -e "<section>\n<h3>Debug information for $(sed '2!d; s|.*: ||' $log)</h3>"
al@898 744 sed -e '/^Debug information/,$!d; /^===/d; /^$/d' $log | sed -n '1!p' | \
al@898 745 if [ -n "$2" ]; then
al@979 746 syntax_highlighter log | sed 's|\([^0-9 ]\)\([0-9][0-9]*\):|\1<a href="#l\2">\2</a>:|'
al@898 747 else
al@898 748 sed 's|^[0-9][0-9]*:||' | syntax_highlighter log
al@898 749 fi | mklog
al@898 750 echo '</section>'
al@898 751 fi
al@898 752 else
al@898 753 [ -n "$pkg" -a -d "$wok/$pkg" ] && show_note e "No log for $pkg"
al@898 754 fi
al@898 755 }
al@898 756
al@898 757
al@898 758 active() {
al@898 759 [ "$cmd" == "$1" -o "$cmd" == "${2:-$1}" ] && echo -n ' active'
al@898 760 }
al@898 761
al@898 762
al@898 763 pkg_info() {
al@998 764 local log active bpkg short_desc=''
al@898 765 log="$LOGS/$pkg.log"
al@898 766
al@1074 767 echo -n "<div id=\"hdr\"><a href=\"$base/${requested_pkg:-$pkg}\">"
al@1076 768 if [ -e $wok/$pkg/.icon.png ]; then
al@1090 769 echo -n "<img src=\"$base/$pkg/browse/.icon.png\" alt=\"$pkg icon\"/>"
al@1074 770 else
al@1090 771 echo -n "<img src=\"/tazpkg.png\" alt=\"package icon\"/>"
al@1074 772 fi
al@1074 773 echo -n "</a>"
al@996 774 echo -n "<h2><a href=\"$base/${requested_pkg:-$pkg}\">${requested_pkg:-$pkg}</a>"
al@998 775 # Get short description for existing packages
al@1096 776 [ -f $PKGS/packages-$ARCH.info ] &&
al@1096 777 short_desc="$(awk -F$'\t' -vp="${requested_pkg:-$pkg}" '{if ($1 == p) { printf("%s", $4); exit; }}' $PKGS/packages-$ARCH.info)"
paul@1006 778 # If package does not exist (not created yet or broken), get short description
al@998 779 # (but only for "main" package) from receipt
al@998 780 [ -n "$short_desc" ] || short_desc="$(. $wok/$pkg/receipt; echo "$SHORT_DESC")"
al@1074 781 echo "<br/>$short_desc</h2></div>"
al@898 782 echo '<div id="info">'
al@898 783 echo "<a class='button icon receipt$(active receipt stuff)' href='$base/$pkg/receipt'>receipt &amp; stuff</a>"
al@898 784
al@1003 785 # In the receipts $EXTRAVERSION is defined using $kvers, get it here [copy from 'cook' set_paths()]
al@1003 786 if [ -f "$wok/linux/receipt" ]; then
al@1003 787 kvers=$(. $wok/linux/receipt; echo $VERSION)
al@1003 788 kbasevers=$(echo $kvers | cut -d. -f1,2)
al@1003 789 elif [ -f "$INSTALLED/linux-api-headers/receipt" ]; then
al@1003 790 kvers=$(. $INSTALLED/linux-api-headers/receipt; echo $VERSION)
al@1003 791 kbasevers=$(echo $kvers | cut -d. -f1,2)
al@1003 792 fi
al@1003 793
al@898 794 unset WEB_SITE WANTED
al@898 795 . $wok/$pkg/receipt
al@898 796
al@898 797 [ -n "$WEB_SITE" ] &&
al@898 798 echo "<a class='button icon website' href='$WEB_SITE' target='_blank' rel='noopener noreferrer'>web site</a>"
al@898 799
al@1003 800 [ -f "$wok/$pkg/taz/$PACKAGE-$VERSION$EXTRAVERSION/receipt" ] &&
al@898 801 echo "<a class='button icon files$(active files)' href='$base/$pkg/files'>files</a>"
al@898 802
al@925 803 [ -n "$(ls $wok/$pkg/description*.txt)" ] &&
al@925 804 echo "<a class='button icon desc$(active description)' href='$base/$pkg/description'>description</a>"
al@898 805
al@925 806 [ -n "$TARBALL" -a -s "$SRC/$TARBALL" -o -d "$wok/$pkg/taz" ] &&
al@1090 807 echo "<a class='button icon download' href='$base/$pkg/download'>downloads</a>"
al@898 808
al@898 809 echo "<a class='button icon browse' href='$base/$pkg/browse/'>browse</a>"
al@898 810
al@1002 811 [ -x ./man2html.bin -a -d "$wok/$pkg/install/usr/share/man" ] &&
al@898 812 echo "<a class='button icon doc$(active man)' href='$base/$pkg/man/'>man</a>"
al@898 813
al@898 814 [ -d "$wok/$pkg/install/usr/share/doc" -o -d "$wok/$pkg/install/usr/share/gtk-doc" ] &&
al@898 815 echo "<a class='button icon doc$(active doc)' href='$base/$pkg/doc/'>doc</a>"
al@898 816
al@898 817 [ -d "$wok/$pkg/install/usr/share/info" ] &&
al@898 818 echo "<a class='button icon doc$(active info)' href='$base/$pkg/info/#Top'>info</a>"
al@898 819
al@989 820 if [ -n "$LFS" ]; then
al@1090 821 printf "<a class='button icon lfs' href='%s' target='_blank' rel='noopener noreferrer'>" "$LFS"
al@989 822 [ "${LFS/blfs/}" != "$LFS" ] && printf "B"
al@989 823 printf "LFS</a>\n"
al@989 824 fi
al@981 825
al@1078 826 ls $log* >/dev/null 2>&1 &&
al@898 827 echo "<a class='button icon log$(active log)' href='$base/$pkg/log/'>logs</a>"
al@898 828
al@898 829 echo '</div>'
al@898 830 }
al@898 831
al@898 832
al@898 833 mktable() {
al@898 834 sed 's# : #|#' | awk -vc="$1" '
al@898 835 BEGIN { printf("<table class=\"%s\">\n", c); FS="|" }
al@898 836 { printf("<tr><td>%s</td>", $1);
al@898 837 if (NF == 2) printf("<td>%s</td>", $2);
al@898 838 printf("</tr>\n", $2) }
al@898 839 END { print "</table>" }'
al@898 840 }
al@898 841
al@898 842
al@898 843 section() {
al@898 844 local i=$(basename "$1")
al@898 845 echo -e '\n\n<section>'
al@898 846 [ $(wc -l < $1) -gt $2 ] && echo "<a class='button icon more r' href='?$i'>${3#*|}</a>"
al@898 847 echo "<h2>${3%|*}</h2>"
al@898 848 mktable "$i"
al@898 849 echo '</section>'
al@898 850 }
al@898 851
al@898 852
al@908 853 show_desc() {
al@908 854 echo "<section><h3>Description of “$1”</h3>"
al@908 855 if [ -n "$md2html" ]; then
al@908 856 $md2html $2
al@908 857 else
al@908 858 show_code markdown < $2
al@908 859 fi
al@908 860 echo "</section>"
al@908 861 }
al@908 862
al@908 863
al@924 864 # Return all the names of packages bundled in this receipt
al@924 865
al@924 866 all_names() {
al@1022 867 # Get package names from $SPLIT variable
al@1022 868 local split=$(echo $SPLIT \
al@1022 869 | awk '
al@1022 870 BEGIN { RS = " "; FS = ":"; }
al@1022 871 { print $1; }' \
al@1022 872 | tr '\n' ' ')
al@1022 873 local split_space=" $split "
al@1022 874 if ! head -n1 $WOK/$pkg/receipt | fgrep -q 'v2'; then
al@1022 875 # For receipts v1: $SPLIT may present in the $WANTED package,
al@1022 876 # but split packages have their own receipts
al@1022 877 echo $PACKAGE
al@1022 878 elif [ "${split_space/ $PACKAGE /}" != "$split_space" ]; then
al@924 879 # $PACKAGE included somewhere in $SPLIT (probably in the end).
al@924 880 # We should build packages in the order defined in the $SPLIT.
al@1022 881 echo $split
al@924 882 else
al@924 883 # We'll build the $PACKAGE, then all defined in the $SPLIT.
al@1022 884 echo $PACKAGE $split
al@924 885 fi
al@924 886 }
al@924 887
al@924 888
al@924 889 toolchain_version() {
al@1007 890 echo "<tr><td><a href='$base/$1'>$1</a></td>"
al@1007 891 awk -F$'\t' -vpkg="$1" '
al@1007 892 BEGIN { version = description = "---"; }
al@1007 893 {
al@1007 894 if ($1 == pkg) { version = $2; description = $4; }
al@1007 895 }
al@1007 896 END { printf("<td>%s</td><td>%s</td></tr>", version, description); }
al@1096 897 ' $PKGS/packages-$ARCH.info
al@924 898 }
al@924 899
al@924 900
al@924 901 files_header() {
al@924 902 echo '<section><h3>Available downloads:</h3>'
al@924 903 echo '<table><thead><tr><th>File</th><th>Size</th><th>Description</th></tr></thead><tbody>'
al@924 904 }
al@924 905
al@924 906
al@933 907 # Update statistics used in web interface.
al@933 908 # There is no need to recalculate the statistics every time the page is displayed.
al@940 909 # Note, $webstat file must be owned by www, otherwise this function will not be able to do the job.
al@933 910
al@933 911 update_webstat() {
al@933 912 # for receipts:
al@933 913 rtotal=$(ls $WOK/*/arch.$ARCH | wc -l)
al@933 914 rcooked=$(ls -d $WOK/*/taz | wc -l)
al@933 915 runbuilt=$(($rtotal - $rcooked))
al@933 916 rblocked=$(wc -l < $blocked)
al@933 917 rbroken=$(wc -l < $broken)
al@933 918
al@933 919 # for packages:
al@936 920 ptotal=$(cut -d$'\t' -f2 $CACHE/split.db | tr ' ' '\n' | sort -u | wc -l)
al@1098 921 pcooked=$(wc -l < $PKGS/packages-$ARCH.info)
al@933 922 punbuilt=$(($ptotal - $pcooked))
al@933 923 pblocked=$(
al@933 924 while read i; do
al@933 925 sed "/^$i\t/!d" $CACHE/split.db
al@933 926 done < $blocked | cut -d$'\t' -f2 | tr ' ' '\n' | wc -l)
al@933 927 pbroken=$(
al@933 928 while read i; do
al@933 929 sed "/^$i\t/!d" $CACHE/split.db
al@933 930 done < $broken | cut -d$'\t' -f2 | tr ' ' '\n' | wc -l)
al@933 931
al@1090 932 cat > $webstat <<-EOT
al@1090 933 rtotal="$rtotal"; rcooked="$rcooked"; runbuilt="$runbuilt"; rblocked="$rblocked"; rbroken="$rbroken"
al@1090 934 ptotal="$ptotal"; pcooked="$pcooked"; punbuilt="$punbuilt"; pblocked="$pblocked"; pbroken="$pbroken"
al@1090 935 EOT
al@1090 936 }
al@1090 937
al@1090 938
al@1090 939 # Show badges for specified package
al@1090 940
al@1090 941 show_badges() {
al@1090 942 local t p s # title problem solution
al@1090 943
al@1090 944 case $layout in
al@1090 945 table)
al@1090 946 echo "<section><h2>Badges</h2><table class=\"badges\"><thead><tr><th></th><th>Problem</th><th>Solution</th></tr></thead><tbody>"
al@1090 947 ;;
al@1090 948 list)
al@1090 949 echo "<section><h2>Badges list</h2><p>Click on badge to get list of packages</p><table class=\"badges\"><thead><tr><th></th><th>Problem</th></tr></thead><tbody>"
al@1090 950 ;;
al@1090 951 esac
al@1090 952
al@1090 953 for badge in $@; do
al@1090 954 case $badge in
al@1090 955 bdbroken)
al@1090 956 t="Broken bdeps"
al@1090 957 p="This package cannot be built because its creation depends on broken packages"
al@1090 958 s="Fix broken build dependencies"
al@1090 959 ;;
al@1090 960 broken)
al@1090 961 t="Broken package"
al@1090 962 p="Package is broken"
al@1093 963 s="Fix package build: analyze <a href=\"$base/$PACKAGE/log/\">logs</a>, upgrade the version, search for patches"
al@1090 964 ;;
al@1090 965 any)
al@1090 966 t="“Any” arch"
al@1093 967 p="This package contains only architecture-less <a href=\"$base/$PACKAGE/files\">files</a>, it does not make sense to make it several times in each build environment"
al@1093 968 s="Add the line <code>HOST_ARCH=\"any\"</code> to <a href=\"$base/$PACKAGE/receipt\">receipt</a>"
al@1090 969 ;;
al@1090 970 noany)
al@1090 971 t="No “any” arch"
al@1093 972 p="This package contains architecture dependent <a href=\"$base/$PACKAGE/files\">files</a>"
al@1093 973 s="Remove the line <code>HOST_ARCH=\"any\"</code> from <a href=\"$base/$PACKAGE/receipt\">receipt</a>"
al@1090 974 ;;
al@1090 975 libtool)
al@1090 976 t="Libtool isn't fixed"
paul@1104 977 p="This package uses <code>libtool</code> that likes to add unnecessary dependencies to programs and libraries"
al@1093 978 s="Add the <code>fix libtool</code> command to the <a href=\"$base/$PACKAGE/receipt\">receipt</a> between the <code>configure</code> and <code>make</code> commands invocation"
al@1090 979 ;;
al@1090 980 nolibtool)
al@1090 981 t="Libtool is absent"
al@1090 982 p="This package does not use <code>libtool</code>, nothing to fix"
al@1093 983 s="Remove the command <code>fix libtool</code> from <a href=\"$base/$PACKAGE/receipt\">receipt</a>"
al@1090 984 ;;
al@1090 985 own)
al@1090 986 t="Ownership problems"
al@1093 987 p="Some files of this package have <a href=\"$base/$PACKAGE/files\">ownership problems</a>"
al@1093 988 s="Correct the ownership or add problem files to the “<a href=\"$base/$PACKAGE/stuff/overrides\">overrides</a>” list if you believe it is OK"
al@1090 989 ;;
al@1090 990 ownover)
al@1090 991 t="Ownership overridden"
al@1093 992 p="This package contains files with <a href=\"$base/$PACKAGE/files\">ownership problems</a> that have been overridden"
al@1093 993 s="<abbr title=\"For your information\">FYI</abbr> only, you may want to revise <a href=\"$base/$PACKAGE/stuff/overrides\">the list</a>"
al@1090 994 ;;
al@1090 995 perm)
al@1090 996 t="Permissions problems"
al@1093 997 p="Some files of this package have <a href=\"$base/$PACKAGE/files\">unusual permissions</a>"
al@1093 998 s="Correct the permissions or add problem files to the “<a href=\"$base/$PACKAGE/stuff/overrides\">overrides</a>” list if you believe it is OK"
al@1090 999 ;;
al@1090 1000 permover)
al@1090 1001 t="Permissions overridden"
al@1093 1002 p="This package contains files with <a href=\"$base/$PACKAGE/files\">unusual permissions</a> that have been recorded"
al@1093 1003 s="<abbr title=\"For your information\">FYI</abbr> only, you may want to revise <a href=\"$base/$PACKAGE/stuff/overrides\">the list</a>"
al@1090 1004 ;;
al@1090 1005 symlink)
al@1090 1006 t="Broken symlink"
al@1093 1007 p="This package contains one or more <a href=\"$base/$PACKAGE/files\">broken symlinks</a>"
al@1090 1008 s="Fix the symlinks destination; you may use <code>fix symlinks</code> when symlinks have absolute path"
al@1090 1009 ;;
al@1090 1010 ss)
al@1090 1011 t="Site script"
paul@1106 1012 p="This autotools-based building system uses site script; most of the paths (like <var>prefix</var>, <var>sysconfdir</var> and <var>mandir</var>) are defined there with correct default values"
al@1090 1013 s="You may remove your paths from <code>configure</code> invocation"
al@1090 1014 ;;
al@1090 1015 fadd)
al@1090 1016 t="Files have been added"
al@1093 1017 p="Some files absent in <var>\$install</var> was <a href=\"$base/$PACKAGE/files#outoftree\">directly added</a> to <var>\$fs</var>"
al@1090 1018 s="Rework your <code>compile_rules()</code> to add all the required files to <var>\$install</var> there"
al@1090 1019 ;;
al@1090 1020 frem)
al@1090 1021 t="Files have been removed"
paul@1106 1022 p="Some files existing in <var>\$install</var> <a href=\"$base/$PACKAGE/files#orphans\">not belonging to any package</a>"
al@1093 1023 s="Revise <code>genpkg_rules()</code> or add files to “<a href=\"$base/$PACKAGE/stuff/overrides\">overrides</a>” list"
al@1090 1024 ;;
al@1090 1025 fdup)
al@1090 1026 t="Files are duplicated"
al@1093 1027 p="Some files existing in <var>\$install</var> was added to <a href=\"$base/$PACKAGE/files#repeats\">more than one</a> package"
al@1090 1028 s="Check your copy rules in <code>genpkg_rules()</code>"
al@1090 1029 ;;
al@1090 1030 old)
al@1090 1031 t="Oldie"
al@1090 1032 p="According to Repology, this package may be <a href=\"https://repology.org/metapackage/${REPOLOGY:-$pkg}\" target=\"_blank\" rel=\"noopener noreferrer\">outdated</a>"
al@1090 1033 s="Update the package"
al@1090 1034 ;;
al@1090 1035 win)
al@1090 1036 t="Winner"
al@1090 1037 p="This package has no problems"
al@1090 1038 s="Well done, keep it up!"
al@1090 1039 ;;
al@1090 1040 orphan)
al@1090 1041 t="Orphaned package"
al@1090 1042 p="It seems that no other package depends on this one"
al@1090 1043 s="See if anyone needs it"
al@1090 1044 ;;
al@1090 1045 patch)
al@1090 1046 t="Patch"
al@1090 1047 p="Patch has been applied"
al@1090 1048 s="<abbr title=\"For your information\">FYI</abbr> only, you may want to revise <a href=\"$base/$PACKAGE/stuff/patches/series\">the list of patches</a>"
al@1090 1049 ;;
al@1095 1050 no-badge)
al@1095 1051 t="No badge"
al@1095 1052 p="Packages without badges"
al@1095 1053 s=""
al@1095 1054 ;;
al@1090 1055 esac
al@1090 1056 case $layout in
al@1090 1057 table)
al@1090 1058 echo "<tr><td><span class=\"badge $badge\" title=\"$t\"/></td><td>$p</td><td>$s</td></tr>"
al@1090 1059 ;;
al@1090 1060 list)
al@1090 1061 p=$(echo $p | sed 's|<a [^>]*>\([^<]*\)</a>|\1|g')
al@1090 1062 s=$(echo $s | sed 's|<a [^>]*>\([^<]*\)</a>|\1|g|')
al@1090 1063 echo "<tr><td><a href=\"$badge\"><span class=\"badge $badge\" title=\"$t\"/></a></td><td>$p</td></tr>"
al@1090 1064 ;;
al@1090 1065 *)
al@1090 1066 echo -n "<span class=\"badge $badge\" title=\"$t\"/>"
al@1090 1067 ;;
al@1090 1068 esac
al@1090 1069 done
al@1090 1070
al@1090 1071 case $layout in
al@1090 1072 table|list)
al@1090 1073 echo "</tbody></table></section>"
al@1090 1074 ;;
al@1090 1075 esac
al@933 1076 }
al@933 1077
al@933 1078
al@1063 1079 # Generate part of the main page
al@1063 1080
al@1063 1081 part() {
al@1071 1082 echo -n "<div id='$1'>"
al@1063 1083
al@1063 1084 case $1 in
al@1063 1085 summary)
al@1063 1086 echo '<h2>Summary</h2>'
al@1063 1087
al@1063 1088 mktable <<EOT
al@1063 1089 Cooker state : $(running_command)
al@1063 1090 Wok revision : <a href='$WOK_URL' target='_blank' rel='noopener noreferrer'>$(cat $wokrev)</a>
al@1063 1091 Commits to cook : $(wc -l < $commits)
al@1063 1092 Current cooklist : $(wc -l < $cooklist)
al@1063 1093 Architecture : $ARCH, <a href="$toolchain">toolchain</a>
al@1063 1094 Server date : <span id='date'>$(date -u '+%F %R %Z')</span>
al@1063 1095 EOT
al@1063 1096
al@1063 1097 # If command is "cook:*", update gauge and percentage periodically.
al@1063 1098 # If different package is cooking, reload the page (with new settings)
al@1063 1099 cmd="$(cat $command)"
al@1063 1100 case "$cmd" in
al@1063 1101 cook:*)
al@1063 1102 pkg=${cmd#*:}
al@1063 1103 echo "<script>updatePkg = '${pkg//+/%2B}';</script>"
al@1063 1104 ;;
al@1063 1105 esac
al@1063 1106 ;;
al@1063 1107 webstat)
al@1063 1108 # Do we need to update the statistics?
al@1071 1109 if [ -n "$nojs" -a "$activity" -nt "$webstat" ]; then update_webstat; fi
al@1063 1110 . $webstat
al@1063 1111
al@1063 1112 pct=0; [ "$rtotal" -gt 0 ] && pct=$(( ($rcooked * 100) / $rtotal ))
al@1063 1113
al@1090 1114 cat <<-EOT
al@1090 1115 <div class="meter"><progress max="100" value="$pct">${pct}%</progress><span>${pct}%</span></div>
al@1063 1116
al@1090 1117 <table class="webstat">
al@1090 1118 <thead>
al@1090 1119 <tr>
al@1090 1120 <th> </th>
al@1090 1121 <th>Total </th>
al@1090 1122 <th>Cooked </th>
al@1090 1123 <th>Unbuilt </th>
al@1090 1124 <th>Blocked </th>
al@1090 1125 <th>Broken </th>
al@1090 1126 </tr>
al@1090 1127 </thead>
al@1090 1128 <tbody>
al@1090 1129 <tr>
al@1090 1130 <td>Receipts</td>
al@1090 1131 <td>$rtotal</td>
al@1090 1132 <td>$rcooked</td>
al@1090 1133 <td>$runbuilt</td>
al@1090 1134 <td>$rblocked</td>
al@1090 1135 <td>$rbroken</td>
al@1090 1136 </tr>
al@1090 1137 <tr>
al@1090 1138 <td>Packages</td>
al@1090 1139 <td>$ptotal</td>
al@1090 1140 <td>$pcooked</td>
al@1090 1141 <td>$punbuilt</td>
al@1090 1142 <td>$pblocked</td>
al@1090 1143 <td>$pbroken</td>
al@1090 1144 </tr>
al@1090 1145 </tbody>
al@1090 1146 </table>
al@1090 1147 EOT
al@1071 1148 if [ -z "$nojs" ]; then echo "<script>getPart('$1')</script>"; fi
al@1063 1149 ;;
al@1063 1150 activity)
al@1063 1151 tac $activity | head -n12 | sed 's|cooker.cgi?pkg=||;
al@1063 1152 s|\[ Done|<span class="r c20">Done|;
al@1063 1153 s|\[ Failed|<span class="r c10">Failed|;
al@1063 1154 s|\[ -Failed|<span class="r c10"><del>Failed</del>|;
al@1063 1155 s| \]|</span>|;
al@1090 1156 s|%2B|\+|g' \
al@1090 1157 | while read line; do
al@1090 1158 case "$line" in
al@1090 1159 *data-badges=*)
al@1090 1160 badges="$(echo "$line" | sed "s|.*data-badges='\([^']*\)'.*|\1|")"
al@1090 1161 echo "$line" | sed "s|</a>|</a> $(show_badges "$badges")|"
al@1090 1162 ;;
al@1090 1163 *)
al@1090 1164 echo "$line"
al@1090 1165 ;;
al@1090 1166 esac
al@1090 1167 done | section $activity 12 "Activity|More activity" \
al@1063 1168 ;;
al@1063 1169 cooknotes)
al@1063 1170 [ -s "$cooknotes" ] && tac $cooknotes | head -n12 | \
al@1063 1171 section $cooknotes 12 "Cooknotes|More notes"
al@1063 1172 ;;
al@1063 1173 commits)
al@1063 1174 [ -s "$commits" ] && head -n20 $commits | \
al@1063 1175 section $commits 20 "Commits|More commits"
al@1063 1176 ;;
al@1063 1177 cooklist)
al@1063 1178 [ -s "$cooklist" ] && head -n 20 $cooklist | \
al@1063 1179 section $cooklist 20 "Cooklist|Full cooklist"
al@1063 1180 ;;
al@1063 1181 broken)
al@1063 1182 [ -s "$broken" ] && head -n20 $broken | sed "s|^[^']*|<a href='\0'>\0</a>|g" | \
al@1063 1183 section $broken 20 "Broken|All broken packages"
al@1063 1184 ;;
al@1063 1185 blocked)
al@1063 1186 [ -s "$blocked" ] && sed "s|^[^']*|<a href='\0'>\0</a>|g" $blocked | \
al@1063 1187 section $blocked 12 "Blocked|All blocked packages"
al@1063 1188 ;;
al@1063 1189 pkgs)
al@1063 1190 cd $PKGS
al@1063 1191 # About BusyBox's `ls`
al@1063 1192 # On the Tank server: BusyBox v1.18.4 (2012-03-14 03:32:25 CET) multi-call binary.
al@1063 1193 # It supported the option `-e`, output with `-let` options like this:
al@1063 1194 # -rw-r--r-- 1 user group 100000 Fri Nov 3 10:00:00 2017 filename
al@1063 1195 # 1 2 3 4 5 6 7 8 9 10 11
al@1063 1196 # Newer BusyBox v1.27.2 doesn't support option `-e` and has no configs to
al@1063 1197 # configure it or return the option back. It supported the long option
al@1063 1198 # `--full-time` instead, but output is different:
al@1063 1199 # -rw-r--r-- 1 user group 100000 2017-11-03 10:00:00 +0200 filename
al@1063 1200 # 1 2 3 4 5 6 7 8 9
al@1063 1201 if ls -let >/dev/null 2>&1; then
al@1063 1202 ls -let *.tazpkg \
al@1063 1203 | awk '
al@1063 1204 (NR<=20){
al@1063 1205 sub(/:[0-9][0-9]$/, "", $9);
al@1063 1206 mon = index(" JanFebMarAprMayJunJulAugSepOctNovDec", $7) / 3;
al@1063 1207 printf("%d-%02d-%02d %s : <a href=\"get/%s\">%s</a>\n", $10, mon, $8, $9, $11, $11);
al@1063 1208 }' \
al@1063 1209 | section $activity 1000 "Latest cook"
al@1063 1210 else
al@1063 1211 ls -lt --full-time *.tazpkg \
al@1063 1212 | awk '
al@1063 1213 (NR<=20){
al@1063 1214 sub(/:[0-9][0-9]$/, "", $7);
al@1063 1215 printf("%s %s : <a href=\"get/%s\">%s</a>\n", $6, $7, $9, $9);
al@1063 1216 }' \
al@1063 1217 | section $activity 1000 "Latest cook"
al@1063 1218 fi
al@1063 1219 ;;
al@1063 1220 esac
al@1071 1221 echo "</div>"
al@1063 1222 }
al@1063 1223
al@1063 1224
al@1063 1225 # Query '?part=<part>': get part of the main page
al@1063 1226
al@1063 1227 if [ -n "$(GET part)" ]; then
al@1063 1228 part="$(GET part)"
al@1063 1229 case $part in
al@1063 1230 summary|webstat|activity|cooknotes|commits|cooklist|broken|blocked|pkgs)
al@1063 1231 nojs='yes'
al@1063 1232 part $part
al@1063 1233 ;;
al@1063 1234 esac
al@1063 1235 exit 0
al@1063 1236 fi
al@1063 1237
al@1063 1238
al@898 1239
al@898 1240
al@898 1241 #
al@898 1242 # Load requested page
al@898 1243 #
al@898 1244
al@898 1245 if [ -z "$pkg" ]; then
al@898 1246
al@898 1247 page_header
al@1076 1248 if [ -n "$QUERY_STRING" ]; then
al@898 1249
al@1076 1250 [ "$QUERY_STRING" != 'commits.log' ] &&
al@1073 1251 for list in activity cooknotes cooklist commits; do
al@898 1252 [ -n "$(GET $list)" ] || continue
al@1073 1253 case $list in
al@1073 1254 cooklist) nb="- Packages: $(wc -l < $cooklist)";;
al@1073 1255 commits) nb="- Packages: $(wc -l < $commits)";;
al@1073 1256 esac
al@898 1257 echo '<section id="content2">'
al@898 1258 echo "<h2>DB: $list $nb</h2>"
al@1090 1259
al@905 1260 tac $CACHE/$list | sed 's|cooker.cgi?pkg=||; s|%2B|+|g;
al@898 1261 s|\[ Done|<span class="r c20">Done|;
al@898 1262 s|\[ Failed|<span class="r c10">Failed|;
al@1027 1263 s|\[ -Failed|<span class="r c10"><del>Failed</del>|;
al@1090 1264 s| \]|</span>|;
al@1090 1265 s|%2B|\+|g' \
al@1090 1266 | while read line; do
al@1090 1267 case "$line" in
al@1090 1268 *data-badges=*)
al@1090 1269 badges="$(echo "$line" | sed "s|.*data-badges='\([^']*\)'.*|\1|")"
al@1090 1270 echo "$line" | sed "s|</a>|</a> $(show_badges "$badges")|"
al@1090 1271 ;;
al@1090 1272 *)
al@1090 1273 echo "$line"
al@1090 1274 ;;
al@1090 1275 esac
al@1090 1276 done \
al@1090 1277 | mktable $list
al@1090 1278
al@898 1279 echo '</section>'
al@898 1280 done
al@898 1281
al@898 1282 if [ -n "$(GET broken)" ]; then
al@938 1283 echo '<section id="content2">'
al@898 1284 echo "<h2>DB: broken - Packages: $(wc -l < $broken)</h2>"
al@898 1285 sort $CACHE/broken | sed "s|^[^']*|<a href='$base/\0'>\0</a>|g" | mktable
al@938 1286 echo '</section>'
al@898 1287 fi
al@898 1288
al@898 1289 case "$QUERY_STRING" in
al@898 1290 *.log)
al@898 1291 log=$LOGS/$QUERY_STRING
al@898 1292 name=$(basename $log)
al@898 1293 if [ -f "$log" ]; then
al@898 1294 echo "<h2>Log for: ${name%.log}</h2>"
al@898 1295 if fgrep -q "Summary" $log; then
al@898 1296 echo '<pre class="log">'
al@942 1297 grep -A 20 'Summary' $log | syntax_highlighter log
al@898 1298 echo '</pre>'
al@898 1299 fi
al@898 1300 echo '<pre class="log">'
al@898 1301 syntax_highlighter log < $log
al@898 1302 echo '</pre>'
al@986 1303 if [ "$QUERY_STRING" == 'pkgdb.log' ]; then
al@985 1304 # Display button only for SliTaz web browser
al@985 1305 case "$HTTP_USER_AGENT" in
al@985 1306 *SliTaz*)
al@985 1307 if [ -f $CACHE/cooker-request -a -n "$HTTP_REFERER" ]; then
al@985 1308 if grep -qs '^pkgdb$' $CACHE/recook-packages; then
al@985 1309 show_note i "The package database has been requested for re-creation"
al@985 1310 else
al@985 1311 echo "<a class='button' href='$base/?recook=pkgdb'>Re-create the DB</a>"
al@985 1312 fi
al@985 1313 fi
al@985 1314 ;;
al@985 1315 esac
al@985 1316 fi
al@898 1317 else
al@898 1318 show_note e "No log file: $log"
al@898 1319 fi
al@898 1320 ;;
al@924 1321 toolchain)
al@1090 1322 cat <<-EOT
al@1090 1323 <div id="content2">
al@1090 1324 <section>
al@1090 1325 <h2>SliTaz GNU/Linux toolchain</h2>
al@924 1326
al@1090 1327 <table>
al@1090 1328 <tr>
al@1090 1329 <td>Build date</td>
al@1090 1330 <td colspan="2">$(sed -n '/^Cook date/s|[^:]*: \(.*\)|\1|p' $LOGS/slitaz-toolchain.log)</td>
al@1090 1331 </tr>
al@1090 1332 <tr>
al@1090 1333 <td>Build duration</td>
al@1090 1334 <td colspan="2">$(sed -n '/^Cook time/s|[^:]*: \(.*\)|\1|p' $LOGS/slitaz-toolchain.log)</td>
al@1090 1335 </tr>
al@1090 1336 <tr>
al@1090 1337 <td>Architecture</td>
al@1090 1338 <td colspan="2">$ARCH</td>
al@1090 1339 </tr>
al@1090 1340 <tr>
al@1090 1341 <td>Host system</td>
al@1090 1342 <td colspan="2">$BUILD_SYSTEM</td>
al@1090 1343 </tr>
al@1090 1344 <tr>
al@1090 1345 <td>Target system</td>
al@1090 1346 <td colspan="2">$HOST_SYSTEM</td>
al@1090 1347 </tr>
al@1090 1348 <tr>
al@1090 1349 <th>Package</th>
al@1090 1350 <th>Version</th>
al@1090 1351 <th>Description</th>
al@1090 1352 </tr>
al@1090 1353 $(toolchain_version slitaz-toolchain)
al@1090 1354 $(toolchain_version binutils)
al@1090 1355 $(toolchain_version linux-api-headers)
al@1090 1356 $(toolchain_version gcc)
al@1090 1357 $(toolchain_version glibc)
al@1090 1358 </table>
al@924 1359
al@1090 1360 <p>Toolchain documentation: <a target="_blank" rel="noopener noreferrer"
al@1090 1361 href="http://doc.slitaz.org/en:cookbook:toolchain">http://doc.slitaz.org/en:cookbook:toolchain</a>
al@1090 1362 </p>
al@924 1363
al@1090 1364 </section>
al@1090 1365 </div>
al@1090 1366 EOT
al@924 1367 ;;
al@1083 1368 maintainer*)
al@1089 1369 maintainer=$(GET maintainer); maintainer=${maintainer/maintainer/}
al@1089 1370 regexp=$(GET regexp); regexp=${regexp/regexp/}
al@1089 1371 [ -n "$regexp" ] && maintainer=''
al@1090 1372 cat <<-EOT
al@1090 1373 <section>
al@1090 1374 <h2>For maintainers</h2>
al@1091 1375 <p>Here you can <a href="=/">explore the badges</a>.</p>
al@1090 1376 <p>Or see some <a href="?maintainer&amp;stats">repository statistics</a>.</p>
paul@1104 1377 <p>Or check packages version either for specified maintainer or using regular expressions:</p>
al@1090 1378 <form>
al@1090 1379 <select name="maintainer">
al@1090 1380 <option value=''>--- select maintainer ---
al@1090 1381 EOT
al@1083 1382 cut -d$'\t' -f1 $maintdb | sort -u \
al@1083 1383 | awk -vm=$maintainer '{
al@1083 1384 selected=$0==m?"selected":""
al@1089 1385 printf("<option %s value=\"%s\">%s\n", selected, $0, $0)
al@1083 1386 }'
al@1090 1387 cat <<-EOT
al@1090 1388 </select>
al@1090 1389 or
al@1090 1390 <input type="text" name="regexp" value="$regexp"/>
al@1090 1391 <button type="submit">Go</button>
al@1090 1392 </form>
al@1090 1393 EOT
al@1089 1394 if [ -n "$maintainer" -o -n "$regexp" ]; then
al@1083 1395 tmp_status=$(mktemp)
al@1090 1396 cat <<-EOT
al@1090 1397 <table class="maint">
al@1090 1398 <thead><tr><th>Package</th><th>Version</th><th>Repology</th></tr></thead>
al@1090 1399 EOT
al@1089 1400 {
al@1089 1401 if [ -n "$maintainer" ]; then
al@1089 1402 awk -vm=$maintainer '{if ($1 == m) print $2}' $maintdb
al@1089 1403 fi
al@1089 1404 if [ -n "$regexp" ]; then
al@1089 1405 cd $wok; ls | grep "$regexp"
al@1089 1406 fi
al@1089 1407 } | while read pkg; do
al@1083 1408 unset VERSION; REPOLOGY=$pkg
al@1083 1409 . $wok/$pkg/receipt
al@1097 1410 ver=$(awk -F$'\t' -vpkg="$pkg" '{if ($1 == pkg) {print $2; exit}}' $PKGS/packages-$ARCH.info)
al@1083 1411 if [ "$REPOLOGY" == '-' ]; then
al@1083 1412 unset repo_info1 repo_info2
al@1083 1413 echo '-' >>$tmp_status
al@1083 1414 else
al@1083 1415 repo_ver=$(repology_get $REPOLOGY)
al@1083 1416 if [ "$repo_ver" == '-' ]; then
al@1083 1417 echo '-' >>$tmp_status
al@1083 1418 icon='more'
al@1081 1419 else
al@1083 1420 if echo " $repo_ver " | fgrep -q " ${ver:-$VERSION} "; then
al@1082 1421 icon='actual'
al@1082 1422 else
al@1082 1423 icon='update'
al@1082 1424 fi
al@1083 1425 echo $icon >>$tmp_status
al@1081 1426 fi
al@1083 1427 repo_info1="<a class='icon $icon' href='https://repology.org/metapackage/$REPOLOGY' target='_blank'"
al@1083 1428 repo_info2="rel='noopener noreferrer' title='latest packaged version(s)'>${repo_ver// /, }</a>"
al@1083 1429 fi
al@1090 1430 cat <<-EOT
al@1090 1431 <tr>
al@1090 1432 <td><img src="$base/s/$pkg" alt="$pkg"> <a href="$pkg">$pkg</a></td>
al@1090 1433 <td>${ver:-$VERSION}</td>
al@1090 1434 <td>$repo_info1 $repo_info2</td>
al@1090 1435 </tr>
al@1090 1436 EOT
al@1081 1437 done
al@1081 1438
al@1083 1439 pkg_total=$( wc -l < $tmp_status)
al@1083 1440 pkg_actual=$( fgrep actual $tmp_status | wc -l)
al@1083 1441 pkg_outdated=$(fgrep update $tmp_status | wc -l)
al@1083 1442 pkg_unknown=$( fgrep '-' $tmp_status | wc -l)
al@1083 1443
al@1083 1444 pct_actual=$(( $pkg_actual * 100 / $pkg_total ))
al@1083 1445 pct_outdated=$(( $pkg_outdated * 100 / $pkg_total ))
al@1083 1446 pct_unknown=$(( $pkg_unknown * 100 / $pkg_total ))
al@1083 1447
al@1083 1448 [ "$pkg_actual" -eq 0 ] && pkg_actual=''
al@1083 1449 [ "$pkg_outdated" -eq 0 ] && pkg_outdated=''
al@1083 1450 [ "$pkg_unknown" -eq 0 ] && pkg_unknown=''
al@1083 1451
al@1090 1452 cat <<-EOT
al@1090 1453 </table>
al@1083 1454
al@1090 1455 <div class="meter" style="width:100%;text-align:center"><div
al@1090 1456 style="display:inline-block;background-color:#090;width:$pct_actual%">$pkg_actual</div><div
al@1090 1457 style="display:inline-block;background-color:#f90;width:$pct_outdated%">$pkg_outdated</div><div
al@1090 1458 style="display:inline-block;background-color:#ccc;width:$pct_unknown%">$pkg_unknown</div></div>
al@1090 1459 EOT
al@1083 1460 rm $tmp_status
al@1083 1461 fi
al@1090 1462 cat <<-EOT
al@1090 1463 </section>
al@1090 1464 EOT
al@1081 1465 ;;
al@898 1466 esac
al@898 1467 page_footer
al@898 1468 exit 0
al@898 1469 fi
al@898 1470
al@898 1471
al@898 1472 # We may have a toolchain.cgi script for cross cooker's
al@898 1473 if [ -f "toolchain.cgi" ]; then
al@898 1474 toolchain="toolchain.cgi"
al@898 1475 else
al@924 1476 toolchain="?toolchain"
al@898 1477 fi
al@933 1478
paul@900 1479 # Main page with summary. Count only packages included in ARCH,
al@898 1480 # use 'cooker arch-db' to manually create arch.$ARCH files.
al@933 1481
al@1090 1482 cat <<-EOT
al@1090 1483 <div id="content2">
al@898 1484
al@1090 1485 <section>
al@1090 1486 <form method="get" action="" class="search r">
al@1090 1487 <input type="hidden" name="search" value="pkg"/>
al@1090 1488 <button type="submit" title="Search">Search</button>
al@1090 1489 <input type="search" name="q" placeholder="Package" list="packages" autocorrect="off" autocapitalize="off"/>
al@1090 1490 </form>
al@1090 1491 EOT
al@898 1492
al@1071 1493 unset nojs
al@1063 1494 part summary
al@1063 1495 part webstat
al@933 1496
al@1090 1497 cat <<-EOT
al@1090 1498 <p>
al@1090 1499 Service logs:
al@1090 1500 <a href="?cookorder.log">cookorder</a> ·
al@1090 1501 <a href="?commits.log">commits</a> ·
al@1090 1502 <a href="?pkgdb.log">pkgdb</a>
al@1090 1503 </p>
al@1090 1504 EOT
al@1081 1505
al@898 1506 if [ -e "$CACHE/cooker-request" -a ! -s $command ]; then
al@898 1507 if [ "$activity" -nt "$CACHE/cooker-request" ]; then
al@898 1508 echo '<a class="button icon bell r" href="?poke">Wake up</a>'
al@898 1509 else
al@898 1510 show_note i 'Cooker will be launched in the next 5 minutes.'
al@898 1511 fi
al@898 1512 fi
al@898 1513
al@1090 1514 cat <<-EOT
al@1090 1515 <a class="button icon maintainers" href="?maintainer">For maintainers</a>
al@1090 1516 <a class="button icon tag" href="~/">Tags</a>
al@1090 1517 </section>
al@1090 1518 EOT
al@898 1519
al@1063 1520 part activity
al@1063 1521 part cooknotes
al@1063 1522 part commits
al@1063 1523 part cooklist
al@1063 1524 part broken
al@1063 1525 part blocked
al@1063 1526 part pkgs
al@898 1527
al@898 1528 echo '</div>'
al@898 1529 datalist
al@898 1530 page_footer
al@898 1531 exit 0
al@898 1532 fi
al@898 1533
al@898 1534
al@1007 1535 # show tag
al@1007 1536
al@1090 1537 if [ "$pkg" == '~' ]; then
al@1007 1538 page_header
al@1090 1539 echo '<div id="content2"><section>'
al@1007 1540
al@1090 1541 if [ -n "$cmd" ]; then
al@1090 1542 tag="$cmd"
al@1090 1543 cat <<-EOT
al@1090 1544 <h2>Tag “$tag”</h2>
al@1090 1545
al@1090 1546 <table>
al@1090 1547 <thead><tr><th>Name</th><th>Description</th><th>Category</th></tr></thead>
al@1090 1548 <tbody>
al@1090 1549 EOT
al@1090 1550 sort $PKGS/packages-$ARCH.info \
al@1090 1551 | awk -F$'\t' -vtag=" $tag " -vbase="$base/" '{
al@1090 1552 if (index(" " $6 " ", tag)) {
al@1090 1553 url = base $1 "/";
al@1090 1554 gsub("+", "%2B", url);
al@1090 1555 printf("<tr><td><img src=\"%ss/%s\" alt=\"%s\"> ", base, $1, $1);
al@1090 1556 printf("<a href=\"%s\">%s</a></td><td>%s</td><td>%s</td></tr>\n", url, $1, $4, $3);
al@1090 1557 }
al@1090 1558 }'
al@1090 1559 echo '</tbody></table>'
al@1090 1560 else
al@1090 1561 # Fast and nice tag cloud
al@1090 1562 echo '<h2>Tag cloud</h2><p class="tags">'
al@1090 1563 # Some magic in tag sizes :-) It's because of non-linear distribution
al@1090 1564 # of tags. Currently 1x198 (each of 198 tags marks one package);
al@1090 1565 # 2x79 (each of 79 other tags marks two packages); 3x28 (and so on);
al@1090 1566 # 4x23; 5x14; 6x5; 7x9; 8x11; 9x4; 10x3; 11x5; 12x6; 13x3; 14x1; 15x1;
al@1090 1567 # 16x2; 18x1; 20x3; 22x3; 23, 24, 27, 33, 39, 42, 45, 57, 59, 65, 90x1.
al@1090 1568 awk -F$'\t' -vbase="$base/~/" '
al@1090 1569 {
al@1090 1570 split($6, tags, " ");
al@1090 1571 for (i in tags) { tag[tags[i]]++; if (tag[tags[i]] > max) max = tag[tags[i]]; }
al@1090 1572 }
al@1090 1573 END {
al@1090 1574 for (i in tag) {
al@1090 1575 j = tag[i];
al@1090 1576 size = (j == 1) ? 0 : (j == 2) ? 1 : (j < 5) ? 2 : (j < 9) ? 3 : (j < 18) ? 4 : 5;
al@1090 1577 printf("<a href=\"%s\" class=\"tag%s\">%s<sup>%s</sup></a>\n", base i, size, i, tag[i]);
al@1090 1578 }
al@1090 1579 }
al@1090 1580 ' $PKGS/packages-$ARCH.info | sort -f # sort alphabetically case insensitive
al@1090 1581 fi
al@1090 1582 echo '</p></section></div>'
al@1090 1583 page_footer
al@1090 1584 exit 0
al@1090 1585 fi
al@1090 1586
al@1090 1587
al@1090 1588 # show badges
al@1090 1589
al@1091 1590 if [ "$pkg" == '=' ]; then
al@1090 1591 page_header
al@1090 1592 echo '<div id="content2">'
al@1090 1593
al@1090 1594 if [ -n "$cmd" ]; then
al@1090 1595 badge="$cmd"
al@1095 1596 case "$badge" in
al@1095 1597 no-badge)
al@1095 1598 cat <<-EOT
al@1095 1599 <section>
al@1095 1600 <h2 class="badge $badge"> Packages without badges</h2>
al@1090 1601
al@1095 1602 <table>
al@1095 1603 <thead><tr><th>Name</th><th>Description</th><th>Category</th></tr></thead>
al@1095 1604 <tbody>
al@1095 1605 EOT
al@1095 1606
al@1095 1607 ls $WOK \
al@1095 1608 | while read pkg; do
al@1095 1609 [ -s $WOK/$pkg/.badges ] && continue
al@1095 1610 awk -F$'\t' -vpkg="$pkg" -vbase="$base/" '{
al@1095 1611 if ($1 == pkg) {
al@1095 1612 url = base $1 "/";
al@1095 1613 gsub("+", "%2B", url);
al@1095 1614 printf("<tr><td><img src=\"%ss/%s\" alt=\"%s\"> ", base, $1, $1);
al@1095 1615 printf("<a href=\"%s\">%s</a></td><td>%s</td><td>%s</td></tr>\n", url, $1, $4, $3);
al@1095 1616 }
al@1095 1617 }' $PKGS/packages-$ARCH.info
al@1095 1618 done
al@1095 1619 ;;
al@1095 1620 *)
al@1095 1621 cat <<-EOT
al@1095 1622 <section>
al@1095 1623 <h2 class="badge $badge"> Badge “$badge”</h2>
al@1095 1624
al@1095 1625 <table>
al@1095 1626 <thead><tr><th>Name</th><th>Description</th><th>Category</th></tr></thead>
al@1095 1627 <tbody>
al@1095 1628 EOT
al@1095 1629
al@1095 1630 ls $WOK \
al@1095 1631 | while read pkg; do
al@1095 1632 [ -e $WOK/$pkg/.badges ] || continue
al@1095 1633 grep -q "^${badge}$" $WOK/$pkg/.badges &&
al@1095 1634 awk -F$'\t' -vpkg="$pkg" -vbase="$base/" '{
al@1095 1635 if ($1 == pkg) {
al@1095 1636 url = base $1 "/";
al@1095 1637 gsub("+", "%2B", url);
al@1095 1638 printf("<tr><td><img src=\"%ss/%s\" alt=\"%s\"> ", base, $1, $1);
al@1095 1639 printf("<a href=\"%s\">%s</a></td><td>%s</td><td>%s</td></tr>\n", url, $1, $4, $3);
al@1095 1640 }
al@1095 1641 }' $PKGS/packages-$ARCH.info
al@1095 1642 done
al@1095 1643 ;;
al@1095 1644 esac
al@1090 1645 echo '</tbody></table></section>'
al@1090 1646 else
al@1095 1647 layout='list' show_badges bdbroken broken any noany libtool nolibtool own ownover perm permover symlink ss fadd frem fdup old orphan patch win no-badge
al@1090 1648 fi
al@1090 1649 echo '</div>'
al@1007 1650 page_footer
al@1007 1651 exit 0
al@1007 1652 fi
al@1007 1653
al@1007 1654
al@898 1655 case "$cmd" in
al@898 1656 '')
al@898 1657 page_header
al@898 1658
al@989 1659 requested_pkg="$pkg"
al@898 1660 # Package info.
al@940 1661 if [ ! -f "$wok/$pkg/receipt" ]; then
al@940 1662 # Let's look at the cases when the package was not found
al@940 1663
al@940 1664 # Maybe query is the exact name of split package? -> proceed to main package
al@940 1665 mainpkg=$(awk -F$'\t' -vpkg=" $pkg " '{
al@940 1666 if (index(" " $2 " ", pkg)) {print $1; exit}
al@940 1667 }' $splitdb)
al@940 1668
al@940 1669 # No, so let's find any matches among packages names (both main and split)
al@940 1670 if [ -z "$mainpkg" ]; then
al@940 1671 pkgs=$(cut -d$'\t' -f2 $splitdb | tr ' ' '\n' | fgrep "$pkg")
al@940 1672 # Nothing matched
al@940 1673 if [ -z "$pkgs" ]; then
al@940 1674 echo "<h2>Not Found</h2>"
al@940 1675 show_note e "The requested package <b>$pkg</b> was not found on this server."
al@940 1676 page_footer; exit 0
al@940 1677 fi
al@940 1678 # Search results page
al@898 1679 echo "<section><h2>Package names matching “$pkg”</h2>"
al@898 1680 echo "<table><thead><tr><th>Name</th><th>Description</th><th>Category</th></tr></thead><tbody>"
al@940 1681 query="$pkg"
al@940 1682 for pkg in $pkgs; do
al@940 1683 # Find main package
al@940 1684 mainpkg=$(awk -F$'\t' -vpkg=" $pkg " '{
al@940 1685 if (index(" " $2 " ", pkg)) {print $1; exit}
al@940 1686 }' $splitdb)
al@940 1687 unset SHORT_DESC CATEGORY; . $wok/$mainpkg/receipt
al@940 1688
al@898 1689 unset SHORT_DESC CATEGORY
al@940 1690 [ -e "$wok/$mainpkg/taz/$PACKAGE-$VERSION/receipt" ] &&
al@940 1691 . $wok/$mainpkg/taz/$PACKAGE-$VERSION/receipt
al@940 1692
al@940 1693 echo -n "<tr><td><a href="$base/$pkg">${pkg//$query/<mark>$query</mark>}</a>"
al@940 1694 [ "$pkg" == "$mainpkg" ] || echo -n " (${mainpkg//$query/<mark>$query</mark>})"
al@940 1695 echo -n "</td><td>$SHORT_DESC</td><td>$CATEGORY</td></tr>"
al@898 1696 done
al@898 1697 echo '</tbody></table></section>'
al@940 1698 page_footer; exit 0
al@898 1699 fi
al@940 1700 pkg="$mainpkg"
al@898 1701 fi
al@898 1702
al@940 1703 log=$LOGS/$pkg.log
al@940 1704 pkg_info
al@940 1705
al@898 1706 # Check for a log file and display summary if it exists.
al@898 1707 summary "$log"
al@898 1708
al@994 1709
al@1090 1710 # Show Cooker badges
al@1090 1711 if [ -s $wok/$pkg/.badges ]; then
al@1090 1712 layout='table' show_badges $(cat $wok/$pkg/.badges)
al@1090 1713 fi
al@1090 1714
al@1090 1715
al@1080 1716 # Repology badge
al@1090 1717 [ "$REPOLOGY" == '-' ] || cat <<-EOT
al@1090 1718 <section>
al@1090 1719 <h3>Repology</h3>
al@1090 1720 <a href="https://repology.org/metapackage/${REPOLOGY:-$pkg}" target='_blank'
al@1090 1721 rel='noopener noreferrer' title="latest packaged version(s) by Repology">
al@1090 1722 <img src="https://repology.org/badge/latest-versions/${REPOLOGY:-$pkg}.svg" alt="latest packaged version(s)">
al@1090 1723 <img src="https://repology.org/badge/tiny-repos/${REPOLOGY:-$pkg}.svg" alt="Packaging status">
al@1090 1724 </a>
al@1090 1725 </section>
al@1090 1726 EOT
al@1080 1727
al@1080 1728
al@1007 1729 # Show tag list
al@1007 1730 taglist=$(
al@1007 1731 for i in $pkg $(awk -F$'\t' -vp="$pkg" '{if ($1 == p) print $2}' $splitdb); do
al@1096 1732 [ -s "$PKGS/packages-$ARCH.info" ] &&
al@1007 1733 awk -F$'\t' -vpkg="$i" '{
al@1007 1734 if ($1 == pkg) { print $6; exit; }
al@1096 1735 }' "$PKGS/packages-$ARCH.info"
al@1007 1736 done \
al@1007 1737 | tr ' ' '\n' \
al@1007 1738 | sort -u
al@1007 1739 )
al@1007 1740 if [ -n "$taglist" ]; then
al@1007 1741 echo -n '<section><h3>Tags</h3><p>'
al@1007 1742 lasttag=$(echo "$taglist" | tail -n1)
al@1007 1743 for tag in $taglist; do
al@1007 1744 echo -n "<a href=\"$base/~/${tag//+/%2B}\">$tag</a>"
al@1007 1745 [ "$tag" != "$lasttag" ] && echo -n " · "
al@1007 1746 done
al@1007 1747 echo '</p></section>'
al@1007 1748 fi
al@994 1749
al@994 1750
al@1007 1751 # Informational table with dependencies
al@989 1752 pkg="$requested_pkg"
al@994 1753 inf="$(mktemp -d)"
al@994 1754
al@995 1755 # 1/3: Build dependencies (from receipt and pkgdb)
al@997 1756 for i in $WANTED $BUILD_DEPENDS $(awk -F$'\t' -vp=" $pkg " '{if (index(" " $2 " ", p) && (" " $1 " " != p)) print $1}' $splitdb); do
al@994 1757 echo "$i" >> $inf/a
al@994 1758 done
al@994 1759
al@994 1760 # 2/3: Runtime dependencies (from pkgdb)
al@994 1761 {
al@1096 1762 [ -s "$PKGS/packages-$ARCH.info" ] &&
al@994 1763 awk -F$'\t' -vp="$pkg" '{
al@994 1764 if ($1 == p) print $8
al@1096 1765 }' "$PKGS/packages-$ARCH.info"
al@994 1766 } | tr ' ' '\n' | sort -u > $inf/b
al@994 1767
al@994 1768 # 3/3: Required by (from pkgdb)
al@994 1769 {
al@995 1770 for i in $pkg $(awk -F$'\t' -vp="$pkg" '{if ($1 == p) print $2}' $splitdb); do
al@1096 1771 [ -s "$PKGS/packages-$ARCH.info" ] &&
al@994 1772 awk -F$'\t' -vp=" $i " '{
al@994 1773 if (index(" " $8 " ", p)) print $1
al@1096 1774 }' "$PKGS/packages-$ARCH.info"
al@994 1775
al@994 1776 [ -s "$PKGS/bdeps.txt" ] &&
al@994 1777 awk -F$'\t' -vp=" $i " '{
al@994 1778 if (index(" " $2 " ", p)) print $1
al@994 1779 }' $PKGS/bdeps.txt
al@994 1780 done
al@994 1781 } | sort -u > $inf/c
al@994 1782
al@1090 1783 cat <<-EOT
al@1090 1784 <section>
al@1090 1785 <h3>Related packages</h3>
al@1090 1786 <table class="third">
al@1090 1787 <thead>
al@1090 1788 <tr>
al@1090 1789 <th>Build dependencies</th>
al@1090 1790 <th>Runtime dependencies</th>
al@1090 1791 <th>Required by</th>
al@1090 1792 </tr>
al@1090 1793 </thead>
al@1090 1794 <tbody>
al@1090 1795 EOT
al@989 1796
al@994 1797 awk -vinf="$inf" -vbase="$base" '
al@994 1798 function linki(i) {
al@1090 1799 if (i) return sprintf("<img src=\"%s/s/%s\" alt=\"%s\"> <a href=\"%s/%s\">%s</a>", base, i, i, base, i, i);
al@994 1800 }
al@994 1801 BEGIN{
al@994 1802 do {
al@994 1803 a = b = c = "";
al@994 1804 getline a < inf "/a";
al@994 1805 getline b < inf "/b";
al@994 1806 getline c < inf "/c";
al@994 1807 printf("<tr><td>%s </td><td>%s </td><td>%s </td></tr>", linki(a), linki(b), linki(c));
al@994 1808 } while ( a b c )
al@994 1809 }'
al@1090 1810 cat <<-EOT
al@1090 1811 </tbody>
al@1090 1812 </table>
al@1090 1813 </section>
al@1090 1814 EOT
al@994 1815 # Clean
al@994 1816 rm -r $inf
al@994 1817
al@994 1818
al@994 1819
al@982 1820
al@898 1821 # Display <Recook> button only for SliTaz web browser
al@971 1822 case "$HTTP_USER_AGENT" in
al@971 1823 *SliTaz*)
al@971 1824 if [ -f $CACHE/cooker-request -a -n "$HTTP_REFERER" ]; then
al@971 1825 if grep -qs "^$pkg$" $CACHE/recook-packages; then
al@971 1826 show_note i "The package “$pkg” has been requested for recook"
al@971 1827 else
al@971 1828 echo "<a class='button' href='$base/?recook=${pkg//+/%2B}'>Recook $pkg</a>"
al@898 1829 fi
al@971 1830 fi
al@971 1831 ;;
al@971 1832 esac
al@898 1833 ;;
al@898 1834
al@898 1835 receipt)
al@898 1836 page_header
al@898 1837 pkg_info
al@898 1838 echo "<a class='button receipt' href='$base/$pkg/receipt'>receipt</a>"
al@898 1839 ( cd $wok/$pkg; find stuff -type f 2>/dev/null ) | sort | \
al@898 1840 awk -vb="$base/$pkg" '{printf("<a class=\"button\" href=\"%s/%s\">%s</a>\n", b, $0, $0)}'
al@898 1841
al@898 1842 show_code bash < $wok/$pkg/receipt
al@898 1843 ;;
al@898 1844
al@898 1845 stuff)
al@898 1846 page_header
al@898 1847 pkg_info
al@898 1848 file="$pkg/stuff/$arg"
al@898 1849 echo "<a class='button' href='$base/$pkg/receipt'>receipt</a>"
al@898 1850 ( cd $wok/$pkg; find stuff -type f 2>/dev/null ) | sort | \
al@898 1851 awk -vb="$base/$pkg" -va="stuff/$arg" '{
al@898 1852 printf("<a class=\"button%s\" href=\"%s/%s\">%s</a>\n", a==$0 ? " receipt" : "", b, $0, $0)
al@898 1853 }'
al@898 1854
al@898 1855 if [ -f "$wok/$file" ]; then
al@898 1856 case $file in
al@898 1857 *.desktop|*.theme) class="ini" ;;
al@898 1858 *.patch|*.diff|*.u) class="diff" ;;
al@1090 1859 */patches/series) class="bash";;
al@898 1860 *.sh) class="bash" ;;
al@898 1861 *.conf*|*.ini)
al@898 1862 class="bash"
al@898 1863 [ -n "$(cut -c1 < $wok/$file | fgrep '[')" ] && class="ini"
al@898 1864 ;;
al@898 1865 *.pl) class="perl" ;;
al@898 1866 *.c|*.h|*.awk) class="clike" ;;
al@898 1867 *.svg) class="svg" ;;
al@898 1868 *Makefile*) class="makefile" ;;
al@898 1869 *.po|*.pot) class="bash" ;;
al@898 1870 *.css) class="css" ;;
al@898 1871 *.htm|*.html) class="html" ;;
al@898 1872 *.js) class="js" ;;
al@898 1873 *.txt) class="asciidoc" ;;
al@898 1874 *)
al@898 1875 case $(head -n1 $wok/$file) in
al@898 1876 *!/bin/sh*|*!/bin/bash*) class="bash" ;;
al@898 1877 esac
al@898 1878 if [ -z "$class" -a "$(head -n1 $wok/$file | cut -b1)" == '#' ]; then
al@898 1879 class="bash"
al@898 1880 fi
al@898 1881 if [ -z "$class" ]; then
al@898 1882 # Follow Busybox restrictions. Search for non-printable chars
al@898 1883 if [ $(tr -d '[:alnum:][:punct:][:blank:][:cntrl:]' < "$wok/$file" | wc -c) -gt 0 ]; then
al@898 1884 raw="true"
al@898 1885 fi
al@898 1886 fi
al@898 1887 ;;
al@898 1888 esac
al@898 1889
al@898 1890 # Display image
al@898 1891 case $file in
al@898 1892 *.png|*.svg|*.jpg|*.jpeg|*.ico)
al@1090 1893 echo "<img src='$base/$pkg/browse/stuff/$arg' style='display: block; max-width: 100%; margin: auto' alt=''/>"
al@898 1894 ;;
al@898 1895 esac
al@898 1896
al@898 1897 # Display colored listing for all text-based documents (also for *.svg)
al@898 1898 case $file in
al@898 1899 *.png|*.jpg|*.jpeg|*.ico) ;;
al@898 1900 *)
al@898 1901 if [ -z "$raw" ]; then
al@898 1902 cat $wok/$file | show_code $class
al@898 1903 fi
al@898 1904 ;;
al@898 1905 esac
al@898 1906
al@898 1907 # Display hex dump for binary files
al@898 1908 if [ -n "$raw" ]; then
al@898 1909 hexdump -C $wok/$file | show_code #| sed 's|^\([0-9a-f][0-9a-f]*\)|<span class="c2">\1</span>|'
al@898 1910 fi
al@898 1911 else
al@898 1912 show_note e "File “$file” absent!"
al@898 1913 fi
al@898 1914 ;;
al@898 1915
al@898 1916 files)
al@898 1917 page_header
al@898 1918 pkg_info
al@898 1919
al@898 1920 # find main package
al@898 1921 wanted=$(. $wok/$pkg/receipt; echo $WANTED)
al@898 1922 main=${wanted:-$pkg}
al@1010 1923 devpkg=''; [ -d "$wok/$main-dev" ] && devpkg="$main-dev"
al@915 1924
al@1010 1925 splitsets=$(echo $SPLIT" " \
al@1010 1926 | awk '
al@1010 1927 BEGIN { RS = " "; FS = ":"; }
al@1010 1928 { print $2; }' \
al@1010 1929 | sort -u \
al@1010 1930 | tr '\n' ' ' \
al@1010 1931 | sed 's|^ *||; s| *$||')
al@915 1932
al@1010 1933 splitpkgs=$(echo $SPLIT" " \
al@1010 1934 | awk '
al@1010 1935 BEGIN { RS = " "; FS = ":"; }
al@1010 1936 { print $1; }' \
al@1010 1937 | tr '\n' ' ' \
al@1010 1938 | sed 's|^ *||; s| *$||')
al@1010 1939
al@1010 1940 # we need the version
al@915 1941 if [ -f "$WOK/linux/receipt" ]; then
al@915 1942 kvers=$(. $WOK/linux/receipt; echo $VERSION)
al@915 1943 kbasevers=$(echo $kvers | cut -d. -f1,2)
al@915 1944 elif [ -f "$INSTALLED/linux-api-headers/receipt" ]; then
al@915 1945 kvers=$(. $INSTALLED/linux-api-headers/receipt; echo $VERSION)
al@915 1946 kbasevers=$(echo $kvers | cut -d. -f1,2)
al@915 1947 fi
al@898 1948 ver=$(. $wok/$main/receipt; echo $VERSION$EXTRAVERSION)
al@898 1949
al@1010 1950 echo "<section><h3>Quick jump:</h3>"
al@924 1951
al@924 1952
al@1010 1953 for part in head body; do
al@898 1954
al@1010 1955 for set in '' $splitsets; do
al@1010 1956 pkgsofset=$(echo $SPLIT" " \
al@1010 1957 | awk -vset="$set" -vmain="$main" -vdev="$devpkg" '
al@1010 1958 BEGIN {
al@1010 1959 RS = " "; FS = ":";
al@1010 1960 if (!set) print main;
al@1010 1961 if (!set && dev) print dev;
al@1010 1962 }
al@1010 1963 {
al@1010 1964 if ($2 == set) print $1;
al@1010 1965 }' \
al@1010 1966 | sort -u)
al@898 1967
al@1010 1968 set_description=''
al@1010 1969 [ -n "$splitsets" ] &&
al@1010 1970 case "$set" in
al@1010 1971 '')
al@1010 1972 set_description=' (default set)'
al@1010 1973 set_title='Default set'
al@1010 1974 ;;
al@1010 1975 *)
al@1010 1976 set_description=" (set “$set”)"
al@1010 1977 set_title="Set “$set”"
al@1010 1978 ;;
al@1010 1979 esac
al@898 1980
al@1010 1981 install="$wok/$main/install"
al@1010 1982 [ -n "$set" ] && install="$install-$set"
al@898 1983
al@1010 1984 case $part in
al@1010 1985 head)
al@1010 1986 [ -n "$splitsets" ] &&
al@1010 1987 case "$set" in
al@1010 1988 '') echo "<ul><li>Default set:";;
al@1010 1989 *) echo "<li>Set “$set”:";;
al@1010 1990 esac
al@1010 1991 echo -e '\t<ul>'
al@1010 1992 echo "$pkgsofset" | sed 'p' | xargs printf "\t\t<li><a href='#%s'>%s</a></li>\n"
al@1090 1993 cat <<-EOT
al@1090 1994 <li id='li-repeats$set' style='display:none'>
al@1090 1995 <a href='#repeats$set'>repeatedly packaged files</a></li>
al@1090 1996 <li id='li-empty$set' style='display:none'>
al@1090 1997 <a href='#empty$set'>unpackaged empty folders</a></li>
al@1090 1998 <li id='li-outoftree$set' style='display:none'>
al@1090 1999 <a href='#outoftree$set'>out-of-tree files</a></li>
al@1090 2000 <li id='li-orphans$set' style='display:none'>
al@1090 2001 <a href='#orphans$set'>unpackaged files</a>
al@1090 2002 <span id='orphansTypes$set'></span></li>
al@1090 2003 EOT
al@1010 2004 echo -e '\t</ul>'
al@1010 2005 [ -n "$splitsets" ] && echo "</li>"
al@1010 2006 ;;
al@1010 2007 body)
al@1010 2008 all_files=$(mktemp)
al@1010 2009 cd $install; find ! -type d | sed 's|\.||' > $all_files
al@964 2010
al@1010 2011 # ------------------------------------------------------
al@1010 2012 # Packages content
al@1010 2013 # ------------------------------------------------------
al@1010 2014 packaged=$(mktemp)
al@1010 2015 for p in $pkgsofset; do
al@1058 2016 namever="$(awk -F$'\t' -vp="$p" '{
al@1058 2017 if ($1==p) {printf("%s-%s\n", $1, $2); exit}
al@1090 2018 }' $PKGS/packages-$ARCH.info)"
al@1010 2019 if [ -d "$wok/$p/taz/$p-$ver" ]; then
al@1010 2020 indir=$p
al@1010 2021 elif [ -d "$wok/$main/taz/$p-$ver" ]; then
al@1010 2022 indir=$main
al@1010 2023 fi
al@1010 2024 dir="$wok/$indir/taz/$p-$ver/fs"
al@912 2025
al@1010 2026 size=$(du -hs $dir | awk '{ sub(/\.0/, ""); print $1 }')
al@1010 2027
al@1010 2028 echo
al@1010 2029 echo "<section id='$p'>"
al@1010 2030 echo " <h3>Contents of package “$namever” (${size:-empty}):</h3>"
al@1010 2031 echo ' <pre class="files">'
al@1010 2032 if [ -s "$wok/$indir/taz/$p-$ver/files.list" ]; then
al@1010 2033 echo -en '<span class="underline">permissions·lnk·user ·group · size·date &amp; time ·name\n</span>'
al@1010 2034 cd $dir
al@1010 2035 find . -print0 \
al@1010 2036 | sort -z \
al@1010 2037 | xargs -0 ls -ldp --color=always \
al@1010 2038 | syntax_highlighter files \
al@1010 2039 | sed "s|\([^>]*\)>\.\([^<]*\)\(<.*\)$|\1 href='$base/$indir/browse/taz/$p-$ver/fs\2'>\2\3|;" \
al@1010 2040 | awk 'BEGIN { FS="\""; }
al@1010 2041 { gsub("+", "%2B", $2); print; }'
al@1010 2042 else
al@1010 2043 echo 'No files'
al@1010 2044 fi
al@1010 2045 echo '</pre>'
al@1010 2046 echo '</section>'
al@1010 2047
al@1010 2048 cat $wok/$indir/taz/$p-$ver/files.list >> $packaged
al@1010 2049 done
al@1010 2050 # ------------------------------------------------------
al@1010 2051 # /Packages content
al@1010 2052 # ------------------------------------------------------
al@1010 2053
al@1010 2054 # ------------------------------------------------------
al@1010 2055 # Repeatedly packaged files
al@1010 2056 # ------------------------------------------------------
al@1010 2057 repeats=$(mktemp)
al@1010 2058 sort $packaged | uniq -d > $repeats
al@1010 2059 if [ -s "$repeats" ]; then
al@1090 2060 cat <<-EOT
al@1090 2061
al@1090 2062 <script>document.getElementById('li-repeats$set').style.display = 'list-item'</script>
al@1090 2063 <section id='repeats$set'>
al@1090 2064 <h3>Repeatedly packaged files$set_description:</h3>
al@1090 2065 EOT
al@1010 2066 cd $install
al@1010 2067
al@1010 2068 IFS=$'\n'
al@1010 2069 echo -n ' <pre class="files">'
al@1010 2070 echo -en '<span class="underline">permissions·lnk·user ·group · size·date &amp; time ·name\n</span>'
al@1010 2071 while read i; do
al@1010 2072 find .$i -exec ls -ldp --color=always '{}' \; \
al@1010 2073 | syntax_highlighter files \
al@1010 2074 | sed 's|>\./|>/|'
al@1010 2075 done < $repeats
al@1090 2076 cat <<-EOT
al@1090 2077 </pre>
al@1090 2078 </section>
al@1090 2079 EOT
al@1010 2080 unset IFS
al@1010 2081 fi
al@1010 2082 rm $repeats
al@1010 2083 # ------------------------------------------------------
al@1010 2084 # /Repeatedly packaged files
al@1010 2085 # ------------------------------------------------------
al@1010 2086
al@1010 2087 # ------------------------------------------------------
al@1010 2088 # Unpackaged empty folders
al@1010 2089 # ------------------------------------------------------
al@1010 2090 emptydirs=$(mktemp)
al@1010 2091 cd $install
al@1010 2092 IFS=$'\n'
al@1010 2093 find -type d \
al@1010 2094 | sed 's|\.||' \
al@1010 2095 | while read d; do
al@1055 2096 [ -z "$(ls "$install$d")" ] || continue
al@1055 2097 # empty dir determined by empty `ls`
al@1010 2098 echo $d
al@1010 2099 done \
al@1010 2100 | while read d; do
al@1010 2101 notfound='yes'
al@1010 2102 for p in $(cd $wok/$main/taz; ls); do
al@1010 2103 if [ -d "$wok/$main/taz/$p/fs$d" ]; then
al@1010 2104 notfound=''
al@1010 2105 break
al@1010 2106 fi
al@1010 2107 done
al@1010 2108 [ -n "$notfound" ] &&
al@1010 2109 ls -ldp --color=always .$d \
al@1010 2110 | syntax_highlighter files \
al@1010 2111 | sed 's|>\./|>/|'
al@1010 2112 done > $emptydirs
al@1010 2113 unset IFS
al@1010 2114 if [ -s "$emptydirs" ]; then
al@1090 2115 cat <<-EOT
al@1090 2116
al@1090 2117 <script>document.getElementById('li-empty$set').style.display = 'list-item'</script>
al@1090 2118 <section id='empty$set'>
al@1090 2119 <h3>Unpackaged empty folders$set_description:</h3>
al@1090 2120 EOT
al@1010 2121 echo -n ' <pre class="files">'
al@1010 2122 echo -en '<span class="underline">permissions·lnk·user ·group · size·date &amp; time ·name\n</span>'
al@1010 2123 cat $emptydirs
al@1090 2124 cat <<-EOT
al@1090 2125 </pre>
al@1090 2126 </section>
al@1090 2127 EOT
al@1010 2128 fi
al@1010 2129 rm $emptydirs
al@1010 2130 # ------------------------------------------------------
al@1010 2131 # /Unpackaged empty folders
al@1010 2132 # ------------------------------------------------------
al@1010 2133
al@1010 2134 # ------------------------------------------------------
al@1010 2135 # Out-of-tree files
al@1010 2136 # ------------------------------------------------------
al@1010 2137 outoftree=$(mktemp)
al@1010 2138 awk -F$'\n' -vall="$all_files" '
al@1010 2139 {
al@1010 2140 if (FILENAME == all) files_all[$1] = "1";
al@1010 2141 else files_pkg[$1] = "1";
al@1010 2142 }
al@1010 2143 END {
al@1010 2144 for (i in files_pkg) {
al@1010 2145 if (! files_all[i]) print i;
al@1010 2146 }
al@1010 2147 }
al@1010 2148 ' "$all_files" "$packaged" > $outoftree
al@1010 2149
al@1010 2150 if [ -d "$install" -a -s "$outoftree" ]; then
al@1010 2151 echo
al@1010 2152 echo "<script>document.getElementById('li-outoftree$set').style.display = 'list-item'</script>"
al@1010 2153 echo "<section id='outoftree$set'>"
al@1010 2154 echo " <h3>Out-of-tree files$set_description:</h3>"
al@1010 2155 echo -n ' <pre class="files">'
al@1010 2156 echo -en '<span class="underline">permissions·lnk·user ·group · size·date &amp; time ·name\n</span>'
al@1010 2157 IFS=$'\n'
al@1010 2158 while read outoftree_line; do
al@1010 2159 # Find the package out-of-tree file belongs to
al@1010 2160 for i in $pkgsofset; do
al@1010 2161 if grep -q "^$outoftree_line$" $wok/$main/taz/$i-$ver/files.list; then
al@1010 2162 cd $wok/$main/taz/$i-$ver/fs
al@1010 2163 ls -ldp --color=always ".$outoftree_line" \
al@1010 2164 | syntax_highlighter files \
al@1010 2165 | sed "s|\([^>]*\)>\.\([^<]*\)\(<.*\)$|\1 href='$base/$main/browse/taz/$i-$ver/fs\2'>\2\3|;" \
al@1010 2166 | awk 'BEGIN { FS="\""; }
al@1010 2167 { gsub("+", "%2B", $2); print; }'
al@1010 2168 fi
al@1010 2169 done
al@1010 2170 done < $outoftree
al@1010 2171 unset IFS
al@1010 2172 echo '</pre>'
al@1010 2173 echo '</section>'
al@1010 2174 fi
al@1010 2175 rm $outoftree
al@1010 2176 # ------------------------------------------------------
al@1010 2177 # /Out-of-tree files
al@1010 2178 # ------------------------------------------------------
al@1010 2179
al@1010 2180 # ------------------------------------------------------
al@1010 2181 # Unpackaged files
al@1010 2182 # ------------------------------------------------------
al@1010 2183 orphans=$(mktemp)
al@1011 2184 awk -F$'\n' -vall="$all_files" '
al@1010 2185 {
al@1010 2186 if (FILENAME == all) files_all[$1] = "1";
al@1010 2187 else files_pkg[$1] = "1";
al@1010 2188 }
al@1010 2189 END {
al@1010 2190 for (i in files_all) {
al@1010 2191 if (! files_pkg[i]) print i;
al@1010 2192 }
al@1010 2193 }
al@1019 2194 ' "$all_files" "$packaged" | sort > $orphans
al@1010 2195 if [ -d "$install" -a -s "$orphans" ]; then
al@1010 2196 echo
al@1010 2197 echo "<script>document.getElementById('li-orphans$set').style.display = 'list-item'</script>"
al@1010 2198 echo "<section id='orphans$set'>"
al@1010 2199 echo " <h3>Unpackaged files$set_description:</h3>"
al@1010 2200 table=$(mktemp)
al@1010 2201 awk '
al@1010 2202 function tag(text, color) {
al@1010 2203 printf("<span class=\"c%s1\">%s</span> ", color, text);
al@1010 2204 printf("%s\n", $0);
al@1010 2205 }
al@1048 2206 /\/perllocal\.pod$/ || /\/\.packlist$/ ||
al@1048 2207 /\/share\/bash-completion\// || /\/etc\/bash_completion\.d\// ||
al@1048 2208 /\/lib\/systemd\// || /\.pyc$/ || /\.pyo$/ ||
al@1088 2209 /\/fonts\.scale$/ || /\/fonts\.dir$/ || /\.la$/ ||
al@1088 2210 /\/cache\/.*\.gem$/ {
al@1010 2211 tag("---", 0); next }
al@1010 2212 /\.pod$/ { tag("pod", 5); next }
al@1010 2213 /\/share\/man\// { tag("man", 5); next }
al@1010 2214 /\/share\/doc\// || /\/share\/gtk-doc\// || /\/share\/info\// ||
al@1010 2215 /\/share\/devhelp\// { tag("doc", 5); next }
al@1010 2216 /\/share\/icons\// { tag("ico", 2); next }
al@1010 2217 /\/share\/locale\// { tag("loc", 4); next }
al@1042 2218 /\.h$/ || /\.a$/ || /\.pc$/ || /\/bin\/.*-config$/ ||
al@1010 2219 /\/Makefile.*$/ { tag("dev", 3); next }
al@1072 2220 /\/share\/help\// || /\/share\/appdata\// ||
al@1090 2221 /\/share\/metainfo\// || /\/share\/application-registry\// ||
al@1090 2222 /\/share\/mime-info\// || /\/share\/gnome\/help\// || /\/share\/omf\// {
al@1090 2223 tag("gnm", 6); next }
al@1010 2224 { tag("???", 1) }
al@1010 2225 ' "$orphans" > $table
al@1010 2226
al@1010 2227 # Summary table
al@1010 2228 orphans_types='()'
al@1010 2229 for i in head body; do
al@1010 2230 case $i in
al@1010 2231 head) echo -n '<table class="summary"><tr>';;
al@1010 2232 body) echo -n '<th> </th></tr><tr>';;
al@1010 2233 esac
al@1010 2234 for j in '???1' dev3 loc4 ico2 doc5 man5 pod5 gnm6 '---0'; do
al@1010 2235 tag=${j:0:3}; class="c${j:3:1}0"; [ "$class" == 'c00' ] && class='c01'
al@1010 2236 case $i in
al@1010 2237 head) echo -n "<th class='$class'>$tag</th>";;
al@1010 2238 body)
al@1010 2239 tagscount="$(grep ">$tag<" $table | wc -l)"
al@1010 2240 printf '<td>%s</td>' "$tagscount"
al@1010 2241 [ "$tagscount" -gt 0 ] && orphans_types="${orphans_types/)/ $tag)}"
al@1010 2242 ;;
al@1010 2243 esac
al@1010 2244 done
al@1010 2245 done
al@1010 2246 echo '<td> </td></tr></table>'
al@1010 2247 orphans_types="${orphans_types/( /(}"
al@1010 2248 [ "$orphans_types" != '()' ] &&
al@1010 2249 echo "<script>document.getElementById('orphansTypes$set').innerText = '${orphans_types// /, }';</script>"
al@1010 2250
al@1011 2251 suffix=''; [ -n "$set" ] && suffix="-$set"
al@1010 2252 echo -n ' <pre class="files">'
al@1010 2253 echo -en '<span class="underline">tag·permissions·lnk·user ·group · size·date &amp; time ·name\n</span>'
al@1010 2254 IFS=$'\n'
al@1010 2255 while read orphan_line; do
al@1010 2256 echo -n "${orphan_line/span> */span>} "
al@1011 2257 cd $install
al@1010 2258 ls -ldp --color=always ".${orphan_line#*</span> }" \
al@1010 2259 | syntax_highlighter files \
al@1010 2260 | sed "s|\([^>]*\)>\.\([^<]*\)\(<.*\)$|\1 href='$base/$main/browse/install$suffix\2'>\2\3|;" \
al@1010 2261 | awk 'BEGIN { FS="\""; }
al@1010 2262 { gsub("+", "%2B", $2); print; }'
al@1010 2263 done < $table
al@1010 2264 unset IFS
al@1010 2265 echo '</pre>'
al@1010 2266 echo '</section>'
al@1010 2267 rm $table
al@1010 2268 fi
al@1010 2269 rm $orphans
al@1010 2270 # ------------------------------------------------------
al@1010 2271 # /Unpackaged files
al@1010 2272 # ------------------------------------------------------
al@1010 2273
al@1010 2274 rm $all_files $packaged
al@1010 2275 ;;
al@912 2276 esac
al@1010 2277 done # /set
al@912 2278
al@1010 2279 case "$part" in
al@1010 2280 head)
al@1010 2281 [ -n "$splitsets" ] && echo "</ul>"
al@1010 2282 echo "</section>"
al@1010 2283 ;;
al@1010 2284 esac
al@1010 2285 done # /part
al@1010 2286
al@898 2287 ;;
al@898 2288
al@898 2289 description)
al@898 2290 page_header
al@898 2291 pkg_info
al@908 2292 descs="$(ls $WOK/$pkg/description*.txt)"
al@908 2293 if [ -n "$descs" ]; then
al@898 2294 echo '<div id="content2">'
al@908 2295 [ -f "$WOK/$pkg/description.txt" ] && show_desc "$pkg" "$WOK/$pkg/description.txt"
al@908 2296 for i in $descs; do
al@908 2297 case $i in
al@908 2298 */description.txt) continue ;;
al@908 2299 *) package=$(echo $i | cut -d. -f2) ;;
al@908 2300 esac
al@908 2301 show_desc "$package" "$i"
al@908 2302 done
al@898 2303 echo '</div>'
al@898 2304 else
al@898 2305 show_note w "No description of $pkg"
al@898 2306 fi
al@898 2307 ;;
al@898 2308
al@898 2309 log)
al@898 2310 page_header
al@898 2311 pkg_info
al@898 2312 [ -z "$arg" ] && arg=$(stat -c %Y $LOGS/$pkg.log)
al@898 2313
al@898 2314 echo '<div class="btnList">'
al@924 2315 acc='l' # access key for the latest log is 'L'
al@898 2316 while read log; do
al@924 2317 # for all $pkg.log, $pkg.log.0 .. $pkg.log.9, $pkg-pack.log (if any)
al@898 2318 timestamp=$(stat -c %Y $log)
al@898 2319 class=''
al@898 2320 if [ "$arg" == "$timestamp" ]; then
al@898 2321 class=' log'
al@898 2322 logfile="$log"
al@898 2323 fi
al@924 2324 case $log in *-pack.log) acc='p';; esac # access key for the packing log is 'P'
al@898 2325 echo -n "<a class='button$class' data-acc='$acc' accesskey='$acc' href='$base/$pkg/log/$timestamp'>"
al@898 2326 echo "$(stat -c %y $log | cut -d: -f1,2)</a>"
al@898 2327 case $acc in
al@898 2328 l) acc=0;;
al@898 2329 *) acc=$((acc+1));;
al@898 2330 esac
al@898 2331 done <<EOT
al@898 2332 $(find $LOGS -name "$pkg.log*" | sort)
al@924 2333 $(find $LOGS -name "$pkg-pack.log")
al@898 2334 EOT
al@898 2335 echo '</div>'
al@898 2336
al@898 2337 if [ -z "$logfile" ]; then
al@898 2338 show_note e "Requested log is absent"
al@898 2339 page_footer
al@898 2340 exit 0
al@898 2341 fi
al@898 2342
al@898 2343 # Define cook variables for syntax highlighter
al@898 2344 if [ -s "$WOK/$pkg/receipt" ]; then
al@898 2345 . "$WOK/$pkg/receipt"
al@898 2346 _wok='/home/slitaz/wok'
al@898 2347 _src="$_wok/$pkg/source/$PACKAGE-$VERSION"
al@898 2348 _install="$_wok/$pkg/install"
al@898 2349 _fs="$_wok/$pkg/taz/$PACKAGE-$VERSION/fs"
al@898 2350 _stuff="$_wok/$pkg/stuff"
al@898 2351 fi
al@898 2352
al@898 2353 # if [ ! -f "gzlog/$pkg.$arg" ]; then
al@898 2354 # {
al@898 2355 # summary "$logfile" links
al@898 2356 #
al@898 2357 # syntax_highlighter log < $logfile | awk '
al@898 2358 # BEGIN { print "<pre class=\"log\">"; }
al@898 2359 # { printf("<a name=\"l%d\" href=\"#l%d\">%5d</a> %s\n", NR, NR, NR, $0); }
al@898 2360 # END { print "</pre>"; }
al@898 2361 # '
al@898 2362 #
al@898 2363 # page_footer
al@898 2364 # } | gzip > gzlog/$pkg.$arg
al@898 2365 # fi
al@898 2366
al@898 2367 blog=$(basename $logfile)
al@898 2368 summary "$logfile" links
al@898 2369
al@898 2370 # disable next `sed` for the 'like2016' theme
al@898 2371 theme=$(COOKIE theme); theme=${theme:-default}; [ "$theme" != 'like2016' ] && theme=''
al@898 2372 cat $logfile | syntax_highlighter log | \
al@1090 2373 sed -e "/(pkg\/local$theme):/ s|: \([^<]*\)|<img src='$base/i/$blog/\1' alt=''> \1|" | \
al@898 2374 awk '
al@898 2375 BEGIN { print "<pre class=\"log\">"; }
al@972 2376 { printf("<span id=\"l%d\">%s</span><a href=\"#l%d\"></a>\n", NR, $0, NR); }
al@898 2377 END { print "</pre>"; }
al@898 2378 '
al@898 2379 ;;
al@898 2380
al@898 2381
al@898 2382 man|doc|info)
al@898 2383 page_header
al@898 2384 pkg_info
al@898 2385 echo '<div style="max-height: 6.4em; overflow: auto; padding: 0 4px">'
al@898 2386
al@1088 2387 dir="wok/$pkg/install/usr/share/$cmd/"; dir2=''
al@1088 2388 if [ "$cmd" == 'doc' ]; then
al@1088 2389 dir2="wok/$pkg/install/usr/share/gtk-doc/"
al@1088 2390 subdirs="$(ls -p $dir | sed '/\/$/!d')"
al@1088 2391 [ $(echo "$subdirs" | wc -l) -eq 1 ] && dir="$dir$subdirs"
al@1088 2392 if [ -z "$arg" ]; then
al@1088 2393 try=$(for i in $dir $dir2; do find $i -name 'index.htm*'; done | sed q)
al@1088 2394 [ -n "$try" ] && arg="$try"
al@1088 2395 fi
al@898 2396 fi
al@1088 2397
al@898 2398 while read i; do
al@898 2399 [ -s "$i" ] || continue
al@898 2400 case "$i" in
al@898 2401 *.jp*g|*.png|*.gif|*.svg|*.css) continue
al@898 2402 esac
al@1088 2403 i=${i#$dir}; i=${i#$dir2}
al@898 2404 [ -n "$arg" ] || arg="$i"
al@898 2405 class=''; [ "$arg" == "$i" ] && class=" doc"
al@898 2406 case "$cmd" in
al@898 2407 man)
al@898 2408 case $i in
al@898 2409 man*) lang='';;
al@898 2410 *) lang="${i%%/*}: ";;
al@898 2411 esac
al@898 2412 man=$(basename $i .gz)
al@898 2413 echo "<a class='button$class' href='$base/$pkg/man/$i'>$lang${man%.*} (${man##*.})</a>"
al@898 2414 ;;
al@898 2415 doc)
al@1088 2416 echo "<a class='button$class' href='$base/$pkg/doc/$i'>$i</a>"
al@898 2417 ;;
al@898 2418 info)
al@898 2419 info=$(basename $i)
al@898 2420 echo "<a class='button$class' href='$base/$pkg/info/$i#Top'>${info/.info/}</a>"
al@898 2421 ;;
al@898 2422 esac
al@898 2423 done <<EOT
al@1088 2424 $(for i in $dir $dir2; do find $i -type f; done | sort)
al@898 2425 EOT
al@898 2426 echo '</div>'
al@898 2427
al@898 2428 [ -f "$arg" ] || arg="$dir/$arg"
al@898 2429 if [ -f "$arg" ]; then
al@898 2430 tmp="$(mktemp)"
al@898 2431 docat "$arg" > $tmp
al@898 2432 [ -s "$tmp" ] &&
al@898 2433 case "$cmd" in
al@898 2434 info)
al@898 2435 echo '<div id="content2" class="texinfo"><pre class="first">'
al@898 2436 info2html < "$tmp"
al@898 2437 echo '</pre></div>'
al@898 2438 ;;
al@898 2439 doc)
al@898 2440 case "$arg" in
al@898 2441 *.sgml|*.devhelp2) class='xml';;
al@898 2442 *.py) class='python';; # pycurl package
al@898 2443 *.css) class='css';;
al@976 2444 *.sh) class='bash';;
al@1088 2445 *.rb|*/Rakefile*|*/Gemfile*) class='ruby';;
al@1088 2446 *.rdoc) class='asciidoc';;
al@976 2447 *)
al@976 2448 first=$(head -n1 "$tmp")
al@976 2449 if [ "${first:0:1}" == '#' ]; then
al@976 2450 class='bash' # first line begins with '#'
al@976 2451 else
al@976 2452 class='asciidoc'
al@976 2453 fi;;
al@898 2454 esac
al@898 2455 case "$arg" in
al@898 2456 *.htm*)
al@898 2457 case $arg in
al@898 2458 wok/*) page="${arg#wok/}"; page="$base/$pkg/browse/${page#*/}";;
al@898 2459 *) page="$base/$pkg/browse/install/usr/share/$cmd/$arg";;
al@898 2460 esac
paul@929 2461 # make the iframe height so long to contain its contents without scrollbar
al@898 2462 echo "<iframe id='idoc' src='$page' width='100%' onload='resizeIframe(this)'></iframe>"
al@898 2463 ;;
al@898 2464 *.pdf)
al@898 2465 case $arg in
al@898 2466 wok/*) page="${arg#wok/}"; page="$base/$pkg/browse/${page#*/}";;
al@898 2467 *) page="$base/$pkg/browse/install/usr/share/$cmd/$arg";;
al@898 2468 esac
al@1090 2469 cat <<-EOT
al@1090 2470 <object id="idoc" data="$page" width="100%" height="100%" type="application/pdf" style="min-height: 600px">
al@1090 2471 $(show_note w "Missing PDF plugin.<br/>Get the file <a href="$page">$(basename "$page")</a>.")
al@1090 2472 </object>
al@1090 2473 EOT
al@898 2474 ;;
al@958 2475 *.md|*.markdown)
al@1090 2476 echo '<section class="markdown">'
al@1088 2477 $md2html "$tmp" | sed 's|class="|class="language-|g'
al@958 2478 echo '</section>'
al@958 2479 ;;
al@898 2480 *)
al@898 2481 show_code $class < "$tmp"
al@898 2482 ;;
al@898 2483 esac
al@898 2484 ;;
al@898 2485 man)
al@898 2486 #export TEXTDOMAIN='man2html'
al@898 2487 echo "<div id='content2'>"
al@898 2488
al@1002 2489 html=$(./man2html.bin "$tmp" | sed -e '1,/<header>/d' -e '/<footer>/,$d' \
al@898 2490 -e 's|<a href="file:///[^>]*>\([^<]*\)</a>|\1|g' \
al@898 2491 -e 's|<a href="?[1-9]\+[^>]*>\([^<]*\)</a>|\1|g')
al@898 2492
al@898 2493 if [ -n "$(echo "$html" | fgrep 'The requested file /tmp/tmp.')" ]; then
al@898 2494 # Process the pre-formatted man-cat page
al@912 2495 # (for example see sudo package without groff in build dependencies)
al@912 2496 sed -i '
al@898 2497 s|M-bM-^@M-^S|—|g;
al@898 2498 s|M-bM-^@M-^\\|<b>|g;
al@898 2499 s|M-bM-^@M-^]|</b>|g
al@898 2500 s|M-bM-^@M-^X|<u>|g;
al@898 2501 s|M-bM-^@M-^Y|</u>|g;
al@898 2502 s|M-BM-||g;
al@912 2503 s|++oo|•|g;
al@912 2504 s|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g;
al@898 2505 ' "$tmp"
al@912 2506 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 2507 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 2508 0 1 2 3 4 5 6 7 8 9 _ - '\\+' '\.' /; do
al@912 2509 sed -i "s|$i$i|<b>$i</b>|g; s|_$i|<u>$i</u>|g" "$tmp"
al@912 2510 done
al@912 2511 echo '<pre class="catman">'
al@912 2512 sed 's|</b><b>||g; s|</u><u>||g; s|</u><b>_</b><u>|_|g; s|</b> <b>| |g;' "$tmp"
al@898 2513 echo '</pre>'
al@898 2514 else
al@898 2515 echo "$html"
al@898 2516 fi
al@898 2517 echo "</div>"
al@898 2518 ;;
al@898 2519 esac
al@898 2520 rm -f $tmp
al@898 2521 else
paul@1006 2522 show_note e "File “$arg” does not exist!"
al@898 2523 fi
al@898 2524 ;;
al@898 2525
al@924 2526 download)
al@924 2527 page_header
al@924 2528 pkg_info
al@924 2529 show=0
al@924 2530
al@924 2531 . $wok/$pkg/receipt
al@924 2532
al@924 2533 if [ -n "$TARBALL" -a -s "$SRC/$TARBALL" ]; then
al@924 2534 files_header
al@1090 2535 echo "<tr><td><a href='$base/src/$TARBALL' class='icon tarball'>$TARBALL</a></td>"
al@924 2536 ls -lh "$SRC/$TARBALL" | awk '{printf("<td>%sB</td>", $5)}'
al@924 2537 echo "<td>Sources for building the package “$pkg”</td></tr>"
al@924 2538 show=1
al@924 2539 fi
al@924 2540
al@924 2541 if [ -d "$wok/$pkg/taz" ]; then
al@924 2542 [ "$show" -eq 1 ] || files_header
al@924 2543
al@1057 2544 common_version=$VERSION
al@1090 2545 for i in $(all_names | tr ' ' '\n' | sort); do
al@1057 2546 [ -e "$wok/$pkg/taz/$i-$common_version$EXTRAVERSION/receipt" ] || continue
al@1057 2547 . $wok/$pkg/taz/$i-$common_version$EXTRAVERSION/receipt
al@924 2548
al@1090 2549 for filename in "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" "$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg" "$PACKAGE-$VERSION$EXTRAVERSION-any.tazpkg"; do
al@1090 2550 [ -f "$PKGS/$filename" ] || continue
al@1090 2551
al@1090 2552 case $filename in
al@1090 2553 *-x86_64.tazpkg) class='pkg64';;
al@1090 2554 *-any.tazpkg) class='pkgany';;
al@1090 2555 *) class='pkg32';;
al@1090 2556 esac
al@1090 2557 cat <<-EOT
al@1090 2558 <tr>
al@1090 2559 <td><a href="$base/get/$filename" class='icon $class'>$filename</a></td>
al@1090 2560 <td>$(ls -lh ./packages/$filename | awk '{printf("%sB", $5)}')</td>
al@1090 2561 <td>$SHORT_DESC</td>
al@1090 2562 </tr>
al@1090 2563 EOT
al@924 2564 done
al@924 2565 done
al@924 2566 show=1
al@924 2567 fi
al@924 2568
al@924 2569 if [ "$show" -eq 1 ]; then
al@924 2570 echo '</tbody></table></section>'
al@924 2571 else
al@924 2572 show_note w "Sorry, there's nothing to download…"
al@924 2573 fi
al@924 2574 ;;
al@924 2575
al@898 2576 esac
al@898 2577
al@898 2578
al@898 2579 page_footer
al@898 2580 exit 0