tazpanel view pkgs.cgi @ rev 225

Added tag 1.2.2 for changeset 71b4d133679e
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Sat Feb 18 23:23:38 2012 +0100 (2012-02-18)
parents 0dea654704fb
children ba47fb2fc52a
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="- 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 pkgs="$(httpd -d "$pkgs")"
469 cmd=$(echo $cmd | tr [:upper:] [:lower:])
470 case $cmd in
471 install)
472 cmd=get-install opt=--forced ;;
473 link)
474 opt=$(readlink $LOCALSTATE/fslink) ;;
475 esac
476 search_form
477 sidebar
478 LOADING_MSG="${cmd}ing packages..."
479 loading_msg
480 cat << EOT
481 <h2>Tazpkg: $cmd</h2>
482 <form method="get" action="$SCRIPT_NAME">
483 <div id="actions">
484 <div class="float-left">
485 <p>
486 `gettext "Performing tasks on packages"`
487 </p>
488 </div>
489 <div class="float-right">
490 <p>
491 <a class="button" href='$SCRIPT_NAME?list'>
492 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
493 </p>
494 </div>
495 </div>
496 EOT
497 echo '<div class="box">'
498 gettext "Executing $cmd for:$pkgs"
499 echo '</div>'
500 for pkg in $pkgs
501 do
502 echo '<pre>'
503 echo 'y' | tazpkg $cmd $pkg $opt 2>/dev/null | filter_taztools_msgs
504 echo '</pre>'
505 done ;;
506 *\ info\ *)
507 #
508 # Packages info
509 #
510 pkg=$(GET info)
511 search_form
512 sidebar
513 if [ -d $INSTALLED/$pkg ]; then
514 . $INSTALLED/$pkg/receipt
515 files=`cat $INSTALLED/$pkg/files.list | wc -l`
516 action=$(gettext "Remove")
517 else
518 cd $LOCALSTATE
519 LOADING_MSG=$(gettext "Getting package info...")
520 loading_msg
521 IFS='|'
522 set -- $(grep -hs "^$pkg |" packages.desc \
523 undigest/*/packages.desc)
524 unset IFS
525 PACKAGE=$1
526 VERSION="$(echo $2)"
527 SHORT_DESC="$(echo $3)"
528 CATEGORY="$(echo $4)"
529 WEB_SITE="$(echo $5)"
530 action=$(gettext "Install")
531 fi
532 cat << EOT
533 <h2>`gettext "Package"` $PACKAGE</h2>
534 <div id="actions">
535 <div class="float-left">
536 <p>
537 <a class="button" href='$SCRIPT_NAME?do=$action&$pkg'>$action</a>
538 EOT
539 if [ -d $INSTALLED/$pkg ]; then
540 if grep -qs "^$pkg$" $LOCALSTATE/blocked-packages.list; then
541 block=$(gettext "Unblock")
542 else
543 block=$(gettext "Block")
544 fi
545 cat << EOT
546 <a class="button" href='$SCRIPT_NAME?do=$block&$pkg'>$block</a>
547 <a class="button" href='$SCRIPT_NAME?do=Repack&$pkg'>Repack</a>
548 EOT
549 fi
550 cat << EOT
551 </p>
552 </div>
553 <div class="float-right">
554 <p>
555 <a class="button" href='$SCRIPT_NAME?list'>
556 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
557 </p>
558 </div>
559 </div>
560 <pre>
561 Name : $PACKAGE
562 Version : $VERSION
563 Description : $SHORT_DESC
564 Category : $CATEGORY
565 EOT
566 if [ -d $INSTALLED/$pkg ]; then
567 cat << EOT
568 Maintainer : $MAINTAINER
569 Website : <a href="$WEB_SITE">$WEB_SITE</a>
570 Sizes : $PACKED_SIZE/$UNPACKED_SIZE
571 EOT
572 if [ -n "$DEPENDS" ]; then
573 echo -n "Depends : "
574 for i in $DEPENDS; do
575 echo -n "<a href="$SCRIPT_NAME?info=$i">$i</a> "
576 done
577 echo ""
578 fi
579 if [ -n "$SUGGESTED" ]; then
580 echo -n "Suggested : "
581 for i in $SUGGESTED; do
582 echo -n "<a href="$SCRIPT_NAME?info=$i">$i</a> "
583 done
584 echo ""
585 fi
586 [ -n "$TAGS" ] && echo "Tags : $TAGS"
587 cat << EOT
588 </pre>
590 <p>`gettext "Installed files:"` `cat $INSTALLED/$pkg/files.list | wc -l`</p>
591 <pre>
592 `cat $INSTALLED/$pkg/files.list`
593 </pre>
594 EOT
595 else
596 cat << EOT
597 Website : <a href="$WEB_SITE">$WEB_SITE</a>
598 Sizes : `grep -hsA 3 ^$pkg$ packages.txt undigest/*/packages.txt | \
599 tail -n 1 | sed 's/ *//'`
600 </pre>
602 <p>`gettext "Installed files:"`</p>
603 <pre>
604 `unlzma -c files.list.lzma undigest/*/files.list.lzma 2> /dev/null | \
605 sed "/^$pkg: /!d;s/^$pkg: //"`
606 </pre>
607 EOT
608 fi
609 ;;
610 *\ admin\ * )
611 #
612 # Tazpkg configuration page
613 #
614 cmd=$(GET admin)
615 case "$cmd" in
616 clean)
617 rm -rf /var/cache/tazpkg/* ;;
618 add-mirror)
619 # Decode url
620 mirror=$(GET mirror)
621 case "$mirror" in
622 http://*|ftp://*)
623 echo "$mirror" >> $(GET file) ;;
624 esac ;;
625 rm-mirror=http://*|rm-mirror=ftp://*)
626 mirror=${cmd#rm-mirror=}
627 sed -i -e "s@$mirror@@" -e '/^$/d' $(GET file) ;;
628 add-repo)
629 # Decode url
630 mirror=$(GET mirror)
631 repository=$LOCALSTATE/undigest/$(GET repository)
632 case "$mirror" in
633 http://*|ftp://*)
634 mkdir -p $repository
635 echo "$mirror" > $repository/mirror
636 echo "$mirror" > $repository/mirrors ;;
637 esac ;;
638 rm-repo=*)
639 repository=${cmd#rm-repo=}
640 rm -rf $LOCALSTATE/undigest/$repository ;;
641 esac
642 [ "$cmd" == "$(gettext "Set link")" ] &&
643 [ -d "$(GET link)/$INSTALLED" ] &&
644 ln -fs $(GET link) $LOCALSTATE/fslink
645 [ "$cmd" == "$(gettext "Remove link")" ] &&
646 rm -f $LOCALSTATE/fslink
647 cache_files=`find /var/cache/tazpkg -name *.tazpkg | wc -l`
648 cache_size=`du -sh /var/cache/tazpkg`
649 sidebar
650 cat << EOT
651 <h2>$(gettext "Administration")</h2>
652 <div>
653 <p>$(gettext "Tazpkg administration and settings")</p>
654 </div>
655 <div id="actions">
656 <a class="button" href='$SCRIPT_NAME?admin=&action=saveconf'>
657 <img src="$IMAGES/tazpkg.png" />`gettext "Save configuration"`</a>
658 <a class="button" href='$SCRIPT_NAME?admin=&action=listconf'>
659 <img src="$IMAGES/edit.png" />`gettext "List configuration files"`</a>
660 <a class="button" href='$SCRIPT_NAME?admin=&action=quickcheck'>
661 <img src="$IMAGES/recharge.png" />`gettext "Quick check"`</a>
662 <a class="button" href='$SCRIPT_NAME?admin=&action=fullcheck'>
663 <img src="$IMAGES/recharge.png" />`gettext "Full check"`</a>
664 </div>
665 EOT
666 case "$(GET action)" in
667 saveconf)
668 LOADING_MSG=$(gettext "Creating the package...")
669 loading_msg
670 echo "<pre>"
671 cd $HOME
672 tazpkg repack-config | filter_taztools_msgs
673 gettext "Path : " && ls $HOME/config-*.tazpkg
674 echo "</pre>" ;;
675 listconf)
676 echo "<h4>`gettext "Configuration files"`</h4>"
677 echo "<ul>"
678 tazpkg list-config | while read file; do
679 [ "${file:0:1}" == "/" ] || continue
680 if [ -e $file ]; then
681 echo "<li><a href=\"index.cgi?file=$file\">$file</a></li>"
682 else
683 echo "<li>$file</li>"
684 fi
685 done
686 echo "</ul>"
687 echo "</pre>" ;;
688 quickcheck)
689 LOADING_MSG=$(gettext "Checking packages consistency...")
690 loading_msg
691 echo "<pre>"
692 tazpkg check
693 echo "</pre>" ;;
694 fullcheck)
695 LOADING_MSG=$(gettext "Full packages check...")
696 loading_msg
697 echo "<pre>"
698 tazpkg check --full
699 echo "</pre>" ;;
700 esac
701 cat << EOT
702 <h3>$(gettext "Packages cache")</h3>
703 <div>
704 <form method="get" action="$SCRIPT_NAME">
705 <p>
706 `gettext "Packages in the cache:"` $cache_files ($cache_size)
707 <input type="hidden" name="admin" value="clean" />
708 <input type="submit" value="Clean" />
709 </p>
710 </form>
711 </div>
713 <h3>`gettext "Current mirror list"`</h3>
714 EOT
715 for i in $LOCALSTATE/mirrors $LOCALSTATE/undigest/*/mirrors; do
716 [ -s $i ] || continue
717 echo '<div class="box">'
718 [ $i != $LOCALSTATE/mirrors ] &&
719 echo "<h4>Repository: $(repo_name $(dirname $i))</h4>"
720 echo "<ul>"
721 list_mirrors $i
722 echo "</ul>"
723 cat << EOT
724 </div>
725 <form method="get" action="$SCRIPT_NAME">
726 <p>
727 <input type="hidden" name="admin" value="add-mirror" />
728 <input type="hidden" name="file" value="$i" />
729 <input type="text" name="mirror" size="60">
730 <input type="submit" value="Add mirror" />
731 </p>
732 </form>
733 EOT
734 done
735 echo "<h3>"
736 gettext "Private repositories"
737 echo "</h3>"
738 [ -n "$(ls $LOCALSTATE/undigest 2> /dev/null)" ] && cat << EOT
739 <div class="box">
740 <ul>
741 $(list_repos)
742 </ul>
743 </div>
744 EOT
745 cat << EOT
746 <form method="get" action="$SCRIPT_NAME">
747 <p>
748 <input type="hidden" name="admin" value="add-repo" />
749 Name <input type="text" name="repository" size="10">
750 mirror
751 <input type="text" name="mirror" value="http://" size="50">
752 <input type="submit" value="Add repository" />
753 </p>
754 </form>
755 <h3>`gettext "Link to another SliTaz installation"`</h3>
756 <p>
757 $(gettext "This link points to the root of another SliTaz installation. \
758 You will be able to install packages using soft links to it.")
759 </p>
760 <form method="get" action="$SCRIPT_NAME">
761 <p>
762 <input type="hidden" name="admin" value="add-link" />
763 <input type="text" name="link"
764 value="$(readlink $LOCALSTATE/fslink 2> /dev/null)" size="50">
765 <input type="submit" name="admin" value="$(gettext "Set link")" />
766 <input type="submit" name="admin" value="$(gettext "Remove link")" />
767 </p>
768 </form>
769 EOT
770 version=$(cat /etc/slitaz-release)
771 cat << EOT
773 <a name="dvd"></a>
774 <h3>`gettext "SliTaz packages DVD"`</h3>
775 <p>
776 $(gettext "A bootable DVD image of all available packages for \
777 the $version version is generated every day. It also contains a copy of \
778 the website and can be used without an internet connection. This image can be \
779 installed on a DVD or an USB key.")
780 </p>
781 <div>
782 <form method="post" action='$SCRIPT_NAME?admin&action=dvdimage#dvd'>
783 <p>
784 <a class="button"
785 href='http://mirror.slitaz.org/iso/$version/packages-$version.iso'>
786 <img src="$IMAGES/tazpkg.png" />$(gettext "Download DVD image")</a>
787 <a class="button" href='$SCRIPT_NAME?admin&action=dvdusbkey#dvd'>
788 <img src="$IMAGES/tazpkg.png" />$(gettext "Install from DVD/USB key")</a>
789 </p>
790 <div class="box">
791 $(gettext "Install from ISO image: ")
792 <input type="text" name="dvdimage" size="40" value="/root/packages-$version.iso">
793 </div>
794 </form>
795 </div>
796 EOT
797 if [ "$(GET action)" == "dvdimage" ]; then
798 dev=$(POST dvdimage)
799 mkdir -p /mnt/packages 2> /dev/null
800 echo "<pre>"
801 mount -t iso9660 -o loop,ro $dev /mnt/packages &&
802 /mnt/packages/install.sh &&
803 echo "$dev is installed on /mnt/packages"
804 echo "</pre>"
805 fi
806 if [ "$(GET action)" == "dvdusbkey" ]; then
807 mkdir -p /mnt/packages 2> /dev/null
808 for tag in "LABEL=\"packages-$version\" TYPE=\"iso9660\"" \
809 "LABEL=\"sources-$version\" TYPE=\"iso9660\"" ; do
810 dev=$(blkid | grep "$tag" | cut -d: -f1)
811 [ -n "$dev" ] || continue
812 echo "<pre>"
813 mount -t iso9660 -o ro $dev /mnt/packages &&
814 /mnt/packages/install.sh &&
815 echo "$dev is installed on /mnt/packages"
816 echo "</pre>"
817 break
818 done
819 fi
820 ;;
821 *)
822 #
823 # Default to summary
824 #
825 search_form
826 sidebar
827 [ -n "$(GET block)" ] && tazpkg block $(GET block)
828 [ -n "$(GET unblock)" ] && tazpkg unblock $(GET unblock)
829 cat << EOT
830 <h2>`gettext "Summary"`</h2>
831 <div id="actions">
832 <a class="button" href='$SCRIPT_NAME?list'>
833 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
834 EOT
835 fslink=$(readlink $LOCALSTATE/fslink)
836 [ -n "$fslink" -a -d "$fslink/$INSTALLED" ] &&
837 cat << EOT
838 <a class="button" href='$SCRIPT_NAME?linkable'>
839 <img src="$IMAGES/tazpkg.png" />`gettext "Linkable packages"`</a>
840 EOT
841 cat << EOT
842 <a class="button" href='$SCRIPT_NAME?recharge'>
843 <img src="$IMAGES/recharge.png" />`gettext "Recharge list"`</a>
844 <a class="button" href='$SCRIPT_NAME?up'>
845 <img src="$IMAGES/update.png" />`gettext "Check upgrades"`</a>
846 <a class="button" href='$SCRIPT_NAME?admin'>
847 <img src="$IMAGES/edit.png" />`gettext "Administration"`</a>
848 </div>
849 <pre class="pre-main">
850 `packages_summary`
851 </pre>
853 <h3>`gettext "Latest log entries"`</h3>
854 <pre>
855 `tail -n 5 /var/log/tazpkg.log | fgrep "-" | \
856 awk '{print $1, $2, $3, $4, $5, $6, $7}'`
857 </pre>
858 EOT
859 ;;
860 esac
862 # xHTML 5 footer
863 xhtml_footer
864 exit 0