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