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