tazpkg view pkgs.cgi @ rev 700

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