tazpanel view pkgs.cgi @ rev 195

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