tazpkg view tazpkg @ rev 699

Introduce packages.info: download on recharge.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Dec 04 01:23:47 2014 +0200 (2014-12-04)
parents bd0e2ed0e601
children 1d7f3c9ce99c
line source
1 #!/bin/sh
2 #
3 # TazPKG - Tiny autonomous zone packages manager.
4 #
5 # This is a lightweight packages manager for *.tazpkg files written in SHell
6 # script. It works well with Busybox ash shell and bash. TazPKG lets you
7 # list, install, remove, download or get information about a package. You
8 # can use 'tazpkg usage' to get a list of commands with short descriptions.
9 # TazPKG also resolves dependencies and can upgrade packages from a mirror.
10 #
11 # (C) 2007-2014 SliTaz - GNU General Public License v3.
12 #
13 # Authors: See the AUTHORS files
14 #
16 ####################
17 # Script variables #
18 ####################
20 # TazPKG version
21 VERSION=5.3.2
23 . /etc/slitaz/slitaz.conf
24 . /etc/slitaz/tazpkg.conf
26 . /lib/libtaz.sh
27 . /usr/lib/slitaz/libpkg.sh
28 . /usr/lib/tazpkg/tazpkg-find-depends
30 # Internationalization.
31 #. /usr/bin/gettext.sh
32 export TEXTDOMAIN='tazpkg'
35 #
36 # Functions set for translate categories
37 #
40 # No operations, only for xgettext collect
42 gettext_noop() {
43 _ 'base-system'; _ 'x-window'; _ 'utilities'; _ 'network'; _ 'graphics';
44 _ 'multimedia'; _ 'office'; _ 'development'; _ 'system-tools'; _ 'security';
45 _ 'games'; _ 'misc'; _ 'meta'; _ "non-free"
46 }
49 # Make array of pre-translated categories
51 cat_i18n=""
52 for c in "base-system" "x-window" "utilities" "network" "graphics" "multimedia" "office" "development" "system-tools" "security" "games" "misc" "meta" "non-free"; do
53 cat_i18n="$cat_i18n
54 $(gettext "$c") $c"
55 done
58 # If category is not one of those translated in native language, keep it
59 # untranslated. This allows both native and english language support.
60 # This also supports custom categories.
61 # And now we support spaces in translated categories
63 reverse_translate_category()
64 {
65 echo "$cat_i18n" | awk "BEGIN{FS=\" \"}{if (/^$@ /) a=\$2}END{if (a==\"\") a=\"$@\"; print a}"
66 }
70 #
71 # TazPKG output functions
72 #
75 # Print localized title
77 title() { newline; boldify "$(eval_gettext "$1")"; separator; }
80 # Print footer
82 footer() { separator; echo "$1"; [ -n "$1" ] && newline; }
85 # Print current action in brown color (separate from any other msgs)
87 action() {
88 case $output in
89 raw|gtk|html) eval_gettext "$@" ;;
90 *) echo -ne "\033[0;33m"$(eval_gettext "$@")"\033[0m" ;;
91 esac
92 }
95 # Initialize some variables to use words rather than numbers for functions
96 # and actions.
97 COMMAND=$1
98 PACKAGE=${2%/}
99 PACKAGE_DIR="$(cd $(dirname $PACKAGE 2>/dev/null) 2>/dev/null; pwd)"
100 [ -n "$PACKAGE" ] && PACKAGE_FILE="$PACKAGE_DIR/${PACKAGE##*/}"
101 if [ -f "$PACKAGE" ]; then
102 # Set pkg basename for install, extract
103 PACKAGE=$(basename $PACKAGE .tazpkg 2>/dev/null)
104 else
105 # Pkg name for remove, search and all other cmds
106 PACKAGE=${PACKAGE%.tazpkg}
107 fi
108 TARGET_DIR=$3
109 TOP_DIR=$(pwd)
110 TMP_DIR=/tmp/$RANDOM
111 INSTALL_LIST=""
112 SAVE_CACHE_DIR="$CACHE_DIR"
114 # Path to tazpkg used dir and configuration files
115 MIRROR=$LOCALSTATE/mirror
116 BLOCKED=$LOCALSTATE/blocked-packages.list
117 UP_LIST=$LOCALSTATE/packages.up
118 DEFAULT_MIRROR="$ONLINE_PKGS"
123 ####################
124 # Script functions #
125 ####################
128 # Print the usage.
130 usage () {
131 cat << EOT
133 $(_ 'SliTaz package manager - Version:') $(colorize 34 $VERSION)
135 $(boldify "$(_ 'Usage:')")
136 $(_ 'tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]')
138 $(boldify "$(_ 'SHell:')") tazpkg shell
140 $(boldify "$(_ 'Commands:')")
141 usage $(_ 'Print this short usage')
142 bugs $(_ 'Show known bugs in packages')
143 activity|-a $(_ 'Show TazPKG activity log')
144 list|-l $(_ 'List installed packages on the system by category or all')
145 list-mirror|-lm $(_ 'List all available packages on the mirror (--diff for new)')
146 info $(_ 'Print information about a package')
147 desc $(_ 'Print description of a package (if it exists)')
148 list-files|-lf $(_ 'List the files installed with a package')
149 list-config $(_ 'List the configuration files')
150 search|-s $(_ 'Search for a package by pattern or name (options: -i|-l|-m)')
151 search-pkgname $(_ 'Search on mirror for package having a particular file')
152 search-file|-sf $(_ 'Search for file(s) in all installed packages files')
153 install|-i $(_ 'Install a local (*.tazpkg) package (--forced to force)')
154 install-list $(_ 'Install all packages from a list of packages.')
155 remove|-r $(_ 'Remove the specified package and all installed files')
156 extract|-e $(_ 'Extract a (*.tazpkg) package into a directory')
157 pack $(_ 'Pack an unpacked or prepared package tree')
158 recharge $(_ 'Recharge your packages.list from the mirror')
159 up|help-up $(_ 'Check packages $CHECKSUM to list and install latest upgrades')
160 repack $(_ 'Create a package archive from an installed package')
161 repack-config $(_ 'Create a package archive with configuration files')
162 recompress $(_ 'Rebuild a package with a better compression ratio')
163 block|unblock $(_ 'Block an installed package version or unblock it for upgrade')
164 get $(_ 'Download a package into the current directory')
165 get-install|-gi $(_ 'Download and install a package from the mirror')
166 get-install-list $(_ 'Download and install a list of packages from the mirror')
167 check $(_ 'Verify consistency of installed packages')
168 add-flavor $(_ 'Install the flavor list of packages')
169 install-flavor $(_ 'Install the flavor list of packages and remove other ones')
170 set-release $(_ 'Change release and update packages')
171 clean-cache|-cc $(_ 'Clean all packages downloaded in cache directory')
172 depends $(_ 'Display dependencies tree')
173 rdepends $(_ 'Display reverse dependencies tree')
174 convert $(_ 'Convert deb/rpm/tgz/pet/sfs/sb/arch/ipk package to tazpkg)')
175 link $(_ 'Link a package from another slitaz installation')
176 setup-mirror|-sm $(_ 'Change the mirror url configuration')
177 list-undigest $(_ 'List undigest mirrors')
178 remove-undigest $(_ 'Remove an undigest mirror')
179 add-undigest $(_ 'Add an undigest mirror')
180 setup-undigest $(_ 'Update an undigest mirror')
181 reconfigure $(_ 'Replay post install script from package')
183 EOT
184 }
187 usage_up() {
188 cat << EOT
189 $(emsg "<b>$(_ 'Usage for command up:')</b>") tazpkg up [$(_ 'option')]
191 * $(_ 'Without options run in interactive mode and ask before install')
193 $(boldify "$(_ 'Where options are:')")
194 --check |-c $(_ 'Check only for available upgrades')
195 --recharge |-r $(_ 'Force recharge of packages list and check')
196 --install |-i $(_ 'Check for upgrades and install them all')
198 $(boldify "$(_ 'Example:')")
199 tazpkg up --recharge --install
200 tazpkg up -c -r
201 EOT
202 }
205 # Check if dir exists
207 check_dir()
208 {
209 if ! [ -d "$1" ]; then
210 FOLDER=$1
211 action 'Creating $FOLDER...'
212 mkdir -p "$FOLDER"
213 status
214 return 1
215 fi
216 }
219 # Check if the directories and files used by TazPKG
220 # exist. If not and user is root we create them.
222 check_base_dir()
223 {
224 if [ "$(id -u)" = "0" ]; then
225 check_dir $1$CACHE_DIR
226 check_dir $1$INSTALLED
227 check_dir $1$SLITAZ_LOGS
228 if [ ! -f "$1$LOCALSTATE/mirror" ]; then
229 echo "${DEFAULT_MIRROR%/}/" > $1$LOCALSTATE/mirror
230 [ -n "$1" ] && cp $LOCALSTATE/packages.* $1$LOCALSTATE/
231 fi
232 fi
233 }
234 check_base_dir
237 # Check for a package name on cmdline.
239 check_for_package_on_cmdline()
240 {
241 if [ -z "$PACKAGE" ]; then
242 newline
243 _ 'Please specify a package name on the command line.'
244 newline
245 exit 0
246 fi
247 }
250 # Check if the package (*.tazpkg) exists before installing or extracting.
252 check_for_package_file()
253 {
254 if [ ! -f "$PACKAGE_FILE" ]; then
255 newline
256 _ 'Unable to find: $PACKAGE_FILE'
257 newline
258 exit 0
259 fi
260 }
263 # Check for the receipt of an installed package.
265 check_for_receipt()
266 {
267 receipt_path="$1$INSTALLED/$PACKAGE/receipt"
268 if [ ! -f $receipt_path ]; then
269 newline
270 _ 'Unable to find the receipt: $receipt_path'
271 newline
272 exit 0
273 fi
274 }
277 # Get repositories priority using $LOCALSTATE/priority.
278 # In this files, undigest are called by their name and main mirror
279 # by main. Sort order: priority
281 look_for_priority()
282 {
283 [ -s $LOCALSTATE/priority ] && priority=$(cat $LOCALSTATE/priority)
284 for rep in main $(ls $LOCALSTATE/undigest 2>/dev/null); do
285 if [ ! -s $LOCALSTATE/priority ] || \
286 ! grep -q ^$rep$ $LOCALSTATE/priority; then
287 priority=$(echo -e "$priority\n$rep")
288 fi
289 done
290 priority=$(echo "$priority" | sed '/^$/d' | \
291 while read line; do
292 if [ "$line" = main ]; then
293 echo $LOCALSTATE
294 else
295 echo $LOCALSTATE/undigest/$line
296 fi
297 done)
298 }
301 # Get package name in a directory
303 package_fullname_in_dir()
304 {
305 [ -f $1/receipt ] || return
306 EXTRAVERSION=""
307 . $1/receipt
308 echo $PACKAGE-$VERSION$EXTRAVERSION
309 }
312 # Get package name that is already installed.
314 get_installed_package_pathname()
315 {
316 for i in $2$INSTALLED/${1%%-*}*; do
317 [ -d $i ] || continue
318 if [ "$1" = "$(package_fullname_in_dir $i)" ]; then
319 echo $i
320 return
321 fi
322 done
323 }
326 # Check if a package is already installed.
328 check_for_installed_package()
329 {
330 if [ -n "$(get_installed_package_pathname $PACKAGE $1)" ]; then
331 newline
332 # FIXME
333 cat << EOT
334 $(colorize 34 $PACKAGE) $(_ "package is already installed.
335 You can use the --forced option to force installation.")
336 EOT
337 newline
338 exit 0
339 fi
340 }
343 # Check for packages.list to download and install packages.
345 check_for_packages_list()
346 {
347 list_path="$LOCALSTATE/packages.list"
348 if [ ! -f "$list_path" ]; then
349 if test $(id -u) = 0 ; then
350 tazpkg recharge
351 else
352 newline
353 _ 'Unable to find the list: $list_path'
354 _ \
355 "You must probably run 'tazpkg recharge' as root to get the latest list of
356 packages available on the mirror."
357 newline
358 exit 0
359 fi
360 fi
361 }
364 get_cache_dir()
365 {
366 echo $rep > $tmp/rep
367 if [ "$rep" = "$LOCALSTATE" ]; then
368 CACHE_DIR="$SAVE_CACHE_DIR/$SLITAZ_RELEASE/packages"
369 elif [ "${rep%-incoming}" = "$rep" ]; then
370 CACHE_DIR="$SAVE_CACHE_DIR/${rep##*/}/packages"
371 else
372 rep="${rep%-incoming}"
373 CACHE_DIR="$SAVE_CACHE_DIR/${rep##*/}/packages-incoming"
374 fi
375 [ -d "$CACHE_DIR" ] || mkdir -p $CACHE_DIR
376 echo $CACHE_DIR > $tmp/cachedir
377 }
380 # get an already installed package from packages.equiv
382 equivalent_pkg()
383 {
384 for i in $(grep -hs "^$1=" $LOCALSTATE/packages.equiv \
385 $LOCALSTATE/undigest/*/packages.equiv | sed "s/^$1=//"); do
386 if echo $i | fgrep -q : ; then
387 # format 'alternative:newname'
388 # if alternative is installed then substitute newname
389 if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
390 # substitute package dependency
391 echo ${i#*:}
392 return
393 fi
394 else
395 # if alternative is installed then nothing to install
396 if [ -f $2$INSTALLED/$i/receipt ]; then
397 # substitute installed package
398 echo $i
399 return
400 fi
401 fi
402 done
403 # if not found in packages.equiv then no substitution
404 echo $1
405 }
408 # get a virtual package from packages.equiv
410 virtual_pkg()
411 {
412 for i in $(for rep in $priority; do
413 grep -hs "^$1=" $rep/packages.equiv
414 done | sed "s/^$1=//"); do
415 if echo $i | fgrep -q : ; then
416 # format 'alternative:newname'
417 # if alternative is installed then substitute newname
418 if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
419 # substitute package dependency
420 echo ${i#*:}
421 return
422 fi
423 else
424 # unconditional substitution
425 echo $i
426 return
427 fi
428 done
429 }
432 # Get package filename available on the mirror
434 get_package_filename()
435 {
436 local pkg
437 for rep in $priority; do
438 pkg=$(grep -A 1 -sh "^$1$" $rep/packages.txt | tail -1 | sed 's/^ *//')
439 [ "$pkg" ] && pkg=$(grep -sh "^$1-$pkg" $rep/packages.list | head -1)
441 # Allow user to call a package with his version number.
442 [ "$pkg" ] || pkg=$(grep -sh "^$1$" $rep/packages.list | head -1)
444 [ "$pkg" ] || pkg=$(grep -sh "^$1-[0-9]" $rep/packages.list | head -1)
445 [ "$pkg" ] || pkg=$(grep -sh "^$1-.[\.0-9]" $rep/packages.list | head -1)
446 [ "$pkg" ] && get_cache_dir && break
447 done
448 if [ -z "$pkg" ]; then
449 # Check for virtual package
450 local equiv
451 equiv=$(virtual_pkg $1)
452 if [ "$equiv" != "$1" ]; then
453 PACKAGE=$equiv
454 get_package_filename $PACKAGE
455 return
456 fi
457 fi
458 echo $pkg
459 }
462 # Check for a package in packages.list. Used by get and get-install to grep
463 # package basename.
465 check_for_package_in_list()
466 {
467 local filename
468 local check_only
469 check_only="$1"
470 filename=$(get_package_filename $PACKAGE)
471 if [ "$filename" ]; then
472 PACKAGE=$filename
473 CACHE_DIR=$(cat $tmp/cachedir)
474 rep=$(cat $tmp/rep)
475 rm -f $tmp/rep $tmp/cachedir
476 else
477 newline
478 _ 'Unable to find: $PACKAGE in the mirrored packages list.'
479 newline
480 [ -n "$check_only" ] && return 1
481 exit 0
482 fi
483 }
486 # Log this activity
487 # (there log_pkg because we have log() in libtaz.sh)
489 log_pkg()
490 {
491 local extra
493 [ "$1" = "Installed" ] && \
494 extra=" - $(fgrep $PACKAGE-$VERSION $LOCALSTATE/installed.$SUM | awk '{ print $1 }')"
496 [ -e $LOG ] || touch $LOG
498 [ -w $LOG ] &&
499 echo "$(date +'%F %T') - $1 - $PACKAGE ($VERSION$EXTRAVERSION)$extra" >> $LOG
500 }
503 # Download a get-package script from this mirror
505 download_get_script()
506 {
507 local p
508 for p in $priority ; do
509 local i
510 for i in $(cat $p/mirror) ; do
511 case "$i" in
512 http://*|ftp://*)
513 wget -O $2 ${i%packages/*}packages/get/$1 && return 0 ;;
514 esac
515 done
516 done
517 return 1
518 }
521 # Download a file from this mirror
523 download_from()
524 {
525 local i
526 local mirrors
527 mirrors="$1"
528 shift
529 for i in $mirrors; do
530 case "$i" in
531 # Mirror URL can have a trailing slash or not.
532 http://*|ftp://*)
533 busybox wget -c ${i%/}/$@ && break ;;
534 https://*)
535 echo 'Sorry, https not supported' ;;
536 *)
537 ln -sf $i/$1 . && break ;;
538 esac
539 done
540 }
543 # Download a file trying all mirrors
545 download()
546 {
547 local i
548 case "$1" in
549 *.tazpkg)
550 for i in $priority ; do
551 grep -q "^${1%.tazpkg}$" $i/packages.list 2>/dev/null || continue
552 download_from "$(cat $i/mirror)" "$@" && return
553 done
554 esac
555 for i in $(cat $(for rep in $priority; do echo $rep/mirror; done) 2>/dev/null); do
556 download_from "$i" "$@" && break
557 done
558 }
561 # Extract a package with cpio and gzip/lzma.
563 extract_package()
564 {
565 action 'Extracting $PACKAGE...'
566 cpio -idm --quiet < ${PACKAGE_FILE##*/} && rm -f ${PACKAGE_FILE##*/}
567 status
568 if [ -f fs.cpio.lzma ]; then
569 unlzma -c fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
570 elif [ -f fs.cpio.gz ]; then
571 zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz
572 fi
573 }
576 remove_with_path()
577 {
578 # Avoid dirname errors by checking for argument.
579 [ "$1" ] || return
581 local dir
582 rm -f $1 2>/dev/null
583 dir="$1"
584 while [ "$dir" != "/" ]; do
585 dir="$(dirname $dir)"
586 rmdir $dir 2> /dev/null || break
587 done
588 }
591 grepesc()
592 {
593 sed 's/\[/\\[/g'
594 }
597 # This function installs a package in the rootfs.
599 install_package()
600 {
601 ROOT=$1
602 if [ -n "$ROOT" ]; then
603 # Get absolute path
604 ROOT=$(realpath $ROOT)
605 fi
606 {
607 # Create package path early to avoid dependencies loop
608 mkdir -p $TMP_DIR
609 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $PACKAGE_FILE
610 . $TMP_DIR/receipt
611 if grep -q ^pre_depends $TMP_DIR/receipt; then
612 pre_depends $ROOT
613 fi
615 # Keep modifiers and file list on upgrade
616 cp $ROOT$INSTALLED/$PACKAGE/modifiers \
617 $ROOT$INSTALLED/$PACKAGE/files.list $TMP_DIR 2> /dev/null
618 rm -rf $ROOT$INSTALLED/$PACKAGE 2> /dev/null
620 # Make the installed package data dir to store
621 # the receipt and the files list.
622 mkdir -p $ROOT$INSTALLED/$PACKAGE
623 cp $TMP_DIR/modifiers $ROOT$INSTALLED/$PACKAGE 2> /dev/null
624 cp $TMP_DIR/files.list $ROOT$INSTALLED/$PACKAGE 2> /dev/null
625 rm -rf $TMP_DIR 2> /dev/null
626 sed -i "/ $(basename $PACKAGE_FILE)$/d" \
627 $ROOT$LOCALSTATE/installed.$SUM 2> /dev/null
628 cd $(dirname $PACKAGE_FILE)
629 $CHECKSUM $(basename $PACKAGE_FILE) >> $ROOT$LOCALSTATE/installed.$SUM
630 }
632 # Resolve package deps.
633 check_for_deps $ROOT
634 if [ -n "$MISSING_PACKAGE" ]; then
635 install_deps $ROOT
636 fi
637 mkdir -p $TMP_DIR
638 [ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> $ROOT$LOCALSTATE/$INSTALL_LIST-processed
640 title 'Installation of: $PACKAGE'
642 action 'Copying $PACKAGE...'
643 cp $PACKAGE_FILE $TMP_DIR
644 status
646 cd $TMP_DIR
647 extract_package
648 SELF_INSTALL=0
649 EXTRAVERSION=""
650 CONFIG_FILES=""
652 # Include temporary receipt to get the right variables.
653 . $PWD/receipt
654 cd $ROOT$INSTALLED
656 if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then
657 action "Checking post install dependencies..."
658 [ -f $INSTALLED/$PACKAGE/receipt ]
659 if ! status; then
660 command="tazpkg install $PACKAGE_FILE"
661 _ "Please run '\$command' in / and retry."
662 rm -rf $TMP_DIR
663 exit 1
664 fi
665 fi
667 # Get files to remove if upgrading
668 if [ -f $PACKAGE/files.list ]; then
669 while read file; do
670 grep -q "^$(echo $file | grepesc)$" $TMP_DIR/files.list && continue
671 for i in $(cat $PACKAGE/modifiers 2> /dev/null ;
672 fgrep -sl $PACKAGE */modifiers | cut -d/ -f1 ); do
673 grep -qs "^$(echo $file | grepesc)$" $i/files.list && continue 2
674 done
675 echo $file
676 done < $PACKAGE/files.list > $TMP_DIR/files2remove.list
677 fi
679 # Remember modified packages
680 {
681 check=false
682 for i in $(fgrep -v [ $TMP_DIR/files.list); do
683 [ -e "$ROOT$i" ] || continue
684 [ -d "$ROOT$i" ] && continue
685 echo "- $i"
686 check=true
687 done ;
688 $check && \
689 for i in *; do
690 [ "$i" == "$PACKAGE" ] && continue
691 [ -s $i/files.list ] || continue
692 awk "{ printf \"$i %s\\n\",\$1 }" < $i/files.list
693 done;
694 } | awk '
695 {
696 if ($1 == "-" || file[$2] != "") {
697 file[$2] = file[$2] " " $1
698 if ($1 != "-") {
699 if (pkg[$1] == "") all = all " " $1
700 pkg[$1] = pkg[$1] " " $2
701 }
702 }
703 }
704 END {
705 for (i = split(all, p, " "); i > 0; i--)
706 for (j = split(pkg[p[i]], f, " "); j > 0; j--)
707 printf "%s %s\n",p[i],f[j];
708 }
709 ' | while read dir file; do
710 if grep -qs ^$dir$ $PACKAGE/modifiers; then
711 # Do not overload an overloaded file !
712 rm $TMP_DIR$file 2> /dev/null
713 continue
714 fi
715 grep -qs ^$PACKAGE$ $dir/modifiers && continue
716 if [ -s "$dir/volatile.cpio.gz" ]; then
717 # We can modify backed up files without notice
718 zcat $dir/volatile.cpio.gz | cpio -t --quiet | \
719 grep -q "^${file#/}$" && continue
720 fi
721 echo "$PACKAGE" >> $dir/modifiers
722 done
724 cd $TMP_DIR
725 cp receipt files.list $ROOT$INSTALLED/$PACKAGE
727 # Copy the description if found.
728 if [ -f "description.txt" ]; then
729 cp description.txt $ROOT$INSTALLED/$PACKAGE
730 fi
732 # Copy the md5sum if found.
733 if [ -f "$CHECKSUM" ]; then
734 cp $CHECKSUM $ROOT$INSTALLED/$PACKAGE
735 fi
737 # Pre install commands.
738 if grep -q ^pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then
739 pre_install $ROOT
740 fi
741 if [ -n "$CONFIG_FILES" ]; then
742 # save 'official' configuration files
743 action 'Saving configuration files for $PACKAGE...'
744 for i in $CONFIG_FILES; do
745 { cd fs ; find ${i#/} -type f 2> /dev/null; cd ..; }
746 done | { cd fs ; cpio -o -H newc --quiet | gzip -9; cd ..; } > \
747 $ROOT$INSTALLED/$PACKAGE/volatile.cpio.gz
749 # keep user configuration files
750 for i in $CONFIG_FILES; do
751 { cd fs ; find ${i#/} -type f 2> /dev/null; cd ..; }
752 done | while read i; do
753 [ -e $ROOT/$i ] || continue
754 cp -a $ROOT/$i fs/$i
755 done
756 status
757 fi
759 action 'Installing $PACKAGE...'
760 [ "$(busybox ls fs/* 2> /dev/null)" ] && cp -a fs/* $ROOT/
761 status
763 if [ -s files2remove.list ]; then
764 action 'Removing old $PACKAGE...'
765 while read file; do
766 remove_with_path $ROOT$file
767 done < files2remove.list
768 true
769 status
770 fi
772 # Remove the temporary random directory.
773 action "Removing all tmp files..."
774 cd ..; rm -rf $TMP_DIR
775 status
777 # Post install commands.
778 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
779 post_install $ROOT
780 fi
782 # Update-desktop-database if needed.
783 if [ "$(fgrep .desktop $ROOT$INSTALLED/$PACKAGE/files.list | fgrep /usr/share/applications/)" ]; then
784 updatedesktopdb=yes
785 fi
787 # Update-mime-database if needed.
788 if [ "$(fgrep /usr/share/mime $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
789 updatemimedb=yes
790 fi
792 # Update-icon-database
793 if [ "$(fgrep /usr/share/icon/hicolor $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
794 updateicondb=yes
795 fi
797 # Compile glib schemas if needed.
798 if [ "$(fgrep /usr/share/glib-2.0/schemas $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
799 compile_schemas=yes
800 fi
802 # Update depmod list
803 if [ "$(fgrep /lib/modules $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
804 updatedepmod=yes
805 fi
807 cd $TOP_DIR
808 pkg_name="$PACKAGE ($VERSION$EXTRAVERSION)"
809 footer "$(_ '$pkg_name is installed.')"
811 # Log this activity
812 [ -n "$ROOT" ] || log_pkg Installed
813 }
816 # This function may be called by a get script.
818 abort_package()
819 {
820 cd $CUR_DIR
821 rm -rf $TMP_DIR
822 echo "${1:-Abort $PACKAGE.}"
823 exit 1
824 }
827 # This function installs a package from a get script in the rootfs.
829 install_package_from_get_script()
830 {
831 SCRIPT="$1"
832 ROOT="$2"
833 [ -d $ROOT$INSTALLED/$PACKAGE ] && exit 1
835 grep -q no-check-certificate $SCRIPT &&
836 [ ! -d $INSTALLED/wget ] && tazpkg get-install wget
838 mkdir -p $TMP_DIR && cd $TMP_DIR
839 saved=$PACKAGE
840 unset_receipt
841 PACKAGE=$saved
843 set -e
844 . $SCRIPT
845 set +e
846 cd $TMP_DIR
847 [ -d $PACKAGE-$VERSION ] || abort_package \
848 "Could not download ${TARBALL:-$PACKAGE} from ${WGET_URL:-$WEB_SITE}. Exiting."
850 if [ ! -s $PACKAGE-$VERSION/receipt ]; then
851 cat > $PACKAGE-$VERSION/receipt <<EOT
852 # SliTaz package receipt.
854 PACKAGE="$PACKAGE"
855 VERSION="${VERSION:-unknown}"
856 CATEGORY="${CATEGORY:-non-free}"
857 WEB_SITE="$WEB_SITE"
858 SHORT_DESC="${SHORT_DESC:-$PACKAGE}"
859 MAINTAINER="${MAINTAINER:-nobody@slitaz.org}"
860 EOT
861 for i in LICENSE TARBALL WGET_URL CONFIG_FILES SUGGESTED \
862 PROVIDE DEPENDS HOST_ARCH TAGS EXTRA_SOURCE_FILES ; do
863 eval "[ -n \"\$$i\" ] && echo \"$i=\\\"\$$i\\\"\""
864 done >> $PACKAGE-$VERSION/receipt
865 fi
867 DEPENDS="$(unset DEPENDS; . $PACKAGE-$VERSION/receipt ; echo $DEPENDS)"
868 for i in $(find_depends $PACKAGE-$VERSION/fs); do
869 case " $DEPENDS " in
870 *\ $i\ *) continue;;
871 esac
872 grep -q '^DEPENDS="' $PACKAGE-$VERSION/receipt ||
873 echo 'DEPENDS=""' >> $PACKAGE-$VERSION/receipt
874 sed -i "s/^DEPENDS=\"/&$i /" $PACKAGE-$VERSION/receipt
875 done
877 tazpkg pack $PACKAGE-$VERSION
879 # Clean to save RAM memory before installation
880 rm -rf $PACKAGE-$VERSION
882 # Install pseudo package
883 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
884 mv $PACKAGE-$VERSION.tazpkg $CACHE_DIR
886 # Clean
887 cd $TOP_DIR
888 rm -rf $TMP_DIR
889 }
892 # Check for loop in deps tree.
894 check_for_deps_loop()
895 {
896 local list
897 local pkg
898 local deps
899 pkg=$1
900 shift
901 [ -n "$1" ] || return
902 list=""
904 # Filter out already processed deps
905 for i in $@; do
906 case " $ALL_DEPS" in
907 *\ $i\ *);;
908 *) list="$list $i";;
909 esac
910 done
911 ALL_DEPS="$ALL_DEPS$list "
912 for i in $list; do
913 [ -f $i/receipt ] || continue
914 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
915 case " $deps " in
916 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
917 *) check_for_deps_loop $pkg $deps;;
918 esac
919 done
920 }
923 # Check for missing deps listed in a receipt packages.
925 check_for_deps()
926 {
927 local saved;
928 saved=$PACKAGE
929 mkdir -p $TMP_DIR
930 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $PACKAGE_FILE
931 . $TMP_DIR/receipt
932 PACKAGE=$saved
933 rm -rf $TMP_DIR
935 num=0
936 for pkgorg in $DEPENDS; do
937 i=$(equivalent_pkg $pkgorg $1)
938 if [ ! -d "$1$INSTALLED/$i" ]; then
939 MISSING_PACKAGE=$i
940 num=$(($num+1))
941 elif [ ! -f "$1$INSTALLED/$i/receipt" ]; then
942 _ 'WARNING Dependency loop between $PACKAGE and $i.'
943 fi
944 done
946 if [ ! "$MISSING_PACKAGE" = "" ]; then
947 title "$(_ 'Tracking dependencies for: $PACKAGE')"
948 for pkgorg in $DEPENDS; do
949 i=$(equivalent_pkg $pkgorg $1)
950 if [ ! -d "$1$INSTALLED/$i" ]; then
951 MISSING_PACKAGE=$i
952 _ 'Missing: $MISSING_PACKAGE'
953 fi
954 done
955 separator
956 eval_ngettext \
957 '$num missing package to install.' \
958 '$num missing packages to install.' $num; echo
959 fi
960 }
963 # Install all missing deps. Auto install or ask user then install all missing
964 # deps from local dir, cdrom, media or from the mirror. In case we want to
965 # install packages from local, we need a packages.list to find the version.
967 install_deps()
968 {
969 local root
970 root=""
971 [ -n "$1" ] && root="--root=$1"
972 if [ "$AUTO_INSTALL_DEPS" == "yes" ]; then
973 answer=0
974 else
975 newline
976 confirm "$(_ 'Install all missing dependencies? (y/N)')"
977 answer=$?
978 newline
979 fi
980 if [ $answer = 0 ]; then
981 for pkgorg in $DEPENDS; do
982 pkg=$(equivalent_pkg $pkgorg $1)
983 if [ ! -d "$1$INSTALLED/$pkg" ]; then
984 local list
985 list="$INSTALL_LIST"
986 [ -n "$list" ] || list="$TOP_DIR/packages.list"
987 # We can install packages from a local dir by greping
988 # the TAZPKG_BASENAME in the local packages.list.
989 found=0
990 if [ -f "$list" ]; then
991 _ 'Checking if $pkg exists in local list...'
992 mkdir $TMP_DIR
993 for i in $pkg-*.tazpkg; do
994 [ -f $i ] || continue
995 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $i
996 [ "$(. $TMP_DIR/receipt; echo $PACKAGE)" = "$pkg" ] || continue
997 if grep -q ^$(package_fullname_in_dir $TMP_DIR).tazpkg$ $list
998 then
999 found=1
1000 tazpkg install $i $root --list=$list
1001 break
1002 fi
1003 done
1004 rm -rf $TMP_DIR
1005 fi
1006 # Install deps from the mirror.
1007 if [ $found -eq 0 ]; then
1008 if [ ! -f "$LOCALSTATE/packages.list" ]; then
1009 tazpkg recharge
1010 fi
1011 tazpkg get-install $pkg $root
1012 fi
1013 fi
1014 done
1015 else
1016 newline
1017 _ \
1018 "Leaving dependencies for \$PACKAGE unresolved.
1019 The package is installed but will probably not work."
1020 newline
1021 fi
1025 # Search pattern in installed packages.
1027 search_in_installed_packages()
1029 _ 'Installed packages'
1030 separator
1031 list=`ls -1 $INSTALLED | grep -i "$PATTERN"`
1032 num=0
1033 for pkg in $list; do
1034 EXTRAVERSION=""
1035 [ -f $INSTALLED/$pkg/receipt ] || continue
1036 . $INSTALLED/$pkg/receipt
1037 emsg "$PACKAGE<i 24> $VERSION$EXTRAVERSION<i 42> $(_n $CATEGORY)"
1038 num=$(($num+1))
1039 done
1041 # Set correct ending messages.
1042 if [ x$num == x ]; then
1043 _ 'No installed packages found for: $PATTERN'
1044 newline
1045 else
1046 footer "$(eval_ngettext \
1047 '$num installed package found for: $PATTERN' \
1048 '$num installed packages found for: $PATTERN' $num)"
1049 fi
1053 # Search in packages.list for available pkgs.
1055 search_in_packages_list()
1057 _ 'Available packages name-version'
1058 separator
1059 num=0
1060 BPATTERN="$(emsg "<b>$PATTERN</b>")"
1061 for i in $LOCALSTATE/packages.list $LOCALSTATE/undigest/*/packages.list; do
1062 grep -is "$PATTERN" $i | sed "s|$PATTERN|$BPATTERN|"
1063 num=$(($num + `grep -is "$PATTERN" $i | wc -l`))
1064 done
1065 if [ ! -f "$LOCALSTATE/packages.list" ]; then
1066 newline
1067 _ \
1068 "No 'packages.list' found to check for mirrored packages. For more results,
1069 please run 'tazpkg recharge' once as root before searching."
1070 newline
1071 fi
1072 if [ "$num" = "0" ]; then
1073 _ 'No available packages found for: $PATTERN'
1074 newline
1075 else
1076 footer "$(eval_ngettext \
1077 '$num available package found for: $PATTERN' \
1078 '$num available packages found for: $PATTERN' $packages)"
1079 fi
1083 # search --mirror: Search in packages.txt for available pkgs and give more
1084 # info than --list or default.
1086 search_in_packages_txt()
1088 _ 'Matching packages name with version and desc'
1089 separator
1090 num=0
1091 for i in $LOCALSTATE/packages.txt $LOCALSTATE/undigest/*/packages.txt; do
1092 grep -is -A 2 "^$PATTERN" $i
1093 num=$(($num + `grep -is "^$PATTERN" $i | wc -l`))
1094 done
1095 if [ ! -f "$LOCALSTATE/packages.txt" ]; then
1096 newline
1097 _ \
1098 "No 'packages.txt' found to check for mirrored packages. For more results,
1099 please run 'tazpkg recharge' once as root before searching."
1100 newline
1101 fi
1102 if [ "$num" = "0" ]; then
1103 _ 'No available packages found for: $PATTERN'
1104 newline
1105 else
1106 footer "$(eval_ngettext \
1107 '$num available package found for: $PATTERN' \
1108 '$num available packages found for: $PATTERN' $packages)"
1109 fi
1113 # Install package-list from a flavor
1115 install_flavor()
1117 check_root $@
1119 # Get repositories priority list.
1120 look_for_priority
1122 FLAVOR=$1
1123 ARG=$2
1124 mkdir -p $TMP_DIR
1125 [ -f $FLAVOR.flavor ] && cp $FLAVOR.flavor $TMP_DIR
1126 cd $TMP_DIR
1127 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
1128 zcat < $FLAVOR.flavor | cpio --quiet -i >/dev/null
1130 while read file; do
1131 for pkg in $(ls -d $INSTALLED/${file%%-*}*); do
1132 [ -f $pkg/receipt ] || continue
1133 EXTRAVERSION=""
1134 . $pkg/receipt
1135 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && break
1136 done
1137 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && continue
1138 cd $CACHE_DIR
1139 download $file.tazpkg
1140 cd $TMP_DIR
1141 tazpkg install $CACHE_DIR/$file.tazpkg --forced
1142 done < $FLAVOR.pkglist
1144 [ -f $FLAVOR.nonfree ] && while read pkg; do
1145 [ -d $INSTALLED/$pkg ] || continue
1146 [ -d $INSTALLED/get-$pkg ] && tazpkg get-install get-$pkg
1147 get-$pkg
1148 done < $FLAVOR.nonfree
1150 [ "$ARG" == "--purge" ] && for pkg in $(ls $INSTALLED); do
1151 [ -f $INSTALLED/$pkg/receipt ] || continue
1152 EXTRAVERSION=""
1153 . $INSTALLED/$pkg/receipt
1154 grep -q ^$PACKAGE-$VERSION$EXTRAVERSION$ $FLAVOR.pkglist && continue
1155 grep -qs ^$PACKAGE$ $FLAVOR.nonfree && continue
1156 tazpkg remove $PACKAGE
1157 done
1158 else
1159 _ "Can't find flavor \$FLAVOR. Abort."
1160 fi
1161 cd $TOP_DIR
1162 rm -rf $TMP_DIR
1166 # Update mirror urls
1168 setup_mirror()
1170 # Backup old list.
1171 if [ -f "$1/mirror" ]; then
1172 cp -f $1/mirror $1/mirror.bak
1173 fi
1174 title 'Current mirror(s)'
1175 echo " `cat $1/mirror 2> /dev/null`"
1176 _ \
1177 "Please enter URL of the new mirror (http, ftp or local path). You must specify
1178 the complete address to the directory of the packages and packages.list file."
1179 newline
1180 _n 'New mirror(s) URL: '
1181 NEW_MIRROR_URL=$2
1182 if [ -n "$NEW_MIRROR_URL" ]; then
1183 echo $NEW_MIRROR_URL
1184 else
1185 read NEW_MIRROR_URL
1186 fi
1187 if [ "$NEW_MIRROR_URL" = "" ]; then
1188 _ 'Nothing has been changed.'
1189 else
1190 _ 'Setting mirror(s) to: $NEW_MIRROR_URL'
1191 rm -f $1/mirror
1192 for i in $NEW_MIRROR_URL; do
1193 echo "${i%/}/" >> $1/mirror
1194 done
1195 fi
1196 newline
1200 # recursive dependencies scan
1202 dep_scan()
1204 for i in $1; do
1205 case " $ALL_DEPS " in
1206 *\ $i\ *) continue;;
1207 esac
1208 ALL_DEPS="$ALL_DEPS $i"
1209 [ -n "$2" ] && echo "$2$i ($(fgrep -A 3 $i $LOCALSTATE/packages.txt | \
1210 tail -1 | sed 's/.*(\([^ ]*\).*/\1/'))"
1211 [ -f $i/receipt ] || continue
1212 DEPENDS=""
1213 . $i/receipt
1214 [ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2 "
1215 done
1219 # recursive reverse dependencies scan
1221 rdep_scan()
1223 SEARCH=$1
1225 for i in * ; do
1226 DEPENDS=""
1227 . $i/receipt
1228 echo "$i $(echo $DEPENDS)"
1229 done | busybox awk -v search=$SEARCH '
1230 function show_deps(deps, all_deps, pkg, space)
1232 if (all_deps[pkg] == 1) return
1233 all_deps[pkg] = 1
1234 if (space != "") printf "%s %s\n",space,pkg
1235 for (i = 1, n = split(deps[pkg], mydeps, " "); i <= n; i++) {
1236 show_deps(deps, all_deps, mydeps[i],"==" space)
1241 all_deps[$1] = 0
1242 for (i = 2; i <= NF; i++)
1243 deps[$i] = deps[$i] " " $1
1246 END {
1247 show_deps(deps, all_deps, search, "")
1249 ' | while read spc pkg; do
1250 echo -n $spc | sed 's/=/ /g'
1251 echo -n $pkg
1252 echo -n ' ('
1253 fgrep -A 3 $pkg $LOCALSTATE/packages.txt | tail -1 | \
1254 sed 's/.*(\([^ ]*\).*/\1)/'
1255 done
1259 update_desktop_database()
1261 if [ -f $1/usr/bin/update-desktop-database ] && [ -n "$updatedesktopdb" ]; then
1262 chroot "$1/" /usr/bin/update-desktop-database /usr/share/applications 2>/dev/null
1263 fi
1267 update_mime_database()
1269 if [ -f $1/usr/bin/update-mime-database ] && [ -n "$updatemimedb" ]; then
1270 chroot "$1/" /usr/bin/update-mime-database /usr/share/mime
1271 fi
1275 update_icon_database()
1277 if [ -f $1/usr/bin/gtk-update-icon-cache ] && [ -n "$updateicondb" ]; then
1278 chroot "$1/" /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor
1279 fi
1283 compile_glib_schemas()
1285 if [ -f $1/usr/bin/glib-compile-schemas ] && [ -n "$compile_schemas" ]; then
1286 chroot "$1/" /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas
1287 fi
1291 update_kernel_modules()
1293 if [ -f $1/sbin/depmod ] && [ -n "$updatedepmod" ]; then
1294 chroot "$1/" /sbin/depmod -a
1295 fi
1302 ###################
1303 # TazPKG commands #
1304 ###################
1306 case "$COMMAND" in
1307 list|-l)
1308 shift
1310 # List all installed packages or a specific category.
1311 if [ "$1" = "blocked" ]; then
1312 title 'Blocked packages'
1313 if [ -s "$BLOCKED" ];then
1314 cat $BLOCKED
1315 else
1316 _ 'No blocked packages found.'
1317 fi
1318 newline; exit 0
1319 fi
1321 # Display the list of categories.
1322 if [ "$1" = "cat" -o "$1" = "categories" ]; then
1323 title 'Packages categories'
1324 num=0
1325 for i in $PKGS_CATEGORIES; do
1326 _ $i
1327 num=$(($num+1))
1328 done
1329 footer "$(eval_ngettext '$num category' '$num categories' $num)"; echo
1330 exit 0
1331 fi
1333 # Check for an asked category.
1334 ASKED_CATEGORY_I18N="$@"
1335 if [ -n "$ASKED_CATEGORY_I18N" ]; then
1336 ASKED_CATEGORY=$(reverse_translate_category "$ASKED_CATEGORY_I18N")
1337 title 'Installed packages of category: $ASKED_CATEGORY_I18N'
1338 for pkg in $INSTALLED/*; do
1339 [ -f $pkg/receipt ] || continue
1340 EXTRAVERSION=""
1341 . $pkg/receipt
1342 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
1343 echo -e "$PACKAGE\033[24G $VERSION$EXTRAVERSION"
1344 packages=$(($packages+1))
1345 fi
1346 done
1347 num="<c 32>$packages</c>"; cat_name="<c 34>$ASKED_CATEGORY_I18N</c>"
1348 footer "$(emsg $(eval_ngettext \
1349 '$num package installed of category $cat_name.' \
1350 '$num packages installed of category $cat_name.' \
1351 $packages))"; echo
1352 else
1354 # By default list all packages and versions.
1355 title 'List of all installed packages'
1356 for pkg in $INSTALLED/*; do
1357 [ -f $pkg/receipt ] || continue
1358 EXTRAVERSION=""
1359 . $pkg/receipt
1360 echo -e "$PACKAGE\033[35G $VERSION$EXTRAVERSION\033[53G $(_ $CATEGORY)"
1361 packages=$(($packages+1))
1362 done
1363 num="<c 32>$packages</c>"
1364 footer "$(emsg $(eval_ngettext \
1365 '$num package installed.' \
1366 '$num packages installed.' $packages))"
1367 fi ;;
1370 list-mirror|-lm)
1371 # List all available packages on the mirror. Option --diff displays
1372 # last mirrored packages diff (see recharge).
1373 check_for_packages_list
1374 case $2 in
1375 --diff)
1376 if [ -f "$LOCALSTATE/packages.diff" ]; then
1377 title 'Mirrored packages diff'
1378 cat $LOCALSTATE/packages.diff
1379 num=$(wc -l < $LOCALSTATE/packages.diff)
1380 footer "$(eval_ngettext \
1381 '$num new package listed on the mirror.' \
1382 '$num new packages listed on the mirror.' $num)"
1383 else
1384 newline
1385 _ 'Unable to list anything, no packages.diff found.'
1386 _ 'Recharge your current list to create a first diff.'
1387 newline
1388 fi; exit 0 ;;
1389 --text|--txt|--raw|*)
1390 title 'List of available packages on the mirror'
1391 cat $LOCALSTATE/packages.txt ;;
1392 esac
1393 pkgs=$(wc -l < $LOCALSTATE/packages.list)
1394 num=$(emsg "<c 32>$pkgs</c>")
1395 footer "$(eval_ngettext \
1396 '$num package in the last recharged list.' \
1397 '$num packages in the last recharged list.' $pkgs)"
1398 ;;
1401 list-files|-lf)
1402 # List files installed with the package.
1403 check_for_package_on_cmdline
1404 check_for_receipt
1405 title 'Installed files by: $PACKAGE'
1406 sort < $INSTALLED/$PACKAGE/files.list
1407 files=$(wc -l < $INSTALLED/$PACKAGE/files.list)
1408 num=$(emsg "<c 32>$files</c>")
1409 footer "$(eval_ngettext \
1410 '$num file installed with $PACKAGE' \
1411 '$num files installed with $PACKAGE' $files)"
1412 ;;
1415 info)
1416 # Information about package.
1417 check_for_package_on_cmdline
1418 check_for_receipt
1419 EXTRAVERSION=""
1420 . $INSTALLED/$PACKAGE/receipt
1421 title 'TazPKG information'
1422 # Display localized short description
1423 if [ -e "$LOCALSTATE/packages-desc.$LANG" ]; then
1424 LOCDESC=$(grep -e "^$PACKAGE " $LOCALSTATE/packages-desc.$LANG | cut -d' ' -f2)
1425 [ "x$LOCDESC" != "x" ] && SHORT_DESC="$LOCDESC"
1426 fi
1427 emsg "\
1428 <b>$(_ 'Package :')</b> $PACKAGE
1429 <b>$(_ 'Version :')</b> $VERSION$EXTRAVERSION
1430 <b>$(_ 'Category :')</b> $(_ $CATEGORY)
1431 <b>$(_ 'Short desc :')</b> $SHORT_DESC
1432 <b>$(_ 'Maintainer :')</b> $MAINTAINER"
1433 [ -n "$LICENSE" ] && emsg "<b>$(_ 'License :')</b> $LICENSE"
1434 [ -n "$DEPENDS" ] && emsg "<b>$(_ 'Depends :')</b> $DEPENDS"
1435 [ -n "$SUGGESTED" ] && emsg "<b>$(_ 'Suggested :')</b> $SUGGESTED"
1436 [ -n "$BUILD_DEPENDS" ] && emsg "<b>$(_ 'Build deps :')</b> $BUILD_DEPENDS"
1437 [ -n "$WANTED" ] && emsg "<b>$(_ 'Wanted src :')</b> $WANTED"
1438 [ -n "$WEB_SITE" ] && emsg "<b>$(_ 'Web site :')</b> $WEB_SITE"
1439 footer ;;
1442 desc)
1443 # Display package description.txt if available.
1444 if [ -f "$INSTALLED/$PACKAGE/description.txt" ]; then
1445 title 'Description of: $PACKAGE'
1446 cat $INSTALLED/$PACKAGE/description.txt
1447 footer
1448 else
1449 newline
1450 _ 'Sorry, no description available for this package.'
1451 newline
1452 fi ;;
1455 activity|log|-a)
1456 # Show activity log
1457 [ "$nb" ] || nb=18
1458 title 'TazPKG Activity'
1459 IFS=" "
1460 tail -n ${nb} ${LOG} | \
1461 while read date hour none action none pkg vers none; do
1462 case $action in
1463 Installed)
1464 action=$(colorize 32 $action) ;;
1465 Removed)
1466 action=$(colorize 31 $action) ;;
1467 *)
1468 action=$(boldify $action) ;;
1469 esac
1470 echo "$date $hour : $action $pkg $vers"
1471 done
1472 unset IFS
1473 footer ;;
1476 search|-s)
1477 # Search for a package by pattern or name.
1478 PATTERN="$2"
1479 if [ -z "$PATTERN" ]; then
1480 newline
1481 _ 'Please specify a pattern or package name to search for.'
1482 echo "$(_ 'Example:') 'tazpkg search paint'"
1483 newline
1484 exit 0
1485 fi
1486 title 'Search result for: $PATTERN'
1487 # Default is to search in installed pkgs and the raw list.
1488 case "$3" in
1489 -i|--installed)
1490 search_in_installed_packages ;;
1491 -l|--list)
1492 search_in_packages_list ;;
1493 -m|--mirror)
1494 search_in_packages_txt ;;
1495 *)
1496 search_in_installed_packages
1497 search_in_packages_list ;;
1498 esac ;;
1501 search-file|-sf)
1502 # Search for a file by pattern or name in all files.list.
1503 if [ -z "$2" ]; then
1504 newline
1505 _ 'Please specify a pattern or file name to search for.'
1506 echo "$(_ 'Example:') 'tazpkg search-file libnss'"
1507 newline
1508 exit 0
1509 fi
1510 s_file="$2"
1511 title 'Search result for file $s_file'
1513 if [ "$3" == "--mirror" ]; then
1515 match=0
1516 for i in $LOCALSTATE/files.list.lzma \
1517 $LOCALSTATE/undigest/*/files.list.lzma; do
1518 [ -f $i ] || continue
1519 unlzma -c $i | grep -- ".*:.*$2" | awk '
1520 BEGIN { last="" }
1522 pkg=substr($0,0,index($0,":")-1);
1523 file=substr($0,index($0,":")+2);
1524 if (last != pkg) {
1525 last = pkg;
1526 printf("\n%c[1mPackage %s:%c[0m\n",27,pkg,27);
1528 printf("%s\n",file);
1529 }'
1530 match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | wc -l`))
1531 done
1533 else
1535 # Check all pkg files.list in search match which specify the package
1536 # name and the full path to the file(s).
1537 for pkg in $INSTALLED/*; do
1538 if grep -qs "$2" $pkg/files.list; then
1539 . $pkg/receipt
1540 newline
1541 boldify "$(_ 'Package $PACKAGE:')"
1542 grep "$2" $pkg/files.list
1543 files=`grep $2 $pkg/files.list | wc -l`
1544 match=$(($match+$files))
1545 fi
1546 done
1548 fi
1549 pkg=$2
1550 if [ "$match" = "" ]; then
1551 # FIXME
1552 _ '0 files found for: $pkg'
1553 else
1554 num=$(emsg "<c 32>$files</c>")
1555 footer "$(eval_ngettext \
1556 '$num file found for: $pkg' \
1557 '$num files found for: $pkg' $match)"
1558 fi
1559 ;;
1562 search-pkgname)
1563 # Search for a package name
1564 if [ -z "$2" ]; then
1565 newline
1566 _ 'Please specify a pattern or file name to search for.'
1567 echo "$(_ 'Example:') 'tazpkg search-pkgname libnss'"
1568 newline
1569 exit 0
1570 fi
1571 s_pkg="$2"
1572 title 'Search result for package $s_pkg'
1574 # Search for a file on mirror and output only the package name
1575 match=0
1576 for i in $LOCALSTATE/files.list.lzma \
1577 $LOCALSTATE/undigest/*/files.list.lzma; do
1578 [ -f $i ] || continue
1579 unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | awk '{ print $1 }'
1580 match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | wc -l`))
1581 done
1582 file=$2
1583 if [ "$match" = "0" ]; then
1584 _ 'No file found for: $file'
1585 newline
1586 else
1587 num=$(emsg "<c 32>$files</c>")
1588 footer "$(eval_ngettext \
1589 '$num package found with file: $file' \
1590 '$num packages found with file: $file' $match)"
1591 fi
1592 ;;
1595 install|-i)
1596 # Install .tazpkg packages.
1597 check_root $@
1598 check_for_package_on_cmdline
1599 check_for_package_file
1601 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
1602 [ "$list" ] && INSTALL_LIST="$list"
1603 if [ "$rootconfig" ]; then
1604 if [ "$root" ]; then
1605 CACHE_DIR=$root/$CACHE_DIR
1606 SAVE_CACHE_DIR=$CACHE_DIR
1607 LOCALSTATE=$root/$LOCALSTATE
1608 else
1609 echo "rootconfig needs --root= option used." >&2
1610 exit 1
1611 fi
1612 fi
1614 # Get repositories priority list.
1615 look_for_priority
1617 # Check if forced install.
1618 if ! [ "$forced" ]; then
1619 check_for_installed_package $ROOT
1620 fi
1621 install_package $ROOT
1622 update_desktop_database $ROOT
1623 update_mime_database $ROOT
1624 update_icon_database $ROOT
1625 compile_glib_schemas $ROOT ;;
1628 install-list|get-install-list)
1629 # Install a set of packages from a list.
1630 check_root $@
1631 if [ -z "$2" ]; then
1632 newline
1633 _ \
1634 "Please change directory (cd) to the packages repository and specify the
1635 list of packages to install. Example: tazpkg install-list packages.list"
1636 exit 0
1637 fi
1638 # Check if the packages list exist.
1639 list_file=$2
1640 if [ ! -f "$list_file" ]; then
1641 _ 'Unable to find: $list_file'
1642 exit 0
1643 else
1644 LIST=$(cat $2)
1645 fi
1647 # Remember processed list
1648 export INSTALL_LIST="$2"
1650 # Set $COMMAND and install all packages.
1651 if [ "$1" = "get-install-list" ]; then
1652 COMMAND=get-install
1653 else
1654 COMMAND=install
1655 fi
1656 touch $2-processed
1658 # Upgrade tazpkg first. It may handle new features/formats...
1659 # then upgrade essential packages early
1660 for pkg in busybox-pam busybox gcc-lib-base glibc-base \
1661 slitaz-base-files tazpkg ; do
1662 pkg=$(egrep $pkg-[0-9] $INSTALL_LIST)
1663 [ -n "$pkg" ] || continue
1664 _ 'Adding implicit depends $pkg...'
1665 LIST="$pkg
1666 $LIST"
1667 done
1669 for pkg in $LIST; do
1670 grep -qs ^$pkg$ $2-processed && continue
1671 [ -d "$root/var/lib/tazpkg/installed" ] && continue
1672 tazpkg $COMMAND $pkg --list="$2" "$3" "$4" "$5"
1673 done
1674 rm -f $2-processed ;;
1677 add-flavor)
1678 # Install a set of packages from a flavor.
1679 install_flavor $2 ;;
1682 install-flavor)
1683 # Install a set of packages from a flavor and purge other ones.
1684 install_flavor $2 --purge ;;
1687 set-release)
1688 # Change current release and upgrade packages.
1689 RELEASE=$2
1690 if [ -z "$RELEASE" ]; then
1691 newline
1692 _ 'Please specify the release you want on the command line.'
1693 echo "$(_ 'Example:') tazpkg set-release cooking"
1694 newline
1695 exit 0
1696 fi
1697 rm $LOCALSTATE/mirror
1698 echo "$RELEASE" > /etc/slitaz-release
1699 tazpkg recharge && tazpkg upgrade
1701 # Install missing depends
1702 cd $INSTALLED
1703 for i in * ; do
1704 DEPENDS=""
1705 . $i/receipt
1706 for j in $DEPENDS ; do
1707 [ -d $j ] || tazpkg get-install $j
1708 done
1709 done ;;
1712 remove|-r)
1713 # Remove packages.
1714 check_root $@
1715 check_for_package_on_cmdline
1717 [ -n "$root" ] && ROOT="$root"
1718 if [ ! -f "$ROOT$INSTALLED/$PACKAGE/receipt" ]; then
1719 newline
1720 _ '$PACKAGE is not installed.'
1721 exit 0
1722 else
1723 ALTERED=""
1724 THE_PACKAGE=$PACKAGE # altered by receipt
1725 for i in $(cd $ROOT$INSTALLED ; ls); do
1726 [ -f $ROOT$INSTALLED/$i/receipt ] || continue
1727 DEPENDS=""
1728 . $ROOT$INSTALLED/$i/receipt
1729 case " $(echo $DEPENDS) " in
1730 *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
1731 esac
1732 done
1733 EXTRAVERSION=""
1734 . $ROOT$INSTALLED/$THE_PACKAGE/receipt
1735 fi
1736 newline
1737 if [ -n "$ALTERED" ]; then
1738 _ 'The following packages depend on $PACKAGE:'
1739 for i in $ALTERED; do
1740 echo " $i"
1741 done
1742 fi
1743 REFRESH=$(cd $ROOT$INSTALLED ; grep -sl ^$PACKAGE$ */modifiers)
1744 if [ -n "$REFRESH" ]; then
1745 _ 'The following packages have been modified by $PACKAGE:'
1746 for i in $REFRESH; do
1747 echo " ${i%/modifiers}"
1748 done
1749 fi
1750 if [ "$auto" ]; then
1751 answer=0
1752 else
1753 confirm "$(_ 'Remove $PACKAGE ($VERSION$EXTRAVERSION)? (y/N)')"
1754 answer=$?
1755 fi
1756 if [ $answer = 0 ]; then
1757 title 'Removing: $PACKAGE'
1758 # Pre remove commands.
1759 if grep -q ^pre_remove $ROOT$INSTALLED/$PACKAGE/receipt; then
1760 pre_remove $ROOT
1761 fi
1762 action "Removing all files installed..."
1763 if [ -f $ROOT$INSTALLED/$PACKAGE/modifiers ]; then
1764 for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do
1765 for mod in $(cat $ROOT$INSTALLED/$PACKAGE/modifiers); do
1766 [ -f $ROOT$INSTALLED/$mod/files.list ] && [ $(grep "^$(echo $file | grepesc)$" $ROOT$INSTALLED/$mod/files.list | wc -l) -gt 1 ] && continue 2
1767 done
1768 remove_with_path $ROOT$file
1769 done
1770 else
1771 for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do
1772 remove_with_path $ROOT$file
1773 done
1774 fi
1775 status
1776 if grep -q ^post_remove $ROOT$INSTALLED/$PACKAGE/receipt; then
1777 post_remove $ROOT
1778 fi
1780 # Remove package receipt.
1781 action "Removing package receipt..."
1782 rm -rf $ROOT$INSTALLED/$PACKAGE
1783 status
1785 sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION$/d" \
1786 $LOCALSTATE/installed.$SUM 2> /dev/null
1788 # Log this activity
1789 log_pkg Removed
1790 if [ "$ALTERED" ]; then
1791 if [ "$auto" ]; then
1792 answer=0
1793 else
1794 confirm "$(_ 'Remove packages depending on $PACKAGE? (y/N)')"
1795 answer=$?
1796 fi
1797 if [ $answer = 0 ]; then
1798 for i in $ALTERED; do
1799 if [ -d "$ROOT$INSTALLED/$i" ]; then
1800 tazpkg remove $i $ROOTOPTS
1801 fi
1802 done
1803 fi
1804 fi
1805 if [ "$REFRESH" ]; then
1806 if [ "$auto" ]; then
1807 answer=0
1808 else
1809 confirm "$(_ 'Reinstall packages modified by $PACKAGE? (y/N)')"
1810 answer=$?
1811 fi
1812 if [ $answer = 0 ]; then
1813 for i in $REFRESH; do
1814 if [ $(wc -l < $ROOT$INSTALLED/$i) -gt 1 ]; then
1815 _ 'Check $INSTALLED/$i for reinstallation'
1816 continue
1817 fi
1818 rm -r $ROOT$INSTALLED/$i
1819 tazpkg get-install ${i%/modifiers} $ROOTOPTS --forced
1820 done
1821 fi
1822 fi
1823 else
1824 newline
1825 _ 'Uninstallation of $PACKAGE cancelled.'
1826 fi
1827 newline ;;
1830 extract|-e)
1831 # Extract .tazpkg cpio archive into a directory.
1832 check_for_package_on_cmdline
1833 check_for_package_file
1834 title 'Extracting: $PACKAGE'
1836 # If no directory destination is found on the cmdline
1837 # we create one in the current dir using the package name.
1838 if [ -n "$TARGET_DIR" ]; then
1839 DESTDIR=$TARGET_DIR/$PACKAGE
1840 else
1841 DESTDIR=$PACKAGE
1842 fi
1843 mkdir -p $DESTDIR
1845 action "Copying original package..."
1846 cp $PACKAGE_FILE $DESTDIR
1847 status
1849 cd $DESTDIR
1850 extract_package
1851 [ -e "receipt" ] && footer "$(_ '$PACKAGE is extracted to: $DESTDIR')"
1852 ;;
1855 recompress)
1856 # Recompress .tazpkg cpio archive with lzma.
1857 check_for_package_on_cmdline
1858 check_for_package_file
1859 title 'Recompressing: $PACKAGE'
1860 mkdir -p $TMP_DIR
1862 action "Copying original package..."
1863 cp $PACKAGE_FILE $TMP_DIR
1864 status
1866 cd $TMP_DIR
1867 extract_package
1869 action "Recompressing the fs..."
1870 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
1871 rm -rf fs
1872 status
1874 action "Creating new package..."
1875 find . -print | cpio -o -H newc --quiet > \
1876 $TOP_DIR/$(basename $PACKAGE_FILE).$$ && mv -f \
1877 $TOP_DIR/$(basename $PACKAGE_FILE).$$ \
1878 $TOP_DIR/$(basename $PACKAGE_FILE)
1879 status
1881 cd $TOP_DIR
1882 rm -rf $TMP_DIR
1883 separator; newline ;;
1886 list-config)
1887 # List configuration files installed.
1888 if [ "$2" = "--box" ]; then
1889 mkdir -p $TMP_DIR && cd $TMP_DIR
1890 FILES="$INSTALLED/*/volatile.cpio.gz"
1891 [ -n "$3" ] && FILES="$INSTALLED/$3/volatile.cpio.gz"
1892 for i in $FILES; do
1893 zcat $i | cpio -idm --quiet > /dev/null
1894 find * -type f 2>/dev/null | while read file; do
1895 if [ ! -e /$file ]; then
1896 echo -n "----------|----|----|$(_n 'File lost')"
1897 else
1898 echo -n "$(stat -c "%A|%U|%G|%s|" /$file)"
1899 cmp $file /$file > /dev/null 2>&1 || \
1900 echo -n "$(stat -c "%.16y" /$file)"
1901 fi
1902 echo "|/$file"
1903 done
1904 rm -rf *
1905 done
1906 cd $TOP_DIR
1907 rm -rf $TMP_DIR
1908 else
1909 title 'Configuration files'
1910 for i in $INSTALLED/*/volatile.cpio.gz; do
1911 [ -n "$2" -a "$i" != "$INSTALLED/$2/volatile.cpio.gz" ] && continue
1912 [ -f "$i" ] || continue
1913 zcat $i | cpio -t --quiet
1914 done | sed 's|^|/|' | sort
1915 separator
1916 newline
1917 fi ;;
1920 repack-config)
1921 # Create SliTaz package archive from configuration files.
1922 mkdir -p $TMP_DIR && cd $TMP_DIR
1923 CONFIG_VERSION=1.0
1924 mkdir config-$CONFIG_VERSION
1925 cd config-$CONFIG_VERSION
1926 for i in $INSTALLED/*/volatile.cpio.gz; do
1927 zcat $i | cpio -t --quiet
1928 done > files.list
1929 mkdir fs
1930 cd fs
1931 ( cd / ; cpio -o -H newc --quiet ) < ../files.list | cpio -idm --quiet > /dev/null
1932 mkdir -p etc/tazlito
1933 for i in $INSTALLED/*/receipt; do
1934 EXTRAVERSION=""
1935 . $i
1936 echo "$PACKAGE-$VERSION$EXTRAVERSION"
1937 done > etc/tazlito/config-packages.list
1938 cd ..
1939 echo "etc/tazlito/config-packages.list" >> files.list
1940 pkg_date=$(date +"%x %X")
1941 cat > receipt <<EOT
1942 # SliTaz package receipt.
1944 PACKAGE="config"
1945 VERSION="$CONFIG_VERSION"
1946 CATEGORY="base-system"
1947 SHORT_DESC="$(_n 'User configuration backup on $pkg_date')"
1948 DEPENDS="$(ls $INSTALLED)"
1949 EOT
1950 cd ..
1951 tazpkg pack config-$CONFIG_VERSION
1952 cp config-$CONFIG_VERSION.tazpkg $TOP_DIR
1953 cd $TOP_DIR
1954 rm -rf $TMP_DIR
1955 ;;
1958 repack)
1959 # Create SliTaz package archive from an installed package.
1960 check_for_package_on_cmdline
1961 check_for_receipt
1962 EXTRAVERSION=""
1963 . $INSTALLED/$PACKAGE/receipt
1964 title 'Repacking: $PACKAGE-$VERSION$EXTRAVERSION.tazpkg'
1965 if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then
1966 _ "Can't repack \$PACKAGE"
1967 exit 1
1968 fi
1969 if [ -s $INSTALLED/$PACKAGE/modifiers ]; then
1970 _ "Can't repack, \$PACKAGE files have been modified by:"
1971 for i in $(cat $INSTALLED/$PACKAGE/modifiers); do
1972 echo " $i"
1973 done
1974 exit 1
1975 fi
1976 MISSING=""
1977 while read i; do
1978 [ -e "$i" ] && continue
1979 [ -L "$i" ] || MISSING="$MISSING\n $i"
1980 done < $INSTALLED/$PACKAGE/files.list
1981 if [ -n "$MISSING" ]; then
1982 _n "Can't repack, the following files are lost:"
1983 echo -e "$MISSING"
1984 exit 1
1985 fi
1986 mkdir -p $TMP_DIR && cd $TMP_DIR
1987 FILES="fs.cpio.lzma\n"
1988 for i in $(ls $INSTALLED/$PACKAGE) ; do
1989 [ "$i" = "volatile.cpio.gz" ] && continue
1990 [ "$i" = "modifiers" ] && continue
1991 cp $INSTALLED/$PACKAGE/$i . && FILES="$FILES$i\n"
1992 done
1993 ln -s / rootfs
1994 mkdir tmp
1995 sed 's/^/rootfs/' < files.list | cpio -o -H newc --quiet |\
1996 { cd tmp ; cpio -idm --quiet >/dev/null; cd ..; }
1997 mv tmp/rootfs fs
1998 if [ -f $INSTALLED/$PACKAGE/volatile.cpio.gz ]; then
1999 zcat $INSTALLED/$PACKAGE/volatile.cpio.gz | \
2000 { cd fs; cpio -idm --quiet; cd ..; }
2001 fi
2002 if fgrep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then
2003 . $INSTALLED/$PACKAGE/receipt
2004 repack_cleanup fs
2005 fi
2006 if [ -f $INSTALLED/$PACKAGE/$CHECKSUM ]; then
2007 sed 's, , fs,' < $INSTALLED/$PACKAGE/$CHECKSUM | \
2008 $CHECKSUM -s -c || {
2009 _ "Can't repack, \$CHECKSUM error."
2010 cd $TOP_DIR
2011 rm -rf $TMP_DIR
2012 exit 1
2014 fi
2015 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
2016 echo -e "$FILES" | cpio -o -H newc --quiet > \
2017 $TOP_DIR/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
2018 cd $TOP_DIR
2019 \rm -R $TMP_DIR
2020 _ 'Package $PACKAGE repacked successfully.'
2021 pkg_size=$(du -sh $PACKAGE-$VERSION$EXTRAVERSION.tazpkg)
2022 _ 'Size: $pkg_size'
2023 newline ;;
2026 pack)
2027 # Create SliTaz package archive using cpio and lzma.
2028 # TODO: Cook also pack packages, we should share code in libpkg.sh
2029 check_for_package_on_cmdline
2030 cd $PACKAGE
2031 if [ ! -f "receipt" ]; then
2032 _ 'Receipt is missing. Please read the documentation.'
2033 exit 0
2034 else
2035 title 'Packing: $PACKAGE'
2036 # Create files.list with redirecting find outpout.
2037 action "Creating the list of files..."
2038 cd fs
2039 find . -type f -print > ../files.list
2040 find . -type l -print >> ../files.list
2041 cd .. && sed -i s/'^.'/''/ files.list
2042 status
2043 action 'Creating $CHECKSUM of files...'
2044 while read file; do
2045 [ -L "fs$file" ] && continue
2046 [ -f "fs$file" ] || continue
2047 case "$file" in
2048 /lib/modules/*/modules.*|*.pyc) continue;;
2049 esac
2050 $CHECKSUM "fs$file" | sed 's/ fs/ /'
2051 done < files.list > $CHECKSUM
2052 status
2053 UNPACKED_SIZE=$(du -chs fs receipt files.list $CHECKSUM \
2054 description.txt 2> /dev/null | awk \
2055 '{ sz=$1 } END { print sz }')
2056 # Build cpio archives.
2057 action "Compressing the fs..."
2058 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
2059 rm -rf fs
2060 status
2061 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
2062 $CHECKSUM description.txt 2> /dev/null | awk \
2063 '{ sz=$1 } END { print sz }')
2064 action "Updating receipt sizes..."
2065 sed -i s/^PACKED_SIZE.*$// receipt
2066 sed -i s/^UNPACKED_SIZE.*$// receipt
2067 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
2068 status
2069 action "Creating full cpio archive..."
2070 find . -print | cpio -o -H newc --quiet > ../$PACKAGE.tazpkg
2071 status
2072 action "Restoring original package tree..."
2073 unlzma -c fs.cpio.lzma | cpio -idm --quiet
2074 status
2075 rm fs.cpio.lzma && cd ..
2076 footer "$(_ 'Package $PACKAGE compressed successfully.')"
2077 pkg_size=$(du -sh $PACKAGE.tazpkg)
2078 _ 'Size: $pkg_size'
2079 newline
2080 fi ;;
2083 recharge)
2084 # Recharge packages.list from a mirror.
2086 # WARNING: The 'mirrors' file has all SliTaz mirrors but 'mirror'
2087 # must have only the chosen main mirror.
2089 check_root $@
2091 ARG=$2
2092 if [ "$root" ]; then
2093 LOCALSTATE=$root$LOCALSTATE
2094 [ "${2#--}" != "$2" ] && ARG=$3
2095 fi
2096 if [ "$ARG" = main ]; then
2097 repository_to_recharge=$LOCALSTATE
2098 elif [ "$ARG" ]; then
2099 if [ -d "$LOCALSTATE/undigest/$ARG" ]; then
2100 repository_to_recharge=$LOCALSTATE/undigest/$ARG
2101 else
2102 repo="$LOCALSTATE/undigest/$ARG"
2103 _ "\$repo doesn't exist." >&2
2104 exit 1
2105 fi
2106 else
2107 repository_to_recharge="$LOCALSTATE $LOCALSTATE/undigest/*"
2108 fi
2109 for path in $repository_to_recharge; do
2110 [ -f $path/mirror ] || continue
2111 cd $path
2113 # Quietly check if recharging is needed.
2114 [ -f ID ] && mv ID ID.bak
2115 download_from "$(cat mirror)" ID >/dev/null 2>/dev/null
2116 if [ -f ID ] && fgrep -q $(cat ID.bak 2>/dev/null || echo "null") ID; then
2117 if [ "$path" = "$LOCALSTATE" ]; then
2118 repository_name=Main
2119 else
2120 base_path="$(basename $path)"
2121 repository_name="$(_n 'Undigest $base_path')"
2122 fi
2123 _ '$repository_name is up to date.'
2124 rm ID.bak
2125 continue
2126 fi
2128 # Don't let ID be a symlink when using local repository.
2129 if [ -f ID ]; then
2130 mv -f ID ID.bak
2131 cat ID.bak > ID
2132 rm ID.bak
2133 fi
2135 newline
2136 if [ "$path" != "$LOCALSTATE" ]; then
2137 base_path="$(basename $path)"
2138 _ 'Recharging undigest $base_path:'
2139 fi
2141 if [ -f "packages.list" ]; then
2142 action "Creating backup of the last packages list..."
2143 for i in packages.desc packages.$SUM packages.txt \
2144 packages.list packages.equiv files.list.lzma \
2145 extra.list mirrors packages.info
2146 do
2147 mv -f $i $i.bak 2>/dev/null
2148 done
2149 status
2150 fi
2152 for i in desc $SUM txt list equiv; do
2153 download_from "$(cat mirror)" packages.$i
2154 done
2155 download_from "$(cat mirror)" files.list.lzma
2156 download_from "$(cat mirror)" extra.list
2157 download_from "$(sed 's|packages/.*||' mirror)" mirrors
2159 # packages.info
2160 download_from "$(cat mirror)" packages.info.lzma
2161 lzma d packages.info.lzma packages.info
2162 rm packages.info.lzma
2164 if [ -f "packages.list.bak" ]; then
2165 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
2166 [ -f "extra.list.bak" ] &&
2167 diff -u extra.list.bak extra.list | grep ^+[a-z] >> packages.diff
2168 sed -i s/+// packages.diff
2169 title 'Mirrored packages diff'
2170 cat packages.diff
2171 new_pkgs=$(wc -l packages.diff)
2172 if [ "$new_pkgs" != 0 ]; then
2173 num=$(emsg "<c 32>$new_pkgs</c>")
2174 footer "$(eval_ngettext \
2175 '$num new package on the mirror.' \
2176 '$num new packages on the mirror.' $new_pkgs)"
2177 else
2178 _ 'No new packages on the mirror.'
2179 newline
2180 fi
2181 else
2182 footer "$(_ \
2183 'Last packages.list is ready to use. Note that next time you recharge the
2184 list, a list of differences will be displayed to show new and upgradeable
2185 packages.')"
2186 fi
2187 done ;;
2190 help-up)
2191 # Options available for the command: up
2192 newline; usage_up; newline
2193 exit 1 ;;
2196 up|upgrade)
2198 # This is the new way to upgrade packages making 'upgrade' and
2199 # upgradeable out-of-date. This new way is much, much more faster!
2200 # Look into installed packages and get data from receipt, it is fast
2201 # and easy to handle vars after using only md5sum to compare packages
2203 for opt in $@; do
2204 case "$opt" in
2205 --recharge|-r) tazpkg recharge ;;
2206 --install|-i) install="y" ;;
2207 --check|-c) install="n" ;;
2208 esac
2209 done
2210 time=$(date +%s)
2211 installed_sum=$LOCALSTATE/installed.$SUM
2212 look_for_priority
2213 for repo in $priority; do
2214 pkg_list=$repo/packages.list
2215 mtime=$(find $pkg_list -mtime +7)
2216 if [ "$mtime" ]; then
2217 if [ "$repo" = "$LOCALSTATE" ]; then
2218 repo_name=main
2219 else
2220 repo_name="${repo##*/}"
2221 fi
2222 _ '$pkg_list is older than one week... recharging'
2223 tazpkg recharge $repo_name
2224 fi
2225 done
2226 emsg "<n><b>$(_ 'Package')</b><i 28> $(_ 'Version')<i 48> $(_ 'Status')<->"
2227 cd $INSTALLED
2228 newline > $UP_LIST
2229 blocked_count=0
2230 for pkg in *; do
2231 [ ! -d $pkg ] && continue
2232 unset VERSION EXTRAVERSION
2233 . $pkg/receipt
2234 md5=$(fgrep " $PACKAGE-${VERSION}$EXTRAVERSION.tazpkg" \
2235 $installed_sum | awk '{print $1}')
2236 for repo in $priority; do
2237 pkg_desc=$repo/packages.desc
2238 pkg_list=$repo/packages.list
2239 pkg_sum=$repo/packages.$SUM
2241 if ! fgrep -q "$md5 $PACKAGE-" $pkg_sum; then
2242 # Jump to next repository in priority if pkg doesn't exist
2243 # in this one.
2244 grep -q ^$PACKAGE- $pkg_list || continue
2246 emsg -n "$PACKAGE<i 28> $VERSION"
2248 # Skip pkgs listed in $LOCALSTATE/blocked-packages.list
2249 if $(grep -qs "^$PACKAGE" $BLOCKED); then
2250 blocked_count=$(($blocked_count + 1))
2251 emsg "<i 48><c 31> $(_ 'Blocked')</c>"
2252 break
2253 fi
2255 new=$(grep "^$PACKAGE |" $pkg_desc | awk '{print $3}')
2257 if [ "$VERSION" == "$new" ]; then
2258 emsg "<i 48><c 34> $(_ 'New build')</c>"
2259 else
2260 emsg "<i 48><c 32> $(_ 'New version $new')</c>"
2261 fi
2262 echo "$PACKAGE" >> $UP_LIST
2263 break
2264 fi
2265 done
2266 done
2267 sed -i /^$/d $UP_LIST
2268 upnb=$(wc -l < $UP_LIST)
2269 pkgs=$(ls | wc -l)
2270 time=$(($(date +%s) - $time))
2271 if [ "$upnb" = 0 ]; then
2272 install="n"
2273 _ 'System is up-to-date...'
2274 fi
2275 num=$(emsg "<c 32>$pkgs</c>")
2276 footer "$(eval_ngettext \
2277 '$num installed package scanned in ${time}s' \
2278 '$num installed packages scanned in ${time}s' $pkgs)"
2279 if [ "$upnb" != 0 ]; then
2280 if [ "$blocked_count" -gt 0 ]; then
2281 num=$blocked_count
2282 blocked=$(eval_ngettext '$num blocked' '$num blocked' $num)
2283 else
2284 # FIXME
2285 blocked="$(_ '0 blocked')"
2286 fi
2287 num=$upnb
2288 boldify "$(eval_ngettext \
2289 'You have $num available upgrade ($blocked)' \
2290 'You have $num available upgrades ($blocked)' $num)"
2291 newline
2292 fi
2293 # Pkgs to upgrade ? Skip, let install them all or ask user
2294 [ "$install" == "n" ] && exit 0
2295 if [ "$upnb" -gt 0 ]; then
2296 if [ "$install" == "y" ]; then
2297 continue
2298 else
2299 _n 'Do you wish to install them now: y/n ? '
2300 read install
2301 fi
2302 case "$install" in
2303 y|Y|yes|YES|Yes)
2304 for pkg in $(cat $UP_LIST); do
2305 echo 'y' | tazpkg get-install $pkg --forced
2306 done
2307 # List is generated each time and must be cleaned so
2308 # tazpkg-notify doesn't find upgrades anymore.
2309 rm $UP_LIST && touch $UP_LIST ;;
2310 *)
2311 _ 'Leaving without any upgrades installed.'
2312 newline
2313 exit 0 ;;
2314 esac
2315 fi
2316 newline ;;
2319 bugs)
2320 # Show known bugs in package(s)
2321 cd $INSTALLED
2322 shift
2323 LIST=$@
2324 [ -n "$LIST" ] || LIST=$(ls)
2325 MSG=$(_n 'No known bugs.')
2326 for PACKAGE in $LIST; do
2327 BUGS=""
2328 EXTRAVERSION=""
2329 . $PACKAGE/receipt
2330 if [ -n "$BUGS" ]; then
2331 MSG=$(_n 'Bug list completed')
2332 newline
2333 _ 'Bugs in package $PACKAGE version $VERSION$EXTRAVERSION:'
2334 cat <<EOT
2335 $BUGS
2336 EOT
2337 fi
2338 done
2339 echo "$MSG" ;;
2342 check)
2343 # Check installed packages set.
2344 check_root $@
2346 # Get repositories priority list.
2347 look_for_priority
2349 cd $INSTALLED
2350 for PACKAGE in $(ls); do
2351 if [ ! -f $PACKAGE/receipt ]; then
2352 _ 'The package $PACKAGE installation has not completed'
2353 continue
2354 fi
2355 DEPENDS=""
2356 EXTRAVERSION=""
2357 . $PACKAGE/receipt
2358 if [ -s $PACKAGE/modifiers ]; then
2359 _ 'The package $PACKAGE-$VERSION$EXTRAVERSION has been modified by:'
2360 for i in $(cat $PACKAGE/modifiers); do
2361 echo " $i"
2362 done
2363 fi
2364 MSG="$(_n 'Files lost from $PACKAGE-$VERSION$EXTRAVERSION:')\n"
2365 while read file; do
2366 [ -e "$file" ] && continue
2367 if [ -L "$file" ]; then
2368 MSG="$MSG $(_n 'target of symlink')"
2369 fi
2370 echo -e "$MSG $file"
2371 MSG=""
2372 done < $PACKAGE/files.list
2373 MSG="$(_n 'Missing dependencies for $PACKAGE-$VERSION$EXTRAVERSION:')\n"
2374 for i in $DEPENDS; do
2375 [ -d $i ] && continue
2376 [ -d $(equivalent_pkg $i) ] && continue
2377 echo -e "$MSG $i"
2378 MSG=""
2379 done
2380 MSG="$(_n 'Dependencies loop between $PACKAGE and:')\n"
2381 ALL_DEPS=""
2382 check_for_deps_loop $PACKAGE $DEPENDS
2383 done
2385 _ 'Looking for known bugs...'
2386 tazpkg bugs
2388 if [ "$PACKAGE_FILE" = "--full" ]; then
2389 for file in */$CHECKSUM; do
2390 CONFIG_FILES=""
2391 . $(dirname "$file")/receipt
2392 [ -s "$file" ] || continue
2393 while read md5 f; do
2394 [ -f $f ] || continue
2395 for i in $CONFIG_FILES; do
2396 case "$f" in
2397 $i|$i/*) continue 2;;
2398 esac
2399 done
2400 echo "$md5 $f"
2401 done < "$file" | $CHECKSUM -c - 2> /dev/null | \
2402 grep -v OK$ | sed 's/FAILED$/$CHECKSUM MISMATCH/'
2403 done
2404 FILES=" "
2405 for file in $(cat */files.list); do
2406 [ -d "$file" ] && continue
2407 case "$FILES" in *\ $file\ *) continue;; esac
2408 [ $(grep "^$(echo $file | grepesc)$" */files.list 2> /dev/null | \
2409 wc -l) -gt 1 ] || continue
2410 FILES="$FILES$file "
2411 _ 'The following packages provide $file:'
2412 grep -l "^$(echo $file | grepesc)$" */files.list | \
2413 while read f; do
2414 pkg=${f%/files.list}
2415 if [ -f $pkg/modifiers ]; then
2416 pkg_list="$(cat $pkg/modifiers)"
2417 overriders=$(_n '(overridden by $pkg_list)')
2418 else
2419 overriders=''
2420 fi
2421 echo -n " $pkg $overriders"
2422 newline
2423 done
2424 done
2425 MSG="$(_n 'No package has installed the following files:')\n"
2426 find /etc /bin /sbin /lib /usr /var/www -not -type d 2>/dev/null | \
2427 while read file; do
2428 case "$file" in *\[*) continue;; esac
2429 grep -q "^$(echo $file | grepesc)$" */files.list && continue
2430 echo -e "$MSG $file"
2431 MSG=""
2432 done
2433 fi
2434 _ 'Check completed.'; echo ;;
2437 block)
2438 # Add a pkg name to the list of blocked packages.
2439 check_root $@
2440 check_for_package_on_cmdline
2441 newline
2442 if grep -qs "^$PACKAGE" $BLOCKED; then
2443 _ '$PACKAGE is already in the blocked packages list.'
2444 else
2445 action 'Add $PACKAGE to: $BLOCKED...'
2446 echo $PACKAGE >> $BLOCKED
2447 status
2448 # Log this activity
2449 . $INSTALLED/$PACKAGE/receipt
2450 log_pkg Blocked
2451 fi
2452 newline ;;
2455 unblock)
2456 # Remove a pkg name from the list of blocked packages.
2457 check_root $@
2458 check_for_package_on_cmdline
2459 newline
2460 if grep -qs "^$PACKAGE" $BLOCKED; then
2461 action 'Removing $PACKAGE from: $BLOCKED...'
2462 sed -i s/$PACKAGE/''/ $BLOCKED
2463 sed -i '/^$/d' $BLOCKED
2464 status
2465 # Log this activity
2466 . $INSTALLED/$PACKAGE/receipt
2467 log_pkg Unblocked
2468 else
2469 _ '$PACKAGE is not in the blocked packages list.'
2470 fi
2471 newline ;;
2474 get)
2475 # Download a package with wget.
2476 check_root $@
2477 check_for_package_on_cmdline
2478 check_for_packages_list
2480 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
2481 if [ "$rootconfig" ]; then
2482 if [ "$root" ]; then
2483 CACHE_DIR=$root/$CACHE_DIR
2484 SAVE_CACHE_DIR=$CACHE_DIR
2485 LOCALSTATE=$root/$LOCALSTATE
2486 else
2487 _ 'rootconfig needs --root= option used.' >&2
2488 exit 1
2489 fi
2490 fi
2492 # Get repositories priority list.
2493 look_for_priority
2495 CURRENT_DIR=$PWD
2496 check_for_package_in_list
2497 cd $CACHE_DIR
2498 if [ -f "$PACKAGE.tazpkg" ]; then
2499 _ '$PACKAGE already in the cache'
2500 # Check package download was finished
2501 tail -c 2k $PACKAGE.tazpkg | fgrep -q 00000000TRAILER || {
2502 _ 'Continuing $PACKAGE download'
2503 download $PACKAGE.tazpkg
2505 if [ "$($CHECKSUM $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.$SUM)" ]; then
2506 rm -f $PACKAGE.tazpkg
2507 download $PACKAGE.tazpkg
2508 fi
2509 else
2510 download $PACKAGE.tazpkg
2511 fi
2512 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
2513 cp -a $PACKAGE_FILE $CURRENT_DIR ;;
2516 get-install|-gi)
2517 # Download and install a package.
2518 check_root $@
2519 check_for_package_on_cmdline
2520 check_for_packages_list
2522 DO_CHECK=""
2523 [ "$forced" ] && DO_CHECK=no
2524 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
2525 [ "$list" ] && INSTALL_LIST="$list"
2526 if [ "$rootconfig" ]; then
2527 if [ "$root" ]; then
2528 CACHE_DIR=$root/$CACHE_DIR
2529 SAVE_CACHE_DIR=$CACHE_DIR
2530 LOCALSTATE=$root/$LOCALSTATE
2531 else
2532 _ 'rootconfig needs --root= option used.' >&2
2533 exit 1
2534 fi
2535 fi
2537 # Get repositories priority list.
2538 look_for_priority
2540 AUTOEXEC="no"
2541 if ! check_for_package_in_list check; then
2542 CACHE_DIR="${CACHE_DIR%/*}/get"
2543 [ -d "$CACHE_DIR" ] || mkdir -p $CACHE_DIR
2544 if download_get_script $PACKAGE /tmp/$PACKAGE.$$ ; then
2545 install_package_from_get_script /tmp/$PACKAGE.$$ $ROOT
2546 exit 0
2547 else
2548 PACKAGE=get-$PACKAGE
2549 AUTOEXEC=$PACKAGE
2550 check_for_package_in_list
2551 if [ -n "$(get_installed_package_pathname $PACKAGE $ROOT)" ]; then
2552 $AUTOEXEC $ROOT
2553 exit 0
2554 fi
2555 fi
2556 fi
2557 # Check if forced install.
2558 if ! [ "$forced" ]; then
2559 check_for_installed_package $ROOT
2560 fi
2561 cd $CACHE_DIR
2562 if [ -f "$PACKAGE.tazpkg" ]; then
2563 _ '$PACKAGE already in the cache: $CACHE_DIR'
2564 # Check package download was finished
2565 tail -c 2k $PACKAGE.tazpkg | fgrep -q 00000000TRAILER || {
2566 _ 'Continuing $PACKAGE download'
2567 download $PACKAGE.tazpkg
2569 if [ "$($CHECKSUM $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.$SUM)" ]; then
2570 rm -f $PACKAGE.tazpkg
2571 download $PACKAGE.tazpkg
2572 fi
2573 else
2574 newline
2575 download $PACKAGE.tazpkg
2576 fi
2577 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
2578 [ "$rootconfig" ] && LOCALSTATE=${LOCALSTATE#$root}
2579 install_package $ROOT
2580 [ "$AUTOEXEC" != "no" ] && $PACKAGE $ROOT
2581 update_desktop_database $ROOT
2582 update_mime_database $ROOT ;;
2585 clean-cache|-cc)
2586 # Remove all downloaded packages.
2587 check_root $@
2588 files=$(find $CACHE_DIR -name *.tazpkg | wc -l)
2589 title 'Path: $CACHE_DIR'
2590 action "Cleaning cache directory..."
2591 rm -rf $CACHE_DIR/*
2592 status
2593 num=$(colorize 32 "$files")
2595 footer "$(eval_ngettext \
2596 '$num file removed from cache.' \
2597 '$num files removed from cache.' \
2598 $files)"
2599 ;;
2602 list-undigest)
2603 # list undigest URLs.
2604 if [ "$2" = "--box" ]; then
2605 for i in $LOCALSTATE/undigest/*/mirror; do
2606 [ -f $i ] || continue
2607 echo "$(basename $(dirname $i))|$(cat $i)"
2608 done
2609 else
2610 title 'Current undigest(s)'
2611 for i in $LOCALSTATE/undigest/*/mirror; do
2612 if [ ! -f $i ]; then
2613 _ 'No undigest mirror found.'
2614 exit 1
2615 fi
2616 echo "$(basename $(dirname $i)) $(cat $i)"
2617 done
2618 newline
2619 fi ;;
2622 remove-undigest)
2623 # remove undigest URL.
2624 check_root $@
2625 undigest="$2"
2626 if [ -d $LOCALSTATE/undigest/$2 ]; then
2627 confirm "$(_ 'Remove $undigest undigest? (y/N)')"
2628 if [ $? = 0 ]; then
2629 action 'Removing $undigest undigest...'
2630 rm -rf $LOCALSTATE/undigest/$2
2631 status
2632 rmdir $LOCALSTATE/undigest 2> /dev/null
2633 fi
2634 else
2635 _ 'Undigest $undigest not found'
2636 fi ;;
2639 add-undigest|setup-undigest)
2640 # Add undigest URL.
2641 check_root $@
2642 undigest=$2
2643 [ -d $LOCALSTATE/undigest ] || mkdir $LOCALSTATE/undigest
2644 if [ -z "$undigest" ]; then
2645 i=1
2646 while [ -d $LOCALSTATE/undigest/$i ]; do
2647 i=$(($i+1))
2648 done
2649 undigest=$i
2650 fi
2651 if [ ! -d $LOCALSTATE/undigest/$undigest ]; then
2652 _ 'Creating new undigest $undigest.'
2653 mkdir $LOCALSTATE/undigest/$undigest
2654 fi
2655 setup_mirror $LOCALSTATE/undigest/$undigest $3 ;;
2658 setup-mirror|-sm)
2659 # Change mirror URL.
2660 check_root $@
2661 setup_mirror $LOCALSTATE $2 ;;
2664 reconfigure)
2665 # Replay post_install from receipt
2666 check_for_package_on_cmdline
2667 check_root $@
2668 ROOT=""
2669 while [ -n "$3" ]; do
2670 case "$3" in
2671 --root=*)
2672 ROOT="${3#--root=}/" ;;
2673 *)
2674 shift 2
2675 u_opt="$*"
2676 newline >&2
2677 _ 'Unknown option $u_opt.' >&2
2678 exit 1 ;;
2679 esac
2680 shift
2681 done
2682 if [ -d "$ROOT$INSTALLED/$PACKAGE" ]; then
2683 check_for_receipt $ROOT
2684 # Check for post_install
2685 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
2686 . $ROOT$INSTALLED/$PACKAGE/receipt
2687 post_install $ROOT
2688 # Log this activity
2689 [ -n "$ROOT" ] || log_pkg Reconfigured
2690 else
2691 newline
2692 _ 'Nothing to do for $PACKAGE.'
2693 fi
2694 else
2695 newline
2696 _ 'Package $PACKAGE is not installed.'
2697 _ "Install package with 'tazpkg install' or 'tazpkg get-install'"
2698 newline
2699 fi ;;
2702 shell)
2703 # TazPKG SHell
2704 if test $(id -u) = 0 ; then
2705 PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
2706 else
2707 PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
2708 fi
2709 if [ ! "$2" = "--noheader" ]; then
2710 clear
2711 title 'TazPKG SHell.'
2712 _ "Type 'usage' to list all available commands or 'quit' or 'q' to exit."
2713 newline
2714 fi
2715 while true; do
2716 echo -en "$PROMPT"; read cmd
2717 case $cmd in
2718 q|quit)
2719 break ;;
2720 shell)
2721 _ 'You are already running a TazPKG SHell.' ;;
2722 su)
2723 su -c 'exec tazpkg shell --noheader' && break ;;
2724 "")
2725 continue ;;
2726 *)
2727 tazpkg $cmd ;;
2728 esac
2729 done ;;
2732 depends)
2733 # Display dependencies tree
2734 cd $INSTALLED
2735 ALL_DEPS=""
2736 if [ -f $2/receipt ]; then
2737 dep_scan $2 ""
2738 fi ;;
2741 rdepends)
2742 # Display reverse dependencies tree
2743 cd $INSTALLED
2744 ALL_DEPS=""
2745 if [ -f $2/receipt ]; then
2746 rdep_scan $2
2747 fi ;;
2750 convert|-c)
2751 # convert misc package format to .tazpkg
2752 check_for_package_file
2753 tazpkg-convert $@
2754 ;;
2757 link)
2758 # link a package from another slitaz installation
2759 PACKAGE=$2
2760 if [ ! -d "$TARGET_DIR" -o \
2761 ! -d "$TARGET_DIR$INSTALLED/$PACKAGE" ]; then
2762 _n "
2763 usage: tazpkg link package_name slitaz_root
2764 example: 'tazpkg link openoffice /mnt' will use less than 100k in
2765 your running system ram.
2767 exit 1
2768 fi
2769 if [ -e "$INSTALLED/$PACKAGE" ]; then
2770 _ '$PACKAGE is already installed.'
2771 exit 1
2772 fi
2773 ln -s $TARGET_DIR$INSTALLED/$PACKAGE $INSTALLED
2774 DEPENDS="$(. $INSTALLED/$PACKAGE/receipt ; echo $DEPENDS)"
2775 MISSING=""
2776 for i in $DEPENDS; do
2777 [ -e $INSTALLED/$i ] && continue
2778 MISSING="$MISSING$i "
2779 _ 'Missing: $i'
2780 done
2781 if [ -n "$MISSING" ]; then
2782 newline
2783 confirm "$(_ 'Link all missing dependencies? (y/N)')"
2784 answer=$?
2785 newline
2786 if [ $answer = 0 ]; then
2787 for i in $MISSING; do
2788 tazpkg link $i $TARGET_DIR
2789 done
2790 else
2791 newline
2792 _ 'Leaving dependencies unresolved for: $PACKAGE'
2793 _ 'The package is installed but probably will not work.'
2794 newline
2795 fi
2796 fi
2797 . $INSTALLED/$PACKAGE/receipt
2798 if grep -q ^pre_install $INSTALLED/$PACKAGE/receipt; then
2799 pre_install
2800 fi
2801 while read path; do
2802 [ -e $path ] && continue
2803 while true; do
2804 dir=$(dirname $path)
2805 [ -e $dir ] && break
2806 path=$dir
2807 done
2808 ln -s $TARGET_DIR$path $dir
2809 done < $INSTALLED/$PACKAGE/files.list
2810 if grep -q ^post_install $INSTALLED/$PACKAGE/receipt; then
2811 post_install
2812 fi ;;
2815 usage|*)
2816 # Print a short help or give usage for an unknown or empty command.
2817 usage ;;
2818 esac
2820 exit 0