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