tazpkg view tazpkg @ rev 91

tazpkgbox: add check buttons
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon May 19 20:53:00 2008 +0000 (2008-05-19)
parents f4847bc88b0e
children c48294925d77
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=1.9
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-9]*}" ]; 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-9]" $LOCALSTATE/packages.list; then
204 PACKAGE=`grep ^$PACKAGE-[0-9] $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-9]*}" ]
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-9] $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 "================================================================================"
773 # Check all pkg files.list in search match with specify the package
774 # name and the full path to the file(s).
775 for pkg in $INSTALLED/*
776 do
777 if grep -q "$2" $pkg/files.list; then
778 . $pkg/receipt
779 echo ""
780 echo -e "\033[1mPackage $PACKAGE :\033[0m"
781 grep "$2" $pkg/files.list
782 files=`grep $2 $pkg/files.list | wc -l`
783 match=$(($match+$files))
784 fi
785 done
786 if [ "$match" = "" ]; then
787 echo "0 file found for : $2"
788 echo ""
789 else
790 echo ""
791 echo "================================================================================"
792 echo "$match file(s) found for : $2"
793 echo ""
794 fi
795 ;;
796 install)
797 # Install .tazpkg packages.
798 #
799 check_root
800 check_for_package_on_cmdline
801 check_for_package_file
802 # Check if forced install.
803 DO_CHECK="yes"
804 while [ -n "$3" ]; do
805 case "$3" in
806 --forced)
807 DO_CHECK="no"
808 ;;
809 --root=*)
810 install_package ${3#--root=}
811 exit $?
812 ;;
813 *) shift 2
814 echo -e "\nUnknown option $*.\n"
815 exit 1
816 ;;
817 esac
818 shift
819 done
820 if [ "$DO_CHECK" = "yes" ]; then
821 check_for_installed_package
822 fi
823 install_package
824 # Resolv package deps.
825 check_for_deps
826 if [ ! "$MISSING_PACKAGE" = "" ]; then
827 install_deps
828 fi
829 ;;
830 install-list|get-install-list)
831 # Install a set of packages from a list.
832 #
833 check_root
834 if [ -z "$2" ]; then
835 echo -e "
836 Please change directory (cd) to the packages repository, and specify the
837 list of packages to install. Example : tazpkg install-list packages.list\n"
838 exit 0
839 fi
840 # Check if the packages list exist.
841 if [ ! -f "$2" ]; then
842 echo "Unable to find : $2"
843 exit 0
844 else
845 LIST=`cat $2`
846 fi
847 # Set $COMMAND and install all packages.
848 if [ "$1" = "get-install-list" ]; then
849 COMMAND=get-install
850 else
851 COMMAND=install
852 fi
853 for pkg in $LIST
854 do
855 if [ "$3" = "--forced" ]; then
856 tazpkg $COMMAND $pkg --forced
857 else
858 tazpkg $COMMAND $pkg
859 fi
860 done
861 ;;
862 add-flavor)
863 # Install a set of packages from a flavor.
864 #
865 install_flavor $2
866 ;;
867 install-flavor)
868 # Install a set of packages from a flavor and purge other ones.
869 #
870 install_flavor $2 --purge
871 ;;
872 set-release)
873 # Change curent release and upgrade packages.
874 #
875 RELEASE=$2
876 if [ -z "$RELEASE" ]; then
877 echo -e "\nPlease specify the release you want on the command line."
878 echo -e "Example: tazpkg set-release cooking\n"
879 exit 0
880 fi
881 rm /var/lib/tazpkg/mirror
882 echo "$RELEASE" > /etc/slitaz-release
883 tazpkg recharge && tazpkg upgrade
884 ;;
885 remove)
886 # Remove packages.
887 #
888 check_root
889 check_for_package_on_cmdline
890 if [ ! -d "$INSTALLED/$PACKAGE" ]; then
891 echo -e "\n$PACKAGE is not installed.\n"
892 exit 0
893 else
894 ALTERED=""
895 THE_PACKAGE=$PACKAGE # altered by receipt
896 for i in $(cd $INSTALLED ; ls); do
897 DEPENDS=""
898 . $INSTALLED/$i/receipt
899 case " $(echo $DEPENDS) " in
900 *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
901 esac
902 done
903 . $INSTALLED/$THE_PACKAGE/receipt
904 fi
905 echo ""
906 if [ -n "$ALTERED" ]; then
907 echo "The following packages depend on $PACKAGE :"
908 for i in $ALTERED; do
909 echo " $i"
910 done
911 fi
912 echo "Remove $PACKAGE ($VERSION) ?"
913 echo -n "Please confirm uninstallation (y/N) : "; read anser
914 if [ "$anser" = "y" ]; then
915 echo ""
916 echo -e "\033[1mRemoving :\033[0m $PACKAGE"
917 echo "================================================================================"
918 # Pre remove commands.
919 if grep -q ^pre_remove $INSTALLED/$PACKAGE/receipt; then
920 pre_remove
921 fi
922 echo -n "Removing all files installed..."
923 for file in `cat $INSTALLED/$PACKAGE/files.list`
924 do
925 [ $(grep ^$file$ $INSTALLED/*/files.list | wc -l) -gt 1 ] && continue
926 rm -f $file 2>/dev/null
927 done
928 status
929 if grep -q ^post_remove $INSTALLED/$PACKAGE/receipt; then
930 post_remove
931 fi
932 # Remove package receipt.
933 echo -n "Removing package receipt..."
934 rm -rf $INSTALLED/$PACKAGE
935 status
936 if [ -n "$ALTERED" ]; then
937 echo -n "Remove packages depending on $PACKAGE"
938 echo -n " (y/N) ? "; read anser
939 if [ "$anser" = "y" ]; then
940 for i in $ALTERED; do
941 if [ -d "$INSTALLED/$i" ]; then
942 tazpkg remove $i
943 fi
944 done
945 fi
946 fi
947 else
948 echo ""
949 echo "Uninstallation of $PACKAGE cancelled."
950 fi
951 echo ""
952 ;;
953 extract)
954 # Extract .tazpkg cpio archive into a directory.
955 #
956 check_for_package_on_cmdline
957 check_for_package_file
958 echo ""
959 echo -e "\033[1mExtracting :\033[0m $PACKAGE"
960 echo "================================================================================"
961 # If any directory destination is found on the cmdline
962 # we creat one in the current dir using the package name.
963 if [ -n "$TARGET_DIR" ]; then
964 DESTDIR=$TARGET_DIR/$PACKAGE
965 else
966 DESTDIR=$PACKAGE
967 fi
968 mkdir -p $DESTDIR
969 echo -n "Copying original package..."
970 cp $PACKAGE_FILE $DESTDIR
971 status
972 cd $DESTDIR
973 extract_package
974 echo "================================================================================"
975 echo "$PACKAGE is extracted to : $DESTDIR"
976 echo ""
977 ;;
978 repack)
979 # Creat SliTaz package archive from an installed package.
980 #
981 check_for_package_on_cmdline
982 check_for_receipt
983 eval $(grep ^VERSION= $INSTALLED/$PACKAGE/receipt)
984 echo ""
985 echo -e "\033[1mRepacking :\033[0m $PACKAGE-$VERSION.tazpkg"
986 echo "================================================================================"
987 if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then
988 echo "Can't repack $PACKAGE"
989 exit 1
990 fi
991 if [ -s $INSTALLED/$PACKAGE/modifiers ]; then
992 echo "Can't repack, $PACKAGE files have been modified by:"
993 for i in $(cat $INSTALLED/$PACKAGE/modifiers); do
994 echo " $i"
995 done
996 exit 1
997 fi
998 MISSING=""
999 while read i; do
1000 [ -e "$i" ] && continue
1001 [ -L "$i" ] || MISSING="$MISSING\n $i"
1002 done < $INSTALLED/$PACKAGE/files.list
1003 if [ -n "$MISSING" ]; then
1004 echo -n "Can't repack, the following files are lost:"
1005 echo -e "$MISSING"
1006 exit 1
1007 fi
1008 mkdir -p $TMP_DIR && cd $TMP_DIR
1009 FILES="fs.cpio.gz\n"
1010 for i in $(ls $INSTALLED/$PACKAGE) ; do
1011 cp $INSTALLED/$PACKAGE/$i . && FILES="$FILES$i\n"
1012 done
1013 ln -s / rootfs
1014 mkdir tmp
1015 sed 's/^/rootfs/' < files.list | cpio -o -H newc 2>/dev/null |\
1016 ( cd tmp ; cpio -id 2>/dev/null )
1017 mv tmp/rootfs fs
1018 find fs | cpio -o -H newc 2> /dev/null | gzip -9 > fs.cpio.gz
1019 echo -e "$FILES" | cpio -o -H newc 2> /dev/null > \
1020 $TOP_DIR/$PACKAGE-$VERSION.tazpkg
1021 cd $TOP_DIR
1022 \rm -R $TMP_DIR
1023 echo "Package $PACKAGE repacked successfully."
1024 echo "Size : `du -sh $PACKAGE-$VERSION.tazpkg`"
1025 echo ""
1026 ;;
1027 pack)
1028 # Creat SliTaz package archive using cpio and gzip.
1030 check_for_package_on_cmdline
1031 cd $PACKAGE
1032 if [ ! -f "receipt" ]; then
1033 echo "Receipt is missing. Please read the documentation."
1034 exit 0
1035 else
1036 echo ""
1037 echo -e "\033[1mPacking :\033[0m $PACKAGE"
1038 echo "================================================================================"
1039 # Creat files.list with redirecting find outpout.
1040 echo -n "Creating the list of files..." && cd fs
1041 find . -type f -print > ../files.list
1042 find . -type l -print >> ../files.list
1043 cd .. && sed -i s/'^.'/''/ files.list
1044 status
1045 # Build cpio archives.
1046 echo -n "Compressing the fs... "
1047 find fs -print | cpio -o -H newc > fs.cpio
1048 gzip fs.cpio && rm -rf fs
1049 echo -n "Creating full cpio archive... "
1050 find . -print | cpio -o -H newc > ../$PACKAGE.tazpkg
1051 echo -n "Restoring original package tree... "
1052 gzip -d fs.cpio.gz && cpio -id < fs.cpio
1053 rm fs.cpio && cd ..
1054 echo "================================================================================"
1055 echo "Package $PACKAGE compressed successfully."
1056 echo "Size : `du -sh $PACKAGE.tazpkg`"
1057 echo ""
1058 fi
1059 ;;
1060 recharge)
1061 # Recharge packages.list from a mirror.
1063 check_root
1064 cd $LOCALSTATE
1065 echo ""
1066 if [ -f "$LOCALSTATE/packages.list" ]; then
1067 echo -n "Creating backup of the last packages list..."
1068 mv -f packages.desc packages.desc.bak 2>/dev/null
1069 mv -f packages.txt packages.txt.bak 2>/dev/null
1070 mv -f packages.list packages.list.bak 2>/dev/null
1071 status
1072 fi
1073 download packages.desc
1074 download packages.txt
1075 download packages.list
1076 if [ -f "$LOCALSTATE/packages.list.bak" ]; then
1077 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
1078 sed -i s/+// packages.diff
1079 echo ""
1080 echo -e "\033[1mMirrored packages diff\033[0m"
1081 echo "================================================================================"
1082 cat packages.diff
1083 if [ ! "`cat packages.diff | wc -l`" = 0 ]; then
1084 echo "================================================================================"
1085 echo "`cat packages.diff | wc -l` new packages on the mirror."
1086 echo ""
1087 else
1088 echo "`cat packages.diff | wc -l` new packages on the mirror."
1089 echo ""
1090 fi
1091 else
1092 echo -e "
1093 ================================================================================
1094 Last packages.list is ready to use. Note that next time you recharge the list,
1095 a list of differencies will be displayed to show new and upgradable packages.\n"
1096 fi
1097 ;;
1098 upgrade)
1099 # Upgrade all installed packages with the new version from the mirror.
1101 check_root
1102 check_for_packages_list
1103 cd $LOCALSTATE
1104 # Touch the blocked pkgs list to avoid errors and remove any old
1105 # upgrade list.
1106 touch blocked-packages.list
1107 rm -f upradable-packages.list
1108 echo ""
1109 echo -e "\033[1mAvalaible upgrade\033[0m"
1110 echo "================================================================================"
1111 echo ""
1112 # Some packages must be installed first
1113 FIRST_CLASS_PACKAGE=" glibc-base "
1114 FIRST_CLASS=""
1115 for pkg in $INSTALLED/*
1116 do
1117 . $pkg/receipt
1118 # Diplay package name to show that Tazpkg is working...
1119 echo -en "\\033[0G "
1120 echo -en "\\033[0G$PACKAGE"
1121 # Skip specified pkgs listed in $LOCALSTATE/blocked-packages.list
1122 if grep -q "^$PACKAGE" $BLOCKED; then
1123 blocked=$(($blocked+1))
1124 else
1125 # Check if the installed package is in the current list (other
1126 # mirror or local).
1127 if grep -q "^$PACKAGE-[0-9]" packages.list; then
1128 # Set new pkg and version for futur comparaison
1129 NEW_PACKAGE=`grep ^$PACKAGE-[0-9] packages.list`
1130 NEW_VERSION=`echo $NEW_PACKAGE | sed s/$PACKAGE-/''/`
1131 # Change '-' and 'pre' to points.
1132 NEW_VERSION=`echo $NEW_VERSION | sed s/'-'/'.'/`
1133 VERSION=`echo $VERSION | sed s/'-'/'.'/`
1134 NEW_VERSION=`echo $NEW_VERSION | sed s/'pre'/'.'/`
1135 VERSION=`echo $VERSION | sed s/'pre'/'.'/`
1136 # Compare version. Upgrade are only avalaible for official
1137 # packages, so we control de mirror and it should be ok if
1138 # we just check for egality.
1139 if [ "$VERSION" != "$NEW_VERSION" ]; then
1140 # Version seems different. Check for major, minor or
1141 # revision
1142 PKG_MAJOR=`echo $VERSION | cut -f1 -d"."`
1143 NEW_MAJOR=`echo $NEW_VERSION | cut -f1 -d"."`
1144 PKG_MINOR=`echo $VERSION | cut -f2 -d"."`
1145 NEW_MINOR=`echo $NEW_VERSION | cut -f2 -d"."`
1146 # Minor
1147 if [ "$NEW_MINOR" -gt "$PKG_MINOR" ]; then
1148 RELEASE=minor
1149 fi
1150 if [ "$NEW_MINOR" -lt "$PKG_MINOR" ]; then
1151 RELEASE=$WARNING
1152 FIXE=yes
1153 fi
1154 # Major
1155 if [ "$NEW_MAJOR" -gt "$PKG_MAJOR" ]; then
1156 RELEASE=major
1157 FIXE=""
1158 fi
1159 if [ "$NEW_MAJOR" -lt "$PKG_MAJOR" ]; then
1160 RELEASE=$WARNING
1161 FIXE=yes
1162 fi
1163 # Default to revision.
1164 if [ -z $RELEASE ]; then
1165 RELEASE=revision
1166 fi
1167 # Pkg name is already displayed by the check process.
1168 echo -en "\033[24G $VERSION"
1169 echo -en "\033[38G --->"
1170 echo -en "\033[43G $NEW_VERSION"
1171 echo -en "\033[58G $CATEGORY"
1172 echo -e "\033[72G $RELEASE"
1173 up=$(($up+1))
1174 echo "$PACKAGE" >> upradable-packages.list
1175 case "$FIRST_CLASS_PACKAGE" in
1176 *\ $PACKAGE\ *) FIRST_CLASS="$FIRST_CLASS $PACKAGE";;
1177 esac
1178 unset RELEASE
1179 fi
1180 packages=$(($packages+1))
1181 fi
1182 fi
1183 done
1184 if [ -z $blocked ]; then
1185 blocked=0
1186 fi
1187 # Clean last checked package and display summary.
1188 if [ ! "$up" = "" ]; then
1189 echo -e "\\033[0G "
1190 echo "================================================================================"
1191 echo "$packages installed and listed packages to consider, $up to upgrade, $blocked blocked."
1192 echo ""
1193 else
1194 echo -e "\\033[0GSystem is up to date. "
1195 echo ""
1196 echo "================================================================================"
1197 echo "$packages installed and listed packages to consider, 0 to upgrade, $blocked blocked."
1198 echo ""
1199 exit 0
1200 fi
1201 # What to do if major or minor version is smaller.
1202 if [ "$FIXE" == "yes" ]; then
1203 echo -e "$WARNING ---> Installed package seems more recent than the mirrored one."
1204 echo "You can block packages using the command : 'tazpkg block package'"
1205 echo "Or upgrade package at you own risks."
1206 echo ""
1207 fi
1208 # Ask for upgrade, it can be done an other time.
1209 echo -n "Upgrade now (y/N) ? "; read anser
1210 if [ ! "$anser" = "y" ]; then
1211 echo -e "\nExiting. No package upgraded.\n"
1212 exit 0
1213 fi
1214 # If anser is yes (y). Install all new version.
1215 for pkg in $FIRST_CLASS `cat upradable-packages.list`
1216 do
1217 tazpkg get-install $pkg --forced
1218 done
1219 ;;
1220 check)
1221 # check installed packages set.
1223 check_root
1224 cd $INSTALLED
1225 for PACKAGE in `ls`; do
1226 DEPENDS=""
1227 . $PACKAGE/receipt
1228 if [ -s $PACKAGE/modifiers ]; then
1229 echo "The package $PACKAGE $VERSION has been modified by :"
1230 for i in $(cat $PACKAGE/modifiers); do
1231 echo " $i"
1232 done
1233 fi
1234 MSG="Files lost from $PACKAGE $VERSION :\n"
1235 while read file; do
1236 [ -e "$file" ] && continue
1237 if [ -L "$file" ]; then
1238 MSG="$MSG target of symlink"
1239 fi
1240 echo -e "$MSG $file"
1241 MSG=""
1242 done < $PACKAGE/files.list
1243 MSG="Missing dependencies for $PACKAGE $VERSION :\n"
1244 for i in $DEPENDS; do
1245 [ -d $i ] && continue
1246 echo -e "$MSG $i"
1247 MSG=""
1248 done
1249 done
1250 if [ "$PACKAGE_FILE" = "--full" ]; then
1251 FILES=" "
1252 for file in $(cat */files.list); do
1253 [ -d "$file" ] && continue
1254 case "$FILES" in *\ $file\ *) continue;; esac
1255 [ $(grep "^$file$" */files.list 2> /dev/null | \
1256 wc -l) -gt 1 ] || continue
1257 FILES="$FILES$file "
1258 echo "The following packages provide $file :"
1259 grep -l "^$file$" */files.list | while read f
1260 do
1261 pkg=${f%/files.list}
1262 echo -n " $pkg"
1263 if [ -f $pkg/modifiers ]; then
1264 echo -n " (known as overridden by $(cat $pkg/modifiers))"
1265 fi
1266 echo ""
1267 done
1268 done
1269 MSG="No package has installed the following files:\n"
1270 find /etc /bin /sbin /lib /usr /var/www -not -type d | while read file; do
1271 case "$file" in *\[*) continue;; esac
1272 grep -q "^$file$" */files.list && continue
1273 echo -e "$MSG $file"
1274 MSG=""
1275 done
1276 fi
1277 echo "Check completed."
1278 ;;
1279 block)
1280 # Add a pkg name to the list of blocked packages.
1282 check_root
1283 check_for_package_on_cmdline
1284 echo ""
1285 if grep -q "^$PACKAGE" $BLOCKED; then
1286 echo "$PACKAGE is already in the blocked packages list."
1287 echo ""
1288 exit 0
1289 else
1290 echo -n "Add $PACKAGE to : $BLOCKED..."
1291 echo $PACKAGE >> $BLOCKED
1292 status
1293 fi
1294 echo ""
1295 ;;
1296 unblock)
1297 # Remove a pkg name to the list of blocked packages.
1299 check_root
1300 check_for_package_on_cmdline
1301 echo ""
1302 if grep -q "^$PACKAGE" $BLOCKED; then
1303 echo -n "Removing $PACKAGE from : $BLOCKED..."
1304 sed -i s/$PACKAGE/''/ $BLOCKED
1305 sed -i '/^$/d' $BLOCKED
1306 status
1307 else
1308 echo "$PACKAGE is not in the blocked packages list."
1309 echo ""
1310 exit 0
1311 fi
1312 echo ""
1313 ;;
1314 get)
1315 # Downlowd a package with wget.
1317 check_for_package_on_cmdline
1318 check_for_packages_list
1319 check_for_package_in_list
1320 echo ""
1321 download $PACKAGE.tazpkg
1322 echo ""
1323 ;;
1324 get-install)
1325 # Download and install a package.
1327 check_root
1328 check_for_package_on_cmdline
1329 check_for_packages_list
1330 check_for_package_in_list
1331 # Check if forced install.
1332 if [ "$3" = "--forced" ]; then
1333 rm -f $CACHE_DIR/$PACKAGE.tazpkg
1334 else
1335 check_for_installed_package
1336 fi
1337 cd $CACHE_DIR
1338 if [ -f "$PACKAGE.tazpkg" ]; then
1339 echo "$PACKAGE already in the cache : $CACHE_DIR"
1340 else
1341 echo ""
1342 download $PACKAGE.tazpkg
1343 fi
1344 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
1345 install_package
1346 check_for_deps
1347 if [ ! "$MISSING_PACKAGE" = "" ]; then
1348 install_deps
1349 fi
1350 ;;
1351 clean-cache)
1352 # Remove all downloaded packages.
1354 check_root
1355 files=`ls -1 $CACHE_DIR | wc -l`
1356 echo ""
1357 echo -e "\033[1mClean cache :\033[0m $CACHE_DIR"
1358 echo "================================================================================"
1359 echo -n "Cleaning cache directory..."
1360 rm -rf $CACHE_DIR/*
1361 status
1362 echo "================================================================================"
1363 echo "$files file(s) removed from cache."
1364 echo ""
1365 ;;
1366 setup-mirror)
1367 # Change mirror URL.
1369 check_root
1370 # Backup old list.
1371 if [ -f "$LOCALSTATE/mirror" ]; then
1372 cp -f $LOCALSTATE/mirror $LOCALSTATE/mirror.bak
1373 fi
1374 echo ""
1375 echo -e "\033[1mCurrent mirror(s)\033[0m"
1376 echo "================================================================================"
1377 echo " `cat $MIRROR`"
1378 echo "
1379 Please enter URL of the new mirror (http or ftp). You must specify the complet
1380 address to the directory of the packages and packages.list file."
1381 echo ""
1382 echo -n "New mirror URL : "
1383 read NEW_MIRROR_URL
1384 if [ "$NEW_MIRROR_URL" = "" ]; then
1385 echo "Nothing as been change."
1386 else
1387 echo "Setting mirror(s) to : $NEW_MIRROR_URL"
1388 echo "$NEW_MIRROR_URL" > $LOCALSTATE/mirror
1389 fi
1390 echo ""
1391 ;;
1392 reconfigure)
1393 # Replay post_install from receipt
1395 check_for_package_on_cmdline
1396 check_root
1397 if [ -d "$INSTALLED/$PACKAGE" ]; then
1398 check_for_receipt
1399 # Check for post_install
1400 if grep -q ^post_install $INSTALLED/$PACKAGE/receipt; then
1401 . $INSTALLED/$PACKAGE/receipt
1402 post_install
1403 else
1404 echo -e "\nNothing to do for $PACKAGE."
1405 fi
1406 else
1407 echo -e "\npackage $PACKAGE is not installed."
1408 echo -e "Install package with 'tazpkg install' or 'tazpkg get-install'\n"
1409 fi
1410 ;;
1411 shell)
1412 # Tazpkg SHell
1414 if test $(id -u) = 0 ; then
1415 PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
1416 else
1417 PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
1418 fi
1419 if [ ! "$2" = "--noheader" ]; then
1420 clear
1421 echo ""
1422 echo -e "\033[1mTazpkg SHell.\033[0m"
1423 echo "================================================================================"
1424 echo "Type 'usage' to list all avalaible commands and 'quit' or 'q' to exit."
1425 echo ""
1426 fi
1427 while true
1428 do
1429 echo -en "$PROMPT"; read cmd
1430 case $cmd in
1431 q|quit)
1432 break ;;
1433 shell)
1434 echo "You are already running a Tazpkg SHell." ;;
1435 su)
1436 su -c 'exec tazpkg shell --noheader' && break ;;
1437 "")
1438 continue ;;
1439 *)
1440 tazpkg $cmd ;;
1441 esac
1442 done
1443 ;;
1444 usage|*)
1445 # Print a short help or give usage for an unknow or empty command.
1447 usage
1448 ;;
1449 esac
1451 exit 0