tazpanel view pkgs.cgi @ rev 346
hardware.cgi: add menu shortcut
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Feb 02 14:49:17 2013 +0100 (2013-02-02) |
parents | 3e9acc16f728 |
children | 3b65ee3eb139 |
line source
1 #!/bin/sh
2 #
3 # TazPKG CGI interface - Manage packages via a browser
4 #
5 # This CGI interface extensively uses tazpkg to manage packages and have
6 # its own code for some tasks. Please KISS, it is important and keep speed
7 # in mind. Thanks, Pankso.
8 #
9 # (C) 2011 SliTaz GNU/Linux - BSD License
10 #
12 . lib/libtazpanel
13 get_config
14 header
16 # xHTML 5 header with special side bar for categories.
17 TITLE=$(gettext 'TazPanel - Packages')
18 xhtml_header | sed 's/id="content"/id="content-sidebar"/'
20 pkg_info_link()
21 {
22 echo "$SCRIPT_NAME?info=$1" | sed 's/+/%2B/g'
23 }
25 # We need packages information for list and search
26 parse_packages_desc() {
27 IFS="|"
28 cut -f 1,2,3,5 -d "|" | while read PACKAGE VERSION SHORT_DESC WEB_SITE
29 do
30 image=tazpkg-installed.png
31 [ -d $INSTALLED/${PACKAGE% } ] || image=tazpkg.png
32 cat << EOT
33 <tr>
34 <td><input type="checkbox" name="pkg" value="$PACKAGE">
35 <a href="$(pkg_info_link $PACKAGE)"><img
36 src="$IMAGES/$image"/>$PACKAGE</a></td>
37 <td>$VERSION</td>
38 <td class="desc">$SHORT_DESC</td>
39 <td><a href="$WEB_SITE"><img src="$IMAGES/browser.png"/></a></td>
40 </tr>
41 EOT
42 done
43 unset IFS
44 }
46 # Display a full summary of packages stats
47 packages_summary() {
48 cat << EOT
49 <table class="zebra outbox">
50 <tbody>
51 <tr><td>$(gettext 'Last recharge:')</td>
52 EOT
53 stat=$(stat -c %y $LOCALSTATE/packages.list | \
54 sed 's/\(:..\):.*/\1/' | awk '{print $1}')
55 mtime=$(find $LOCALSTATE/packages.list -mtime +10)
56 echo -n "<td>$stat "
57 if [ "$mtime" ]; then
58 gettext '(Older than 10 days)'; echo
59 else
60 gettext '(Not older than 10 days)'; echo
61 fi
62 cat << EOT
63 </td></tr>
64 <tr><td>$(gettext 'Installed packages:')</td>
65 <td>$(ls $INSTALLED | wc -l)</td></tr>
66 <tr><td>$(gettext 'Mirrored packages:')</td>
67 <td>$(cat $LOCALSTATE/packages.list | wc -l)</td></tr>
68 <tr><td>$(gettext 'Upgradeable packages:')</td>
69 <td>$(cat $LOCALSTATE/packages.up | wc -l)</td></tr>
70 <tr><td>$(gettext 'Installed files:')</td>
71 <td>$(cat $INSTALLED/*/files.list | wc -l)</td></tr>
72 <tr><td>$(gettext 'Blocked packages:')</td>
73 <td>$(cat $LOCALSTATE/blocked-packages.list | wc -l)</td></tr>
74 </tbody>
75 </table>
76 EOT
77 }
79 # Parse mirrors list to be able to have an icon and remove link
80 list_mirrors() {
81 while read line
82 do
83 cat << EOT
84 <li>
85 <a href="$SCRIPT_NAME?admin=rm-mirror=$line&file=$(httpd -e $1)">
86 <img src="$IMAGES/clear.png" title="$(gettext 'Delete')" />
87 </a>
88 <a href="$SCRIPT_NAME?admin=select-mirror&mirror=$line">
89 <img src="$IMAGES/start.png" title="$(gettext 'Use as default')" />
90 </a>
91 <a href="$line">$line</a>
92 </li>
93 EOT
94 done < $1
95 }
97 # Parse repositories list to be able to have an icon and remove link
98 list_repos() {
99 ls $LOCALSTATE/undigest 2> /dev/null | while read repo ; do
100 cat <<EOT
101 <li><a href="$SCRIPT_NAME?admin=rm-repo=$repo">
102 <img src="$IMAGES/clear.png">$repo</a></li>
103 EOT
104 done
105 }
107 #
108 # xHTML functions
109 #
111 # ENTER will search but user may search for a button, so put one.
112 search_form() {
113 [ -n "$repo" ] || repo="$(GET repo)"
114 [ -n "$repo" ] || repo=Any
115 cat << EOT
116 <div class="search">
117 <form method="get" action="$SCRIPT_NAME">
118 <p>
119 <input type="text" name="search" size="20">
120 <input type="submit" value="$(gettext 'Search')">
121 <input class="radius" type="submit" name="files"
122 value="$(gettext 'Files')">
123 <input type="hidden" name="repo" value="$repo" />
124 </p>
125 </form>
126 </div>
127 EOT
128 }
130 table_head() {
131 cat << EOT
132 <thead>
133 <tr>
134 <td>$(gettext 'Name')</td>
135 <td>$(gettext 'Version')</td>
136 <td>$(gettext 'Description')</td>
137 <td>$(gettext 'Web')</td>
138 </tr>
139 </thead>
140 EOT
141 }
143 sidebar() {
144 [ -n "$repo" ] || repo=Public
145 cat << EOT
146 <div id="sidebar">
147 <h4>$(gettext 'Categories')</h4>
148 <a class="active_base-system" href="$SCRIPT_NAME?cat=base-system&repo=$repo">$(gettext 'Base-system')</a>
149 <a class="active_x-window" href="$SCRIPT_NAME?cat=x-window&repo=$repo">$(gettext 'X window')</a>
150 <a class="active_utilities" href="$SCRIPT_NAME?cat=utilities&repo=$repo">$(gettext 'Utilities')</a>
151 <a class="active_network" href="$SCRIPT_NAME?cat=network&repo=$repo">$(gettext 'Network')</a>
152 <a class="active_games" href="$SCRIPT_NAME?cat=games&repo=$repo">$(gettext 'Games')</a>
153 <a class="active_graphics" href="$SCRIPT_NAME?cat=graphics&repo=$repo">$(gettext 'Graphics')</a>
154 <a class="active_office" href="$SCRIPT_NAME?cat=office&repo=$repo">$(gettext 'Office')</a>
155 <a class="active_multimedia" href="$SCRIPT_NAME?cat=multimedia&repo=$repo">$(gettext 'Multimedia')</a>
156 <a class="active_development" href="$SCRIPT_NAME?cat=development&repo=$repo">$(gettext 'Development')</a>
157 <a class="active_system-tools" href="$SCRIPT_NAME?cat=system-tools&repo=$repo">$(gettext 'System tools')</a>
158 <a class="active_security" href="$SCRIPT_NAME?cat=security&repo=$repo">$(gettext 'Security')</a>
159 <a class="active_misc" href="$SCRIPT_NAME?cat=misc&repo=$repo">$(gettext 'Misc')</a>
160 <a class="active_meta" href="$SCRIPT_NAME?cat=meta&repo=$repo">$(gettext 'Meta')</a>
161 <a class="active_non-free" href="$SCRIPT_NAME?cat=non-free&repo=$repo">$(gettext 'Non free')</a>
162 <a class="active_all" href="$SCRIPT_NAME?cat=all&repo=$repo">$(gettext 'All')</a>
163 EOT
165 if [ -d $LOCALSTATE/undigest ]; then
166 [ -n "$category" ] || category="base-system"
167 cat << EOT
168 <h4>$(gettext 'Repositories')</h4>
169 <a class="repo_Public" href="$SCRIPT_NAME?repo=Public&cat=$category">$(gettext 'Public')</a>
170 EOT
171 for i in $(ls $LOCALSTATE/undigest); do
172 cat << EOT
173 <a class="repo_$i" href="$SCRIPT_NAME?repo=$i&cat=$category">$i</a>
174 EOT
175 done
176 cat << EOT
177 <a class="repo_Any" href="$SCRIPT_NAME?repo=Any&cat=$category">$(gettext 'Any')</a>
178 EOT
179 fi
180 echo "</div>"
181 }
183 repo_list() {
184 if [ -n "$(ls $LOCALSTATE/undigest/ 2> /dev/null)" ]; then
185 case "$repo" in
186 Public) ;;
187 ""|Any) for i in $LOCALSTATE/undigest/* ; do
188 [ -d "$i" ] && echo "$i$1"
189 done ;;
190 *) echo "$LOCALSTATE/undigest/$repo$1"
191 return ;;
192 esac
193 fi
194 echo "$LOCALSTATE$1"
195 }
197 repo_name() {
198 case "$1" in
199 $LOCALSTATE) echo "Public" ;;
200 $LOCALSTATE/undigest/*) echo ${1#$LOCALSTATE/undigest/} ;;
201 esac
202 }
204 #
205 # Commands
206 #
208 case " $(GET) " in
209 *\ list\ *)
210 #
211 # List installed packages. This is the default because parsing
212 # the full packages.desc can be long and take up some resources
213 #
214 cd $INSTALLED
215 search_form
216 sidebar
217 LOADING_MSG="$(gettext 'Listing packages...')"
218 loading_msg
219 cat << EOT
220 <h2>$(gettext 'My packages')</h2>
221 <form method='get' action='$SCRIPT_NAME'>
222 <input type="hidden" name="do" value="Remove" />
223 <div id="actions">
224 <div class="float-left">
225 $(gettext 'Selection:')
226 <input type="submit" value="$(gettext 'Remove')" />
227 </div>
228 <div class="float-right">
229 <a class="button" href="$SCRIPT_NAME?recharge">
230 <img src="$IMAGES/recharge.png" />$(gettext 'Recharge list')</a>
231 <a class="button" href='$SCRIPT_NAME?up'>
232 <img src="$IMAGES/update.png" />$(gettext 'Check upgrades')</a>
233 </div>
234 </div>
235 EOT
236 cat << EOT
237 <table class="zebra outbox">
238 $(table_head)
239 <tbody>
240 EOT
241 for pkg in *
242 do
243 . $pkg/receipt
244 echo '<tr>'
245 # Use default tazpkg icon since all packages displayed are
246 # installed
247 colorpkg=$pkg
248 grep -qs "^$pkg$" $LOCALSTATE/blocked-packages.list &&
249 colorpkg="<span style='color: red;'>$pkg</span>"
250 cat << EOT
251 <td class="pkg">
252 <input type="checkbox" name="pkg" value="$pkg" />
253 <a href="$(pkg_info_link $pkg)"><img
254 src="$IMAGES/tazpkg-installed.png"/>$colorpkg</a></td>
255 <td>$VERSION</td>
256 <td class="desc">$SHORT_DESC</td>
257 <td><a href="$WEB_SITE"><img src="$IMAGES/browser.png"/></a></td>
258 </tr>
259 EOT
260 done
261 cat << EOT
262 </tbody>
263 </table>
264 </form>
265 EOT
266 ;;
268 *\ linkable\ *)
269 #
270 # List linkable packages.
271 #
272 cd $INSTALLED
273 search_form
274 sidebar
275 LOADING_MSG=$(gettext 'Listing linkable packages...')
276 loading_msg
277 cat << EOT
278 <h2>$(gettext 'Linkable packages')</h2>
280 <form method='get' action='$SCRIPT_NAME'>
281 <input type="hidden" name="do" value="Link" />
282 <div id="actions">
283 <div class="float-left">
284 $(gettext 'Selection:')
285 <input type="submit" value="$(gettext 'Link')" />
286 </div>
287 <div class="float-right">
288 <a class="button" href="$SCRIPT_NAME?recharge">
289 <img src="$IMAGES/recharge.png" />$(gettext 'Recharge list')</a>
290 <a class="button" href="$SCRIPT_NAME?up">
291 <img src="$IMAGES/update.png" />$(gettext 'Check upgrades')</a>
292 </div>
293 </div>
294 EOT
295 cat << EOT
296 <table class="zebra outbox">
297 $(table_head)
298 <tbody>
299 EOT
300 target=$(readlink $LOCALSTATE/fslink)
301 for pkg in $(ls $target/$INSTALLED)
302 do
303 [ -s $pkg/receipt ] && continue
304 . $target/$INSTALLED/$pkg/receipt
305 cat << EOT
306 <tr>
307 <td class="pkg">
308 <input type="checkbox" name="pkg" value="$pkg" />
309 <a href="$(pkg_info_link $pkg)"><img
310 src="$IMAGES/tazpkg.png"/>$pkg</a>
311 </td>
312 <td>$VERSION</td>
313 <td class="desc">$SHORT_DESC</td>
314 <td><a href="$WEB_SITE"><img src="$IMAGES/browser.png"/></a></td>
315 </tr>
316 EOT
317 done
318 cat << EOT
319 </tbody>
320 </table>
321 </form>
322 EOT
323 ;;
326 *\ cat\ *)
327 #
328 # List all available packages by category on mirror. Listing all
329 # packages is too resource intensive and not useful.
330 #
331 cd $LOCALSTATE
332 repo=$(GET repo)
333 category=$(GET cat)
334 [ "$category" == "cat" ] && category="base-system"
335 grep_category=$category
336 [ "$grep_category" == "all" ] && grep_category=".*"
337 search_form
338 sidebar | sed "s/active_$category/active/;s/repo_$repo/active/"
339 LOADING_MSG="$(gettext 'Listing packages...')"
340 loading_msg
341 cat << EOT
342 <h2>$(eval_gettext 'Category: $category')</h2>
344 <form method='get' action='$SCRIPT_NAME'>
345 <div id="actions">
346 <div class="float-left">
347 $(gettext 'Selection:')
348 <input type="submit" name="do" value="Install" />
349 <input type="submit" name="do" value="Remove" />
350 <input type="hidden" name="repo" value="$repo" />
351 </div>
352 <div class="float-right">
353 <a class="button" href="$SCRIPT_NAME?recharge">
354 <img src="$IMAGES/recharge.png" />$(gettext 'Recharge list')</a>
355 <a class="button" href="$SCRIPT_NAME?up">
356 <img src="$IMAGES/update.png" />$(gettext 'Check upgrades')</a>
357 <a class="button" href='$SCRIPT_NAME?list'>
358 <img src="$IMAGES/tazpkg.png" />$(gettext 'My packages')</a>
359 </div>
360 </div>
361 EOT
362 for i in $(repo_list ""); do
363 if [ "$repo" != "Public" ]; then
364 Repo_Name="$(repo_name $i)"
365 cat << EOT
366 <h3>$(eval_gettext "Repository: \$Repo_Name")</h3>
367 EOT
368 fi
369 cat << EOT
370 <table class="zebra outbox">
371 $(table_head)
372 <tbody>
373 EOT
374 grep "| $grep_category |" $i/packages.desc | \
375 parse_packages_desc
376 cat << EOT
377 </tbody>
378 </table>
379 EOT
380 done
381 echo '</form>' ;;
384 *\ search\ *)
385 #
386 # Search for packages. Here default is to search in packages.desc
387 # and so get result including packages names and descriptions
388 #
389 pkg=$(GET search)
390 repo=$(GET repo)
391 cd $LOCALSTATE
392 search_form
393 sidebar | sed "s/repo_$repo/active/"
394 LOADING_MSG="$(gettext 'Searching packages...')"
395 loading_msg
396 cat << EOT
397 <h2>$(gettext 'Search packages')</h2>
398 <form method="get" action="$SCRIPT_NAME">
399 <div id="actions">
400 <div class="float-left">
401 $(gettext 'Selection:')
402 <input type="submit" name="do" value="Install" />
403 <input type="submit" name="do" value="Remove" />
404 <a href="`cat $PANEL/lib/checkbox.js`">$(gettext 'Toogle all')</a>
405 </div>
406 <div class="float-right">
407 <a class="button" href="$SCRIPT_NAME?recharge">
408 <img src="$IMAGES/recharge.png" />$(gettext 'Recharge list')</a>
409 <a class="button" href="$SCRIPT_NAME?up">
410 <img src="$IMAGES/update.png" />$(gettext 'Check upgrades')</a>
411 <a class="button" href='$SCRIPT_NAME?list'>
412 <img src="$IMAGES/tazpkg.png" />$(gettext 'My packages')</a>
413 </div>
414 </div>
415 <input type="hidden" name="repo" value="$repo" />
417 <table class="zebra outbox">
418 EOT
419 if [ "$(GET files)" ]; then
420 cat <<EOT
421 <thead>
422 <tr>
423 <td>$(gettext 'Package')</td>
424 <td>$(gettext 'File')</td>
425 </tr>
426 <thead>
427 <tbody>
428 EOT
429 unlzma -c $(repo_list /files.list.lzma) \
430 | grep -Ei ": .*$(GET search)" | \
431 while read PACKAGE FILE; do
432 PACKAGE=${PACKAGE%:}
433 image=tazpkg-installed.png
434 [ -d $INSTALLED/$PACKAGE ] || image=tazpkg.png
435 cat << EOT
436 <tr>
437 <td><input type="checkbox" name="pkg" value="$PACKAGE">
438 <a href="$(pkg_info_link $PACKAGE)"><img src="$IMAGES/$image" />$PACKAGE</a></td>
439 <td>$FILE</td>
440 </tr>
441 EOT
442 done
443 else
444 cat << EOT
445 $(table_head)
446 <tbody>
447 EOT
448 grep -ih $pkg $(repo_list /packages.desc) | \
449 parse_packages_desc
450 fi
451 cat << EOT
452 </tbody>
453 </table>
454 </form>
455 EOT
456 ;;
459 *\ recharge\ *)
460 #
461 # Lets recharge the packages list
462 #
463 search_form
464 sidebar
465 LOADING_MSG="$(gettext 'Recharging lists...')"
466 loading_msg
467 cat << EOT
468 <h2>$(gettext 'Recharge')</h2>
470 <form method='get' action='$SCRIPT_NAME'>
471 <div id="actions">
472 <div class="float-left">
473 <p>$(gettext 'Recharge checks for new or updated packages')</p>
474 </div>
475 <div class="float-right">
476 <a class="button" href='$SCRIPT_NAME?up'>
477 <img src="$IMAGES/update.png" />$(gettext 'Check upgrades')</a>
478 <a class="button" href='$SCRIPT_NAME?list'>
479 <img src="$IMAGES/tazpkg.png" />$(gettext 'My packages')</a>
480 </div>
481 </div>
482 <div class="wrapper">
483 <pre>
484 EOT
485 echo $(gettext 'Recharging packages list') | log
486 tazpkg recharge | filter_taztools_msgs
487 cat << EOT
488 </pre>
489 </div>
490 <p>$(gettext "Packages lists are up-to-date. You should check for upgrades \
491 now.")</p>
492 EOT
493 ;;
496 *\ up\ *)
497 #
498 # Upgrade packages
499 #
500 cd $LOCALSTATE
501 search_form
502 sidebar
503 LOADING_MSG="$(gettext 'Checking for upgrades...')"
504 loading_msg
505 cat << EOT
506 <h2>$(gettext 'Up packages')</h2>
508 <form method="get" action="$SCRIPT_NAME">
509 <div id="actions">
510 <div class="float-left">
511 $(gettext 'Selection:')
512 <input type="submit" name="do" value="Install" />
513 <input type="submit" name="do" value="Remove" />
514 <a href="$(cat $PANEL/lib/checkbox.js)">$(gettext 'Toogle all')</a>
515 </div>
516 <div class="float-right">
517 <a class="button" href="$SCRIPT_NAME?recharge">
518 <img src="$IMAGES/recharge.png" />$(gettext 'Recharge list')</a>
519 <a class="button" href="$SCRIPT_NAME?list">
520 <img src="$IMAGES/tazpkg.png" />$(gettext 'My packages')</a>
521 </div>
522 </div>
523 EOT
524 tazpkg up --check >/dev/null
525 cat << EOT
526 <table class="zebra outbox">
527 $(table_head)
528 <tbody>
529 EOT
530 for pkg in `cat packages.up`
531 do
532 grep -hs "^$pkg |" $LOCALSTATE/packages.desc \
533 $LOCALSTATE/undigest/*/packages.desc | \
534 parse_packages_desc
535 done
536 cat << EOT
537 </tbody>
538 </table>
539 </form>
540 EOT
541 ;;
544 *\ do\ *)
545 #
546 # Do an action on one or some packages
547 #
548 opt=""
549 pkgs=""
550 cmdline=$(echo ${QUERY_STRING#do=} | sed s'/&/ /g')
551 cmd=$(echo ${cmdline} | awk '{print $1}')
552 cmdline=${cmdline#*repo=* }
553 pkgs=$(echo $cmdline | sed -e s'/+/ /g' -e s'/pkg=//g' -e s/$cmd//)
554 pkgs="$(httpd -d "$pkgs")"
555 cmd=$(echo $cmd | tr [:upper:] [:lower:])
556 case $cmd in
557 install)
558 cmd=get-install opt=--forced
559 LOADING_MSG="get-installing packages..."
560 ;;
561 link)
562 opt=$(readlink $LOCALSTATE/fslink)
563 LOADING_MSG="linking packages..."
564 ;;
565 esac
566 search_form
567 sidebar
568 loading_msg
569 cat << EOT
570 <h2>Tazpkg: $cmd</h2>
572 <form method="get" action="$SCRIPT_NAME">
573 <div id="actions">
574 <div class="float-left">
575 <p>$(gettext 'Performing tasks on packages')</p>
576 </div>
577 <div class="float-right">
578 <p>
579 <a class="button" href="$SCRIPT_NAME?list">
580 <img src="$IMAGES/tazpkg.png" />$(gettext 'My packages')</a>
581 </p>
582 </div>
583 </div>
584 <div class="box">
585 $(eval_gettext 'Executing $cmd for: $pkgs')
586 </div>
587 EOT
588 for pkg in $pkgs
589 do
590 echo '<pre>'
591 echo $(gettext 'y') | tazpkg $cmd $pkg $opt 2>/dev/null | filter_taztools_msgs
592 echo '</pre>'
593 done ;;
596 *\ info\ *)
597 #
598 # Packages info
599 #
600 pkg=$(GET info)
601 search_form
602 sidebar
603 if [ -d $INSTALLED/$pkg ]; then
604 . $INSTALLED/$pkg/receipt
605 files=`cat $INSTALLED/$pkg/files.list | wc -l`
606 action="Remove"
607 action_i18n=$(gettext 'Remove')
608 else
609 cd $LOCALSTATE
610 LOADING_MSG=$(gettext 'Getting package info...')
611 loading_msg
612 IFS='|'
613 set -- $(grep -hs "^$pkg |" packages.desc \
614 undigest/*/packages.desc)
615 unset IFS
616 PACKAGE=$1
617 VERSION="$(echo $2)"
618 SHORT_DESC="$(echo $3)"
619 CATEGORY="$(echo $4)"
620 WEB_SITE="$(echo $5)"
621 action="Install"
622 action_i18n=$(gettext 'Install')
623 temp="$(echo $pkg | sed 's/get-//g')"
624 fi
625 cat << EOT
626 <h2>$(eval_gettext 'Package $PACKAGE')</h2>
628 <div id="actions">
629 <div class="float-left">
630 <p>
631 EOT
632 if [ "$temp" != "$pkg" -a "$action" == "Install" ]; then
633 temp="$(echo $pkg | sed 's/get-//g')"
634 echo "<a class='button' href='$SCRIPT_NAME?do=Install&$temp'>$(gettext 'Install (Non Free)')</a>"
635 else
636 echo "<a class='button' href='$SCRIPT_NAME?do=$action&$pkg'>$action_i18n</a>"
637 fi
639 if [ -d $INSTALLED/$pkg ]; then
640 if grep -qs "^$pkg$" $LOCALSTATE/blocked-packages.list; then
641 cat << EOT
642 <a class="button" href="$SCRIPT_NAME?do=Unblock&$pkg">$(gettext 'Unblock')</a>
643 EOT
644 else
645 cat << EOT
646 <a class="button" href='$SCRIPT_NAME?do=Block&$pkg'>$(gettext 'Block')</a>
647 EOT
648 fi
649 cat << EOT
650 <a class="button" href='$SCRIPT_NAME?do=Repack&$pkg'>$(gettext 'Repack')</a>
651 EOT
652 fi
653 cat << EOT
654 </p>
655 </div>
656 <div class="float-right">
657 <p>
658 <a class="button" href='$SCRIPT_NAME?list'>
659 <img src="$IMAGES/tazpkg.png" />$(gettext 'My packages')</a>
660 </p>
661 </div>
662 </div>
663 <table class="zebra outbox">
664 <tbody>
665 <tr><td>$(gettext 'Name:')</td><td>$PACKAGE</td></tr>
666 <tr><td>$(gettext 'Version:')</td><td>$VERSION</td></tr>
667 <tr><td>$(gettext 'Description:')</td><td>$SHORT_DESC</td></tr>
668 <tr><td>$(gettext 'Category:')</td><td>$CATEGORY</td></tr>
669 EOT
670 if [ -d $INSTALLED/$pkg ]; then
671 cat << EOT
672 <tr><td>$(gettext 'Maintainer:')</td><td>$MAINTAINER</td></tr>
673 <tr><td>$(gettext 'Website:')</td><td><a href="$WEB_SITE">$WEB_SITE</a></td></tr>
674 <tr><td>$(gettext 'Sizes:')</td><td>$PACKED_SIZE/$UNPACKED_SIZE</td></tr>
675 EOT
676 if [ -n "$DEPENDS" ]; then
677 echo "<tr><td>$(gettext 'Depends:')</td><td>"
678 for i in $DEPENDS; do
679 echo -n "<a href="$(pkg_info_link $i)">$i</a> "
680 done
681 echo "</td></tr>"
682 fi
683 if [ -n "$SUGGESTED" ]; then
684 echo "<tr><td>$(gettext 'Suggested:')</td><td>"
685 for i in $SUGGESTED; do
686 echo -n "<a href="$(pkg_info_link $i)">$i</a> "
687 done
688 echo "</td></tr>"
689 fi
690 [ -n "$TAGS" ] && echo "<tr><td>$(gettext 'Tags:')</td><td>$TAGS</td></tr>"
691 I_FILES=$(cat $INSTALLED/$pkg/files.list | wc -l)
692 cat << EOT
693 </tbody>
694 </table>
696 <p>$(eval_gettext 'Installed files: $I_FILES')</p>
698 <pre>$(cat $INSTALLED/$pkg/files.list)</pre>
699 EOT
700 else
701 cat << EOT
702 <tr><td>$(gettext 'Website:')</td><td><a href="$WEB_SITE">$WEB_SITE</a></td></tr>
703 <tr><td>$(gettext 'Sizes:')</td><td>$(grep -hsA 3 ^$pkg$ packages.txt undigest/*/packages.txt | \
704 tail -n 1 | sed 's/ *//')</td></tr>
705 </table>
707 <p>$(gettext 'Installed files:')</p>
709 <pre>
710 `unlzma -c files.list.lzma undigest/*/files.list.lzma 2> /dev/null | \
711 sed "/^$pkg: /!d;s/^$pkg: //"`
712 </pre>
713 EOT
714 fi
715 ;;
718 *\ admin\ * )
719 #
720 # Tazpkg configuration page
721 #
722 cmd=$(GET admin)
723 case "$cmd" in
724 clean)
725 rm -rf /var/cache/tazpkg/* ;;
726 add-mirror)
727 # Decode url
728 mirror=$(GET mirror)
729 case "$mirror" in
730 http://*|ftp://*)
731 echo "$mirror" >> $(GET file) ;;
732 esac ;;
733 rm-mirror=http://*|rm-mirror=ftp://*)
734 mirror=${cmd#rm-mirror=}
735 sed -i -e "s@$mirror@@" -e '/^$/d' $(GET file) ;;
736 select-mirror*)
737 release=`cat /etc/slitaz-release`
738 mirror="$(GET mirror)packages/$release/"
739 tazpkg setup-mirror $mirror | log
740 ;;
741 add-repo)
742 # Decode url
743 mirror=$(GET mirror)
744 repository=$LOCALSTATE/undigest/$(GET repository)
745 case "$mirror" in
746 http://*|ftp://*)
747 mkdir -p $repository
748 echo "$mirror" > $repository/mirror
749 echo "$mirror" > $repository/mirrors ;;
750 esac ;;
751 rm-repo=*)
752 repository=${cmd#rm-repo=}
753 rm -rf $LOCALSTATE/undigest/$repository ;;
754 esac
755 [ "$cmd" == "$(gettext 'Set link')" ] &&
756 [ -d "$(GET link)/$INSTALLED" ] &&
757 ln -fs $(GET link) $LOCALSTATE/fslink
758 [ "$cmd" == "$(gettext 'Remove link')" ] &&
759 rm -f $LOCALSTATE/fslink
760 cache_files=`find /var/cache/tazpkg -name *.tazpkg | wc -l`
761 cache_size=`du -sh /var/cache/tazpkg`
762 sidebar
763 cat << EOT
764 <h2>$(gettext 'Administration')</h2>
765 <div>
766 <p>$(gettext 'Tazpkg administration and settings')</p>
767 </div>
768 <div id="actions">
769 <a class="button" href='$SCRIPT_NAME?admin=&action=saveconf'>
770 <img src="$IMAGES/tazpkg.png" />$(gettext 'Save configuration')</a>
771 <a class="button" href='$SCRIPT_NAME?admin=&action=listconf'>
772 <img src="$IMAGES/edit.png" />$(gettext 'List configuration files')</a>
773 <a class="button" href='$SCRIPT_NAME?admin=&action=quickcheck'>
774 <img src="$IMAGES/recharge.png" />$(gettext 'Quick check')</a>
775 <a class="button" href='$SCRIPT_NAME?admin=&action=fullcheck'>
776 <img src="$IMAGES/recharge.png" />$(gettext 'Full check')</a>
777 </div>
778 EOT
779 case "$(GET action)" in
780 saveconf)
781 LOADING_MSG=$(gettext 'Creating the package...')
782 loading_msg
783 echo "<pre>"
784 cd $HOME
785 tazpkg repack-config | filter_taztools_msgs
786 echo -n "$(gettext 'Path:') " && ls $HOME/config-*.tazpkg
787 echo "</pre>" ;;
788 listconf)
789 echo "<h4>$(gettext 'Configuration files')</h4>"
790 echo "<ul>"
791 tazpkg list-config | while read file; do
792 [ "${file:0:1}" == "/" ] || continue
793 if [ -e $file ]; then
794 echo "<li><a href=\"index.cgi?file=$file\">$file</a></li>"
795 else
796 echo "<li>$file</li>"
797 fi
798 done
799 echo "</ul>"
800 echo "</pre>" ;;
801 quickcheck)
802 LOADING_MSG=$(gettext 'Checking packages consistency...')
803 loading_msg
804 echo "<pre>"
805 tazpkg check
806 echo "</pre>" ;;
807 fullcheck)
808 LOADING_MSG=$(gettext 'Full packages check...')
809 loading_msg
810 echo "<pre>"
811 tazpkg check --full
812 echo "</pre>" ;;
813 esac
814 cat << EOT
815 <h3>$(gettext 'Packages cache')</h3>
817 <div>
818 <form method="get" action="$SCRIPT_NAME">
819 <p>
820 $(eval_gettext 'Packages in the cache: $cache_files ($cache_size)')
821 <input type="hidden" name="admin" value="clean" />
822 <input type="submit" value="Clean" />
823 </p>
824 </form>
825 </div>
827 <h3>$(gettext 'Default mirror')</h3>
829 <pre>$(cat /var/lib/tazpkg/mirror)</pre>
831 <h3>$(gettext 'Current mirror list')</h3>
832 EOT
833 for i in $LOCALSTATE/mirrors $LOCALSTATE/undigest/*/mirrors; do
834 [ -s $i ] || continue
835 echo '<div class="box">'
836 if [ $i != $LOCALSTATE/mirrors ]; then
837 Repo_Name="$(repo_name $(dirname $i))"
838 echo "<h4>$(eval_gettext 'Repository: $Repo_Name')</h4>"
839 fi
840 echo "<ul>"
841 list_mirrors $i
842 echo "</ul>"
843 cat << EOT
844 </div>
845 <form method="get" action="$SCRIPT_NAME">
846 <p>
847 <input type="hidden" name="admin" value="add-mirror" />
848 <input type="hidden" name="file" value="$i" />
849 <input type="text" name="mirror" size="60">
850 <input type="submit" value="Add mirror" />
851 </p>
852 </form>
853 EOT
854 done
855 echo "<h3>$(gettext 'Private repositories')</h3>"
856 [ -n "$(ls $LOCALSTATE/undigest 2> /dev/null)" ] && cat << EOT
857 <div class="box">
858 <ul>
859 $(list_repos)
860 </ul>
861 </div>
862 EOT
863 cat << EOT
864 <form method="get" action="$SCRIPT_NAME">
865 <p>
866 <input type="hidden" name="admin" value="add-repo" />
867 $(gettext 'Name') <input type="text" name="repository" size="10">
868 $(gettext 'mirror')
869 <input type="text" name="mirror" value="http://" size="50">
870 <input type="submit" value="Add repository" />
871 </p>
872 </form>
874 <h3>$(gettext 'Link to another SliTaz installation')</h3>
876 <p>$(gettext "This link points to the root of another SliTaz installation. \
877 You will be able to install packages using soft links to it.")</p>
879 <form method="get" action="$SCRIPT_NAME">
880 <p>
881 <input type="hidden" name="admin" value="add-link" />
882 <input type="text" name="link"
883 value="$(readlink $LOCALSTATE/fslink 2> /dev/null)" size="50">
884 <input type="submit" name="admin" value="$(gettext 'Set link')" />
885 <input type="submit" name="admin" value="$(gettext 'Remove link')" />
886 </p>
887 </form>
888 EOT
889 version=$(cat /etc/slitaz-release)
890 cat << EOT
892 <h3 id="dvd">$(gettext 'SliTaz packages DVD')</h3>
894 <p>$(eval_gettext "A bootable DVD image of all available packages for the \
895 \$version version is generated every day. It also contains a copy of the \
896 website and can be used without an internet connection. This image can be \
897 installed on a DVD or an USB key.")</p>
899 <div>
900 <form method="post" action='$SCRIPT_NAME?admin&action=dvdimage#dvd'>
901 <p>
902 <a class="button"
903 href='http://mirror.slitaz.org/iso/$version/packages-$version.iso'>
904 <img src="$IMAGES/tazpkg.png" />$(gettext 'Download DVD image')</a>
905 <a class="button" href='$SCRIPT_NAME?admin&action=dvdusbkey#dvd'>
906 <img src="$IMAGES/tazpkg.png" />$(gettext 'Install from DVD/USB key')</a>
907 </p>
908 <div class="box">
909 $(gettext 'Install from ISO image:')
910 <input type="text" name="dvdimage" size="40" value="/root/packages-$version.iso">
911 </div>
912 </form>
913 </div>
914 EOT
915 if [ "$(GET action)" == "dvdimage" ]; then
916 dev=$(POST dvdimage)
917 mkdir -p /mnt/packages 2> /dev/null
918 echo "<pre>"
919 mount -t iso9660 -o loop,ro $dev /mnt/packages &&
920 /mnt/packages/install.sh &&
921 echo "$dev is installed on /mnt/packages"
922 echo "</pre>"
923 fi
924 if [ "$(GET action)" == "dvdusbkey" ]; then
925 mkdir -p /mnt/packages 2> /dev/null
926 for tag in "LABEL=\"packages-$version\" TYPE=\"iso9660\"" \
927 "LABEL=\"sources-$version\" TYPE=\"iso9660\"" ; do
928 dev=$(blkid | grep "$tag" | cut -d: -f1)
929 [ -n "$dev" ] || continue
930 echo "<pre>"
931 mount -t iso9660 -o ro $dev /mnt/packages &&
932 /mnt/packages/install.sh &&
933 echo "$dev is installed on /mnt/packages"
934 echo "</pre>"
935 break
936 done
937 fi
938 ;;
939 *)
940 #
941 # Default to summary
942 #
943 search_form
944 sidebar
945 [ -n "$(GET block)" ] && tazpkg block $(GET block)
946 [ -n "$(GET unblock)" ] && tazpkg unblock $(GET unblock)
947 cat << EOT
948 <h2>$(gettext 'Summary')</h2>
950 <div id="actions">
951 <a class="button" href="$SCRIPT_NAME?list">
952 <img src="$IMAGES/tazpkg.png" />$(gettext 'My packages')</a>
953 EOT
954 fslink=$(readlink $LOCALSTATE/fslink)
955 [ -n "$fslink" -a -d "$fslink/$INSTALLED" ] &&
956 cat << EOT
957 <a class="button" href="$SCRIPT_NAME?linkable">
958 <img src="$IMAGES/tazpkg.png" />$(gettext 'Linkable packages')</a>
959 EOT
960 cat << EOT
961 <a class="button" href="$SCRIPT_NAME?recharge">
962 <img src="$IMAGES/recharge.png" />$(gettext 'Recharge list')</a>
963 <a class="button" href="$SCRIPT_NAME?up">
964 <img src="$IMAGES/update.png" />$(gettext 'Check upgrades')</a>
965 <a class="button" href="$SCRIPT_NAME?admin">
966 <img src="$IMAGES/edit.png" />$(gettext 'Administration')</a>
967 </div>
969 $(packages_summary)
972 <h3>$(gettext 'Latest log entries')</h3>
974 <pre>
975 `tail -n 5 /var/log/tazpkg.log | fgrep "-" | \
976 awk '{print $1, $2, $3, $4, $5, $6, $7}'`
977 </pre>
978 EOT
979 ;;
980 esac
982 # xHTML 5 footer
983 xhtml_footer
984 exit 0