tazpkg view tazpkg @ rev 103

Prepa for release 2.2
author Christophe Lincoln <pankso@slitaz.org>
date Tue Jun 24 21:32:52 2008 +0200 (2008-06-24)
parents 7cfc23ba1a4d
children 8874901b805a
line source
1 #!/bin/sh
2 # Tazpkg - Tiny autonomus zone packages manager.
3 #
4 # This is a lightwight packages manager for *.tazpkg files, all written in
5 # SHell script. It works well with Busybox ash shell and bash. Tazpkg let you
6 # list, install, remove, download or get information about a package, you can
7 # use 'tazpkg usage' to get a list of commands with a short description. Tazpkg
8 # also relolv dependencies and can upgrade packages from a mirror.
9 #
10 # (C) 2007-2008 SliTaz - GNU General Public License v3.
11 #
12 # Authors : Christophe Lincoln <pankso@slitaz.org>
13 # Pascal Bellard <pascal.bellard@slitaz.org>
14 # Eric Joseph-Alexandre <erjo@slitaz.org>
15 #
16 VERSION=2.2
18 ####################
19 # Script variables #
20 ####################
22 # Packages categories.
23 CATEGORIES="
24 base-system
25 utilities
26 network
27 graphics
28 multimedia
29 office
30 development
31 system-tools
32 security
33 games
34 misc
35 meta
36 non-free"
38 # Initialize some variables to use words
39 # rater than numbers for functions and actions.
40 COMMAND=$1
41 if [ -f "$2" ]; then
42 # Set pkg basename for install, extract
43 PACKAGE=$(basename ${2%.tazpkg} 2>/dev/null)
44 else
45 # Pkg name for remove, search and all other cmds
46 PACKAGE=${2%.tazpkg}
47 fi
48 PACKAGE_FILE=$2
49 TARGET_DIR=$3
50 TOP_DIR=`pwd`
51 TMP_DIR=/tmp/tazpkg-$$-$RANDOM
53 # Path to tazpkg used dir and configuration files
54 LOCALSTATE=/var/lib/tazpkg
55 INSTALLED=$LOCALSTATE/installed
56 CACHE_DIR=/var/cache/tazpkg
57 MIRROR=$LOCALSTATE/mirror
58 PACKAGES_LIST=$LOCALSTATE/packages.list
59 BLOCKED=$LOCALSTATE/blocked-packages.list
60 DEFAULT_MIRROR="http://download.tuxfamily.org/slitaz/packages/`cat /etc/slitaz-release`/"
62 # Bold red warnig for upgrade.
63 WARNING="\\033[1;31mWARNING\\033[0;39m"
65 # Check if the directories and files used by Tazpkg
66 # exists. If not and user is root we creat them.
67 if test $(id -u) = 0 ; then
68 if [ ! -d "$CACHE_DIR" ]; then
69 mkdir -p $CACHE_DIR
70 fi
71 if [ ! -d "$INSTALLED" ]; then
72 mkdir -p $INSTALLED
73 fi
74 if [ ! -f "$LOCALSTATE/mirror" ]; then
75 echo "$DEFAULT_MIRROR" > $LOCALSTATE/mirror
76 fi
77 fi
79 ####################
80 # Script functions #
81 ####################
83 # Print the usage.
84 usage ()
85 {
86 echo -e "SliTaz packages manager - Version: $VERSION\n
87 \033[1mUsage:\033[0m tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]
88 tazpkg shell\n
89 \033[1mCommands: \033[0m
90 usage Print this short usage.
91 list List installed packages on the system by category or all.
92 xhtml-list Creates a xHTML list of installed packges.
93 list-mirror List all available packages on the mirror (--diff for new).
94 info Print informations about the package.
95 desc Print description of a package (if it exist).
96 list-files List of files installed with the package.
97 search Search for a package by pattern or name (options: -i|-l|-m).
98 search-file Search for file(s) in all installed packages files.
99 install Install a local (*.tazpkg) package (--forced to force).
100 install-list Install all packages from a list of packages.
101 remove Remove the specified package and all installed files.
102 extract Extract a (*.tazpkg) package into a directory.
103 pack Pack an unpacked or prepared package tree.
104 recharge Recharge your packages.list from the mirror.
105 repack Creates a package archive from an installed package.
106 upgrade Upgrade all installed and listed packages on the mirror.
107 block|unblock Block an installed package version or unblock it for upgrade.
108 get Download a package into the current directory.
109 get-install Download and install a package from the mirror.
110 get-install-list Download and install a list of packages from the mirror.
111 check Verify installed packages concistancy.
112 add-flavor Install the flavor list of packages.
113 install-flavor Install the flavor list of packages and remove other ones.
114 set-release Change release and update packages
115 clean-cache Clean all packages downloaded in cache directory.
116 setup-mirror Change the mirror url configuration.
117 reconfigure Replay post install script from package."
118 }
120 # Status function with color (supported by Ash).
121 status()
122 {
123 local CHECK=$?
124 echo -en "\\033[70G[ "
125 if [ $CHECK = 0 ]; then
126 echo -en "\\033[1;33mOK"
127 else
128 echo -en "\\033[1;31mFailed"
129 fi
130 echo -e "\\033[0;39m ]"
131 return $CHECK
132 }
134 # Check if user is root to install, or remove packages.
135 check_root()
136 {
137 if test $(id -u) != 0 ; then
138 echo -e "\nYou must be root to run `basename $0` with this option."
139 echo -e "Please use 'su' and root password to become super-user.\n"
140 exit 0
141 fi
142 }
144 # Check for a package name on cmdline.
145 check_for_package_on_cmdline()
146 {
147 if [ -z "$PACKAGE" ]; then
148 echo -e "\nPlease specify a package name on the command line.\n"
149 exit 0
150 fi
151 }
153 # Check if the package (*.tazpkg) exist before installing or extracting.
154 check_for_package_file()
155 {
156 if [ ! -f "$PACKAGE_FILE" ]; then
157 echo -e "
158 Unable to find : $PACKAGE_FILE\n"
159 exit 0
160 fi
161 }
163 # Check for the receipt of an installed package.
164 check_for_receipt()
165 {
166 if [ ! -f "$INSTALLED/$PACKAGE/receipt" ]; then
167 echo -e "\nUnable to find the receipt : $INSTALLED/$PACKAGE/receipt\n"
168 exit 0
169 fi
170 }
172 # Check if a package is already installed.
173 check_for_installed_package()
174 {
175 if [ -d "$INSTALLED/${PACKAGE%-[0-9A-Z]*}" ]; then
176 echo -e "
177 $PACKAGE is already installed. You can use the --forced option to force
178 installation or remove it and reinstall.\n"
179 exit 0
180 fi
181 }
183 # Check for packages.list to download and install packages.
184 check_for_packages_list()
185 {
186 if [ ! -f "$LOCALSTATE/packages.list" ]; then
187 if test $(id -u) = 0 ; then
188 tazpkg recharge
189 else
190 echo -e "
191 Unable to find the list : $LOCALSTATE/packages.list\n
192 You must probably run 'tazpkg recharge' as root to get the last list of
193 packages avalaible on the mirror.\n"
194 exit 0
195 fi
196 fi
197 }
199 # Check for a package in packages.list. Used by get and get-install to grep
200 # package basename.
201 check_for_package_in_list()
202 {
203 if grep -q "^$PACKAGE-[0-9A-Z]" $LOCALSTATE/packages.list; then
204 PACKAGE=`grep ^$PACKAGE-[0-9A-Z] $LOCALSTATE/packages.list`
205 else
206 echo -e "\nUnable to find : $PACKAGE in the mirrored packages list.\n"
207 exit 0
208 fi
209 }
211 # Download a file trying all mirrors
212 download()
213 {
214 for i in $(cat $MIRROR); do
215 wget $i$@ && break
216 done
217 }
219 # Extract a package with cpio and gzip.
220 extract_package()
221 {
222 echo -n "Extracting $PACKAGE... "
223 cpio -id < $PACKAGE.tazpkg && rm -f $PACKAGE.tazpkg
224 gzip -d fs.cpio.gz
225 echo -n "Extracting the pseudo fs... "
226 cpio -id < fs.cpio && rm fs.cpio
227 }
229 # This function install a package in the rootfs.
230 install_package()
231 {
232 ROOT=$1
233 if [ -n "$ROOT" ]; then
234 # get absolute path
235 ROOT=$(cd $ROOT; pwd)
236 fi
237 mkdir -p $TMP_DIR
238 echo ""
239 echo -e "\033[1mInstallation of :\033[0m $PACKAGE"
240 echo "================================================================================"
241 echo -n "Copying $PACKAGE... "
242 cp $PACKAGE_FILE $TMP_DIR
243 status
244 cd $TMP_DIR
245 extract_package
246 SELF_INSTALL=0
247 # Include temporary receipt to get the right variables.
248 . $PWD/receipt
249 if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then
250 echo -n "Checking post install dependencies... "
251 [ -d "$INSTALLED/${PACKAGE%-[0-9A-Z]*}" ]
252 if ! status; then
253 echo "Please run 'tazpkg install $PACKAGE_FILE' and retry."
254 cd .. && rm -rf $TMP_DIR
255 exit 1
256 fi
257 fi
258 # Remember modified packages
259 for i in $(grep -v '\[' files.list); do
260 [ -e "$ROOT$i" ] || continue
261 [ -d "$ROOT$i" ] && continue
262 for j in $(grep -l "^$i$" $ROOT$INSTALLED/*/files.list); do
263 [ "$j" = "$ROOT$INSTALLED/$PACKAGE/files.list" ] && continue
264 grep -qs ^$PACKAGE$ $(dirname $j)/modifiers && continue
265 echo "$PACKAGE" >> $(dirname $j)/modifiers
266 done
267 done
268 # Make the installed package data dir to store
269 # the receipt and the files list.
270 mkdir -p $ROOT$INSTALLED/$PACKAGE
271 cp receipt files.list $ROOT$INSTALLED/$PACKAGE
272 # Copy the description if found.
273 if [ -f "description.txt" ]; then
274 cp description.txt $ROOT$INSTALLED/$PACKAGE
275 fi
276 # Pre install commands.
277 if grep -q ^pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then
278 pre_install $ROOT
279 fi
280 echo -n "Installing $PACKAGE... "
281 cp -a fs/* $ROOT/
282 status
283 # Remove the temporary random directory.
284 echo -n "Removing all tmp files... "
285 cd .. && rm -rf $TMP_DIR
286 status
287 # Post install commands.
288 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
289 post_install $ROOT
290 fi
291 cd $TOP_DIR
292 echo "================================================================================"
293 echo "$PACKAGE ($VERSION) is installed."
294 echo ""
295 }
297 # Check for missing deps listed in a receipt packages.
298 check_for_deps()
299 {
300 for i in $DEPENDS
301 do
302 if [ ! -d "$INSTALLED/$i" ]; then
303 MISSING_PACKAGE=$i
304 deps=$(($deps+1))
305 fi
306 done
307 if [ ! "$MISSING_PACKAGE" = "" ]; then
308 echo -e "\033[1mTracking dependencies for :\033[0m $PACKAGE"
309 echo "================================================================================"
310 for i in $DEPENDS
311 do
312 if [ ! -d "$INSTALLED/$i" ]; then
313 MISSING_PACKAGE=$i
314 echo "Missing : $MISSING_PACKAGE"
315 fi
316 done
317 echo "================================================================================"
318 echo "$deps missing package(s) to install."
319 fi
320 }
322 # Install all missing deps. First ask user then install all missing deps
323 # from local dir, cdrom, media or from the mirror. In case we want to
324 # install packages from local, we need a packages.list to find the version.
325 install_deps()
326 {
327 echo ""
328 echo -n "Install all missing dependencies (y/N) ? "; read anser
329 if [ "$anser" = "y" ]; then
330 for pkg in $DEPENDS
331 do
332 if [ ! -d "$INSTALLED/$pkg" ]; then
333 # We can install packages from a local dir by greping
334 # the TAZPKG_BASENAME in the local packages.list.
335 if [ -f "$TOP_DIR/packages.list" ]; then
336 echo "Checking if $pkg exist in local list... "
337 TAZPKG_BASENAME=`grep -e ^$pkg-[0-9A-Z] $TOP_DIR/packages.list`
338 if [ -f "$TAZPKG_BASENAME.tazpkg" ]; then
339 tazpkg install $TAZPKG_BASENAME.tazpkg
340 fi
341 # Install deps from the mirror.
342 else
343 if [ ! -f "$LOCALSTATE/packages.list" ]; then
344 tazpkg recharge
345 fi
346 tazpkg get-install $pkg
347 fi
348 fi
349 done
350 else
351 echo -e "\nLeaving dependencies for $PACKAGE unsolved."
352 echo -e "The package is installed but will probably not work.\n"
353 fi
354 }
356 # xHTML packages list header.
357 xhtml_header()
358 {
359 cat > $XHTML_LIST << _EOT_
360 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
361 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
362 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
363 <head>
364 <title>Installed packages list</title>
365 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
366 <meta name="modified" content="$DATE" />
367 <meta name="generator" content="Tazpkg" />
368 <style type="text/css"><!--
369 body { font: 12px sans-serif, vernada, arial; margin: 0; }
370 #header { background: #f0ba08; color: black; height: 50px;
371 border-top: 1px solid black; border-bottom: 1px solid black; }
372 #content { margin: 0px 50px 26px 50px; }
373 #footer { border-top: 1px solid black; padding-top: 10px;}
374 h1 { margin: 14px 0px 0px 16px; }
375 pre { padding-left: 5px; }
376 hr { color: white; background: white; height: 1px; border: 0; }
377 --></style>
378 </head>
379 <body bgcolor="#ffffff">
380 <div id="header">
381 <h1><font color="#3e1220">Installed packages list</font></h1>
382 </div>
383 <hr />
384 <!-- Start content -->
385 <div id="content">
387 <p>
388 _packages_ packages installed - List generated on : $DATE
389 <p>
391 _EOT_
392 }
394 # xHTML content with packages infos.
395 xhtml_pkg_info()
396 {
397 cat >> $XHTML_LIST << _EOT_
398 <h3>$PACKAGE</h3>
399 <pre>
400 Version : $VERSION
401 Short desc : $SHORT_DESC
402 Web site : <a href="$WEB_SITE">$WEB_SITE</a>
403 </pre>
405 _EOT_
406 }
408 # xHTML packages list footer.
409 xhtml_footer()
410 {
411 cat >> $XHTML_LIST << _EOT_
412 <hr />
413 <p id="footer">
414 $packages packages installed - List generated on : $DATE
415 </p>
417 <!-- End content -->
418 </div>
419 </body>
420 </html>
421 _EOT_
422 }
424 # Search pattern in installed packages.
425 search_in_installed_packages()
426 {
427 echo "Installed packages"
428 echo "================================================================================"
429 list=`ls -1 $INSTALLED | grep -i "$PATTERN"`
430 for pkg in $list
431 do
432 . $INSTALLED/$pkg/receipt
433 echo -n "$PACKAGE "
434 echo -en "\033[24G $VERSION"
435 echo -e "\033[42G $CATEGORY"
436 packages=$(($packages+1))
437 done
438 # Set correct ending messages.
439 if [ "$packages" = "" ]; then
440 echo "0 installed packages found for : $PATTERN"
441 echo ""
442 else
443 echo "================================================================================"
444 echo "$packages installed package(s) found for : $PATTERN"
445 echo ""
446 fi
447 }
449 # Search in packages.list for avalaible pkgs.
450 search_in_packages_list()
451 {
452 echo "Available packages name-version"
453 echo "================================================================================"
454 if [ -f "$LOCALSTATE/packages.list" ]; then
455 cat $LOCALSTATE/packages.list | grep -i "$PATTERN"
456 packages=`cat $LOCALSTATE/packages.list | grep "$PATTERN" | wc -l`
457 else
458 echo -e "
459 No 'packages.list' found to check for mirrored packages. For more results,
460 please run once 'tazpkg recharge' as root before searching.\n"
461 fi
462 if [ "$packages" = "0" ]; then
463 echo "0 available packages found for : $PATTERN"
464 echo ""
465 else
466 echo "================================================================================"
467 echo "$packages available package(s) found for : $PATTERN"
468 echo ""
469 fi
470 }
472 # search --mirror: Search in packages.txt for avalaible pkgs and give more
473 # infos than --list or default.
474 search_in_packages_txt()
475 {
476 echo "Matching packages name with version and desc"
477 echo "================================================================================"
478 if [ -f "$LOCALSTATE/packages.txt" ]; then
479 cat $LOCALSTATE/packages.txt | grep -A 2 "^$PATTERN"
480 packages=`cat $LOCALSTATE/packages.txt | grep -i "^$PATTERN" | wc -l`
481 else
482 echo -e "
483 No 'packages.txt' found to check for mirrored packages. For more results,
484 please run once 'tazpkg recharge' as root before searching.\n"
485 fi
486 if [ "$packages" = "0" ]; then
487 echo "0 available packages found for : $PATTERN"
488 echo ""
489 else
490 echo "================================================================================"
491 echo "$packages available package(s) found for : $PATTERN"
492 echo ""
493 fi
494 }
496 # Install package-list from a flavor
497 install_flavor()
498 {
499 check_root
500 FLAVOR=$1
501 ARG=$2
502 mkdir -p $TMP_DIR
503 [ -f $FLAVOR.flavor ] && cp $FLAVOR.flavor $TMP_DIR
504 cd $TMP_DIR
505 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
506 zcat $FLAVOR.flavor | cpio -i 2>/dev/null
507 while read file; do
508 for pkg in $(ls -d $INSTALLED/${file%%-*}*); do
509 . $pkg/receipt
510 [ "$PACKAGE-$VERSION" = "$file" ] && break
511 done
512 [ "$PACKAGE-$VERSION" = "$file" ] && continue
513 cd $CACHE_DIR
514 download $file.tazpkg
515 cd $TMP_DIR
516 tazpkg install $CACHE_DIR/$file.tazpkg --forced
517 done < $FLAVOR.pkglist
518 [ -f $FLAVOR.nonfree ] && while read pkg; do
519 [ -d $INSTALLED/$pkg ] || continue
520 [ -d $INSTALLED/get-$pkg ] && tazpkg get-install get-$pkg
521 get-$pkg
522 done < $FLAVOR.nonfree
523 [ "$ARG" == "--purge" ] && for pkg in $(ls $INSTALLED); do
524 [ -d $INSTALLED/$pkg ] || continue
525 . $INSTALLED/$pkg/receipt
526 grep -q ^$PACKAGE-$VERSION$ $FLAVOR.pkglist && continue
527 grep -qs ^$PACKAGE$ $FLAVOR.nonfree && continue
528 tazpkg remove $PACKAGE
529 done
530 else
531 echo "Can't find flavor $FLAVOR Abort."
532 fi
533 cd $TOP_DIR
534 rm -rf $TMP_DIR
535 }
537 ###################
538 # Tazpkg commands #
539 ###################
541 case "$COMMAND" in
542 list)
543 # List all installed packages or a specific category.
544 #
545 if [ "$2" = "blocked" ]; then
546 if [ -f $BLOCKED ]; then
547 LIST=`cat $BLOCKED`
548 fi
549 echo ""
550 echo -e "\033[1mBlocked packages\033[0m"
551 echo "================================================================================"
552 if [ -n $LIST ];then
553 echo $LIST
554 echo ""
555 else
556 echo -e "No blocked packages found.\n"
557 fi
558 exit 0
559 fi
560 # Display the list of categories.
561 if [ "$2" = "cat" -o "$2" = "categories" ]; then
562 echo ""
563 echo -e "\033[1mPackages categories :\033[0m"
564 echo "================================================================================"
565 for i in $CATEGORIES
566 do
567 echo $i
568 categories=$(($categories+1))
569 done
570 echo "================================================================================"
571 echo "$categories categories"
572 echo ""
573 exit 0
574 fi
575 # Check for an asked category.
576 if [ -n "$2" ]; then
577 ASKED_CATEGORY=$2
578 echo ""
579 echo -e "\033[1mInstalled packages of category :\033[0m $ASKED_CATEGORY"
580 echo "================================================================================"
581 for pkg in $INSTALLED/*
582 do
583 . $pkg/receipt
584 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
585 echo -n "$PACKAGE"
586 echo -e "\033[24G $VERSION"
587 packages=$(($packages+1))
588 fi
589 done
590 echo "================================================================================"
591 echo -e "$packages packages installed of category $ASKED_CATEGORY."
592 echo ""
593 else
594 # By default list all packages and version.
595 echo ""
596 echo -e "\033[1mList of all installed packages\033[0m"
597 echo "================================================================================"
598 for pkg in $INSTALLED/*
599 do
600 . $pkg/receipt
601 echo -n "$PACKAGE"
602 echo -en "\033[24G $VERSION"
603 echo -e "\033[42G $CATEGORY"
604 packages=$(($packages+1))
605 done
606 echo "================================================================================"
607 echo "$packages packages installed."
608 echo ""
609 fi
610 ;;
611 xhtml-list)
612 # Get infos in receipts and build list.
613 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
614 if [ -n "$2" ]; then
615 XHTML_LIST=$2
616 else
617 XHTML_LIST=installed-packages.html
618 fi
619 echo ""
620 echo -e "\033[1mCreating xHTML list of installed packages\033[0m"
621 echo "================================================================================"
622 echo -n "Generating xHTML header..."
623 xhtml_header
624 status
625 # Packages
626 echo -n "Creating packages informations..."
627 for pkg in $INSTALLED/*
628 do
629 . $pkg/receipt
630 xhtml_pkg_info
631 packages=$(($packages+1))
632 done
633 status
634 echo -n "Generating xHTML footer..."
635 xhtml_footer
636 status
637 # sed pkgs nb in header.
638 sed -i s/'_packages_'/"$packages"/ $XHTML_LIST
639 echo "================================================================================"
640 echo "$XHTML_LIST created - $packages packages."
641 echo ""
642 ;;
643 list-mirror)
644 # List all available packages on the mirror. Option --diff display
645 # last mirrored packages diff (see recharge).
646 check_for_packages_list
647 case $2 in
648 --diff)
649 if [ -f "$LOCALSTATE/packages.diff" ]; then
650 echo ""
651 echo -e "\033[1mMirrored packages diff\033[0m"
652 echo "================================================================================"
653 cat $LOCALSTATE/packages.diff
654 echo "================================================================================"
655 pkgs=`cat $LOCALSTATE/packages.diff | wc -l`
656 echo "$pkgs new packages listed on the mirror."
657 echo ""
658 else
659 echo -e "\nUnable to list anything, no packages.diff found."
660 echo -e "Recharge your current list to creat a first diff.\n"
661 fi && exit 0 ;;
662 --text|--txt)
663 echo ""
664 echo -e "\033[1mList of available packages on the mirror\033[0m"
665 echo "================================================================================"
666 cat $LOCALSTATE/packages.txt ;;
667 --raw|*)
668 echo ""
669 echo -e "\033[1mList of available packages on the mirror\033[0m"
670 echo "================================================================================"
671 cat $LOCALSTATE/packages.list ;;
672 esac
673 echo "================================================================================"
674 pkgs=`cat $LOCALSTATE/packages.list | wc -l`
675 echo "$pkgs packages in the last recharged list."
676 echo ""
677 ;;
678 list-files)
679 # List files installed with the package.
680 #
681 check_for_package_on_cmdline
682 check_for_receipt
683 echo ""
684 echo -e "\033[1mInstalled files with :\033[0m $PACKAGE"
685 echo "================================================================================"
686 cat $INSTALLED/$PACKAGE/files.list | sort
687 echo "================================================================================"
688 files=`cat $INSTALLED/$PACKAGE/files.list | wc -l`
689 echo "$files files installed with $PACKAGE."
690 echo ""
691 ;;
692 info)
693 # Informations about package.
694 #
695 check_for_package_on_cmdline
696 check_for_receipt
697 . $INSTALLED/$PACKAGE/receipt
698 echo ""
699 echo -e "\033[1mTazpkg informations\033[0m
700 ================================================================================
701 Package : $PACKAGE
702 Version : $VERSION
703 Category : $CATEGORY
704 Short desc : $SHORT_DESC
705 Maintainer : $MAINTAINER"
706 if [ ! "$DEPENDS" = "" ]; then
707 echo -e "Depends : $DEPENDS"
708 fi
709 if [ ! "$SUGGESTED" = "" ]; then
710 echo -e "Suggested : $SUGGESTED"
711 fi
712 if [ ! "$BUILD_DEPENDS" = "" ]; then
713 echo -e "Build deps : $BUILD_DEPENDS"
714 fi
715 if [ ! "$WANTED" = "" ]; then
716 echo -e "Wanted src : $WANTED"
717 fi
718 if [ ! "$WEB_SITE" = "" ]; then
719 echo -e "Web site : $WEB_SITE"
720 fi
721 echo "================================================================================"
722 echo ""
723 ;;
724 desc)
725 # Display package description.txt if available.
726 if [ -f "$INSTALLED/$PACKAGE/description.txt" ]; then
727 echo ""
728 echo -e "\033[1mDescription of :\033[0m $PACKAGE"
729 echo "================================================================================"
730 cat $INSTALLED/$PACKAGE/description.txt
731 echo "================================================================================"
732 echo ""
733 else
734 echo -e "\nSorry, no description available for this package.\n"
735 fi
736 ;;
737 search)
738 # Search for a package by pattern or name.
739 #
740 PATTERN="$2"
741 if [ -z "$PATTERN" ]; then
742 echo -e "\nPlease specify a pattern or a package name to search."
743 echo -e "Example : 'tazpkg search paint'.\n"
744 exit 0
745 fi
746 echo ""
747 echo -e "\033[1mSearch result for :\033[0m $PATTERN"
748 echo ""
749 # Default is to search in installed pkgs and the raw list.
750 case $3 in
751 -i|--installed)
752 search_in_installed_packages ;;
753 -l|--list)
754 search_in_packages_list ;;
755 -m|--mirror)
756 search_in_packages_txt ;;
757 *)
758 search_in_installed_packages
759 search_in_packages_list ;;
760 esac
761 ;;
762 search-file)
763 # Search for a file by pattern or name in all files.list.
764 #
765 if [ -z "$2" ]; then
766 echo -e "\nPlease specify a pattern or a file name to search."
767 echo -e "Example : 'tazpkg search-file libnss'. \n"
768 exit 0
769 fi
770 echo ""
771 echo -e "\033[1mSearch result for file :\033[0m $2"
772 echo "================================================================================"
774 if [ "$3" == "--mirror" ]; then
776 unlzma -c $LOCALSTATE/files.list.lzma | grep -- ".*:.*$2" | awk '
777 BEGIN { last="" }
778 {
779 pkg=substr($0,0,index($0,":")-1);
780 file=substr($0,index($0,":")+2);
781 if (last != pkg) {
782 last = pkg;
783 printf("\n%c[1mPackage %s :%c[0m\n",27,pkg,27);
784 }
785 printf("%s\n",file);
786 }'
787 match=`unlzma -c $LOCALSTATE/files.list.lzma | \
788 grep -- ".*:.*$2" | wc -l`
790 else
792 # Check all pkg files.list in search match with specify the package
793 # name and the full path to the file(s).
794 for pkg in $INSTALLED/*
795 do
796 if grep -q "$2" $pkg/files.list; then
797 . $pkg/receipt
798 echo ""
799 echo -e "\033[1mPackage $PACKAGE :\033[0m"
800 grep "$2" $pkg/files.list
801 files=`grep $2 $pkg/files.list | wc -l`
802 match=$(($match+$files))
803 fi
804 done
806 fi
808 if [ "$match" = "" ]; then
809 echo "0 file found for : $2"
810 echo ""
811 else
812 echo ""
813 echo "================================================================================"
814 echo "$match file(s) found for : $2"
815 echo ""
816 fi
817 ;;
818 install)
819 # Install .tazpkg packages.
820 #
821 check_root
822 check_for_package_on_cmdline
823 check_for_package_file
824 # Check if forced install.
825 DO_CHECK="yes"
826 while [ -n "$3" ]; do
827 case "$3" in
828 --forced)
829 DO_CHECK="no"
830 ;;
831 --root=*)
832 install_package ${3#--root=}
833 exit $?
834 ;;
835 *) shift 2
836 echo -e "\nUnknown option $*.\n"
837 exit 1
838 ;;
839 esac
840 shift
841 done
842 if [ "$DO_CHECK" = "yes" ]; then
843 check_for_installed_package
844 fi
845 install_package
846 # Resolv package deps.
847 check_for_deps
848 if [ ! "$MISSING_PACKAGE" = "" ]; then
849 install_deps
850 fi
851 ;;
852 install-list|get-install-list)
853 # Install a set of packages from a list.
854 #
855 check_root
856 if [ -z "$2" ]; then
857 echo -e "
858 Please change directory (cd) to the packages repository, and specify the
859 list of packages to install. Example : tazpkg install-list packages.list\n"
860 exit 0
861 fi
862 # Check if the packages list exist.
863 if [ ! -f "$2" ]; then
864 echo "Unable to find : $2"
865 exit 0
866 else
867 LIST=`cat $2`
868 fi
869 # Set $COMMAND and install all packages.
870 if [ "$1" = "get-install-list" ]; then
871 COMMAND=get-install
872 else
873 COMMAND=install
874 fi
875 for pkg in $LIST
876 do
877 if [ "$3" = "--forced" ]; then
878 tazpkg $COMMAND $pkg --forced
879 else
880 tazpkg $COMMAND $pkg
881 fi
882 done
883 ;;
884 add-flavor)
885 # Install a set of packages from a flavor.
886 #
887 install_flavor $2
888 ;;
889 install-flavor)
890 # Install a set of packages from a flavor and purge other ones.
891 #
892 install_flavor $2 --purge
893 ;;
894 set-release)
895 # Change curent release and upgrade packages.
896 #
897 RELEASE=$2
898 if [ -z "$RELEASE" ]; then
899 echo -e "\nPlease specify the release you want on the command line."
900 echo -e "Example: tazpkg set-release cooking\n"
901 exit 0
902 fi
903 rm /var/lib/tazpkg/mirror
904 echo "$RELEASE" > /etc/slitaz-release
905 tazpkg recharge && tazpkg upgrade
906 ;;
907 remove)
908 # Remove packages.
909 #
910 check_root
911 check_for_package_on_cmdline
912 if [ ! -d "$INSTALLED/$PACKAGE" ]; then
913 echo -e "\n$PACKAGE is not installed.\n"
914 exit 0
915 else
916 ALTERED=""
917 THE_PACKAGE=$PACKAGE # altered by receipt
918 for i in $(cd $INSTALLED ; ls); do
919 DEPENDS=""
920 . $INSTALLED/$i/receipt
921 case " $(echo $DEPENDS) " in
922 *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
923 esac
924 done
925 . $INSTALLED/$THE_PACKAGE/receipt
926 fi
927 echo ""
928 if [ -n "$ALTERED" ]; then
929 echo "The following packages depend on $PACKAGE :"
930 for i in $ALTERED; do
931 echo " $i"
932 done
933 fi
934 echo "Remove $PACKAGE ($VERSION) ?"
935 echo -n "Please confirm uninstallation (y/N) : "; read anser
936 if [ "$anser" = "y" ]; then
937 echo ""
938 echo -e "\033[1mRemoving :\033[0m $PACKAGE"
939 echo "================================================================================"
940 # Pre remove commands.
941 if grep -q ^pre_remove $INSTALLED/$PACKAGE/receipt; then
942 pre_remove
943 fi
944 echo -n "Removing all files installed..."
945 for file in `cat $INSTALLED/$PACKAGE/files.list`
946 do
947 [ $(grep ^$file$ $INSTALLED/*/files.list | wc -l) -gt 1 ] && continue
948 rm -f $file 2>/dev/null
949 done
950 status
951 if grep -q ^post_remove $INSTALLED/$PACKAGE/receipt; then
952 post_remove
953 fi
954 # Remove package receipt.
955 echo -n "Removing package receipt..."
956 rm -rf $INSTALLED/$PACKAGE
957 status
958 if [ -n "$ALTERED" ]; then
959 echo -n "Remove packages depending on $PACKAGE"
960 echo -n " (y/N) ? "; read anser
961 if [ "$anser" = "y" ]; then
962 for i in $ALTERED; do
963 if [ -d "$INSTALLED/$i" ]; then
964 tazpkg remove $i
965 fi
966 done
967 fi
968 fi
969 else
970 echo ""
971 echo "Uninstallation of $PACKAGE cancelled."
972 fi
973 echo ""
974 ;;
975 extract)
976 # Extract .tazpkg cpio archive into a directory.
977 #
978 check_for_package_on_cmdline
979 check_for_package_file
980 echo ""
981 echo -e "\033[1mExtracting :\033[0m $PACKAGE"
982 echo "================================================================================"
983 # If any directory destination is found on the cmdline
984 # we creat one in the current dir using the package name.
985 if [ -n "$TARGET_DIR" ]; then
986 DESTDIR=$TARGET_DIR/$PACKAGE
987 else
988 DESTDIR=$PACKAGE
989 fi
990 mkdir -p $DESTDIR
991 echo -n "Copying original package..."
992 cp $PACKAGE_FILE $DESTDIR
993 status
994 cd $DESTDIR
995 extract_package
996 echo "================================================================================"
997 echo "$PACKAGE is extracted to : $DESTDIR"
998 echo ""
999 ;;
1000 repack)
1001 # Creat SliTaz package archive from an installed package.
1003 check_for_package_on_cmdline
1004 check_for_receipt
1005 eval $(grep ^VERSION= $INSTALLED/$PACKAGE/receipt)
1006 echo ""
1007 echo -e "\033[1mRepacking :\033[0m $PACKAGE-$VERSION.tazpkg"
1008 echo "================================================================================"
1009 if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then
1010 echo "Can't repack $PACKAGE"
1011 exit 1
1012 fi
1013 if [ -s $INSTALLED/$PACKAGE/modifiers ]; then
1014 echo "Can't repack, $PACKAGE files have been modified by:"
1015 for i in $(cat $INSTALLED/$PACKAGE/modifiers); do
1016 echo " $i"
1017 done
1018 exit 1
1019 fi
1020 MISSING=""
1021 while read i; do
1022 [ -e "$i" ] && continue
1023 [ -L "$i" ] || MISSING="$MISSING\n $i"
1024 done < $INSTALLED/$PACKAGE/files.list
1025 if [ -n "$MISSING" ]; then
1026 echo -n "Can't repack, the following files are lost:"
1027 echo -e "$MISSING"
1028 exit 1
1029 fi
1030 mkdir -p $TMP_DIR && cd $TMP_DIR
1031 FILES="fs.cpio.gz\n"
1032 for i in $(ls $INSTALLED/$PACKAGE) ; do
1033 cp $INSTALLED/$PACKAGE/$i . && FILES="$FILES$i\n"
1034 done
1035 ln -s / rootfs
1036 mkdir tmp
1037 sed 's/^/rootfs/' < files.list | cpio -o -H newc 2>/dev/null |\
1038 ( cd tmp ; cpio -id 2>/dev/null )
1039 mv tmp/rootfs fs
1040 find fs | cpio -o -H newc 2> /dev/null | gzip -9 > fs.cpio.gz
1041 echo -e "$FILES" | cpio -o -H newc 2> /dev/null > \
1042 $TOP_DIR/$PACKAGE-$VERSION.tazpkg
1043 cd $TOP_DIR
1044 \rm -R $TMP_DIR
1045 echo "Package $PACKAGE repacked successfully."
1046 echo "Size : `du -sh $PACKAGE-$VERSION.tazpkg`"
1047 echo ""
1048 ;;
1049 pack)
1050 # Creat SliTaz package archive using cpio and gzip.
1052 check_for_package_on_cmdline
1053 cd $PACKAGE
1054 if [ ! -f "receipt" ]; then
1055 echo "Receipt is missing. Please read the documentation."
1056 exit 0
1057 else
1058 echo ""
1059 echo -e "\033[1mPacking :\033[0m $PACKAGE"
1060 echo "================================================================================"
1061 # Creat files.list with redirecting find outpout.
1062 echo -n "Creating the list of files..." && cd fs
1063 find . -type f -print > ../files.list
1064 find . -type l -print >> ../files.list
1065 cd .. && sed -i s/'^.'/''/ files.list
1066 status
1067 # Build cpio archives.
1068 echo -n "Compressing the fs... "
1069 find fs -print | cpio -o -H newc > fs.cpio
1070 gzip fs.cpio && rm -rf fs
1071 echo -n "Creating full cpio archive... "
1072 find . -print | cpio -o -H newc > ../$PACKAGE.tazpkg
1073 echo -n "Restoring original package tree... "
1074 gzip -d fs.cpio.gz && cpio -id < fs.cpio
1075 rm fs.cpio && cd ..
1076 echo "================================================================================"
1077 echo "Package $PACKAGE compressed successfully."
1078 echo "Size : `du -sh $PACKAGE.tazpkg`"
1079 echo ""
1080 fi
1081 ;;
1082 recharge)
1083 # Recharge packages.list from a mirror.
1085 check_root
1086 cd $LOCALSTATE
1087 echo ""
1088 if [ -f "$LOCALSTATE/packages.list" ]; then
1089 echo -n "Creating backup of the last packages list..."
1090 mv -f packages.desc packages.desc.bak 2>/dev/null
1091 mv -f packages.txt packages.txt.bak 2>/dev/null
1092 mv -f packages.list packages.list.bak 2>/dev/null
1093 mv -f files.list.lzma files.list.lzma.bak 2> /dev/nul
1094 status
1095 fi
1096 download packages.desc
1097 download packages.txt
1098 download packages.list
1099 download files.list.lzma
1100 if [ -f "$LOCALSTATE/packages.list.bak" ]; then
1101 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
1102 sed -i s/+// packages.diff
1103 echo ""
1104 echo -e "\033[1mMirrored packages diff\033[0m"
1105 echo "================================================================================"
1106 cat packages.diff
1107 if [ ! "`cat packages.diff | wc -l`" = 0 ]; then
1108 echo "================================================================================"
1109 echo "`cat packages.diff | wc -l` new packages on the mirror."
1110 echo ""
1111 else
1112 echo "`cat packages.diff | wc -l` new packages on the mirror."
1113 echo ""
1114 fi
1115 else
1116 echo -e "
1117 ================================================================================
1118 Last packages.list is ready to use. Note that next time you recharge the list,
1119 a list of differencies will be displayed to show new and upgradable packages.\n"
1120 fi
1121 ;;
1122 upgrade)
1123 # Upgrade all installed packages with the new version from the mirror.
1125 check_root
1126 check_for_packages_list
1127 cd $LOCALSTATE
1128 # Touch the blocked pkgs list to avoid errors and remove any old
1129 # upgrade list.
1130 touch blocked-packages.list
1131 rm -f upradable-packages.list
1132 echo ""
1133 echo -e "\033[1mAvalaible upgrade\033[0m"
1134 echo "================================================================================"
1135 echo ""
1136 # Some packages must be installed first
1137 FIRST_CLASS_PACKAGE=" glibc-base "
1138 FIRST_CLASS=""
1139 for pkg in $INSTALLED/*
1140 do
1141 . $pkg/receipt
1142 # Diplay package name to show that Tazpkg is working...
1143 echo -en "\\033[0G "
1144 echo -en "\\033[0G$PACKAGE"
1145 # Skip specified pkgs listed in $LOCALSTATE/blocked-packages.list
1146 if grep -q "^$PACKAGE" $BLOCKED; then
1147 blocked=$(($blocked+1))
1148 else
1149 # Check if the installed package is in the current list (other
1150 # mirror or local).
1151 if grep -q "^$PACKAGE-[0-9A-Z]" packages.list; then
1152 # Set new pkg and version for futur comparaison
1153 NEW_PACKAGE=`grep ^$PACKAGE-[0-9A-Z] packages.list`
1154 NEW_VERSION=`echo $NEW_PACKAGE | sed s/$PACKAGE-/''/`
1155 # Change '-' and 'pre' to points.
1156 NEW_VERSION=`echo $NEW_VERSION | sed s/'-'/'.'/`
1157 VERSION=`echo $VERSION | sed s/'-'/'.'/`
1158 NEW_VERSION=`echo $NEW_VERSION | sed s/'pre'/'.'/`
1159 VERSION=`echo $VERSION | sed s/'pre'/'.'/`
1160 # Compare version. Upgrade are only avalaible for official
1161 # packages, so we control de mirror and it should be ok if
1162 # we just check for egality.
1163 if [ "$VERSION" != "$NEW_VERSION" ]; then
1164 # Version seems different. Check for major, minor or
1165 # revision
1166 PKG_MAJOR=`echo $VERSION | cut -f1 -d"."`
1167 NEW_MAJOR=`echo $NEW_VERSION | cut -f1 -d"."`
1168 PKG_MINOR=`echo $VERSION | cut -f2 -d"."`
1169 NEW_MINOR=`echo $NEW_VERSION | cut -f2 -d"."`
1170 # Minor
1171 if [ "$NEW_MINOR" -gt "$PKG_MINOR" ]; then
1172 RELEASE=minor
1173 fi
1174 if [ "$NEW_MINOR" -lt "$PKG_MINOR" ]; then
1175 RELEASE=$WARNING
1176 FIXE=yes
1177 fi
1178 # Major
1179 if [ "$NEW_MAJOR" -gt "$PKG_MAJOR" ]; then
1180 RELEASE=major
1181 FIXE=""
1182 fi
1183 if [ "$NEW_MAJOR" -lt "$PKG_MAJOR" ]; then
1184 RELEASE=$WARNING
1185 FIXE=yes
1186 fi
1187 # Default to revision.
1188 if [ -z $RELEASE ]; then
1189 RELEASE=revision
1190 fi
1191 # Pkg name is already displayed by the check process.
1192 echo -en "\033[24G $VERSION"
1193 echo -en "\033[38G --->"
1194 echo -en "\033[43G $NEW_VERSION"
1195 echo -en "\033[58G $CATEGORY"
1196 echo -e "\033[72G $RELEASE"
1197 up=$(($up+1))
1198 echo "$PACKAGE" >> upradable-packages.list
1199 case "$FIRST_CLASS_PACKAGE" in
1200 *\ $PACKAGE\ *) FIRST_CLASS="$FIRST_CLASS $PACKAGE";;
1201 esac
1202 unset RELEASE
1203 fi
1204 packages=$(($packages+1))
1205 fi
1206 fi
1207 done
1208 if [ -z $blocked ]; then
1209 blocked=0
1210 fi
1211 # Clean last checked package and display summary.
1212 if [ ! "$up" = "" ]; then
1213 echo -e "\\033[0G "
1214 echo "================================================================================"
1215 echo "$packages installed and listed packages to consider, $up to upgrade, $blocked blocked."
1216 echo ""
1217 else
1218 echo -e "\\033[0GSystem is up to date. "
1219 echo ""
1220 echo "================================================================================"
1221 echo "$packages installed and listed packages to consider, 0 to upgrade, $blocked blocked."
1222 echo ""
1223 exit 0
1224 fi
1225 # What to do if major or minor version is smaller.
1226 if [ "$FIXE" == "yes" ]; then
1227 echo -e "$WARNING ---> Installed package seems more recent than the mirrored one."
1228 echo "You can block packages using the command : 'tazpkg block package'"
1229 echo "Or upgrade package at you own risks."
1230 echo ""
1231 fi
1232 # Ask for upgrade, it can be done an other time.
1233 echo -n "Upgrade now (y/N) ? "; read anser
1234 if [ ! "$anser" = "y" ]; then
1235 echo -e "\nExiting. No package upgraded.\n"
1236 exit 0
1237 fi
1238 # If anser is yes (y). Install all new version.
1239 for pkg in $FIRST_CLASS `cat upradable-packages.list`
1240 do
1241 tazpkg get-install $pkg --forced
1242 done
1243 ;;
1244 check)
1245 # check installed packages set.
1247 check_root
1248 cd $INSTALLED
1249 for PACKAGE in `ls`; do
1250 DEPENDS=""
1251 . $PACKAGE/receipt
1252 if [ -s $PACKAGE/modifiers ]; then
1253 echo "The package $PACKAGE $VERSION has been modified by :"
1254 for i in $(cat $PACKAGE/modifiers); do
1255 echo " $i"
1256 done
1257 fi
1258 MSG="Files lost from $PACKAGE $VERSION :\n"
1259 while read file; do
1260 [ -e "$file" ] && continue
1261 if [ -L "$file" ]; then
1262 MSG="$MSG target of symlink"
1263 fi
1264 echo -e "$MSG $file"
1265 MSG=""
1266 done < $PACKAGE/files.list
1267 MSG="Missing dependencies for $PACKAGE $VERSION :\n"
1268 for i in $DEPENDS; do
1269 [ -d $i ] && continue
1270 echo -e "$MSG $i"
1271 MSG=""
1272 done
1273 done
1274 if [ "$PACKAGE_FILE" = "--full" ]; then
1275 FILES=" "
1276 for file in $(cat */files.list); do
1277 [ -d "$file" ] && continue
1278 case "$FILES" in *\ $file\ *) continue;; esac
1279 [ $(grep "^$file$" */files.list 2> /dev/null | \
1280 wc -l) -gt 1 ] || continue
1281 FILES="$FILES$file "
1282 echo "The following packages provide $file :"
1283 grep -l "^$file$" */files.list | while read f
1284 do
1285 pkg=${f%/files.list}
1286 echo -n " $pkg"
1287 if [ -f $pkg/modifiers ]; then
1288 echo -n " (known as overridden by $(cat $pkg/modifiers))"
1289 fi
1290 echo ""
1291 done
1292 done
1293 MSG="No package has installed the following files:\n"
1294 find /etc /bin /sbin /lib /usr /var/www -not -type d | while read file; do
1295 case "$file" in *\[*) continue;; esac
1296 grep -q "^$file$" */files.list && continue
1297 echo -e "$MSG $file"
1298 MSG=""
1299 done
1300 fi
1301 echo "Check completed."
1302 ;;
1303 block)
1304 # Add a pkg name to the list of blocked packages.
1306 check_root
1307 check_for_package_on_cmdline
1308 echo ""
1309 if grep -q "^$PACKAGE" $BLOCKED; then
1310 echo "$PACKAGE is already in the blocked packages list."
1311 echo ""
1312 exit 0
1313 else
1314 echo -n "Add $PACKAGE to : $BLOCKED..."
1315 echo $PACKAGE >> $BLOCKED
1316 status
1317 fi
1318 echo ""
1319 ;;
1320 unblock)
1321 # Remove a pkg name to the list of blocked packages.
1323 check_root
1324 check_for_package_on_cmdline
1325 echo ""
1326 if grep -q "^$PACKAGE" $BLOCKED; then
1327 echo -n "Removing $PACKAGE from : $BLOCKED..."
1328 sed -i s/$PACKAGE/''/ $BLOCKED
1329 sed -i '/^$/d' $BLOCKED
1330 status
1331 else
1332 echo "$PACKAGE is not in the blocked packages list."
1333 echo ""
1334 exit 0
1335 fi
1336 echo ""
1337 ;;
1338 get)
1339 # Downlowd a package with wget.
1341 check_for_package_on_cmdline
1342 check_for_packages_list
1343 check_for_package_in_list
1344 echo ""
1345 download $PACKAGE.tazpkg
1346 echo ""
1347 ;;
1348 get-install)
1349 # Download and install a package.
1351 check_root
1352 check_for_package_on_cmdline
1353 check_for_packages_list
1354 check_for_package_in_list
1355 # Check if forced install.
1356 if [ "$3" = "--forced" ]; then
1357 rm -f $CACHE_DIR/$PACKAGE.tazpkg
1358 else
1359 check_for_installed_package
1360 fi
1361 cd $CACHE_DIR
1362 if [ -f "$PACKAGE.tazpkg" ]; then
1363 echo "$PACKAGE already in the cache : $CACHE_DIR"
1364 else
1365 echo ""
1366 download $PACKAGE.tazpkg
1367 fi
1368 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
1369 install_package
1370 check_for_deps
1371 if [ ! "$MISSING_PACKAGE" = "" ]; then
1372 install_deps
1373 fi
1374 ;;
1375 clean-cache)
1376 # Remove all downloaded packages.
1378 check_root
1379 files=`ls -1 $CACHE_DIR | wc -l`
1380 echo ""
1381 echo -e "\033[1mClean cache :\033[0m $CACHE_DIR"
1382 echo "================================================================================"
1383 echo -n "Cleaning cache directory..."
1384 rm -rf $CACHE_DIR/*
1385 status
1386 echo "================================================================================"
1387 echo "$files file(s) removed from cache."
1388 echo ""
1389 ;;
1390 setup-mirror)
1391 # Change mirror URL.
1393 check_root
1394 # Backup old list.
1395 if [ -f "$LOCALSTATE/mirror" ]; then
1396 cp -f $LOCALSTATE/mirror $LOCALSTATE/mirror.bak
1397 fi
1398 echo ""
1399 echo -e "\033[1mCurrent mirror(s)\033[0m"
1400 echo "================================================================================"
1401 echo " `cat $MIRROR`"
1402 echo "
1403 Please enter URL of the new mirror (http or ftp). You must specify the complet
1404 address to the directory of the packages and packages.list file."
1405 echo ""
1406 echo -n "New mirror URL : "
1407 read NEW_MIRROR_URL
1408 if [ "$NEW_MIRROR_URL" = "" ]; then
1409 echo "Nothing as been change."
1410 else
1411 echo "Setting mirror(s) to : $NEW_MIRROR_URL"
1412 echo "$NEW_MIRROR_URL" > $LOCALSTATE/mirror
1413 fi
1414 echo ""
1415 ;;
1416 reconfigure)
1417 # Replay post_install from receipt
1419 check_for_package_on_cmdline
1420 check_root
1421 if [ -d "$INSTALLED/$PACKAGE" ]; then
1422 check_for_receipt
1423 # Check for post_install
1424 if grep -q ^post_install $INSTALLED/$PACKAGE/receipt; then
1425 . $INSTALLED/$PACKAGE/receipt
1426 post_install
1427 else
1428 echo -e "\nNothing to do for $PACKAGE."
1429 fi
1430 else
1431 echo -e "\npackage $PACKAGE is not installed."
1432 echo -e "Install package with 'tazpkg install' or 'tazpkg get-install'\n"
1433 fi
1434 ;;
1435 shell)
1436 # Tazpkg SHell
1438 if test $(id -u) = 0 ; then
1439 PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
1440 else
1441 PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
1442 fi
1443 if [ ! "$2" = "--noheader" ]; then
1444 clear
1445 echo ""
1446 echo -e "\033[1mTazpkg SHell.\033[0m"
1447 echo "================================================================================"
1448 echo "Type 'usage' to list all avalaible commands and 'quit' or 'q' to exit."
1449 echo ""
1450 fi
1451 while true
1452 do
1453 echo -en "$PROMPT"; read cmd
1454 case $cmd in
1455 q|quit)
1456 break ;;
1457 shell)
1458 echo "You are already running a Tazpkg SHell." ;;
1459 su)
1460 su -c 'exec tazpkg shell --noheader' && break ;;
1461 "")
1462 continue ;;
1463 *)
1464 tazpkg $cmd ;;
1465 esac
1466 done
1467 ;;
1468 usage|*)
1469 # Print a short help or give usage for an unknow or empty command.
1471 usage
1472 ;;
1473 esac
1475 exit 0