tazpkg view tazpkg @ rev 205

Add tazpkg (r)depends
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Nov 17 23:33:52 2008 +0000 (2008-11-17)
parents bdc5253ca4a8
children 29a82d933b02
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 lets 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 short descriptions. Tazpkg
8 # also resolves 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.5.3
18 ####################
19 # Script variables #
20 ####################
22 # Packages categories.
23 CATEGORIES="
24 base-system
25 x-window
26 utilities
27 network
28 graphics
29 multimedia
30 office
31 development
32 system-tools
33 security
34 games
35 misc
36 meta
37 non-free"
39 # Initialize some variables to use words
40 # rather than numbers for functions and actions.
41 COMMAND=$1
42 if [ -f "$2" ]; then
43 # Set pkg basename for install, extract
44 PACKAGE=$(basename ${2%.tazpkg} 2>/dev/null)
45 else
46 # Pkg name for remove, search and all other cmds
47 PACKAGE=${2%.tazpkg}
48 fi
49 PACKAGE_FILE=$2
50 TARGET_DIR=$3
51 TOP_DIR=`pwd`
52 TMP_DIR=/tmp/tazpkg-$$-$RANDOM
54 # Path to tazpkg used dir and configuration files
55 LOCALSTATE=/var/lib/tazpkg
56 INSTALLED=$LOCALSTATE/installed
57 CACHE_DIR=/var/cache/tazpkg
58 MIRROR=$LOCALSTATE/mirror
59 BLOCKED=$LOCALSTATE/blocked-packages.list
60 DEFAULT_MIRROR="http://mirror.slitaz.org/packages/`cat /etc/slitaz-release`/"
61 INSTALL_LIST=""
62 LOG=/var/log/tazpkg.log
64 # Bold red warning for upgrade.
65 WARNING="\\033[1;31mWARNING\\033[0;39m"
67 # Check if the directories and files used by Tazpkg
68 # exist. If not and user is root we create them.
69 if test $(id -u) = 0 ; then
70 if [ ! -d "$CACHE_DIR" ]; then
71 mkdir -p $CACHE_DIR
72 fi
73 if [ ! -d "$INSTALLED" ]; then
74 mkdir -p $INSTALLED
75 fi
76 if [ ! -f "$LOCALSTATE/mirror" ]; then
77 echo "$DEFAULT_MIRROR" > $LOCALSTATE/mirror
78 fi
79 fi
81 ####################
82 # Script functions #
83 ####################
85 # Print the usage.
86 usage ()
87 {
88 echo -e "SliTaz package manager - Version: $VERSION\n
89 \033[1mUsage:\033[0m tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]
90 tazpkg shell\n
91 \033[1mCommands: \033[0m
92 usage Print this short usage.
93 bugs Show known bugs in packages
94 list List installed packages on the system by category or all.
95 xhtml-list Create a xHTML list of installed packges.
96 list-mirror List all available packages on the mirror (--diff for new).
97 info Print information about a package.
98 desc Print description of a package (if it exists).
99 list-files List the files installed with a package.
100 list-config List the configuration files.
101 search Search for a package by pattern or name (options: -i|-l|-m).
102 search-file Search for file(s) in all installed packages files.
103 install Install a local (*.tazpkg) package (--forced to force).
104 install-list Install all packages from a list of packages.
105 remove Remove the specified package and all installed files.
106 extract Extract a (*.tazpkg) package into a directory.
107 pack Pack an unpacked or prepared package tree.
108 recharge Recharge your packages.list from the mirror.
109 repack Create a package archive from an installed package.
110 repack-config Create a package archive with configuration files.
111 upgrade Upgrade all installed and listed packages on the mirror.
112 block|unblock Block an installed package version or unblock it for upgrade.
113 get Download a package into the current directory.
114 get-install Download and install a package from the mirror.
115 get-install-list Download and install a list of packages from the mirror.
116 check Verify consistency of installed packages.
117 add-flavor Install the flavor list of packages.
118 install-flavor Install the flavor list of packages and remove other ones.
119 set-release Change release and update packages
120 clean-cache Clean all packages downloaded in cache directory.
121 depends Display dependancies tree.
122 rdepends Display reverse dependancies tree.
123 setup-mirror Change the mirror url configuration.
124 list-undigest List undigest mirrors.
125 remove-undigest Remove an undigest mirror.
126 add-undigest Add an undigest mirror.
127 setup-undigest Update an undigest mirror.
128 reconfigure Replay post install script from package."
129 }
131 # Status function with color (supported by Ash).
132 status()
133 {
134 local CHECK=$?
135 echo -en "\\033[70G[ "
136 if [ $CHECK = 0 ]; then
137 echo -en "\\033[1;33mOK"
138 else
139 echo -en "\\033[1;31mFailed"
140 fi
141 echo -e "\\033[0;39m ]"
142 return $CHECK
143 }
145 # Check if user is root to install, or remove packages.
146 check_root()
147 {
148 if test $(id -u) != 0 ; then
149 echo -e "\nYou must be root to run `basename $0` with this option."
150 echo -e "Please use 'su' and root password to become super-user.\n"
151 exit 0
152 fi
153 }
155 # Check for a package name on cmdline.
156 check_for_package_on_cmdline()
157 {
158 if [ -z "$PACKAGE" ]; then
159 echo -e "\nPlease specify a package name on the command line.\n"
160 exit 0
161 fi
162 }
164 # Check if the package (*.tazpkg) exist before installing or extracting.
165 check_for_package_file()
166 {
167 if [ ! -f "$PACKAGE_FILE" ]; then
168 echo -e "
169 Unable to find : $PACKAGE_FILE\n"
170 exit 0
171 fi
172 }
174 # Check for the receipt of an installed package.
175 check_for_receipt()
176 {
177 if [ ! -f "$INSTALLED/$PACKAGE/receipt" ]; then
178 echo -e "\nUnable to find the receipt : $INSTALLED/$PACKAGE/receipt\n"
179 exit 0
180 fi
181 }
183 # Get package name in a directory
184 package_fullname_in_dir()
185 {
186 [ -f $2$1/receipt ] || return
187 EXTRAVERSION=""
188 . $2$1/receipt
189 echo $PACKAGE-$VERSION$EXTRAVERSION
190 }
192 # Get package name that is already installed.
193 get_installed_package_pathname()
194 {
195 for i in $2$INSTALLED/${1%%-*}*; do
196 [ -d $i ] || continue
197 if [ "$1" = "$(package_fullname_in_dir $i $2)" ]; then
198 echo $i
199 return
200 fi
201 done
202 }
204 # Check if a package is already installed.
205 check_for_installed_package()
206 {
207 if [ -n "$(get_installed_package_pathname $PACKAGE $1)" ]; then
208 echo -e "
209 $PACKAGE is already installed. You can use the --forced option to force
210 installation or remove it and reinstall.\n"
211 exit 0
212 fi
213 }
215 # Check for packages.list to download and install packages.
216 check_for_packages_list()
217 {
218 if [ ! -f "$LOCALSTATE/packages.list" ]; then
219 if test $(id -u) = 0 ; then
220 tazpkg recharge
221 else
222 echo -e "
223 Unable to find the list : $LOCALSTATE/packages.list\n
224 You should probably run 'tazpkg recharge' as root to get the latest list of
225 packages available on the mirror.\n"
226 exit 0
227 fi
228 fi
229 }
231 # Get package filename available on the mirror
232 get_package_filename()
233 {
234 local pkg
235 pkg=$(grep -A 1 -sh "^$1$" $LOCALSTATE/packages.txt \
236 $LOCALSTATE/undigest/*/packages.txt | tail -1)
237 pkg=$(echo $pkg)
238 [ -n "$pkg" ] && pkg=$(grep -sh "^$1-$pkg" \
239 $LOCALSTATE/packages.list \
240 $LOCALSTATE/undigest/*/packages.list | head -1)
241 [ -n "$pkg" ] || pkg=$(grep -sh "^$1-[0-9]" \
242 $LOCALSTATE/packages.list \
243 $LOCALSTATE/undigest/*/packages.list | head -1)
244 [ -n "$pkg" ] || pkg=$(grep -sh "^$1-.[\.0-9]" \
245 $LOCALSTATE/packages.list \
246 $LOCALSTATE/undigest/*/packages.list | head -1)
247 echo $pkg
248 }
250 # Check for a package in packages.list. Used by get and get-install to grep
251 # package basename.
252 check_for_package_in_list()
253 {
254 local filename
255 local check_only
256 check_only="$1"
257 filename=$(get_package_filename $PACKAGE)
258 if [ -n "$filename" ]; then
259 PACKAGE=$filename
260 else
261 echo -e "\nUnable to find : $PACKAGE in the mirrored packages list.\n"
262 [ -n "$check_only" ] && return 1
263 exit 0
264 fi
265 }
267 # Log this activity
268 log()
269 {
270 [ -e $LOG ] || touch $LOG
271 DATE=`date +'%F %T'`
272 [ -w $LOG ] &&
273 echo "$DATE - $1 - $PACKAGE ($VERSION$EXTRAVERSION)" >> $LOG
274 }
276 # Download a file from this mirror
277 download_from()
278 {
279 local i
280 local mirrors
281 mirrors="$1"
282 shift
283 for i in $mirrors; do
284 case "$i" in
285 http://*|ftp://*) wget -c $i$@ && break;;
286 *) cp $i/$1 . && break;;
287 esac
288 done
289 }
291 # Download a file trying all mirrors
292 download()
293 {
294 local i
295 for i in $(cat $MIRROR $LOCALSTATE/undigest/*/mirror 2> /dev/null); do
296 download_from "$i" "$@" && break
297 done
298 }
300 # Extract a package with cpio and gzip.
301 extract_package()
302 {
303 echo -n "Extracting $PACKAGE... "
304 cpio -id < $PACKAGE.tazpkg && rm -f $PACKAGE.tazpkg
305 gzip -d fs.cpio.gz
306 echo -n "Extracting the pseudo fs... "
307 cpio -id < fs.cpio && rm fs.cpio
308 }
310 # This function installs a package in the rootfs.
311 install_package()
312 {
313 ROOT=$1
314 if [ -n "$ROOT" ]; then
315 # Get absolute path
316 ROOT=$(cd $ROOT; pwd)
317 fi
318 (
319 # Create package path early to avoid dependencies loop
320 mkdir -p $TMP_DIR
321 ( cd $TMP_DIR ; cpio -i receipt > /dev/null) < $PACKAGE_FILE
322 . $TMP_DIR/receipt
323 rm -rf $TMP_DIR
324 # Make the installed package data dir to store
325 # the receipt and the files list.
326 mkdir -p $ROOT$INSTALLED/$PACKAGE
327 sed -i "/ $(basename $PACKAGE_FILE)$/d" \
328 $ROOT$LOCALSTATE/installed.md5 2> /dev/null
329 cd $(dirname $PACKAGE_FILE)
330 md5sum $(basename $PACKAGE_FILE) >> $ROOT$LOCALSTATE/installed.md5
331 )
332 # Resolve package deps.
333 check_for_deps $ROOT
334 if [ ! "$MISSING_PACKAGE" = "" ]; then
335 install_deps $ROOT
336 fi
337 mkdir -p $TMP_DIR
338 [ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> $INSTALL_LIST-processed
339 echo ""
340 echo -e "\033[1mInstallation of :\033[0m $PACKAGE"
341 echo "================================================================================"
342 echo -n "Copying $PACKAGE... "
343 cp $PACKAGE_FILE $TMP_DIR
344 status
345 cd $TMP_DIR
346 extract_package
347 SELF_INSTALL=0
348 EXTRAVERSION=""
349 CONFIG_FILES=""
350 # Include temporary receipt to get the right variables.
351 . $PWD/receipt
352 if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then
353 echo -n "Checking post install dependencies... "
354 [ -f $INSTALLED/$PACKAGE/receipt ]
355 if ! status; then
356 echo "Please run 'tazpkg install $PACKAGE_FILE' in / and retry."
357 cd .. && rm -rf $TMP_DIR
358 exit 1
359 fi
360 fi
361 # Remember modified packages
362 for i in $(grep -v '\[' files.list); do
363 [ -e "$ROOT$i" ] || continue
364 [ -d "$ROOT$i" ] && continue
365 for j in $(grep -l "^$i$" $ROOT$INSTALLED/*/files.list); do
366 [ "$j" = "$ROOT$INSTALLED/$PACKAGE/files.list" ] && continue
367 grep -qs ^$PACKAGE$ $(dirname $j)/modifiers && continue
368 if [ -s "$(dirname $j)/volatile.cpio.gz" ]; then
369 # We can modify backed up files
370 zcat $(dirname $j)/volatile.cpio.gz | \
371 cpio -t 2> /dev/null | \
372 grep -q "^${i#/}$" && continue
373 fi
374 echo "$PACKAGE" >> $(dirname $j)/modifiers
375 done
376 done
377 cp receipt files.list $ROOT$INSTALLED/$PACKAGE
378 # Copy the description if found.
379 if [ -f "description.txt" ]; then
380 cp description.txt $ROOT$INSTALLED/$PACKAGE
381 fi
382 # Copy the md5sum if found.
383 if [ -f "md5sum" ]; then
384 cp md5sum $ROOT$INSTALLED/$PACKAGE
385 fi
386 # Pre install commands.
387 if grep -q ^pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then
388 pre_install $ROOT
389 fi
390 if [ -n "$CONFIG_FILES" ]; then
391 # save 'official' configuration files
392 echo -n "Save configuration files for $PACKAGE... "
393 for i in $CONFIG_FILES; do
394 ( cd fs ; find ${i#/} -type f )
395 done | ( cd fs ; cpio -o -H newc | gzip -9 ) > \
396 $ROOT$INSTALLED/$PACKAGE/volatile.cpio.gz
397 # keep user configuration files
398 for i in $CONFIG_FILES; do
399 ( cd fs ; find ${i#/} -type f )
400 done | while read i; do
401 [ -e $ROOT/$i ] || continue
402 cp -a $ROOT/$i fs/$i
403 done
404 status
405 fi
406 echo -n "Installing $PACKAGE... "
407 cp -a fs/* $ROOT/
408 status
409 # Remove the temporary random directory.
410 echo -n "Removing all tmp files... "
411 cd .. && rm -rf $TMP_DIR
412 status
413 # Post install commands.
414 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
415 post_install $ROOT
416 fi
417 cd $TOP_DIR
418 echo "================================================================================"
419 echo "$PACKAGE ($VERSION$EXTRAVERSION) is installed."
420 echo ""
421 # Log this activity
422 [ -n "$ROOT" ] || log Installed
424 }
426 # Check for loop in deps tree.
427 check_for_deps_loop()
428 {
429 local list
430 local pkg
431 local deps
432 pkg=$1
433 shift
434 [ -n "$1" ] || return
435 list=""
436 # Filter out already processed deps
437 for i in $@; do
438 case " $ALL_DEPS" in
439 *\ $i\ *);;
440 *) list="$list $i";;
441 esac
442 done
443 ALL_DEPS="$ALL_DEPS$list "
444 for i in $list; do
445 [ -f $i/receipt ] || continue
446 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
447 case " $deps " in
448 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
449 *) check_for_deps_loop $pkg $deps;;
450 esac
451 done
452 }
454 # get package from packages.equiv
455 equivalent_pkg()
456 {
457 for i in $(grep -s "^$1=" $2$LOCALSTATE/packages.equiv | sed "s/^$1=//"); do
458 if echo $i | grep -q : ; then
459 # format 'alternative:newname'
460 # if alternative is installed then substitute newname
461 if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
462 # substitute package dependancy
463 echo ${i#*:}
464 return
465 fi
466 else
467 # if alternative is installed then nothing to install
468 if [ -f $2$INSTALLED/$i/receipt ]; then
469 # substitute installed package
470 echo $i
471 return
472 fi
473 fi
474 done
475 # if not found in packages.equiv then no substitution
476 echo $1
477 }
479 # Check for missing deps listed in a receipt packages.
480 check_for_deps()
481 {
482 local saved;
483 saved=$PACKAGE
484 mkdir -p $TMP_DIR
485 ( cd $TMP_DIR ; cpio -i receipt > /dev/null ) < $PACKAGE_FILE
486 . $TMP_DIR/receipt
487 PACKAGE=$saved
488 rm -rf $TMP_DIR
489 for pkgorg in $DEPENDS
490 do
491 i=$(equivalent_pkg $pkgorg $1)
492 if [ ! -d "$1$INSTALLED/$i" ]; then
493 MISSING_PACKAGE=$i
494 deps=$(($deps+1))
495 elif [ ! -f "$1$INSTALLED/$i/receipt" ]; then
496 echo -e "$WARNING Dependency loop between $PACKAGE and $i."
497 fi
498 done
499 if [ ! "$MISSING_PACKAGE" = "" ]; then
500 echo -e "\033[1mTracking dependencies for :\033[0m $PACKAGE"
501 echo "================================================================================"
502 for pkgorg in $DEPENDS
503 do
504 i=$(equivalent_pkg $pkgorg $1)
505 if [ ! -d "$1$INSTALLED/$i" ]; then
506 MISSING_PACKAGE=$i
507 echo "Missing : $MISSING_PACKAGE"
508 fi
509 done
510 echo "================================================================================"
511 echo "$deps missing package(s) to install."
512 fi
513 }
515 # Install all missing deps. First ask user then install all missing deps
516 # from local dir, cdrom, media or from the mirror. In case we want to
517 # install packages from local, we need a packages.list to find the version.
518 install_deps()
519 {
520 local root
521 root=""
522 [ -n "$1" ] && root="--root=$1"
523 echo ""
524 echo -n "Install all missing dependencies (y/N) ? "; read anser
525 echo ""
526 if [ "$anser" = "y" ]; then
527 for pkgorg in $DEPENDS
528 do
529 pkg=$(equivalent_pkg $pkgorg $1)
530 if [ ! -d "$1$INSTALLED/$pkg" ]; then
531 local list
532 list="$INSTALL_LIST"
533 [ -n "$list" ] || list="$TOP_DIR/packages.list"
534 # We can install packages from a local dir by greping
535 # the TAZPKG_BASENAME in the local packages.list.
536 found=0
537 if [ -f "$list" ]; then
538 echo "Checking if $pkg exist in local list... "
539 mkdir $TMP_DIR
540 for i in $pkg-*.tazpkg; do
541 [ -f $i ] || continue
542 ( cd $TMP_DIR ; cpio -i receipt > /dev/null) < $i
543 [ "$(. $TMP_DIR/receipt; echo $PACKAGE)" = "$pkg" ] || continue
544 if grep -q ^$(package_fullname_in_dir $TMP_DIR).tazpkg$ $list
545 then
546 found=1
547 tazpkg install $i $root --list=$list
548 break
549 fi
550 done
551 rm -rf $TMP_DIR
552 fi
553 # Install deps from the mirror.
554 if [ $found -eq 0 ]; then
555 if [ ! -f "$LOCALSTATE/packages.list" ]; then
556 tazpkg recharge
557 fi
558 tazpkg get-install $pkg $root
559 fi
560 fi
561 done
562 else
563 echo -e "\nLeaving dependencies for $PACKAGE unsolved."
564 echo -e "The package is installed but will probably not work.\n"
565 fi
566 }
568 # xHTML packages list header.
569 xhtml_header()
570 {
571 cat > $XHTML_LIST << _EOT_
572 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
573 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
574 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
575 <head>
576 <title>Installed packages list</title>
577 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
578 <meta name="modified" content="$DATE" />
579 <meta name="generator" content="Tazpkg" />
580 <style type="text/css"><!--
581 body { font: 12px sans-serif, vernada, arial; margin: 0; }
582 #header { background: #f0ba08; color: black; height: 50px;
583 border-top: 1px solid black; border-bottom: 1px solid black; }
584 #content { margin: 0px 50px 26px 50px; }
585 #footer { border-top: 1px solid black; padding-top: 10px;}
586 h1 { margin: 14px 0px 0px 16px; }
587 pre { padding-left: 5px; }
588 hr { color: white; background: white; height: 1px; border: 0; }
589 --></style>
590 </head>
591 <body bgcolor="#ffffff">
592 <div id="header">
593 <h1><font color="#3e1220">Installed packages list</font></h1>
594 </div>
595 <hr />
596 <!-- Start content -->
597 <div id="content">
599 <p>
600 _packages_ packages installed - List generated on : $DATE
601 <p>
603 _EOT_
604 }
606 # xHTML content with packages info.
607 xhtml_pkg_info()
608 {
609 cat >> $XHTML_LIST << _EOT_
610 <h3>$PACKAGE</h3>
611 <pre>
612 Version : $VERSION$EXTRAVERSION
613 Short desc : $SHORT_DESC
614 Web site : <a href="$WEB_SITE">$WEB_SITE</a>
615 </pre>
617 _EOT_
618 }
620 # xHTML packages list footer.
621 xhtml_footer()
622 {
623 cat >> $XHTML_LIST << _EOT_
624 <hr />
625 <p id="footer">
626 $packages packages installed - List generated on : $DATE
627 </p>
629 <!-- End content -->
630 </div>
631 </body>
632 </html>
633 _EOT_
634 }
636 # Search pattern in installed packages.
637 search_in_installed_packages()
638 {
639 echo "Installed packages"
640 echo "================================================================================"
641 list=`ls -1 $INSTALLED | grep -i "$PATTERN"`
642 for pkg in $list
643 do
644 EXTRAVERSION=""
645 [ -f $INSTALLED/$pkg/receipt ] || continue
646 . $INSTALLED/$pkg/receipt
647 echo -n "$PACKAGE "
648 echo -en "\033[24G $VERSION$EXTRAVERSION"
649 echo -e "\033[42G $CATEGORY"
650 packages=$(($packages+1))
651 done
652 # Set correct ending messages.
653 if [ "$packages" = "" ]; then
654 echo "0 installed packages found for : $PATTERN"
655 echo ""
656 else
657 echo "================================================================================"
658 echo "$packages installed package(s) found for : $PATTERN"
659 echo ""
660 fi
661 }
663 # Search in packages.list for available pkgs.
664 search_in_packages_list()
665 {
666 echo "Available packages name-version"
667 echo "================================================================================"
668 packages=0
669 for i in $LOCALSTATE/packages.list $LOCALSTATE/undigest/*/packages.list; do
670 grep -is "$PATTERN" $i
671 packages=$(($packages + `grep -is "$PATTERN" $i | wc -l`))
672 done
673 if [ ! -f "$LOCALSTATE/packages.list" ]; then
674 echo -e "
675 No 'packages.list' found to check for mirrored packages. For more results,
676 please run 'tazpkg recharge' once as root before searching.\n"
677 fi
678 if [ "$packages" = "0" ]; then
679 echo "0 available packages found for : $PATTERN"
680 echo ""
681 else
682 echo "================================================================================"
683 echo "$packages available package(s) found for : $PATTERN"
684 echo ""
685 fi
686 }
688 # search --mirror: Search in packages.txt for available pkgs and give more
689 # info than --list or default.
690 search_in_packages_txt()
691 {
692 echo "Matching packages name with version and desc"
693 echo "================================================================================"
694 packages=0
695 for i in $LOCALSTATE/packages.txt $LOCALSTATE/undigest/*/packages.txt; do
696 grep -is -A 2 "^$PATTERN" $i
697 packages=$(($packages + `grep -is "^$PATTERN" $i | wc -l`))
698 done
699 if [ ! -f "$LOCALSTATE/packages.txt" ]; then
700 echo -e "
701 No 'packages.txt' found to check for mirrored packages. For more results,
702 please run 'tazpkg recharge' once as root before searching.\n"
703 fi
704 if [ "$packages" = "0" ]; then
705 echo "0 available packages found for : $PATTERN"
706 echo ""
707 else
708 echo "================================================================================"
709 echo "$packages available package(s) found for : $PATTERN"
710 echo ""
711 fi
712 }
714 # Install package-list from a flavor
715 install_flavor()
716 {
717 check_root
718 FLAVOR=$1
719 ARG=$2
720 mkdir -p $TMP_DIR
721 [ -f $FLAVOR.flavor ] && cp $FLAVOR.flavor $TMP_DIR
722 cd $TMP_DIR
723 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
724 zcat $FLAVOR.flavor | cpio -i 2>/dev/null
725 while read file; do
726 for pkg in $(ls -d $INSTALLED/${file%%-*}*); do
727 [ -f $pkg/receipt ] || continue
728 EXTRAVERSION=""
729 . $pkg/receipt
730 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && break
731 done
732 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && continue
733 cd $CACHE_DIR
734 download $file.tazpkg
735 cd $TMP_DIR
736 tazpkg install $CACHE_DIR/$file.tazpkg --forced
737 done < $FLAVOR.pkglist
738 [ -f $FLAVOR.nonfree ] && while read pkg; do
739 [ -d $INSTALLED/$pkg ] || continue
740 [ -d $INSTALLED/get-$pkg ] && tazpkg get-install get-$pkg
741 get-$pkg
742 done < $FLAVOR.nonfree
743 [ "$ARG" == "--purge" ] && for pkg in $(ls $INSTALLED); do
744 [ -f $INSTALLED/$pkg/receipt ] || continue
745 EXTRAVERSION=""
746 . $INSTALLED/$pkg/receipt
747 grep -q ^$PACKAGE-$VERSION$EXTRAVERSION$ $FLAVOR.pkglist && continue
748 grep -qs ^$PACKAGE$ $FLAVOR.nonfree && continue
749 tazpkg remove $PACKAGE
750 done
751 else
752 echo "Can't find flavor $FLAVOR Abort."
753 fi
754 cd $TOP_DIR
755 rm -rf $TMP_DIR
756 }
758 # Update mirror urls
759 setup_mirror()
760 {
761 # Backup old list.
762 if [ -f "$1/mirror" ]; then
763 cp -f $1/mirror $1/mirror.bak
764 fi
765 echo ""
766 echo -e "\033[1mCurrent mirror(s)\033[0m"
767 echo "================================================================================"
768 echo " `cat $1/mirror 2> /dev/null`"
769 echo "
770 Please enter URL of the new mirror (http, ftp or local path). You must specify
771 the complete address to the directory of the packages and packages.list file."
772 echo ""
773 echo -n "New mirror(s) URL : "
774 NEW_MIRROR_URL=$2
775 if [ -n "$NEW_MIRROR_URL" ]; then
776 echo $NEW_MIRROR_URL
777 else
778 read NEW_MIRROR_URL
779 fi
780 if [ "$NEW_MIRROR_URL" = "" ]; then
781 echo "Nothing has been changed."
782 else
783 echo "Setting mirror(s) to : $NEW_MIRROR_URL"
784 rm -f $1/mirror
785 for i in $NEW_MIRROR_URL; do
786 echo "$i" >> $1/mirror
787 done
788 fi
789 echo ""
790 }
792 # recursive dependancies scan
793 dep_scan()
794 {
795 for i in $1; do
796 case " $ALL_DEPS " in
797 *\ $i\ *) continue;;
798 esac
799 ALL_DEPS="$ALL_DEPS $i"
800 [ -n "$2" ] && echo "$2$i"
801 [ -f $i/receipt ] || continue
802 DEPENDS=""
803 . $i/receipt
804 [ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2 "
805 done
806 }
808 # recursive reverse dependancies scan
809 rdep_scan()
810 {
811 for i in $1; do
812 case " $ALL_DEPS " in
813 *\ $i\ *) continue;;
814 esac
815 ALL_DEPS="$ALL_DEPS $i"
816 [ -n "$2" ] && echo "$2$i"
817 RDEPENDS=""
818 for j in *; do
819 [ -f $j/receipt ] || continue
820 DEPENDS=""
821 . $j/receipt
822 case " $(echo $DEPENDS) " in
823 *\ $i\ *)
824 RDEPENDS="$RDEPENDS $j";;
825 esac
826 done
827 [ -n "$RDEPENDS" ] && rdep_scan "$RDEPENDS" "$2 "
828 done
829 }
831 ###################
832 # Tazpkg commands #
833 ###################
835 case "$COMMAND" in
836 list)
837 # List all installed packages or a specific category.
838 #
839 if [ "$2" = "blocked" ]; then
840 echo ""
841 echo -e "\033[1mBlocked packages\033[0m"
842 echo "================================================================================"
843 if [ -s "$BLOCKED" ];then
844 cat $BLOCKED
845 echo ""
846 else
847 echo -e "No blocked packages found.\n"
848 fi
849 exit 0
850 fi
851 # Display the list of categories.
852 if [ "$2" = "cat" -o "$2" = "categories" ]; then
853 echo ""
854 echo -e "\033[1mPackages categories :\033[0m"
855 echo "================================================================================"
856 for i in $CATEGORIES
857 do
858 echo $i
859 categories=$(($categories+1))
860 done
861 echo "================================================================================"
862 echo "$categories categories"
863 echo ""
864 exit 0
865 fi
866 # Check for an asked category.
867 if [ -n "$2" ]; then
868 ASKED_CATEGORY=$2
869 echo ""
870 echo -e "\033[1mInstalled packages of category :\033[0m $ASKED_CATEGORY"
871 echo "================================================================================"
872 for pkg in $INSTALLED/*
873 do
874 [ -f $pkg/receipt ] || continue
875 EXTRAVERSION=""
876 . $pkg/receipt
877 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
878 echo -n "$PACKAGE"
879 echo -e "\033[24G $VERSION$EXTRAVERSION"
880 packages=$(($packages+1))
881 fi
882 done
883 echo "================================================================================"
884 echo -e "$packages packages installed of category $ASKED_CATEGORY."
885 echo ""
886 else
887 # By default list all packages and versions.
888 echo ""
889 echo -e "\033[1mList of all installed packages\033[0m"
890 echo "================================================================================"
891 for pkg in $INSTALLED/*
892 do
893 [ -f $pkg/receipt ] || continue
894 EXTRAVERSION=""
895 . $pkg/receipt
896 echo -n "$PACKAGE"
897 echo -en "\033[24G $VERSION$EXTRAVERSION"
898 echo -e "\033[42G $CATEGORY"
899 packages=$(($packages+1))
900 done
901 echo "================================================================================"
902 echo "$packages packages installed."
903 echo ""
904 fi
905 ;;
906 xhtml-list)
907 # Get info in receipts and build list.
908 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
909 if [ -n "$2" ]; then
910 XHTML_LIST=$2
911 else
912 XHTML_LIST=installed-packages.html
913 fi
914 echo ""
915 echo -e "\033[1mCreating xHTML list of installed packages\033[0m"
916 echo "================================================================================"
917 echo -n "Generating xHTML header..."
918 xhtml_header
919 status
920 # Packages
921 echo -n "Creating packages information..."
922 for pkg in $INSTALLED/*
923 do
924 [ -f $pkg/receipt ] || continue
925 EXTRAVERSION=""
926 . $pkg/receipt
927 xhtml_pkg_info
928 packages=$(($packages+1))
929 done
930 status
931 echo -n "Generating xHTML footer..."
932 xhtml_footer
933 status
934 # sed pkgs nb in header.
935 sed -i s/'_packages_'/"$packages"/ $XHTML_LIST
936 echo "================================================================================"
937 echo "$XHTML_LIST created - $packages packages."
938 echo ""
939 ;;
940 list-mirror)
941 # List all available packages on the mirror. Option --diff display
942 # last mirrored packages diff (see recharge).
943 check_for_packages_list
944 case $2 in
945 --diff)
946 if [ -f "$LOCALSTATE/packages.diff" ]; then
947 echo ""
948 echo -e "\033[1mMirrored packages diff\033[0m"
949 echo "================================================================================"
950 cat $LOCALSTATE/packages.diff
951 echo "================================================================================"
952 pkgs=`cat $LOCALSTATE/packages.diff | wc -l`
953 echo "$pkgs new packages listed on the mirror."
954 echo ""
955 else
956 echo -e "\nUnable to list anything, no packages.diff found."
957 echo -e "Recharge your current list to create a first diff.\n"
958 fi && exit 0 ;;
959 --text|--txt)
960 echo ""
961 echo -e "\033[1mList of available packages on the mirror\033[0m"
962 echo "================================================================================"
963 cat $LOCALSTATE/packages.txt ;;
964 --raw|*)
965 echo ""
966 echo -e "\033[1mList of available packages on the mirror\033[0m"
967 echo "================================================================================"
968 cat $LOCALSTATE/packages.list ;;
969 esac
970 echo "================================================================================"
971 pkgs=`cat $LOCALSTATE/packages.list | wc -l`
972 echo "$pkgs packages in the last recharged list."
973 echo ""
974 ;;
975 list-files)
976 # List files installed with the package.
977 #
978 check_for_package_on_cmdline
979 check_for_receipt
980 echo ""
981 echo -e "\033[1mInstalled files with :\033[0m $PACKAGE"
982 echo "================================================================================"
983 cat $INSTALLED/$PACKAGE/files.list | sort
984 echo "================================================================================"
985 files=`cat $INSTALLED/$PACKAGE/files.list | wc -l`
986 echo "$files files installed with $PACKAGE."
987 echo ""
988 ;;
989 info)
990 # Information about package.
991 #
992 check_for_package_on_cmdline
993 check_for_receipt
994 EXTRAVERSION=""
995 . $INSTALLED/$PACKAGE/receipt
996 echo ""
997 echo -e "\033[1mTazpkg information\033[0m
998 ================================================================================
999 Package : $PACKAGE
1000 Version : $VERSION$EXTRAVERSION
1001 Category : $CATEGORY
1002 Short desc : $SHORT_DESC
1003 Maintainer : $MAINTAINER"
1004 if [ ! "$DEPENDS" = "" ]; then
1005 echo -e "Depends : $DEPENDS"
1006 fi
1007 if [ ! "$SUGGESTED" = "" ]; then
1008 echo -e "Suggested : $SUGGESTED"
1009 fi
1010 if [ ! "$BUILD_DEPENDS" = "" ]; then
1011 echo -e "Build deps : $BUILD_DEPENDS"
1012 fi
1013 if [ ! "$WANTED" = "" ]; then
1014 echo -e "Wanted src : $WANTED"
1015 fi
1016 if [ ! "$WEB_SITE" = "" ]; then
1017 echo -e "Web site : $WEB_SITE"
1018 fi
1019 echo "================================================================================"
1020 echo ""
1021 ;;
1022 desc)
1023 # Display package description.txt if available.
1024 if [ -f "$INSTALLED/$PACKAGE/description.txt" ]; then
1025 echo ""
1026 echo -e "\033[1mDescription of :\033[0m $PACKAGE"
1027 echo "================================================================================"
1028 cat $INSTALLED/$PACKAGE/description.txt
1029 echo "================================================================================"
1030 echo ""
1031 else
1032 echo -e "\nSorry, no description available for this package.\n"
1033 fi
1034 ;;
1035 search)
1036 # Search for a package by pattern or name.
1038 PATTERN="$2"
1039 if [ -z "$PATTERN" ]; then
1040 echo -e "\nPlease specify a pattern or package name to search for."
1041 echo -e "Example : 'tazpkg search paint'.\n"
1042 exit 0
1043 fi
1044 echo ""
1045 echo -e "\033[1mSearch result for :\033[0m $PATTERN"
1046 echo ""
1047 # Default is to search in installed pkgs and the raw list.
1048 case $3 in
1049 -i|--installed)
1050 search_in_installed_packages ;;
1051 -l|--list)
1052 search_in_packages_list ;;
1053 -m|--mirror)
1054 search_in_packages_txt ;;
1055 *)
1056 search_in_installed_packages
1057 search_in_packages_list ;;
1058 esac
1059 ;;
1060 search-file)
1061 # Search for a file by pattern or name in all files.list.
1063 if [ -z "$2" ]; then
1064 echo -e "\nPlease specify a pattern or file name to search for."
1065 echo -e "Example : 'tazpkg search-file libnss'. \n"
1066 exit 0
1067 fi
1068 echo ""
1069 echo -e "\033[1mSearch result for file :\033[0m $2"
1070 echo "================================================================================"
1072 if [ "$3" == "--mirror" ]; then
1074 match=0
1075 for i in $LOCALSTATE/files.list.lzma \
1076 $LOCALSTATE/undigest/*/files.list.lzma; do
1077 [ -f $i ] || continue
1078 unlzma -c $i | grep -- ".*:.*$2" | awk '
1079 BEGIN { last="" }
1081 pkg=substr($0,0,index($0,":")-1);
1082 file=substr($0,index($0,":")+2);
1083 if (last != pkg) {
1084 last = pkg;
1085 printf("\n%c[1mPackage %s :%c[0m\n",27,pkg,27);
1087 printf("%s\n",file);
1088 }'
1089 match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | wc -l`))
1090 done
1092 else
1094 # Check all pkg files.list in search match with specify the package
1095 # name and the full path to the file(s).
1096 for pkg in $INSTALLED/*
1097 do
1098 if grep -qs "$2" $pkg/files.list; then
1099 . $pkg/receipt
1100 echo ""
1101 echo -e "\033[1mPackage $PACKAGE :\033[0m"
1102 grep "$2" $pkg/files.list
1103 files=`grep $2 $pkg/files.list | wc -l`
1104 match=$(($match+$files))
1105 fi
1106 done
1108 fi
1110 if [ "$match" = "" ]; then
1111 echo "0 file found for : $2"
1112 echo ""
1113 else
1114 echo ""
1115 echo "================================================================================"
1116 echo "$match file(s) found for : $2"
1117 echo ""
1118 fi
1119 ;;
1120 install)
1121 # Install .tazpkg packages.
1123 check_root
1124 check_for_package_on_cmdline
1125 check_for_package_file
1126 # Check if forced install.
1127 DO_CHECK="yes"
1128 ROOT=""
1129 while [ -n "$3" ]; do
1130 case "$3" in
1131 --forced)
1132 DO_CHECK="no"
1133 ;;
1134 --root=*)
1135 ROOT="${3#--root=}"
1136 ;;
1137 --list=*)
1138 INSTALL_LIST="${3#--list=}"
1139 ;;
1140 *) shift 2
1141 echo -e "\nUnknown option $*.\n"
1142 exit 1
1143 ;;
1144 esac
1145 shift
1146 done
1147 if [ "$DO_CHECK" = "yes" ]; then
1148 check_for_installed_package $ROOT
1149 fi
1150 install_package $ROOT
1151 ;;
1152 install-list|get-install-list)
1153 # Install a set of packages from a list.
1155 check_root
1156 if [ -z "$2" ]; then
1157 echo -e "
1158 Please change directory (cd) to the packages repository, and specify the
1159 list of packages to install. Example : tazpkg install-list packages.list\n"
1160 exit 0
1161 fi
1162 # Check if the packages list exist.
1163 if [ ! -f "$2" ]; then
1164 echo "Unable to find : $2"
1165 exit 0
1166 else
1167 LIST=`cat $2`
1168 fi
1170 # Remember processed list
1171 export INSTALL_LIST="$2"
1173 # Set $COMMAND and install all packages.
1174 if [ "$1" = "get-install-list" ]; then
1175 COMMAND=get-install
1176 else
1177 COMMAND=install
1178 fi
1179 touch $2-processed
1180 for pkg in $LIST
1181 do
1182 grep -qs ^$pkg$ $2-processed && continue
1183 tazpkg $COMMAND $pkg --list=$2 "$3" "$4" "$5"
1184 done
1185 rm -f $2-processed
1186 ;;
1187 add-flavor)
1188 # Install a set of packages from a flavor.
1190 install_flavor $2
1191 ;;
1192 install-flavor)
1193 # Install a set of packages from a flavor and purge other ones.
1195 install_flavor $2 --purge
1196 ;;
1197 set-release)
1198 # Change curent release and upgrade packages.
1200 RELEASE=$2
1201 if [ -z "$RELEASE" ]; then
1202 echo -e "\nPlease specify the release you want on the command line."
1203 echo -e "Example: tazpkg set-release cooking\n"
1204 exit 0
1205 fi
1206 rm /var/lib/tazpkg/mirror
1207 echo "$RELEASE" > /etc/slitaz-release
1208 tazpkg recharge && tazpkg upgrade
1209 ;;
1210 remove)
1211 # Remove packages.
1213 check_root
1214 check_for_package_on_cmdline
1215 if [ ! -f "$INSTALLED/$PACKAGE/receipt" ]; then
1216 echo -e "\n$PACKAGE is not installed.\n"
1217 exit 0
1218 else
1219 ALTERED=""
1220 THE_PACKAGE=$PACKAGE # altered by receipt
1221 for i in $(cd $INSTALLED ; ls); do
1222 [ -f $INSTALLED/$i/receipt ] || continue
1223 DEPENDS=""
1224 . $INSTALLED/$i/receipt
1225 case " $(echo $DEPENDS) " in
1226 *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
1227 esac
1228 done
1229 EXTRAVERSION=""
1230 . $INSTALLED/$THE_PACKAGE/receipt
1231 fi
1232 echo ""
1233 if [ -n "$ALTERED" ]; then
1234 echo "The following packages depend on $PACKAGE :"
1235 for i in $ALTERED; do
1236 echo " $i"
1237 done
1238 fi
1239 REFRESH=$(cd $INSTALLED ; grep -sl ^$PACKAGE$ */modifiers)
1240 if [ -n "$REFRESH" ]; then
1241 echo "The following packages have been modified by $PACKAGE :"
1242 for i in $REFRESH; do
1243 echo " ${i%/modifiers}"
1244 done
1245 fi
1246 echo "Remove $PACKAGE ($VERSION$EXTRAVERSION) ?"
1247 echo -n "Please confirm uninstallation (y/N) : "; read anser
1248 if [ "$anser" = "y" ]; then
1249 echo ""
1250 echo -e "\033[1mRemoving :\033[0m $PACKAGE"
1251 echo "================================================================================"
1252 # Pre remove commands.
1253 if grep -q ^pre_remove $INSTALLED/$PACKAGE/receipt; then
1254 pre_remove
1255 fi
1256 echo -n "Removing all files installed..."
1257 for file in `cat $INSTALLED/$PACKAGE/files.list`
1258 do
1259 [ $(grep ^$file$ $INSTALLED/*/files.list | wc -l) -gt 1 ] && continue
1260 rm -rf $file 2>/dev/null
1261 done
1262 status
1263 if grep -q ^post_remove $INSTALLED/$PACKAGE/receipt; then
1264 post_remove
1265 fi
1266 # Remove package receipt.
1267 echo -n "Removing package receipt..."
1268 rm -rf $INSTALLED/$PACKAGE
1269 status
1270 # Log this activity
1271 log Removed
1272 if [ -n "$ALTERED" ]; then
1273 echo -n "Remove packages depending on $PACKAGE"
1274 echo -n " (y/N) ? "; read anser
1275 if [ "$anser" = "y" ]; then
1276 for i in $ALTERED; do
1277 if [ -d "$INSTALLED/$i" ]; then
1278 tazpkg remove $i
1279 fi
1280 done
1281 fi
1282 fi
1283 if [ -n "$REFRESH" ]; then
1284 echo -n "Reinstall packages modified by $PACKAGE"
1285 echo -n " (y/N) ? "; read anser
1286 if [ "$anser" = "y" ]; then
1287 for i in $REFRESH; do
1288 if [ $(wc -l < $INSTALLED/$i) -gt 1 ]; then
1289 echo "Check $INSTALLED/$i for reinstallation"
1290 continue
1291 fi
1292 rm -r $INSTALLED/$i
1293 tazpkg get-install ${i%/modifiers} --forced
1294 done
1295 fi
1296 fi
1297 else
1298 echo ""
1299 echo "Uninstallation of $PACKAGE cancelled."
1300 fi
1301 echo ""
1302 ;;
1303 extract)
1304 # Extract .tazpkg cpio archive into a directory.
1306 check_for_package_on_cmdline
1307 check_for_package_file
1308 echo ""
1309 echo -e "\033[1mExtracting :\033[0m $PACKAGE"
1310 echo "================================================================================"
1311 # If no directory destination is found on the cmdline
1312 # we create one in the current dir using the package name.
1313 if [ -n "$TARGET_DIR" ]; then
1314 DESTDIR=$TARGET_DIR/$PACKAGE
1315 else
1316 DESTDIR=$PACKAGE
1317 fi
1318 mkdir -p $DESTDIR
1319 echo -n "Copying original package..."
1320 cp $PACKAGE_FILE $DESTDIR
1321 status
1322 cd $DESTDIR
1323 extract_package
1324 echo "================================================================================"
1325 echo "$PACKAGE is extracted to : $DESTDIR"
1326 echo ""
1327 ;;
1328 list-config)
1329 # List configuration files installed.
1331 if [ "$2" = "--box" ]; then
1332 mkdir -p $TMP_DIR && cd $TMP_DIR
1333 for i in $INSTALLED/*/volatile.cpio.gz; do
1334 zcat $i | cpio -id > /dev/null
1335 find * -type f 2>/dev/null | while read file; do
1336 if [ ! -e /$file ]; then
1337 echo -n "|--|--|--|File lost"
1338 else
1339 echo -n "$(stat -c "%A|%U|%G|%s|" /$file)"
1340 cmp $file /$file > /dev/null 2>&1 || \
1341 echo -n "$(stat -c "%.16y" /$file)"
1342 fi
1343 echo "|/$file"
1344 done
1345 rm -rf *
1346 done
1347 cd $TOP_DIR
1348 rm -rf $TMP_DIR
1349 else
1350 echo ""
1351 echo -e "\033[1mConfiguration files"
1352 echo "================================================================================"
1353 for i in $INSTALLED/*/volatile.cpio.gz; do
1354 [ -n "$2" -a "$i" != "$INSTALLED/$2/volatile.cpio.gz" ] && continue
1355 [ -f "$i" ] || continue
1356 zcat $i | cpio -t | grep -v "[0-9]* blocks"
1357 done | sed 's|^|/|' | sort
1358 echo "================================================================================"
1359 echo ""
1360 fi
1361 ;;
1362 repack-config)
1363 # Create SliTaz package archive from configuration files.
1365 mkdir -p $TMP_DIR && cd $TMP_DIR
1366 CONFIG_VERSION=1.0
1367 mkdir config-$CONFIG_VERSION
1368 cd config-$CONFIG_VERSION
1369 for i in $INSTALLED/*/volatile.cpio.gz; do
1370 zcat $i | cpio -t | grep -v "[0-9]* blocks"
1371 done > files.list
1372 mkdir fs
1373 cd fs
1374 ( cd / ; cpio -o -H newc ) < ../files.list | cpio -id > /dev/null
1375 mkdir -p etc/tazlito
1376 for i in $INSTALLED/*/receipt; do
1377 EXTRAVERSION=""
1378 . $i
1379 echo "$PACKAGE-$VERSION$EXTRAVERSION"
1380 done > etc/tazlito/config-packages.list
1381 cd ..
1382 echo "etc/tazlito/config-packages.list" >> files.list
1383 cat > receipt <<EOT
1384 # SliTaz package receipt.
1386 PACKAGE="config"
1387 VERSION="$CONFIG_VERSION"
1388 CATEGORY="base-system"
1389 SHORT_DESC="User configuration backup on $(date)"
1390 DEPENDS="$(ls $INSTALLED)"
1391 EOT
1392 cd ..
1393 tazpkg pack config-$CONFIG_VERSION
1394 cp config-$CONFIG_VERSION.tazpkg $TOP_DIR
1395 cd $TOP_DIR
1396 rm -rf $TMP_DIR
1397 ;;
1398 repack)
1399 # Create SliTaz package archive from an installed package.
1401 check_for_package_on_cmdline
1402 check_for_receipt
1403 EXTRAVERSION=""
1404 . $INSTALLED/$PACKAGE/receipt
1405 echo ""
1406 echo -e "\033[1mRepacking :\033[0m $PACKAGE-$VERSION$EXTRAVERSION.tazpkg"
1407 echo "================================================================================"
1408 if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then
1409 echo "Can't repack $PACKAGE"
1410 exit 1
1411 fi
1412 if [ -s $INSTALLED/$PACKAGE/modifiers ]; then
1413 echo "Can't repack, $PACKAGE files have been modified by:"
1414 for i in $(cat $INSTALLED/$PACKAGE/modifiers); do
1415 echo " $i"
1416 done
1417 exit 1
1418 fi
1419 MISSING=""
1420 while read i; do
1421 [ -e "$i" ] && continue
1422 [ -L "$i" ] || MISSING="$MISSING\n $i"
1423 done < $INSTALLED/$PACKAGE/files.list
1424 if [ -n "$MISSING" ]; then
1425 echo -n "Can't repack, the following files are lost:"
1426 echo -e "$MISSING"
1427 exit 1
1428 fi
1429 mkdir -p $TMP_DIR && cd $TMP_DIR
1430 FILES="fs.cpio.gz\n"
1431 for i in $(ls $INSTALLED/$PACKAGE) ; do
1432 [ "$i" = "volatile.cpio.gz" ] && continue
1433 [ "$i" = "modifiers" ] && continue
1434 cp $INSTALLED/$PACKAGE/$i . && FILES="$FILES$i\n"
1435 done
1436 ln -s / rootfs
1437 mkdir tmp
1438 sed 's/^/rootfs/' < files.list | cpio -o -H newc 2>/dev/null |\
1439 ( cd tmp ; cpio -id 2>/dev/null )
1440 mv tmp/rootfs fs
1441 if [ -f $INSTALLED/$PACKAGE/volatile.cpio.gz ]; then
1442 zcat $INSTALLED/$PACKAGE/volatile.cpio.gz | \
1443 ( cd fs; cpio -id )
1444 fi
1445 if grep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then
1446 . $INSTALLED/$PACKAGE/receipt
1447 repack_cleanup fs
1448 fi
1449 if [ -f $INSTALLED/$PACKAGE/md5sum ]; then
1450 sed 's, , fs,' < $INSTALLED/$PACKAGE/md5sum | \
1451 if ! md5sum -s -c; then
1452 echo -n "Can't repack, md5sum error."
1453 cd $TOP_DIR
1454 \rm -R $TMP_DIR
1455 exit 1
1456 fi
1457 fi
1458 find fs | cpio -o -H newc 2> /dev/null | gzip -9 > fs.cpio.gz
1459 echo -e "$FILES" | cpio -o -H newc 2> /dev/null > \
1460 $TOP_DIR/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
1461 cd $TOP_DIR
1462 \rm -R $TMP_DIR
1463 echo "Package $PACKAGE repacked successfully."
1464 echo "Size : `du -sh $PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
1465 echo ""
1466 ;;
1467 pack)
1468 # Create SliTaz package archive using cpio and gzip.
1470 check_for_package_on_cmdline
1471 cd $PACKAGE
1472 if [ ! -f "receipt" ]; then
1473 echo "Receipt is missing. Please read the documentation."
1474 exit 0
1475 else
1476 echo ""
1477 echo -e "\033[1mPacking :\033[0m $PACKAGE"
1478 echo "================================================================================"
1479 # Create files.list with redirecting find outpout.
1480 echo -n "Creating the list of files..." && cd fs
1481 find . -type f -print > ../files.list
1482 find . -type l -print >> ../files.list
1483 cd .. && sed -i s/'^.'/''/ files.list
1484 status
1485 echo -n "Creating md5sum of files..."
1486 while read file; do
1487 [ -L "fs$file" ] && continue
1488 [ -f "fs$file" ] || continue
1489 case "$file" in
1490 /lib/modules/*/modules.*|*.pyc) continue;;
1491 esac
1492 md5sum "fs$file" | sed 's/ fs/ /'
1493 done < files.list > md5sum
1494 status
1495 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
1496 description.txt 2> /dev/null | awk \
1497 '{ sz=$1 } END { print sz }')
1498 # Build cpio archives.
1499 echo -n "Compressing the fs... "
1500 find fs -print | cpio -o -H newc | gzip > fs.cpio.gz
1501 rm -rf fs
1502 status
1503 PACKED_SIZE=$(du -chs fs.cpio.gz receipt files.list \
1504 md5sum description.txt 2> /dev/null | awk \
1505 '{ sz=$1 } END { print sz }')
1506 echo -n "Undating receipt sizes..."
1507 sed -i s/^PACKED_SIZE.*$// receipt
1508 sed -i s/^UNPACKED_SIZE.*$// receipt
1509 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1510 status
1511 echo -n "Creating full cpio archive... "
1512 find . -print | cpio -o -H newc > ../$PACKAGE.tazpkg
1513 status
1514 echo -n "Restoring original package tree... "
1515 zcat fs.cpio.gz | cpio -id
1516 status
1517 rm fs.cpio.gz && cd ..
1518 echo "================================================================================"
1519 echo "Package $PACKAGE compressed successfully."
1520 echo "Size : `du -sh $PACKAGE.tazpkg`"
1521 echo ""
1522 fi
1523 ;;
1524 recharge)
1525 # Recharge packages.list from a mirror.
1527 check_root
1528 for path in $LOCALSTATE $LOCALSTATE/undigest/*; do
1529 [ -f $path/mirror ] || continue
1530 echo ""
1531 if [ "$path" != "$LOCALSTATE" ]; then
1532 echo "Recharge undigest $(basename $path):"
1533 fi
1534 cd $path
1535 if [ -f "packages.list" ]; then
1536 echo -n "Creating backup of the last packages list..."
1537 mv -f packages.desc packages.desc.bak 2>/dev/null
1538 mv -f packages.md5 packages.md5.txt 2>/dev/null
1539 mv -f packages.txt packages.txt.bak 2>/dev/null
1540 mv -f packages.list packages.list.bak 2>/dev/null
1541 mv -f packages.equiv packages.equiv.bak 2>/dev/null
1542 mv -f files.list.lzma files.list.lzma.bak 2> /dev/nul
1543 status
1544 fi
1545 download_from "$(cat mirror)" packages.desc
1546 download_from "$(cat mirror)" packages.md5
1547 download_from "$(cat mirror)" packages.txt
1548 download_from "$(cat mirror)" packages.list
1549 download_from "$(cat mirror)" packages.equiv
1550 download_from "$(cat mirror)" files.list.lzma
1551 if [ -f "packages.list.bak" ]; then
1552 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
1553 sed -i s/+// packages.diff
1554 echo ""
1555 echo -e "\033[1mMirrored packages diff\033[0m"
1556 echo "================================================================================"
1557 cat packages.diff
1558 if [ ! "`cat packages.diff | wc -l`" = 0 ]; then
1559 echo "================================================================================"
1560 echo "`cat packages.diff | wc -l` new packages on the mirror."
1561 echo ""
1562 else
1563 echo "`cat packages.diff | wc -l` new packages on the mirror."
1564 echo ""
1565 fi
1566 else
1567 echo -e "
1568 ================================================================================
1569 Last packages.list is ready to use. Note that next time you recharge the list,
1570 a list of differencies will be displayed to show new and upgradeable packages.\n"
1571 fi
1572 done
1573 ;;
1574 upgrade)
1575 # Upgrade all installed packages with the new version from the mirror.
1577 check_root
1578 check_for_packages_list
1579 cd $LOCALSTATE
1580 # Touch the blocked pkgs list to avoid errors and remove any old
1581 # upgrade list.
1582 touch blocked-packages.list
1583 rm -f upgradeable-packages.list
1584 echo ""
1585 echo -e "\033[1mAvailable upgrades\033[0m"
1586 echo "================================================================================"
1587 echo ""
1588 # Some packages must be installed first
1589 FIRST_CLASS_PACKAGE=" glibc-base slitaz-base-files slitaz-boot-scripts "
1590 for pkg in $INSTALLED/*
1591 do
1592 [ -f $pkg/receipt ] || continue
1593 EXTRAVERSION=""
1594 . $pkg/receipt
1595 # Display package name to show that Tazpkg is working...
1596 echo -en "\\033[0G "
1597 echo -en "\\033[0G$PACKAGE"
1598 # Skip specified pkgs listed in $LOCALSTATE/blocked-packages.list
1599 if grep -q "^$PACKAGE" $BLOCKED; then
1600 blocked=$(($blocked+1))
1601 else
1602 # Check if the installed package is in the current list (other
1603 # mirror or local).
1604 NEW_PACKAGE=$(get_package_filename $PACKAGE)
1606 if [ -n "$NEW_PACKAGE" ]; then
1607 # Set new pkg and version for futur comparaison
1608 NEW_VERSION=`echo $NEW_PACKAGE | sed s/$PACKAGE-/''/`
1609 # Change '-' and 'pre' to points.
1610 NEW_VERSION=`echo $NEW_VERSION | sed s/'-'/'.'/`
1611 VERSION=`echo $VERSION | sed s/'-'/'.'/`$EXTRAVERSION
1612 NEW_VERSION=`echo $NEW_VERSION | sed s/'pre'/'.'/`
1613 VERSION=`echo $VERSION | sed s/'pre'/'.'/`
1614 NEW_VERSION=`echo $NEW_VERSION | sed 's/[A-Z]\.//'`
1615 VERSION=`echo $VERSION | sed 's/[A-Z]\.//'`
1616 # Compare version. Upgrade are only available for official
1617 # packages, so we control de mirror and it should be ok if
1618 # we just check for egality.
1619 RELEASE=""
1620 if [ -f installed.md5 -a -f packages.md5 ]; then
1621 current_md5=$(grep -s " $PACKAGE-$VERSION" installed.md5 | awk '{ print $1 }')
1622 new_md5=$(grep -hs " $PACKAGE-$VERSION" packages.md5 undigest/*/packages.md5 | head -1 | awk '{ print $1 }')
1623 [ -n "$current_md5" ] && [ -n "$new_md5" ] &&
1624 [ "$current_md5" != "$new_md5" ] && RELEASE=build
1625 fi
1626 if [ "$VERSION" != "$NEW_VERSION" -o -n "$RELEASE" ]; then
1627 # Version seems different. Check for major, minor or
1628 # revision
1629 PKG_MAJOR=`echo ${VERSION%_*} | cut -f1 -d"."`
1630 NEW_MAJOR=`echo ${NEW_VERSION%_*} | cut -f1 -d"."`
1631 PKG_MINOR=`echo ${VERSION%_*} | cut -f2 -d"."`
1632 NEW_MINOR=`echo ${NEW_VERSION%_*} | cut -f2 -d"."`
1633 # Minor
1634 if [ "$NEW_MINOR" -gt "$PKG_MINOR" ] 2> /dev/null; then
1635 RELEASE=minor
1636 fi
1637 if [ "$NEW_MINOR" -lt "$PKG_MINOR" ] 2> /dev/null; then
1638 RELEASE=$WARNING
1639 FIXE=yes
1640 fi
1641 # Major
1642 if [ "$NEW_MAJOR" -gt "$PKG_MAJOR" ] 2> /dev/null; then
1643 RELEASE=major
1644 FIXE=""
1645 fi
1646 if [ "$NEW_MAJOR" -lt "$PKG_MAJOR" ] 2> /dev/null; then
1647 RELEASE=$WARNING
1648 FIXE=yes
1649 fi
1650 # Default to revision.
1651 if [ -z $RELEASE ]; then
1652 RELEASE=revision
1653 fi
1654 # Pkg name is already displayed by the check process.
1655 echo -en "\033[24G $VERSION"
1656 echo -en "\033[38G --->"
1657 echo -en "\033[43G $NEW_VERSION"
1658 echo -en "\033[58G $CATEGORY"
1659 echo -e "\033[72G $RELEASE"
1660 up=$(($up+1))
1661 echo "$PACKAGE" >> upgradeable-packages.list
1662 case "$FIRST_CLASS_PACKAGE" in
1663 *\ $PACKAGE\ *) echo "$PACKAGE" >> upgradeable-packages.list$$;;
1664 esac
1665 unset RELEASE
1666 fi
1667 packages=$(($packages+1))
1668 fi
1669 fi
1670 done
1671 if [ -z $blocked ]; then
1672 blocked=0
1673 fi
1674 # Clean last checked package and display summary.
1675 if [ ! "$up" = "" ]; then
1676 echo -e "\\033[0G "
1677 echo "================================================================================"
1678 echo "$packages installed and listed packages to consider, $up to upgrade, $blocked blocked."
1679 echo ""
1680 else
1681 echo -e "\\033[0GSystem is up-to-date. "
1682 echo ""
1683 echo "================================================================================"
1684 echo "$packages installed and listed packages to consider, 0 to upgrade, $blocked blocked."
1685 echo ""
1686 exit 0
1687 fi
1688 # What to do if major or minor version is smaller.
1689 if [ "$FIXE" == "yes" ]; then
1690 echo -e "$WARNING ---> Installed package seems more recent than the mirrored one."
1691 echo "You can block packages using the command : 'tazpkg block package'"
1692 echo "Or upgrade package at you own risks."
1693 echo ""
1694 fi
1695 # Ask for upgrade, it can be done another time.
1696 echo -n "Upgrade now (y/N) ? "; read anser
1697 if [ ! "$anser" = "y" ]; then
1698 echo -e "\nExiting. No package upgraded.\n"
1699 exit 0
1700 fi
1701 # If anser is yes (y). Install all new versions.
1702 cat upgradeable-packages.list >> upgradeable-packages.list$$
1703 mv -f upgradeable-packages.list$$ upgradeable-packages.list
1704 yes y | tazpkg get-install-list upgradeable-packages.list --forced
1705 rm -f upgradeable-packages.list
1706 ;;
1707 bugs)
1708 # Show known bugs in package(s)
1710 cd $INSTALLED
1711 shift
1712 LIST=$@
1713 [ -n "$LIST" ] || LIST=`ls`
1714 MSG="No known bugs."
1715 for PACKAGE in $LIST; do
1716 BUGS=""
1717 EXTRAVERSION=""
1718 . $PACKAGE/receipt
1719 if [ -n "$BUGS" ]; then
1720 MSG="
1721 Bug list completed"
1722 cat <<EOT
1724 Bugs in package $PACKAGE version $VERSION$EXTRAVERSION:
1725 $BUGS
1726 EOT
1727 fi
1728 done
1729 echo "$MSG"
1730 ;;
1731 check)
1732 # Check installed packages set.
1734 check_root
1735 cd $INSTALLED
1736 for PACKAGE in `ls`; do
1737 if [ ! -f $PACKAGE/receipt ]; then
1738 echo "The package $PACKAGE installation is not completed"
1739 continue
1740 fi
1741 DEPENDS=""
1742 EXTRAVERSION=""
1743 . $PACKAGE/receipt
1744 if [ -s $PACKAGE/modifiers ]; then
1745 echo "The package $PACKAGE $VERSION$EXTRAVERSION has been modified by :"
1746 for i in $(cat $PACKAGE/modifiers); do
1747 echo " $i"
1748 done
1749 fi
1750 MSG="Files lost from $PACKAGE $VERSION$EXTRAVERSION :\n"
1751 while read file; do
1752 [ -e "$file" ] && continue
1753 if [ -L "$file" ]; then
1754 MSG="$MSG target of symlink"
1755 fi
1756 echo -e "$MSG $file"
1757 MSG=""
1758 done < $PACKAGE/files.list
1759 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
1760 for i in $DEPENDS; do
1761 [ -d $i ] && continue
1762 echo -e "$MSG $i"
1763 MSG=""
1764 done
1765 MSG="Dependencies loop between $PACKAGE and :\n"
1766 ALL_DEPS=""
1767 check_for_deps_loop $PACKAGE $DEPENDS
1768 done
1769 echo -n "Looking for known bugs... "
1770 tazpkg bugs
1771 if [ "$PACKAGE_FILE" = "--full" ]; then
1772 for file in */md5sum; do
1773 CONFIG_FILES=""
1774 . $(dirname "$file")/receipt
1775 [ -s "$file" ] || continue
1776 while read md5 f; do
1777 [ -f $f ] || continue
1778 for i in $CONFIG_FILES; do
1779 case "$f" in
1780 $i|$i/*) continue 2;;
1781 esac
1782 done
1783 echo "$md5 $f"
1784 done < "$file" | md5sum -c - 2> /dev/null | \
1785 grep -v OK$ | sed 's/FAILED$/MD5SUM MISMATCH/'
1786 done
1787 FILES=" "
1788 for file in $(cat */files.list); do
1789 [ -d "$file" ] && continue
1790 case "$FILES" in *\ $file\ *) continue;; esac
1791 [ $(grep "^$file$" */files.list 2> /dev/null | \
1792 wc -l) -gt 1 ] || continue
1793 FILES="$FILES$file "
1794 echo "The following packages provide $file :"
1795 grep -l "^$file$" */files.list | while read f
1796 do
1797 pkg=${f%/files.list}
1798 echo -n " $pkg"
1799 if [ -f $pkg/modifiers ]; then
1800 echo -n " (overridden by $(echo "$(cat $pkg/modifiers)"))"
1801 fi
1802 echo ""
1803 done
1804 done
1805 MSG="No package has installed the following files:\n"
1806 find /etc /bin /sbin /lib /usr /var/www \
1807 -not -type d 2> /dev/null | while read file; do
1808 case "$file" in *\[*) continue;; esac
1809 grep -q "^$file$" */files.list && continue
1810 echo -e "$MSG $file"
1811 MSG=""
1812 done
1813 fi
1814 echo "Check completed."
1815 ;;
1816 block)
1817 # Add a pkg name to the list of blocked packages.
1819 check_root
1820 check_for_package_on_cmdline
1821 echo ""
1822 if grep -q "^$PACKAGE" $BLOCKED; then
1823 echo "$PACKAGE is already in the blocked packages list."
1824 echo ""
1825 exit 0
1826 else
1827 echo -n "Add $PACKAGE to : $BLOCKED..."
1828 echo $PACKAGE >> $BLOCKED
1829 status
1830 # Log this activity
1831 . $INSTALLED/$PACKAGE/receipt
1832 log Blocked
1833 fi
1834 echo ""
1835 ;;
1836 unblock)
1837 # Remove a pkg name from the list of blocked packages.
1839 check_root
1840 check_for_package_on_cmdline
1841 echo ""
1842 if grep -q "^$PACKAGE" $BLOCKED; then
1843 echo -n "Removing $PACKAGE from : $BLOCKED..."
1844 sed -i s/$PACKAGE/''/ $BLOCKED
1845 sed -i '/^$/d' $BLOCKED
1846 status
1847 # Log this activity
1848 . $INSTALLED/$PACKAGE/receipt
1849 log Unblocked
1850 else
1851 echo "$PACKAGE is not in the blocked packages list."
1852 echo ""
1853 exit 0
1854 fi
1855 echo ""
1856 ;;
1857 get)
1858 # Downlowd a package with wget.
1860 check_for_package_on_cmdline
1861 check_for_packages_list
1862 check_for_package_in_list
1863 echo ""
1864 download $PACKAGE.tazpkg
1865 echo ""
1866 ;;
1867 get-install)
1868 # Download and install a package.
1870 check_root
1871 check_for_package_on_cmdline
1872 check_for_packages_list
1873 DO_CHECK=""
1874 while [ -n "$3" ]; do
1875 case "$3" in
1876 --forced)
1877 DO_CHECK="no"
1878 ;;
1879 --root=*)
1880 ROOT="${3#--root=}"
1881 ;;
1882 --list=*)
1883 INSTALL_LIST="${3#--list=}"
1884 ;;
1885 *) shift 2
1886 echo -e "\nUnknown option $*.\n"
1887 exit 1
1888 ;;
1889 esac
1890 shift
1891 done
1892 AUTOEXEC="no"
1893 if ! check_for_package_in_list check; then
1894 PACKAGE=get-$PACKAGE
1895 AUTOEXEC=$PACKAGE
1896 check_for_package_in_list
1897 if [ -n "$(get_installed_package_pathname $PACKAGE $ROOT)" ]; then
1898 $AUTOEXEC $ROOT
1899 exit 0
1900 fi
1901 fi
1902 # Check if forced install.
1903 if [ "$DO_CHECK" = "no" ]; then
1904 rm -f $CACHE_DIR/$PACKAGE.tazpkg
1905 else
1906 check_for_installed_package $ROOT
1907 fi
1908 cd $CACHE_DIR
1909 if [ -f "$PACKAGE.tazpkg" ]; then
1910 echo "$PACKAGE already in the cache : $CACHE_DIR"
1911 # Check package download was finished
1912 tail -c 2k $PACKAGE.tazpkg | grep -q 00000000TRAILER || {
1913 echo "Continue $PACKAGE download"
1914 download $PACKAGE.tazpkg
1916 else
1917 echo ""
1918 download $PACKAGE.tazpkg
1919 fi
1920 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
1921 install_package $ROOT
1922 [ "$AUTOEXEC" != "no" ] && $PACKAGE $ROOT
1923 ;;
1924 clean-cache)
1925 # Remove all downloaded packages.
1927 check_root
1928 files=`ls -1 $CACHE_DIR | wc -l`
1929 echo ""
1930 echo -e "\033[1mClean cache :\033[0m $CACHE_DIR"
1931 echo "================================================================================"
1932 echo -n "Cleaning cache directory..."
1933 rm -rf $CACHE_DIR/*
1934 status
1935 echo "================================================================================"
1936 echo "$files file(s) removed from cache."
1937 echo ""
1938 ;;
1939 list-undigest)
1940 # list undigest URLs.
1942 if [ "$2" = "--box" ]; then
1943 for i in $LOCALSTATE/undigest/*/mirror; do
1944 [ -f $i ] || continue
1945 echo "$(basename $(dirname $i))|$(cat $i)"
1946 done
1947 else
1948 echo ""
1949 echo -e "\033[1mCurrent undigest(s)\033[0m"
1950 echo "================================================================================"
1951 for i in $LOCALSTATE/undigest/*/mirror; do
1952 if [ ! -f $i ]; then
1953 echo "No undigest mirror found."
1954 exit 1
1955 fi
1956 echo "$(basename $(dirname $i)) $(cat $i)"
1957 done
1958 echo ""
1959 fi
1960 ;;
1961 remove-undigest)
1962 # remove undigest URL.
1964 check_root
1965 if [ -d $LOCALSTATE/undigest/$2 ]; then
1966 echo -n "Remove $2 undigest (y/N) ? "; read anser
1967 if [ "$anser" = "y" ]; then
1968 echo -n "Removing $2 undigest..."
1969 rm -rf $LOCALSTATE/undigest/$2
1970 status
1971 rmdir $LOCALSTATE/undigest 2> /dev/null
1972 fi
1973 else
1974 echo "Undigest $2 not found"
1975 fi
1976 ;;
1977 add-undigest|setup-undigest)
1978 # Add undigest URL.
1980 check_root
1981 undigest=$2
1982 [ -d $LOCALSTATE/undigest ] || mkdir $LOCALSTATE/undigest
1983 if [ -z "$undigest" ]; then
1984 i=1
1985 while [ -d $LOCALSTATE/undigest/$i ]; do
1986 i=$(($i+1))
1987 done
1988 undigest=$i
1989 fi
1990 if [ ! -d $LOCALSTATE/undigest/$undigest ]; then
1991 echo "Creating new undigest $undigest."
1992 mkdir $LOCALSTATE/undigest/$undigest
1993 fi
1994 setup_mirror $LOCALSTATE/undigest/$undigest $3
1995 ;;
1996 setup-mirror)
1997 # Change mirror URL.
1999 check_root
2000 setup_mirror $LOCALSTATE $2
2001 ;;
2002 reconfigure)
2003 # Replay post_install from receipt
2005 check_for_package_on_cmdline
2006 check_root
2007 if [ -d "$INSTALLED/$PACKAGE" ]; then
2008 check_for_receipt
2009 # Check for post_install
2010 if grep -q ^post_install $INSTALLED/$PACKAGE/receipt; then
2011 . $INSTALLED/$PACKAGE/receipt
2012 post_install
2013 # Log this activity
2014 log Reconfigured
2015 else
2016 echo -e "\nNothing to do for $PACKAGE."
2017 fi
2018 else
2019 echo -e "\npackage $PACKAGE is not installed."
2020 echo -e "Install package with 'tazpkg install' or 'tazpkg get-install'\n"
2021 fi
2022 ;;
2023 shell)
2024 # Tazpkg SHell
2026 if test $(id -u) = 0 ; then
2027 PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
2028 else
2029 PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
2030 fi
2031 if [ ! "$2" = "--noheader" ]; then
2032 clear
2033 echo ""
2034 echo -e "\033[1mTazpkg SHell.\033[0m"
2035 echo "================================================================================"
2036 echo "Type 'usage' to list all available commands or 'quit' or 'q' to exit."
2037 echo ""
2038 fi
2039 while true
2040 do
2041 echo -en "$PROMPT"; read cmd
2042 case $cmd in
2043 q|quit)
2044 break ;;
2045 shell)
2046 echo "You are already running a Tazpkg SHell." ;;
2047 su)
2048 su -c 'exec tazpkg shell --noheader' && break ;;
2049 "")
2050 continue ;;
2051 *)
2052 tazpkg $cmd ;;
2053 esac
2054 done
2055 ;;
2056 depends)
2057 # Display dependancies tree
2058 cd $INSTALLED
2059 ALL_DEPS=""
2060 if [ -f $2/receipt ]; then
2061 dep_scan $2 ""
2062 fi
2063 ;;
2064 rdepends)
2065 # Display reverse dependancies tree
2066 cd $INSTALLED
2067 ALL_DEPS=""
2068 if [ -f $2/receipt ]; then
2069 rdep_scan $2 ""
2070 fi
2071 ;;
2072 usage|*)
2073 # Print a short help or give usage for an unknown or empty command.
2075 usage
2076 ;;
2077 esac
2079 exit 0