tazpkg view tazpkg @ rev 697

tazpkg-convert: update WEB_SITE in debian packages
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Dec 02 09:14:09 2014 +0100 (2014-12-02)
parents 608981c962f8
children 1b791f0f9239
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 *)
535 ln -sf $i/$1 . && break ;;
536 esac
537 done
538 }
541 # Download a file trying all mirrors
543 download()
544 {
545 local i
546 case "$1" in
547 *.tazpkg)
548 for i in $priority ; do
549 grep -q "^${1%.tazpkg}$" $i/packages.list 2>/dev/null || continue
550 download_from "$(cat $i/mirror)" "$@" && return
551 done
552 esac
553 for i in $(cat $(for rep in $priority; do echo $rep/mirror; done) 2>/dev/null); do
554 download_from "$i" "$@" && break
555 done
556 }
559 # Extract a package with cpio and gzip/lzma.
561 extract_package()
562 {
563 action 'Extracting $PACKAGE...'
564 cpio -idm --quiet < ${PACKAGE_FILE##*/} && rm -f ${PACKAGE_FILE##*/}
565 status
566 if [ -f fs.cpio.lzma ]; then
567 unlzma -c fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
568 elif [ -f fs.cpio.gz ]; then
569 zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz
570 fi
571 }
574 remove_with_path()
575 {
576 # Avoid dirname errors by checking for argument.
577 [ "$1" ] || return
579 local dir
580 rm -f $1 2>/dev/null
581 dir="$1"
582 while [ "$dir" != "/" ]; do
583 dir="$(dirname $dir)"
584 rmdir $dir 2> /dev/null || break
585 done
586 }
589 grepesc()
590 {
591 sed 's/\[/\\[/g'
592 }
595 # This function installs a package in the rootfs.
597 install_package()
598 {
599 ROOT=$1
600 if [ -n "$ROOT" ]; then
601 # Get absolute path
602 ROOT=$(realpath $ROOT)
603 fi
604 {
605 # Create package path early to avoid dependencies loop
606 mkdir -p $TMP_DIR
607 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $PACKAGE_FILE
608 . $TMP_DIR/receipt
609 if grep -q ^pre_depends $TMP_DIR/receipt; then
610 pre_depends $ROOT
611 fi
613 # Keep modifiers and file list on upgrade
614 cp $ROOT$INSTALLED/$PACKAGE/modifiers \
615 $ROOT$INSTALLED/$PACKAGE/files.list $TMP_DIR 2> /dev/null
616 rm -rf $ROOT$INSTALLED/$PACKAGE 2> /dev/null
618 # Make the installed package data dir to store
619 # the receipt and the files list.
620 mkdir -p $ROOT$INSTALLED/$PACKAGE
621 cp $TMP_DIR/modifiers $ROOT$INSTALLED/$PACKAGE 2> /dev/null
622 cp $TMP_DIR/files.list $ROOT$INSTALLED/$PACKAGE 2> /dev/null
623 rm -rf $TMP_DIR 2> /dev/null
624 sed -i "/ $(basename $PACKAGE_FILE)$/d" \
625 $ROOT$LOCALSTATE/installed.$SUM 2> /dev/null
626 cd $(dirname $PACKAGE_FILE)
627 $CHECKSUM $(basename $PACKAGE_FILE) >> $ROOT$LOCALSTATE/installed.$SUM
628 }
630 # Resolve package deps.
631 check_for_deps $ROOT
632 if [ -n "$MISSING_PACKAGE" ]; then
633 install_deps $ROOT
634 fi
635 mkdir -p $TMP_DIR
636 [ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> $ROOT$LOCALSTATE/$INSTALL_LIST-processed
638 title 'Installation of: $PACKAGE'
640 action 'Copying $PACKAGE...'
641 cp $PACKAGE_FILE $TMP_DIR
642 status
644 cd $TMP_DIR
645 extract_package
646 SELF_INSTALL=0
647 EXTRAVERSION=""
648 CONFIG_FILES=""
650 # Include temporary receipt to get the right variables.
651 . $PWD/receipt
652 cd $ROOT$INSTALLED
654 if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then
655 action "Checking post install dependencies..."
656 [ -f $INSTALLED/$PACKAGE/receipt ]
657 if ! status; then
658 command="tazpkg install $PACKAGE_FILE"
659 _ "Please run '\$command' in / and retry."
660 rm -rf $TMP_DIR
661 exit 1
662 fi
663 fi
665 # Get files to remove if upgrading
666 if [ -f $PACKAGE/files.list ]; then
667 while read file; do
668 grep -q "^$(echo $file | grepesc)$" $TMP_DIR/files.list && continue
669 for i in $(cat $PACKAGE/modifiers 2> /dev/null ;
670 fgrep -sl $PACKAGE */modifiers | cut -d/ -f1 ); do
671 grep -qs "^$(echo $file | grepesc)$" $i/files.list && continue 2
672 done
673 echo $file
674 done < $PACKAGE/files.list > $TMP_DIR/files2remove.list
675 fi
677 # Remember modified packages
678 {
679 check=false
680 for i in $(fgrep -v [ $TMP_DIR/files.list); do
681 [ -e "$ROOT$i" ] || continue
682 [ -d "$ROOT$i" ] && continue
683 echo "- $i"
684 check=true
685 done ;
686 $check && \
687 for i in *; do
688 [ "$i" == "$PACKAGE" ] && continue
689 [ -s $i/files.list ] || continue
690 awk "{ printf \"$i %s\\n\",\$1 }" < $i/files.list
691 done;
692 } | awk '
693 {
694 if ($1 == "-" || file[$2] != "") {
695 file[$2] = file[$2] " " $1
696 if ($1 != "-") {
697 if (pkg[$1] == "") all = all " " $1
698 pkg[$1] = pkg[$1] " " $2
699 }
700 }
701 }
702 END {
703 for (i = split(all, p, " "); i > 0; i--)
704 for (j = split(pkg[p[i]], f, " "); j > 0; j--)
705 printf "%s %s\n",p[i],f[j];
706 }
707 ' | while read dir file; do
708 if grep -qs ^$dir$ $PACKAGE/modifiers; then
709 # Do not overload an overloaded file !
710 rm $TMP_DIR$file 2> /dev/null
711 continue
712 fi
713 grep -qs ^$PACKAGE$ $dir/modifiers && continue
714 if [ -s "$dir/volatile.cpio.gz" ]; then
715 # We can modify backed up files without notice
716 zcat $dir/volatile.cpio.gz | cpio -t --quiet | \
717 grep -q "^${file#/}$" && continue
718 fi
719 echo "$PACKAGE" >> $dir/modifiers
720 done
722 cd $TMP_DIR
723 cp receipt files.list $ROOT$INSTALLED/$PACKAGE
725 # Copy the description if found.
726 if [ -f "description.txt" ]; then
727 cp description.txt $ROOT$INSTALLED/$PACKAGE
728 fi
730 # Copy the md5sum if found.
731 if [ -f "$CHECKSUM" ]; then
732 cp $CHECKSUM $ROOT$INSTALLED/$PACKAGE
733 fi
735 # Pre install commands.
736 if grep -q ^pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then
737 pre_install $ROOT
738 fi
739 if [ -n "$CONFIG_FILES" ]; then
740 # save 'official' configuration files
741 action 'Saving configuration files for $PACKAGE...'
742 for i in $CONFIG_FILES; do
743 { cd fs ; find ${i#/} -type f 2> /dev/null; cd ..; }
744 done | { cd fs ; cpio -o -H newc --quiet | gzip -9; cd ..; } > \
745 $ROOT$INSTALLED/$PACKAGE/volatile.cpio.gz
747 # keep user configuration files
748 for i in $CONFIG_FILES; do
749 { cd fs ; find ${i#/} -type f 2> /dev/null; cd ..; }
750 done | while read i; do
751 [ -e $ROOT/$i ] || continue
752 cp -a $ROOT/$i fs/$i
753 done
754 status
755 fi
757 action 'Installing $PACKAGE...'
758 [ "$(busybox ls fs/* 2> /dev/null)" ] && cp -a fs/* $ROOT/
759 status
761 if [ -s files2remove.list ]; then
762 action 'Removing old $PACKAGE...'
763 while read file; do
764 remove_with_path $ROOT$file
765 done < files2remove.list
766 true
767 status
768 fi
770 # Remove the temporary random directory.
771 action "Removing all tmp files..."
772 cd ..; rm -rf $TMP_DIR
773 status
775 # Post install commands.
776 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
777 post_install $ROOT
778 fi
780 # Update-desktop-database if needed.
781 if [ "$(fgrep .desktop $ROOT$INSTALLED/$PACKAGE/files.list | fgrep /usr/share/applications/)" ]; then
782 updatedesktopdb=yes
783 fi
785 # Update-mime-database if needed.
786 if [ "$(fgrep /usr/share/mime $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
787 updatemimedb=yes
788 fi
790 # Update-icon-database
791 if [ "$(fgrep /usr/share/icon/hicolor $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
792 updateicondb=yes
793 fi
795 # Compile glib schemas if needed.
796 if [ "$(fgrep /usr/share/glib-2.0/schemas $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
797 compile_schemas=yes
798 fi
800 # Update depmod list
801 if [ "$(fgrep /lib/modules $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
802 updatedepmod=yes
803 fi
805 cd $TOP_DIR
806 pkg_name="$PACKAGE ($VERSION$EXTRAVERSION)"
807 footer "$(_ '$pkg_name is installed.')"
809 # Log this activity
810 [ -n "$ROOT" ] || log_pkg Installed
811 }
814 # This function may be called by a get script.
816 abort_package()
817 {
818 cd $CUR_DIR
819 rm -rf $TMP_DIR
820 echo "${1:-Abort $PACKAGE.}"
821 exit 1
822 }
825 # This function installs a package from a get script in the rootfs.
827 install_package_from_get_script()
828 {
829 SCRIPT="$1"
830 ROOT="$2"
831 [ -d $ROOT$INSTALLED/$PACKAGE ] && exit 1
833 grep -q no-check-certificate $SCRIPT &&
834 [ ! -d $INSTALLED/wget ] && tazpkg get-install wget
836 mkdir -p $TMP_DIR && cd $TMP_DIR
837 saved=$PACKAGE
838 unset_receipt
839 PACKAGE=$saved
841 set -e
842 . $SCRIPT
843 set +e
844 cd $TMP_DIR
845 [ -d $PACKAGE-$VERSION ] || abort_package \
846 "Could not download ${TARBALL:-$PACKAGE} from ${WGET_URL:-$WEB_SITE}. Exiting."
848 if [ ! -s $PACKAGE-$VERSION/receipt ]; then
849 cat > $PACKAGE-$VERSION/receipt <<EOT
850 # SliTaz package receipt.
852 PACKAGE="$PACKAGE"
853 VERSION="${VERSION:-unknown}"
854 CATEGORY="${CATEGORY:-non-free}"
855 WEB_SITE="$WEB_SITE"
856 SHORT_DESC="${SHORT_DESC:-$PACKAGE}"
857 MAINTAINER="${MAINTAINER:-nobody@slitaz.org}"
858 EOT
859 for i in LICENSE TARBALL WGET_URL CONFIG_FILES SUGGESTED \
860 PROVIDE DEPENDS HOST_ARCH TAGS EXTRA_SOURCE_FILES ; do
861 eval "[ -n \"\$$i\" ] && echo \"$i=\\\"\$$i\\\"\""
862 done >> $PACKAGE-$VERSION/receipt
863 fi
865 DEPENDS="$(unset DEPENDS; . $PACKAGE-$VERSION/receipt ; echo $DEPENDS)"
866 for i in $(find_depends $PACKAGE-$VERSION/fs); do
867 case " $DEPENDS " in
868 *\ $i\ *) continue;;
869 esac
870 grep -q '^DEPENDS="' $PACKAGE-$VERSION/receipt ||
871 echo 'DEPENDS=""' >> $PACKAGE-$VERSION/receipt
872 sed -i "s/^DEPENDS=\"/&$i /" $PACKAGE-$VERSION/receipt
873 done
875 tazpkg pack $PACKAGE-$VERSION
877 # Clean to save RAM memory before installation
878 rm -rf $PACKAGE-$VERSION
880 # Install pseudo package
881 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
882 mv $PACKAGE-$VERSION.tazpkg $CACHE_DIR
884 # Clean
885 cd $TOP_DIR
886 rm -rf $TMP_DIR
887 }
890 # Check for loop in deps tree.
892 check_for_deps_loop()
893 {
894 local list
895 local pkg
896 local deps
897 pkg=$1
898 shift
899 [ -n "$1" ] || return
900 list=""
902 # Filter out already processed deps
903 for i in $@; do
904 case " $ALL_DEPS" in
905 *\ $i\ *);;
906 *) list="$list $i";;
907 esac
908 done
909 ALL_DEPS="$ALL_DEPS$list "
910 for i in $list; do
911 [ -f $i/receipt ] || continue
912 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
913 case " $deps " in
914 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
915 *) check_for_deps_loop $pkg $deps;;
916 esac
917 done
918 }
921 # Check for missing deps listed in a receipt packages.
923 check_for_deps()
924 {
925 local saved;
926 saved=$PACKAGE
927 mkdir -p $TMP_DIR
928 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $PACKAGE_FILE
929 . $TMP_DIR/receipt
930 PACKAGE=$saved
931 rm -rf $TMP_DIR
933 num=0
934 for pkgorg in $DEPENDS; do
935 i=$(equivalent_pkg $pkgorg $1)
936 if [ ! -d "$1$INSTALLED/$i" ]; then
937 MISSING_PACKAGE=$i
938 num=$(($num+1))
939 elif [ ! -f "$1$INSTALLED/$i/receipt" ]; then
940 _ 'WARNING Dependency loop between $PACKAGE and $i.'
941 fi
942 done
944 if [ ! "$MISSING_PACKAGE" = "" ]; then
945 title "$(_ 'Tracking dependencies for: $PACKAGE')"
946 for pkgorg in $DEPENDS; do
947 i=$(equivalent_pkg $pkgorg $1)
948 if [ ! -d "$1$INSTALLED/$i" ]; then
949 MISSING_PACKAGE=$i
950 _ 'Missing: $MISSING_PACKAGE'
951 fi
952 done
953 separator
954 eval_ngettext \
955 '$num missing package to install.' \
956 '$num missing packages to install.' $num; echo
957 fi
958 }
961 # Install all missing deps. Auto install or ask user then install all missing
962 # deps from local dir, cdrom, media or from the mirror. In case we want to
963 # install packages from local, we need a packages.list to find the version.
965 install_deps()
966 {
967 local root
968 root=""
969 [ -n "$1" ] && root="--root=$1"
970 if [ "$AUTO_INSTALL_DEPS" == "yes" ]; then
971 answer=0
972 else
973 newline
974 confirm "$(_ 'Install all missing dependencies? (y/N)')"
975 answer=$?
976 newline
977 fi
978 if [ $answer = 0 ]; then
979 for pkgorg in $DEPENDS; do
980 pkg=$(equivalent_pkg $pkgorg $1)
981 if [ ! -d "$1$INSTALLED/$pkg" ]; then
982 local list
983 list="$INSTALL_LIST"
984 [ -n "$list" ] || list="$TOP_DIR/packages.list"
985 # We can install packages from a local dir by greping
986 # the TAZPKG_BASENAME in the local packages.list.
987 found=0
988 if [ -f "$list" ]; then
989 _ 'Checking if $pkg exists in local list...'
990 mkdir $TMP_DIR
991 for i in $pkg-*.tazpkg; do
992 [ -f $i ] || continue
993 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $i
994 [ "$(. $TMP_DIR/receipt; echo $PACKAGE)" = "$pkg" ] || continue
995 if grep -q ^$(package_fullname_in_dir $TMP_DIR).tazpkg$ $list
996 then
997 found=1
998 tazpkg install $i $root --list=$list
999 break
1000 fi
1001 done
1002 rm -rf $TMP_DIR
1003 fi
1004 # Install deps from the mirror.
1005 if [ $found -eq 0 ]; then
1006 if [ ! -f "$LOCALSTATE/packages.list" ]; then
1007 tazpkg recharge
1008 fi
1009 tazpkg get-install $pkg $root
1010 fi
1011 fi
1012 done
1013 else
1014 newline
1015 _ \
1016 "Leaving dependencies for \$PACKAGE unresolved.
1017 The package is installed but will probably not work."
1018 newline
1019 fi
1023 # Search pattern in installed packages.
1025 search_in_installed_packages()
1027 _ 'Installed packages'
1028 separator
1029 list=`ls -1 $INSTALLED | grep -i "$PATTERN"`
1030 num=0
1031 for pkg in $list; do
1032 EXTRAVERSION=""
1033 [ -f $INSTALLED/$pkg/receipt ] || continue
1034 . $INSTALLED/$pkg/receipt
1035 emsg "$PACKAGE<i 24> $VERSION$EXTRAVERSION<i 42> $(_n $CATEGORY)"
1036 num=$(($num+1))
1037 done
1039 # Set correct ending messages.
1040 if [ x$num == x ]; then
1041 _ 'No installed packages found for: $PATTERN'
1042 newline
1043 else
1044 footer "$(eval_ngettext \
1045 '$num installed package found for: $PATTERN' \
1046 '$num installed packages found for: $PATTERN' $num)"
1047 fi
1051 # Search in packages.list for available pkgs.
1053 search_in_packages_list()
1055 _ 'Available packages name-version'
1056 separator
1057 num=0
1058 BPATTERN="$(emsg "<b>$PATTERN</b>")"
1059 for i in $LOCALSTATE/packages.list $LOCALSTATE/undigest/*/packages.list; do
1060 grep -is "$PATTERN" $i | sed "s|$PATTERN|$BPATTERN|"
1061 num=$(($num + `grep -is "$PATTERN" $i | wc -l`))
1062 done
1063 if [ ! -f "$LOCALSTATE/packages.list" ]; then
1064 newline
1065 _ \
1066 "No 'packages.list' found to check for mirrored packages. For more results,
1067 please run 'tazpkg recharge' once as root before searching."
1068 newline
1069 fi
1070 if [ "$num" = "0" ]; then
1071 _ 'No available packages found for: $PATTERN'
1072 newline
1073 else
1074 footer "$(eval_ngettext \
1075 '$num available package found for: $PATTERN' \
1076 '$num available packages found for: $PATTERN' $packages)"
1077 fi
1081 # search --mirror: Search in packages.txt for available pkgs and give more
1082 # info than --list or default.
1084 search_in_packages_txt()
1086 _ 'Matching packages name with version and desc'
1087 separator
1088 num=0
1089 for i in $LOCALSTATE/packages.txt $LOCALSTATE/undigest/*/packages.txt; do
1090 grep -is -A 2 "^$PATTERN" $i
1091 num=$(($num + `grep -is "^$PATTERN" $i | wc -l`))
1092 done
1093 if [ ! -f "$LOCALSTATE/packages.txt" ]; then
1094 newline
1095 _ \
1096 "No 'packages.txt' found to check for mirrored packages. For more results,
1097 please run 'tazpkg recharge' once as root before searching."
1098 newline
1099 fi
1100 if [ "$num" = "0" ]; then
1101 _ 'No available packages found for: $PATTERN'
1102 newline
1103 else
1104 footer "$(eval_ngettext \
1105 '$num available package found for: $PATTERN' \
1106 '$num available packages found for: $PATTERN' $packages)"
1107 fi
1111 # Install package-list from a flavor
1113 install_flavor()
1115 check_root $@
1117 # Get repositories priority list.
1118 look_for_priority
1120 FLAVOR=$1
1121 ARG=$2
1122 mkdir -p $TMP_DIR
1123 [ -f $FLAVOR.flavor ] && cp $FLAVOR.flavor $TMP_DIR
1124 cd $TMP_DIR
1125 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
1126 zcat < $FLAVOR.flavor | cpio --quiet -i >/dev/null
1128 while read file; do
1129 for pkg in $(ls -d $INSTALLED/${file%%-*}*); do
1130 [ -f $pkg/receipt ] || continue
1131 EXTRAVERSION=""
1132 . $pkg/receipt
1133 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && break
1134 done
1135 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && continue
1136 cd $CACHE_DIR
1137 download $file.tazpkg
1138 cd $TMP_DIR
1139 tazpkg install $CACHE_DIR/$file.tazpkg --forced
1140 done < $FLAVOR.pkglist
1142 [ -f $FLAVOR.nonfree ] && while read pkg; do
1143 [ -d $INSTALLED/$pkg ] || continue
1144 [ -d $INSTALLED/get-$pkg ] && tazpkg get-install get-$pkg
1145 get-$pkg
1146 done < $FLAVOR.nonfree
1148 [ "$ARG" == "--purge" ] && for pkg in $(ls $INSTALLED); do
1149 [ -f $INSTALLED/$pkg/receipt ] || continue
1150 EXTRAVERSION=""
1151 . $INSTALLED/$pkg/receipt
1152 grep -q ^$PACKAGE-$VERSION$EXTRAVERSION$ $FLAVOR.pkglist && continue
1153 grep -qs ^$PACKAGE$ $FLAVOR.nonfree && continue
1154 tazpkg remove $PACKAGE
1155 done
1156 else
1157 _ "Can't find flavor \$FLAVOR. Abort."
1158 fi
1159 cd $TOP_DIR
1160 rm -rf $TMP_DIR
1164 # Update mirror urls
1166 setup_mirror()
1168 # Backup old list.
1169 if [ -f "$1/mirror" ]; then
1170 cp -f $1/mirror $1/mirror.bak
1171 fi
1172 title 'Current mirror(s)'
1173 echo " `cat $1/mirror 2> /dev/null`"
1174 _ \
1175 "Please enter URL of the new mirror (http, ftp or local path). You must specify
1176 the complete address to the directory of the packages and packages.list file."
1177 newline
1178 _n 'New mirror(s) URL: '
1179 NEW_MIRROR_URL=$2
1180 if [ -n "$NEW_MIRROR_URL" ]; then
1181 echo $NEW_MIRROR_URL
1182 else
1183 read NEW_MIRROR_URL
1184 fi
1185 if [ "$NEW_MIRROR_URL" = "" ]; then
1186 _ 'Nothing has been changed.'
1187 else
1188 _ 'Setting mirror(s) to: $NEW_MIRROR_URL'
1189 rm -f $1/mirror
1190 for i in $NEW_MIRROR_URL; do
1191 echo "${i%/}/" >> $1/mirror
1192 done
1193 fi
1194 newline
1198 # recursive dependencies scan
1200 dep_scan()
1202 for i in $1; do
1203 case " $ALL_DEPS " in
1204 *\ $i\ *) continue;;
1205 esac
1206 ALL_DEPS="$ALL_DEPS $i"
1207 [ -n "$2" ] && echo "$2$i ($(fgrep -A 3 $i $LOCALSTATE/packages.txt | \
1208 tail -1 | sed 's/.*(\([^ ]*\).*/\1/'))"
1209 [ -f $i/receipt ] || continue
1210 DEPENDS=""
1211 . $i/receipt
1212 [ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2 "
1213 done
1217 # recursive reverse dependencies scan
1219 rdep_scan()
1221 SEARCH=$1
1223 for i in * ; do
1224 DEPENDS=""
1225 . $i/receipt
1226 echo "$i $(echo $DEPENDS)"
1227 done | busybox awk -v search=$SEARCH '
1228 function show_deps(deps, all_deps, pkg, space)
1230 if (all_deps[pkg] == 1) return
1231 all_deps[pkg] = 1
1232 if (space != "") printf "%s %s\n",space,pkg
1233 for (i = 1, n = split(deps[pkg], mydeps, " "); i <= n; i++) {
1234 show_deps(deps, all_deps, mydeps[i],"==" space)
1239 all_deps[$1] = 0
1240 for (i = 2; i <= NF; i++)
1241 deps[$i] = deps[$i] " " $1
1244 END {
1245 show_deps(deps, all_deps, search, "")
1247 ' | while read spc pkg; do
1248 echo -n $spc | sed 's/=/ /g'
1249 echo -n $pkg
1250 echo -n ' ('
1251 fgrep -A 3 $pkg $LOCALSTATE/packages.txt | tail -1 | \
1252 sed 's/.*(\([^ ]*\).*/\1)/'
1253 done
1257 update_desktop_database()
1259 if [ -f $1/usr/bin/update-desktop-database ] && [ -n "$updatedesktopdb" ]; then
1260 chroot "$1/" /usr/bin/update-desktop-database /usr/share/applications 2>/dev/null
1261 fi
1265 update_mime_database()
1267 if [ -f $1/usr/bin/update-mime-database ] && [ -n "$updatemimedb" ]; then
1268 chroot "$1/" /usr/bin/update-mime-database /usr/share/mime
1269 fi
1273 update_icon_database()
1275 if [ -f $1/usr/bin/gtk-update-icon-cache ] && [ -n "$updateicondb" ]; then
1276 chroot "$1/" /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor
1277 fi
1281 compile_glib_schemas()
1283 if [ -f $1/usr/bin/glib-compile-schemas ] && [ -n "$compile_schemas" ]; then
1284 chroot "$1/" /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas
1285 fi
1289 update_kernel_modules()
1291 if [ -f $1/sbin/depmod ] && [ -n "$updatedepmod" ]; then
1292 chroot "$1/" /sbin/depmod -a
1293 fi
1300 ###################
1301 # TazPKG commands #
1302 ###################
1304 case "$COMMAND" in
1305 list|-l)
1306 shift
1308 # List all installed packages or a specific category.
1309 if [ "$1" = "blocked" ]; then
1310 title 'Blocked packages'
1311 if [ -s "$BLOCKED" ];then
1312 cat $BLOCKED
1313 else
1314 _ 'No blocked packages found.'
1315 fi
1316 newline; exit 0
1317 fi
1319 # Display the list of categories.
1320 if [ "$1" = "cat" -o "$1" = "categories" ]; then
1321 title 'Packages categories'
1322 num=0
1323 for i in $PKGS_CATEGORIES; do
1324 _ $i
1325 num=$(($num+1))
1326 done
1327 footer "$(eval_ngettext '$num category' '$num categories' $num)"; echo
1328 exit 0
1329 fi
1331 # Check for an asked category.
1332 ASKED_CATEGORY_I18N="$@"
1333 if [ -n "$ASKED_CATEGORY_I18N" ]; then
1334 ASKED_CATEGORY=$(reverse_translate_category "$ASKED_CATEGORY_I18N")
1335 title 'Installed packages of category: $ASKED_CATEGORY_I18N'
1336 for pkg in $INSTALLED/*; do
1337 [ -f $pkg/receipt ] || continue
1338 EXTRAVERSION=""
1339 . $pkg/receipt
1340 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
1341 echo -e "$PACKAGE\033[24G $VERSION$EXTRAVERSION"
1342 packages=$(($packages+1))
1343 fi
1344 done
1345 num="<c 32>$packages</c>"; cat_name="<c 34>$ASKED_CATEGORY_I18N</c>"
1346 footer "$(emsg $(eval_ngettext \
1347 '$num package installed of category $cat_name.' \
1348 '$num packages installed of category $cat_name.' \
1349 $packages))"; echo
1350 else
1352 # By default list all packages and versions.
1353 title 'List of all installed packages'
1354 for pkg in $INSTALLED/*; do
1355 [ -f $pkg/receipt ] || continue
1356 EXTRAVERSION=""
1357 . $pkg/receipt
1358 echo -e "$PACKAGE\033[35G $VERSION$EXTRAVERSION\033[53G $(_ $CATEGORY)"
1359 packages=$(($packages+1))
1360 done
1361 num="<c 32>$packages</c>"
1362 footer "$(emsg $(eval_ngettext \
1363 '$num package installed.' \
1364 '$num packages installed.' $packages))"
1365 fi ;;
1368 list-mirror|-lm)
1369 # List all available packages on the mirror. Option --diff displays
1370 # last mirrored packages diff (see recharge).
1371 check_for_packages_list
1372 case $2 in
1373 --diff)
1374 if [ -f "$LOCALSTATE/packages.diff" ]; then
1375 title 'Mirrored packages diff'
1376 cat $LOCALSTATE/packages.diff
1377 num=$(wc -l < $LOCALSTATE/packages.diff)
1378 footer "$(eval_ngettext \
1379 '$num new package listed on the mirror.' \
1380 '$num new packages listed on the mirror.' $num)"
1381 else
1382 newline
1383 _ 'Unable to list anything, no packages.diff found.'
1384 _ 'Recharge your current list to create a first diff.'
1385 newline
1386 fi; exit 0 ;;
1387 --text|--txt|--raw|*)
1388 title 'List of available packages on the mirror'
1389 cat $LOCALSTATE/packages.txt ;;
1390 esac
1391 pkgs=$(wc -l < $LOCALSTATE/packages.list)
1392 num=$(emsg "<c 32>$pkgs</c>")
1393 footer "$(eval_ngettext \
1394 '$num package in the last recharged list.' \
1395 '$num packages in the last recharged list.' $pkgs)"
1396 ;;
1399 list-files|-lf)
1400 # List files installed with the package.
1401 check_for_package_on_cmdline
1402 check_for_receipt
1403 title 'Installed files by: $PACKAGE'
1404 sort < $INSTALLED/$PACKAGE/files.list
1405 files=$(wc -l < $INSTALLED/$PACKAGE/files.list)
1406 num=$(emsg "<c 32>$files</c>")
1407 footer "$(eval_ngettext \
1408 '$num file installed with $PACKAGE' \
1409 '$num files installed with $PACKAGE' $files)"
1410 ;;
1413 info)
1414 # Information about package.
1415 check_for_package_on_cmdline
1416 check_for_receipt
1417 EXTRAVERSION=""
1418 . $INSTALLED/$PACKAGE/receipt
1419 title 'TazPKG information'
1420 # Display localized short description
1421 if [ -e "$LOCALSTATE/packages-desc.$LANG" ]; then
1422 LOCDESC=$(grep -e "^$PACKAGE " $LOCALSTATE/packages-desc.$LANG | cut -d' ' -f2)
1423 [ "x$LOCDESC" != "x" ] && SHORT_DESC="$LOCDESC"
1424 fi
1425 emsg "\
1426 <b>$(_ 'Package :')</b> $PACKAGE
1427 <b>$(_ 'Version :')</b> $VERSION$EXTRAVERSION
1428 <b>$(_ 'Category :')</b> $(_ $CATEGORY)
1429 <b>$(_ 'Short desc :')</b> $SHORT_DESC
1430 <b>$(_ 'Maintainer :')</b> $MAINTAINER"
1431 [ -n "$LICENSE" ] && emsg "<b>$(_ 'License :')</b> $LICENSE"
1432 [ -n "$DEPENDS" ] && emsg "<b>$(_ 'Depends :')</b> $DEPENDS"
1433 [ -n "$SUGGESTED" ] && emsg "<b>$(_ 'Suggested :')</b> $SUGGESTED"
1434 [ -n "$BUILD_DEPENDS" ] && emsg "<b>$(_ 'Build deps :')</b> $BUILD_DEPENDS"
1435 [ -n "$WANTED" ] && emsg "<b>$(_ 'Wanted src :')</b> $WANTED"
1436 [ -n "$WEB_SITE" ] && emsg "<b>$(_ 'Web site :')</b> $WEB_SITE"
1437 footer ;;
1440 desc)
1441 # Display package description.txt if available.
1442 if [ -f "$INSTALLED/$PACKAGE/description.txt" ]; then
1443 title 'Description of: $PACKAGE'
1444 cat $INSTALLED/$PACKAGE/description.txt
1445 footer
1446 else
1447 newline
1448 _ 'Sorry, no description available for this package.'
1449 newline
1450 fi ;;
1453 activity|log|-a)
1454 # Show activity log
1455 [ "$nb" ] || nb=18
1456 title 'TazPKG Activity'
1457 IFS=" "
1458 tail -n ${nb} ${LOG} | \
1459 while read date hour none action none pkg vers none; do
1460 case $action in
1461 Installed)
1462 action=$(colorize 32 $action) ;;
1463 Removed)
1464 action=$(colorize 31 $action) ;;
1465 *)
1466 action=$(boldify $action) ;;
1467 esac
1468 echo "$date $hour : $action $pkg $vers"
1469 done
1470 unset IFS
1471 footer ;;
1474 search|-s)
1475 # Search for a package by pattern or name.
1476 PATTERN="$2"
1477 if [ -z "$PATTERN" ]; then
1478 newline
1479 _ 'Please specify a pattern or package name to search for.'
1480 echo "$(_ 'Example:') 'tazpkg search paint'"
1481 newline
1482 exit 0
1483 fi
1484 title 'Search result for: $PATTERN'
1485 # Default is to search in installed pkgs and the raw list.
1486 case "$3" in
1487 -i|--installed)
1488 search_in_installed_packages ;;
1489 -l|--list)
1490 search_in_packages_list ;;
1491 -m|--mirror)
1492 search_in_packages_txt ;;
1493 *)
1494 search_in_installed_packages
1495 search_in_packages_list ;;
1496 esac ;;
1499 search-file|-sf)
1500 # Search for a file by pattern or name in all files.list.
1501 if [ -z "$2" ]; then
1502 newline
1503 _ 'Please specify a pattern or file name to search for.'
1504 echo "$(_ 'Example:') 'tazpkg search-file libnss'"
1505 newline
1506 exit 0
1507 fi
1508 s_file="$2"
1509 title 'Search result for file $s_file'
1511 if [ "$3" == "--mirror" ]; then
1513 match=0
1514 for i in $LOCALSTATE/files.list.lzma \
1515 $LOCALSTATE/undigest/*/files.list.lzma; do
1516 [ -f $i ] || continue
1517 unlzma -c $i | grep -- ".*:.*$2" | awk '
1518 BEGIN { last="" }
1520 pkg=substr($0,0,index($0,":")-1);
1521 file=substr($0,index($0,":")+2);
1522 if (last != pkg) {
1523 last = pkg;
1524 printf("\n%c[1mPackage %s:%c[0m\n",27,pkg,27);
1526 printf("%s\n",file);
1527 }'
1528 match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | wc -l`))
1529 done
1531 else
1533 # Check all pkg files.list in search match which specify the package
1534 # name and the full path to the file(s).
1535 for pkg in $INSTALLED/*; do
1536 if grep -qs "$2" $pkg/files.list; then
1537 . $pkg/receipt
1538 newline
1539 boldify "$(_ 'Package $PACKAGE:')"
1540 grep "$2" $pkg/files.list
1541 files=`grep $2 $pkg/files.list | wc -l`
1542 match=$(($match+$files))
1543 fi
1544 done
1546 fi
1547 pkg=$2
1548 if [ "$match" = "" ]; then
1549 # FIXME
1550 _ '0 files found for: $pkg'
1551 else
1552 num=$(emsg "<c 32>$files</c>")
1553 footer "$(eval_ngettext \
1554 '$num file found for: $pkg' \
1555 '$num files found for: $pkg' $match)"
1556 fi
1557 ;;
1560 search-pkgname)
1561 # Search for a package name
1562 if [ -z "$2" ]; then
1563 newline
1564 _ 'Please specify a pattern or file name to search for.'
1565 echo "$(_ 'Example:') 'tazpkg search-pkgname libnss'"
1566 newline
1567 exit 0
1568 fi
1569 s_pkg="$2"
1570 title 'Search result for package $s_pkg'
1572 # Search for a file on mirror and output only the package name
1573 match=0
1574 for i in $LOCALSTATE/files.list.lzma \
1575 $LOCALSTATE/undigest/*/files.list.lzma; do
1576 [ -f $i ] || continue
1577 unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | awk '{ print $1 }'
1578 match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | wc -l`))
1579 done
1580 file=$2
1581 if [ "$match" = "0" ]; then
1582 _ 'No file found for: $file'
1583 newline
1584 else
1585 num=$(emsg "<c 32>$files</c>")
1586 footer "$(eval_ngettext \
1587 '$num package found with file: $file' \
1588 '$num packages found with file: $file' $match)"
1589 fi
1590 ;;
1593 install|-i)
1594 # Install .tazpkg packages.
1595 check_root $@
1596 check_for_package_on_cmdline
1597 check_for_package_file
1599 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
1600 [ "$list" ] && INSTALL_LIST="$list"
1601 if [ "$rootconfig" ]; then
1602 if [ "$root" ]; then
1603 CACHE_DIR=$root/$CACHE_DIR
1604 SAVE_CACHE_DIR=$CACHE_DIR
1605 LOCALSTATE=$root/$LOCALSTATE
1606 else
1607 echo "rootconfig needs --root= option used." >&2
1608 exit 1
1609 fi
1610 fi
1612 # Get repositories priority list.
1613 look_for_priority
1615 # Check if forced install.
1616 if ! [ "$forced" ]; then
1617 check_for_installed_package $ROOT
1618 fi
1619 install_package $ROOT
1620 update_desktop_database $ROOT
1621 update_mime_database $ROOT
1622 update_icon_database $ROOT
1623 compile_glib_schemas $ROOT ;;
1626 install-list|get-install-list)
1627 # Install a set of packages from a list.
1628 check_root $@
1629 if [ -z "$2" ]; then
1630 newline
1631 _ \
1632 "Please change directory (cd) to the packages repository and specify the
1633 list of packages to install. Example: tazpkg install-list packages.list"
1634 exit 0
1635 fi
1636 # Check if the packages list exist.
1637 list_file=$2
1638 if [ ! -f "$list_file" ]; then
1639 _ 'Unable to find: $list_file'
1640 exit 0
1641 else
1642 LIST=$(cat $2)
1643 fi
1645 # Remember processed list
1646 export INSTALL_LIST="$2"
1648 # Set $COMMAND and install all packages.
1649 if [ "$1" = "get-install-list" ]; then
1650 COMMAND=get-install
1651 else
1652 COMMAND=install
1653 fi
1654 touch $2-processed
1656 # Upgrade tazpkg first. It may handle new features/formats...
1657 # then upgrade essential packages early
1658 for pkg in busybox-pam busybox gcc-lib-base glibc-base \
1659 slitaz-base-files tazpkg ; do
1660 pkg=$(egrep $pkg-[0-9] $INSTALL_LIST)
1661 [ -n "$pkg" ] || continue
1662 _ 'Adding implicit depends $pkg...'
1663 LIST="$pkg
1664 $LIST"
1665 done
1667 for pkg in $LIST; do
1668 grep -qs ^$pkg$ $2-processed && continue
1669 [ -d "$root/var/lib/tazpkg/installed" ] && continue
1670 tazpkg $COMMAND $pkg --list="$2" "$3" "$4" "$5"
1671 done
1672 rm -f $2-processed ;;
1675 add-flavor)
1676 # Install a set of packages from a flavor.
1677 install_flavor $2 ;;
1680 install-flavor)
1681 # Install a set of packages from a flavor and purge other ones.
1682 install_flavor $2 --purge ;;
1685 set-release)
1686 # Change current release and upgrade packages.
1687 RELEASE=$2
1688 if [ -z "$RELEASE" ]; then
1689 newline
1690 _ 'Please specify the release you want on the command line.'
1691 echo "$(_ 'Example:') tazpkg set-release cooking"
1692 newline
1693 exit 0
1694 fi
1695 rm $LOCALSTATE/mirror
1696 echo "$RELEASE" > /etc/slitaz-release
1697 tazpkg recharge && tazpkg upgrade
1699 # Install missing depends
1700 cd $INSTALLED
1701 for i in * ; do
1702 DEPENDS=""
1703 . $i/receipt
1704 for j in $DEPENDS ; do
1705 [ -d $j ] || tazpkg get-install $j
1706 done
1707 done ;;
1710 remove|-r)
1711 # Remove packages.
1712 check_root $@
1713 check_for_package_on_cmdline
1715 [ -n "$root" ] && ROOT="$root"
1716 if [ ! -f "$ROOT$INSTALLED/$PACKAGE/receipt" ]; then
1717 newline
1718 _ '$PACKAGE is not installed.'
1719 exit 0
1720 else
1721 ALTERED=""
1722 THE_PACKAGE=$PACKAGE # altered by receipt
1723 for i in $(cd $ROOT$INSTALLED ; ls); do
1724 [ -f $ROOT$INSTALLED/$i/receipt ] || continue
1725 DEPENDS=""
1726 . $ROOT$INSTALLED/$i/receipt
1727 case " $(echo $DEPENDS) " in
1728 *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
1729 esac
1730 done
1731 EXTRAVERSION=""
1732 . $ROOT$INSTALLED/$THE_PACKAGE/receipt
1733 fi
1734 newline
1735 if [ -n "$ALTERED" ]; then
1736 _ 'The following packages depend on $PACKAGE:'
1737 for i in $ALTERED; do
1738 echo " $i"
1739 done
1740 fi
1741 REFRESH=$(cd $ROOT$INSTALLED ; grep -sl ^$PACKAGE$ */modifiers)
1742 if [ -n "$REFRESH" ]; then
1743 _ 'The following packages have been modified by $PACKAGE:'
1744 for i in $REFRESH; do
1745 echo " ${i%/modifiers}"
1746 done
1747 fi
1748 if [ "$auto" ]; then
1749 answer=0
1750 else
1751 confirm "$(_ 'Remove $PACKAGE ($VERSION$EXTRAVERSION)? (y/N)')"
1752 answer=$?
1753 fi
1754 if [ $answer = 0 ]; then
1755 title 'Removing: $PACKAGE'
1756 # Pre remove commands.
1757 if grep -q ^pre_remove $ROOT$INSTALLED/$PACKAGE/receipt; then
1758 pre_remove $ROOT
1759 fi
1760 action "Removing all files installed..."
1761 if [ -f $ROOT$INSTALLED/$PACKAGE/modifiers ]; then
1762 for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do
1763 for mod in $(cat $ROOT$INSTALLED/$PACKAGE/modifiers); do
1764 [ -f $ROOT$INSTALLED/$mod/files.list ] && [ $(grep "^$(echo $file | grepesc)$" $ROOT$INSTALLED/$mod/files.list | wc -l) -gt 1 ] && continue 2
1765 done
1766 remove_with_path $ROOT$file
1767 done
1768 else
1769 for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do
1770 remove_with_path $ROOT$file
1771 done
1772 fi
1773 status
1774 if grep -q ^post_remove $ROOT$INSTALLED/$PACKAGE/receipt; then
1775 post_remove $ROOT
1776 fi
1778 # Remove package receipt.
1779 action "Removing package receipt..."
1780 rm -rf $ROOT$INSTALLED/$PACKAGE
1781 status
1783 sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION$/d" \
1784 $LOCALSTATE/installed.$SUM 2> /dev/null
1786 # Log this activity
1787 log_pkg Removed
1788 if [ "$ALTERED" ]; then
1789 if [ "$auto" ]; then
1790 answer=0
1791 else
1792 confirm "$(_ 'Remove packages depending on $PACKAGE? (y/N)')"
1793 answer=$?
1794 fi
1795 if [ $answer = 0 ]; then
1796 for i in $ALTERED; do
1797 if [ -d "$ROOT$INSTALLED/$i" ]; then
1798 tazpkg remove $i $ROOTOPTS
1799 fi
1800 done
1801 fi
1802 fi
1803 if [ "$REFRESH" ]; then
1804 if [ "$auto" ]; then
1805 answer=0
1806 else
1807 confirm "$(_ 'Reinstall packages modified by $PACKAGE? (y/N)')"
1808 answer=$?
1809 fi
1810 if [ $answer = 0 ]; then
1811 for i in $REFRESH; do
1812 if [ $(wc -l < $ROOT$INSTALLED/$i) -gt 1 ]; then
1813 _ 'Check $INSTALLED/$i for reinstallation'
1814 continue
1815 fi
1816 rm -r $ROOT$INSTALLED/$i
1817 tazpkg get-install ${i%/modifiers} $ROOTOPTS --forced
1818 done
1819 fi
1820 fi
1821 else
1822 newline
1823 _ 'Uninstallation of $PACKAGE cancelled.'
1824 fi
1825 newline ;;
1828 extract|-e)
1829 # Extract .tazpkg cpio archive into a directory.
1830 check_for_package_on_cmdline
1831 check_for_package_file
1832 title 'Extracting: $PACKAGE'
1834 # If no directory destination is found on the cmdline
1835 # we create one in the current dir using the package name.
1836 if [ -n "$TARGET_DIR" ]; then
1837 DESTDIR=$TARGET_DIR/$PACKAGE
1838 else
1839 DESTDIR=$PACKAGE
1840 fi
1841 mkdir -p $DESTDIR
1843 action "Copying original package..."
1844 cp $PACKAGE_FILE $DESTDIR
1845 status
1847 cd $DESTDIR
1848 extract_package
1849 [ -e "receipt" ] && footer "$(_ '$PACKAGE is extracted to: $DESTDIR')"
1850 ;;
1853 recompress)
1854 # Recompress .tazpkg cpio archive with lzma.
1855 check_for_package_on_cmdline
1856 check_for_package_file
1857 title 'Recompressing: $PACKAGE'
1858 mkdir -p $TMP_DIR
1860 action "Copying original package..."
1861 cp $PACKAGE_FILE $TMP_DIR
1862 status
1864 cd $TMP_DIR
1865 extract_package
1867 action "Recompressing the fs..."
1868 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
1869 rm -rf fs
1870 status
1872 action "Creating new package..."
1873 find . -print | cpio -o -H newc --quiet > \
1874 $TOP_DIR/$(basename $PACKAGE_FILE).$$ && mv -f \
1875 $TOP_DIR/$(basename $PACKAGE_FILE).$$ \
1876 $TOP_DIR/$(basename $PACKAGE_FILE)
1877 status
1879 cd $TOP_DIR
1880 rm -rf $TMP_DIR
1881 separator; newline ;;
1884 list-config)
1885 # List configuration files installed.
1886 if [ "$2" = "--box" ]; then
1887 mkdir -p $TMP_DIR && cd $TMP_DIR
1888 FILES="$INSTALLED/*/volatile.cpio.gz"
1889 [ -n "$3" ] && FILES="$INSTALLED/$3/volatile.cpio.gz"
1890 for i in $FILES; do
1891 zcat $i | cpio -idm --quiet > /dev/null
1892 find * -type f 2>/dev/null | while read file; do
1893 if [ ! -e /$file ]; then
1894 echo -n "----------|----|----|$(_n 'File lost')"
1895 else
1896 echo -n "$(stat -c "%A|%U|%G|%s|" /$file)"
1897 cmp $file /$file > /dev/null 2>&1 || \
1898 echo -n "$(stat -c "%.16y" /$file)"
1899 fi
1900 echo "|/$file"
1901 done
1902 rm -rf *
1903 done
1904 cd $TOP_DIR
1905 rm -rf $TMP_DIR
1906 else
1907 title 'Configuration files'
1908 for i in $INSTALLED/*/volatile.cpio.gz; do
1909 [ -n "$2" -a "$i" != "$INSTALLED/$2/volatile.cpio.gz" ] && continue
1910 [ -f "$i" ] || continue
1911 zcat $i | cpio -t --quiet
1912 done | sed 's|^|/|' | sort
1913 separator
1914 newline
1915 fi ;;
1918 repack-config)
1919 # Create SliTaz package archive from configuration files.
1920 mkdir -p $TMP_DIR && cd $TMP_DIR
1921 CONFIG_VERSION=1.0
1922 mkdir config-$CONFIG_VERSION
1923 cd config-$CONFIG_VERSION
1924 for i in $INSTALLED/*/volatile.cpio.gz; do
1925 zcat $i | cpio -t --quiet
1926 done > files.list
1927 mkdir fs
1928 cd fs
1929 ( cd / ; cpio -o -H newc --quiet ) < ../files.list | cpio -idm --quiet > /dev/null
1930 mkdir -p etc/tazlito
1931 for i in $INSTALLED/*/receipt; do
1932 EXTRAVERSION=""
1933 . $i
1934 echo "$PACKAGE-$VERSION$EXTRAVERSION"
1935 done > etc/tazlito/config-packages.list
1936 cd ..
1937 echo "etc/tazlito/config-packages.list" >> files.list
1938 pkg_date=$(date +"%x %X")
1939 cat > receipt <<EOT
1940 # SliTaz package receipt.
1942 PACKAGE="config"
1943 VERSION="$CONFIG_VERSION"
1944 CATEGORY="base-system"
1945 SHORT_DESC="$(_n 'User configuration backup on $pkg_date')"
1946 DEPENDS="$(ls $INSTALLED)"
1947 EOT
1948 cd ..
1949 tazpkg pack config-$CONFIG_VERSION
1950 cp config-$CONFIG_VERSION.tazpkg $TOP_DIR
1951 cd $TOP_DIR
1952 rm -rf $TMP_DIR
1953 ;;
1956 repack)
1957 # Create SliTaz package archive from an installed package.
1958 check_for_package_on_cmdline
1959 check_for_receipt
1960 EXTRAVERSION=""
1961 . $INSTALLED/$PACKAGE/receipt
1962 title 'Repacking: $PACKAGE-$VERSION$EXTRAVERSION.tazpkg'
1963 if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then
1964 _ "Can't repack \$PACKAGE"
1965 exit 1
1966 fi
1967 if [ -s $INSTALLED/$PACKAGE/modifiers ]; then
1968 _ "Can't repack, \$PACKAGE files have been modified by:"
1969 for i in $(cat $INSTALLED/$PACKAGE/modifiers); do
1970 echo " $i"
1971 done
1972 exit 1
1973 fi
1974 MISSING=""
1975 while read i; do
1976 [ -e "$i" ] && continue
1977 [ -L "$i" ] || MISSING="$MISSING\n $i"
1978 done < $INSTALLED/$PACKAGE/files.list
1979 if [ -n "$MISSING" ]; then
1980 _n "Can't repack, the following files are lost:"
1981 echo -e "$MISSING"
1982 exit 1
1983 fi
1984 mkdir -p $TMP_DIR && cd $TMP_DIR
1985 FILES="fs.cpio.lzma\n"
1986 for i in $(ls $INSTALLED/$PACKAGE) ; do
1987 [ "$i" = "volatile.cpio.gz" ] && continue
1988 [ "$i" = "modifiers" ] && continue
1989 cp $INSTALLED/$PACKAGE/$i . && FILES="$FILES$i\n"
1990 done
1991 ln -s / rootfs
1992 mkdir tmp
1993 sed 's/^/rootfs/' < files.list | cpio -o -H newc --quiet |\
1994 { cd tmp ; cpio -idm --quiet >/dev/null; cd ..; }
1995 mv tmp/rootfs fs
1996 if [ -f $INSTALLED/$PACKAGE/volatile.cpio.gz ]; then
1997 zcat $INSTALLED/$PACKAGE/volatile.cpio.gz | \
1998 { cd fs; cpio -idm --quiet; cd ..; }
1999 fi
2000 if fgrep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then
2001 . $INSTALLED/$PACKAGE/receipt
2002 repack_cleanup fs
2003 fi
2004 if [ -f $INSTALLED/$PACKAGE/$CHECKSUM ]; then
2005 sed 's, , fs,' < $INSTALLED/$PACKAGE/$CHECKSUM | \
2006 $CHECKSUM -s -c || {
2007 _ "Can't repack, \$CHECKSUM error."
2008 cd $TOP_DIR
2009 rm -rf $TMP_DIR
2010 exit 1
2012 fi
2013 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
2014 echo -e "$FILES" | cpio -o -H newc --quiet > \
2015 $TOP_DIR/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
2016 cd $TOP_DIR
2017 \rm -R $TMP_DIR
2018 _ 'Package $PACKAGE repacked successfully.'
2019 pkg_size=$(du -sh $PACKAGE-$VERSION$EXTRAVERSION.tazpkg)
2020 _ 'Size: $pkg_size'
2021 newline ;;
2024 pack)
2025 # Create SliTaz package archive using cpio and lzma.
2026 # TODO: Cook also pack packages, we should share code in libpkg.sh
2027 check_for_package_on_cmdline
2028 cd $PACKAGE
2029 if [ ! -f "receipt" ]; then
2030 _ 'Receipt is missing. Please read the documentation.'
2031 exit 0
2032 else
2033 title 'Packing: $PACKAGE'
2034 # Create files.list with redirecting find outpout.
2035 action "Creating the list of files..."
2036 cd fs
2037 find . -type f -print > ../files.list
2038 find . -type l -print >> ../files.list
2039 cd .. && sed -i s/'^.'/''/ files.list
2040 status
2041 action 'Creating $CHECKSUM of files...'
2042 while read file; do
2043 [ -L "fs$file" ] && continue
2044 [ -f "fs$file" ] || continue
2045 case "$file" in
2046 /lib/modules/*/modules.*|*.pyc) continue;;
2047 esac
2048 $CHECKSUM "fs$file" | sed 's/ fs/ /'
2049 done < files.list > $CHECKSUM
2050 status
2051 UNPACKED_SIZE=$(du -chs fs receipt files.list $CHECKSUM \
2052 description.txt 2> /dev/null | awk \
2053 '{ sz=$1 } END { print sz }')
2054 # Build cpio archives.
2055 action "Compressing the fs..."
2056 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
2057 rm -rf fs
2058 status
2059 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
2060 $CHECKSUM description.txt 2> /dev/null | awk \
2061 '{ sz=$1 } END { print sz }')
2062 action "Updating receipt sizes..."
2063 sed -i s/^PACKED_SIZE.*$// receipt
2064 sed -i s/^UNPACKED_SIZE.*$// receipt
2065 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
2066 status
2067 action "Creating full cpio archive..."
2068 find . -print | cpio -o -H newc --quiet > ../$PACKAGE.tazpkg
2069 status
2070 action "Restoring original package tree..."
2071 unlzma -c fs.cpio.lzma | cpio -idm --quiet
2072 status
2073 rm fs.cpio.lzma && cd ..
2074 footer "$(_ 'Package $PACKAGE compressed successfully.')"
2075 pkg_size=$(du -sh $PACKAGE.tazpkg)
2076 _ 'Size: $pkg_size'
2077 newline
2078 fi ;;
2081 recharge)
2082 # Recharge packages.list from a mirror.
2084 # WARNING: The 'mirrors' file has all SliTaz mirrors but 'mirror'
2085 # must have only the chosen main mirror.
2087 check_root $@
2089 ARG=$2
2090 if [ "$root" ]; then
2091 LOCALSTATE=$root$LOCALSTATE
2092 [ "${2#--}" != "$2" ] && ARG=$3
2093 fi
2094 if [ "$ARG" = main ]; then
2095 repository_to_recharge=$LOCALSTATE
2096 elif [ "$ARG" ]; then
2097 if [ -d "$LOCALSTATE/undigest/$ARG" ]; then
2098 repository_to_recharge=$LOCALSTATE/undigest/$ARG
2099 else
2100 repo="$LOCALSTATE/undigest/$ARG"
2101 _ "\$repo doesn't exist." >&2
2102 exit 1
2103 fi
2104 else
2105 repository_to_recharge="$LOCALSTATE $LOCALSTATE/undigest/*"
2106 fi
2107 for path in $repository_to_recharge; do
2108 [ -f $path/mirror ] || continue
2109 cd $path
2111 # Quietly check if recharging is needed.
2112 [ -f ID ] && mv ID ID.bak
2113 download_from "$(cat mirror)" ID >/dev/null 2>/dev/null
2114 if [ -f ID ] && fgrep -q $(cat ID.bak 2>/dev/null || echo "null") ID; then
2115 if [ "$path" = "$LOCALSTATE" ]; then
2116 repository_name=Main
2117 else
2118 base_path="$(basename $path)"
2119 repository_name="$(_n 'Undigest $base_path')"
2120 fi
2121 _ '$repository_name is up to date.'
2122 rm ID.bak
2123 continue
2124 fi
2126 # Don't let ID be a symlink when using local repository.
2127 if [ -f ID ]; then
2128 mv -f ID ID.bak
2129 cat ID.bak > ID
2130 rm ID.bak
2131 fi
2133 newline
2134 if [ "$path" != "$LOCALSTATE" ]; then
2135 base_path="$(basename $path)"
2136 _ 'Recharging undigest $base_path:'
2137 fi
2139 if [ -f "packages.list" ]; then
2140 action "Creating backup of the last packages list..."
2141 for i in packages.desc packages.$SUM packages.txt \
2142 packages.list packages.equiv files.list.lzma \
2143 extra.list mirrors
2144 do
2145 mv -f $i $i.bak 2>/dev/null
2146 done
2147 status
2148 fi
2150 for i in desc md5 txt list equiv; do
2151 download_from "$(cat mirror)" packages.$i
2152 done
2153 download_from "$(cat mirror)" files.list.lzma
2154 download_from "$(cat mirror)" extra.list
2155 download_from "$(sed 's|packages/.*||' < mirror)" mirrors
2157 if [ -f "packages.list.bak" ]; then
2158 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
2159 [ -f "extra.list.bak" ] &&
2160 diff -u extra.list.bak extra.list | grep ^+[a-z] >> packages.diff
2161 sed -i s/+// packages.diff
2162 title 'Mirrored packages diff'
2163 cat packages.diff
2164 new_pkgs=$(wc -l < packages.diff)
2165 if [ "$new_pkgs" != 0 ]; then
2166 num=$(emsg "<c 32>$new_pkgs</c>")
2167 footer "$(eval_ngettext \
2168 '$num new package on the mirror.' \
2169 '$num new packages on the mirror.' $new_pkgs)"
2170 else
2171 _ 'No new packages on the mirror.'
2172 newline
2173 fi
2174 else
2175 footer "$(_ \
2176 'Last packages.list is ready to use. Note that next time you recharge the
2177 list, a list of differences will be displayed to show new and upgradeable
2178 packages.')"
2179 fi
2180 done ;;
2183 help-up)
2184 # Options available for the command: up
2185 newline; usage_up; newline
2186 exit 1 ;;
2189 up|upgrade)
2191 # This is the new way to upgrade packages making 'upgrade' and
2192 # upgradeable out-of-date. This new way is much, much more faster!
2193 # Look into installed packages and get data from receipt, it is fast
2194 # and easy to handle vars after using only md5sum to compare packages
2196 for opt in $@; do
2197 case "$opt" in
2198 --recharge|-r) tazpkg recharge ;;
2199 --install|-i) install="y" ;;
2200 --check|-c) install="n" ;;
2201 esac
2202 done
2203 time=$(date +%s)
2204 installed_sum=$LOCALSTATE/installed.$SUM
2205 look_for_priority
2206 for repo in $priority; do
2207 pkg_list=$repo/packages.list
2208 mtime=$(find $pkg_list -mtime +7)
2209 if [ "$mtime" ]; then
2210 if [ "$repo" = "$LOCALSTATE" ]; then
2211 repo_name=main
2212 else
2213 repo_name="${repo##*/}"
2214 fi
2215 _ '$pkg_list is older than one week... recharging'
2216 tazpkg recharge $repo_name
2217 fi
2218 done
2219 emsg "<n><b>$(_ 'Package')</b><i 28> $(_ 'Version')<i 48> $(_ 'Status')<->"
2220 cd $INSTALLED
2221 newline > $UP_LIST
2222 blocked_count=0
2223 for pkg in *; do
2224 [ ! -d $pkg ] && continue
2225 unset VERSION EXTRAVERSION
2226 . $pkg/receipt
2227 md5=$(fgrep " $PACKAGE-${VERSION}$EXTRAVERSION.tazpkg" \
2228 $installed_sum | awk '{print $1}')
2229 for repo in $priority; do
2230 pkg_desc=$repo/packages.desc
2231 pkg_list=$repo/packages.list
2232 pkg_sum=$repo/packages.$SUM
2234 if ! fgrep -q "$md5 $PACKAGE-" $pkg_sum; then
2235 # Jump to next repository in priority if pkg doesn't exist
2236 # in this one.
2237 grep -q ^$PACKAGE- $pkg_list || continue
2239 emsg -n "$PACKAGE<i 28> $VERSION"
2241 # Skip pkgs listed in $LOCALSTATE/blocked-packages.list
2242 if $(grep -qs "^$PACKAGE" $BLOCKED); then
2243 blocked_count=$(($blocked_count + 1))
2244 emsg "<i 48><c 31> $(_ 'Blocked')</c>"
2245 break
2246 fi
2248 new=$(grep "^$PACKAGE |" $pkg_desc | awk '{print $3}')
2250 if [ "$VERSION" == "$new" ]; then
2251 emsg "<i 48><c 34> $(_ 'New build')</c>"
2252 else
2253 emsg "<i 48><c 32> $(_ 'New version $new')</c>"
2254 fi
2255 echo "$PACKAGE" >> $UP_LIST
2256 break
2257 fi
2258 done
2259 done
2260 sed -i /^$/d $UP_LIST
2261 upnb=$(wc -l < $UP_LIST)
2262 pkgs=$(ls | wc -l)
2263 time=$(($(date +%s) - $time))
2264 if [ "$upnb" = 0 ]; then
2265 install="n"
2266 _ 'System is up-to-date...'
2267 fi
2268 num=$(emsg "<c 32>$pkgs</c>")
2269 footer "$(eval_ngettext \
2270 '$num installed package scanned in ${time}s' \
2271 '$num installed packages scanned in ${time}s' $pkgs)"
2272 if [ "$upnb" != 0 ]; then
2273 if [ "$blocked_count" -gt 0 ]; then
2274 num=$blocked_count
2275 blocked=$(eval_ngettext '$num blocked' '$num blocked' $num)
2276 else
2277 # FIXME
2278 blocked="$(_ '0 blocked')"
2279 fi
2280 num=$upnb
2281 boldify "$(eval_ngettext \
2282 'You have $num available upgrade ($blocked)' \
2283 'You have $num available upgrades ($blocked)' $num)"
2284 newline
2285 fi
2286 # Pkgs to upgrade ? Skip, let install them all or ask user
2287 [ "$install" == "n" ] && exit 0
2288 if [ "$upnb" -gt 0 ]; then
2289 if [ "$install" == "y" ]; then
2290 continue
2291 else
2292 _n 'Do you wish to install them now: y/n ? '
2293 read install
2294 fi
2295 case "$install" in
2296 y|Y|yes|YES|Yes)
2297 for pkg in $(cat $UP_LIST); do
2298 echo 'y' | tazpkg get-install $pkg --forced
2299 done
2300 # List is generated each time and must be cleaned so
2301 # tazpkg-notify doesn't find upgrades anymore.
2302 rm $UP_LIST && touch $UP_LIST ;;
2303 *)
2304 _ 'Leaving without any upgrades installed.'
2305 newline
2306 exit 0 ;;
2307 esac
2308 fi
2309 newline ;;
2312 bugs)
2313 # Show known bugs in package(s)
2314 cd $INSTALLED
2315 shift
2316 LIST=$@
2317 [ -n "$LIST" ] || LIST=$(ls)
2318 MSG=$(_n 'No known bugs.')
2319 for PACKAGE in $LIST; do
2320 BUGS=""
2321 EXTRAVERSION=""
2322 . $PACKAGE/receipt
2323 if [ -n "$BUGS" ]; then
2324 MSG=$(_n 'Bug list completed')
2325 newline
2326 _ 'Bugs in package $PACKAGE version $VERSION$EXTRAVERSION:'
2327 cat <<EOT
2328 $BUGS
2329 EOT
2330 fi
2331 done
2332 echo "$MSG" ;;
2335 check)
2336 # Check installed packages set.
2337 check_root $@
2339 # Get repositories priority list.
2340 look_for_priority
2342 cd $INSTALLED
2343 for PACKAGE in $(ls); do
2344 if [ ! -f $PACKAGE/receipt ]; then
2345 _ 'The package $PACKAGE installation has not completed'
2346 continue
2347 fi
2348 DEPENDS=""
2349 EXTRAVERSION=""
2350 . $PACKAGE/receipt
2351 if [ -s $PACKAGE/modifiers ]; then
2352 _ 'The package $PACKAGE-$VERSION$EXTRAVERSION has been modified by:'
2353 for i in $(cat $PACKAGE/modifiers); do
2354 echo " $i"
2355 done
2356 fi
2357 MSG="$(_n 'Files lost from $PACKAGE-$VERSION$EXTRAVERSION:')\n"
2358 while read file; do
2359 [ -e "$file" ] && continue
2360 if [ -L "$file" ]; then
2361 MSG="$MSG $(_n 'target of symlink')"
2362 fi
2363 echo -e "$MSG $file"
2364 MSG=""
2365 done < $PACKAGE/files.list
2366 MSG="$(_n 'Missing dependencies for $PACKAGE-$VERSION$EXTRAVERSION:')\n"
2367 for i in $DEPENDS; do
2368 [ -d $i ] && continue
2369 [ -d $(equivalent_pkg $i) ] && continue
2370 echo -e "$MSG $i"
2371 MSG=""
2372 done
2373 MSG="$(_n 'Dependencies loop between $PACKAGE and:')\n"
2374 ALL_DEPS=""
2375 check_for_deps_loop $PACKAGE $DEPENDS
2376 done
2378 _ 'Looking for known bugs...'
2379 tazpkg bugs
2381 if [ "$PACKAGE_FILE" = "--full" ]; then
2382 for file in */$CHECKSUM; do
2383 CONFIG_FILES=""
2384 . $(dirname "$file")/receipt
2385 [ -s "$file" ] || continue
2386 while read md5 f; do
2387 [ -f $f ] || continue
2388 for i in $CONFIG_FILES; do
2389 case "$f" in
2390 $i|$i/*) continue 2;;
2391 esac
2392 done
2393 echo "$md5 $f"
2394 done < "$file" | $CHECKSUM -c - 2> /dev/null | \
2395 grep -v OK$ | sed 's/FAILED$/$CHECKSUM MISMATCH/'
2396 done
2397 FILES=" "
2398 for file in $(cat */files.list); do
2399 [ -d "$file" ] && continue
2400 case "$FILES" in *\ $file\ *) continue;; esac
2401 [ $(grep "^$(echo $file | grepesc)$" */files.list 2> /dev/null | \
2402 wc -l) -gt 1 ] || continue
2403 FILES="$FILES$file "
2404 _ 'The following packages provide $file:'
2405 grep -l "^$(echo $file | grepesc)$" */files.list | \
2406 while read f; do
2407 pkg=${f%/files.list}
2408 if [ -f $pkg/modifiers ]; then
2409 pkg_list="$(cat $pkg/modifiers)"
2410 overriders=$(_n '(overridden by $pkg_list)')
2411 else
2412 overriders=''
2413 fi
2414 echo -n " $pkg $overriders"
2415 newline
2416 done
2417 done
2418 MSG="$(_n 'No package has installed the following files:')\n"
2419 find /etc /bin /sbin /lib /usr /var/www -not -type d 2>/dev/null | \
2420 while read file; do
2421 case "$file" in *\[*) continue;; esac
2422 grep -q "^$(echo $file | grepesc)$" */files.list && continue
2423 echo -e "$MSG $file"
2424 MSG=""
2425 done
2426 fi
2427 _ 'Check completed.'; echo ;;
2430 block)
2431 # Add a pkg name to the list of blocked packages.
2432 check_root $@
2433 check_for_package_on_cmdline
2434 newline
2435 if grep -qs "^$PACKAGE" $BLOCKED; then
2436 _ '$PACKAGE is already in the blocked packages list.'
2437 else
2438 action 'Add $PACKAGE to: $BLOCKED...'
2439 echo $PACKAGE >> $BLOCKED
2440 status
2441 # Log this activity
2442 . $INSTALLED/$PACKAGE/receipt
2443 log_pkg Blocked
2444 fi
2445 newline ;;
2448 unblock)
2449 # Remove a pkg name from the list of blocked packages.
2450 check_root $@
2451 check_for_package_on_cmdline
2452 newline
2453 if grep -qs "^$PACKAGE" $BLOCKED; then
2454 action 'Removing $PACKAGE from: $BLOCKED...'
2455 sed -i s/$PACKAGE/''/ $BLOCKED
2456 sed -i '/^$/d' $BLOCKED
2457 status
2458 # Log this activity
2459 . $INSTALLED/$PACKAGE/receipt
2460 log_pkg Unblocked
2461 else
2462 _ '$PACKAGE is not in the blocked packages list.'
2463 fi
2464 newline ;;
2467 get)
2468 # Download a package with wget.
2469 check_root $@
2470 check_for_package_on_cmdline
2471 check_for_packages_list
2473 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
2474 if [ "$rootconfig" ]; then
2475 if [ "$root" ]; then
2476 CACHE_DIR=$root/$CACHE_DIR
2477 SAVE_CACHE_DIR=$CACHE_DIR
2478 LOCALSTATE=$root/$LOCALSTATE
2479 else
2480 _ 'rootconfig needs --root= option used.' >&2
2481 exit 1
2482 fi
2483 fi
2485 # Get repositories priority list.
2486 look_for_priority
2488 CURRENT_DIR=$PWD
2489 check_for_package_in_list
2490 cd $CACHE_DIR
2491 if [ -f "$PACKAGE.tazpkg" ]; then
2492 _ '$PACKAGE already in the cache'
2493 # Check package download was finished
2494 tail -c 2k $PACKAGE.tazpkg | fgrep -q 00000000TRAILER || {
2495 _ 'Continuing $PACKAGE download'
2496 download $PACKAGE.tazpkg
2498 if [ "$($CHECKSUM $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.$SUM)" ]; then
2499 rm -f $PACKAGE.tazpkg
2500 download $PACKAGE.tazpkg
2501 fi
2502 else
2503 download $PACKAGE.tazpkg
2504 fi
2505 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
2506 cp -a $PACKAGE_FILE $CURRENT_DIR ;;
2509 get-install|-gi)
2510 # Download and install a package.
2511 check_root $@
2512 check_for_package_on_cmdline
2513 check_for_packages_list
2515 DO_CHECK=""
2516 [ "$forced" ] && DO_CHECK=no
2517 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
2518 [ "$list" ] && INSTALL_LIST="$list"
2519 if [ "$rootconfig" ]; then
2520 if [ "$root" ]; then
2521 CACHE_DIR=$root/$CACHE_DIR
2522 SAVE_CACHE_DIR=$CACHE_DIR
2523 LOCALSTATE=$root/$LOCALSTATE
2524 else
2525 _ 'rootconfig needs --root= option used.' >&2
2526 exit 1
2527 fi
2528 fi
2530 # Get repositories priority list.
2531 look_for_priority
2533 AUTOEXEC="no"
2534 if ! check_for_package_in_list check; then
2535 CACHE_DIR="${CACHE_DIR%/*}/get"
2536 [ -d "$CACHE_DIR" ] || mkdir -p $CACHE_DIR
2537 if download_get_script $PACKAGE /tmp/$PACKAGE.$$ ; then
2538 install_package_from_get_script /tmp/$PACKAGE.$$ $ROOT
2539 exit 0
2540 else
2541 PACKAGE=get-$PACKAGE
2542 AUTOEXEC=$PACKAGE
2543 check_for_package_in_list
2544 if [ -n "$(get_installed_package_pathname $PACKAGE $ROOT)" ]; then
2545 $AUTOEXEC $ROOT
2546 exit 0
2547 fi
2548 fi
2549 fi
2550 # Check if forced install.
2551 if ! [ "$forced" ]; then
2552 check_for_installed_package $ROOT
2553 fi
2554 cd $CACHE_DIR
2555 if [ -f "$PACKAGE.tazpkg" ]; then
2556 _ '$PACKAGE already in the cache: $CACHE_DIR'
2557 # Check package download was finished
2558 tail -c 2k $PACKAGE.tazpkg | fgrep -q 00000000TRAILER || {
2559 _ 'Continuing $PACKAGE download'
2560 download $PACKAGE.tazpkg
2562 if [ "$($CHECKSUM $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.$SUM)" ]; then
2563 rm -f $PACKAGE.tazpkg
2564 download $PACKAGE.tazpkg
2565 fi
2566 else
2567 newline
2568 download $PACKAGE.tazpkg
2569 fi
2570 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
2571 [ "$rootconfig" ] && LOCALSTATE=${LOCALSTATE#$root}
2572 install_package $ROOT
2573 [ "$AUTOEXEC" != "no" ] && $PACKAGE $ROOT
2574 update_desktop_database $ROOT
2575 update_mime_database $ROOT ;;
2578 clean-cache|-cc)
2579 # Remove all downloaded packages.
2580 check_root $@
2581 files=$(find $CACHE_DIR -name *.tazpkg | wc -l)
2582 title 'Path: $CACHE_DIR'
2583 action "Cleaning cache directory..."
2584 rm -rf $CACHE_DIR/*
2585 status
2586 num=$(colorize 32 "$files")
2588 footer "$(eval_ngettext \
2589 '$num file removed from cache.' \
2590 '$num files removed from cache.' \
2591 $files)"
2592 ;;
2595 list-undigest)
2596 # list undigest URLs.
2597 if [ "$2" = "--box" ]; then
2598 for i in $LOCALSTATE/undigest/*/mirror; do
2599 [ -f $i ] || continue
2600 echo "$(basename $(dirname $i))|$(cat $i)"
2601 done
2602 else
2603 title 'Current undigest(s)'
2604 for i in $LOCALSTATE/undigest/*/mirror; do
2605 if [ ! -f $i ]; then
2606 _ 'No undigest mirror found.'
2607 exit 1
2608 fi
2609 echo "$(basename $(dirname $i)) $(cat $i)"
2610 done
2611 newline
2612 fi ;;
2615 remove-undigest)
2616 # remove undigest URL.
2617 check_root $@
2618 undigest="$2"
2619 if [ -d $LOCALSTATE/undigest/$2 ]; then
2620 confirm "$(_ 'Remove $undigest undigest? (y/N)')"
2621 if [ $? = 0 ]; then
2622 action 'Removing $undigest undigest...'
2623 rm -rf $LOCALSTATE/undigest/$2
2624 status
2625 rmdir $LOCALSTATE/undigest 2> /dev/null
2626 fi
2627 else
2628 _ 'Undigest $undigest not found'
2629 fi ;;
2632 add-undigest|setup-undigest)
2633 # Add undigest URL.
2634 check_root $@
2635 undigest=$2
2636 [ -d $LOCALSTATE/undigest ] || mkdir $LOCALSTATE/undigest
2637 if [ -z "$undigest" ]; then
2638 i=1
2639 while [ -d $LOCALSTATE/undigest/$i ]; do
2640 i=$(($i+1))
2641 done
2642 undigest=$i
2643 fi
2644 if [ ! -d $LOCALSTATE/undigest/$undigest ]; then
2645 _ 'Creating new undigest $undigest.'
2646 mkdir $LOCALSTATE/undigest/$undigest
2647 fi
2648 setup_mirror $LOCALSTATE/undigest/$undigest $3 ;;
2651 setup-mirror|-sm)
2652 # Change mirror URL.
2653 check_root $@
2654 setup_mirror $LOCALSTATE $2 ;;
2657 reconfigure)
2658 # Replay post_install from receipt
2659 check_for_package_on_cmdline
2660 check_root $@
2661 ROOT=""
2662 while [ -n "$3" ]; do
2663 case "$3" in
2664 --root=*)
2665 ROOT="${3#--root=}/" ;;
2666 *)
2667 shift 2
2668 u_opt="$*"
2669 newline >&2
2670 _ 'Unknown option $u_opt.' >&2
2671 exit 1 ;;
2672 esac
2673 shift
2674 done
2675 if [ -d "$ROOT$INSTALLED/$PACKAGE" ]; then
2676 check_for_receipt $ROOT
2677 # Check for post_install
2678 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
2679 . $ROOT$INSTALLED/$PACKAGE/receipt
2680 post_install $ROOT
2681 # Log this activity
2682 [ -n "$ROOT" ] || log_pkg Reconfigured
2683 else
2684 newline
2685 _ 'Nothing to do for $PACKAGE.'
2686 fi
2687 else
2688 newline
2689 _ 'Package $PACKAGE is not installed.'
2690 _ "Install package with 'tazpkg install' or 'tazpkg get-install'"
2691 newline
2692 fi ;;
2695 shell)
2696 # TazPKG SHell
2697 if test $(id -u) = 0 ; then
2698 PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
2699 else
2700 PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
2701 fi
2702 if [ ! "$2" = "--noheader" ]; then
2703 clear
2704 title 'TazPKG SHell.'
2705 _ "Type 'usage' to list all available commands or 'quit' or 'q' to exit."
2706 newline
2707 fi
2708 while true; do
2709 echo -en "$PROMPT"; read cmd
2710 case $cmd in
2711 q|quit)
2712 break ;;
2713 shell)
2714 _ 'You are already running a TazPKG SHell.' ;;
2715 su)
2716 su -c 'exec tazpkg shell --noheader' && break ;;
2717 "")
2718 continue ;;
2719 *)
2720 tazpkg $cmd ;;
2721 esac
2722 done ;;
2725 depends)
2726 # Display dependencies tree
2727 cd $INSTALLED
2728 ALL_DEPS=""
2729 if [ -f $2/receipt ]; then
2730 dep_scan $2 ""
2731 fi ;;
2734 rdepends)
2735 # Display reverse dependencies tree
2736 cd $INSTALLED
2737 ALL_DEPS=""
2738 if [ -f $2/receipt ]; then
2739 rdep_scan $2
2740 fi ;;
2743 convert|-c)
2744 # convert misc package format to .tazpkg
2745 check_for_package_file
2746 tazpkg-convert $@
2747 ;;
2750 link)
2751 # link a package from another slitaz installation
2752 PACKAGE=$2
2753 if [ ! -d "$TARGET_DIR" -o \
2754 ! -d "$TARGET_DIR$INSTALLED/$PACKAGE" ]; then
2755 _n "
2756 usage: tazpkg link package_name slitaz_root
2757 example: 'tazpkg link openoffice /mnt' will use less than 100k in
2758 your running system ram.
2760 exit 1
2761 fi
2762 if [ -e "$INSTALLED/$PACKAGE" ]; then
2763 _ '$PACKAGE is already installed.'
2764 exit 1
2765 fi
2766 ln -s $TARGET_DIR$INSTALLED/$PACKAGE $INSTALLED
2767 DEPENDS="$(. $INSTALLED/$PACKAGE/receipt ; echo $DEPENDS)"
2768 MISSING=""
2769 for i in $DEPENDS; do
2770 [ -e $INSTALLED/$i ] && continue
2771 MISSING="$MISSING$i "
2772 _ 'Missing: $i'
2773 done
2774 if [ -n "$MISSING" ]; then
2775 newline
2776 confirm "$(_ 'Link all missing dependencies? (y/N)')"
2777 answer=$?
2778 newline
2779 if [ $answer = 0 ]; then
2780 for i in $MISSING; do
2781 tazpkg link $i $TARGET_DIR
2782 done
2783 else
2784 newline
2785 _ 'Leaving dependencies unresolved for: $PACKAGE'
2786 _ 'The package is installed but probably will not work.'
2787 newline
2788 fi
2789 fi
2790 . $INSTALLED/$PACKAGE/receipt
2791 if grep -q ^pre_install $INSTALLED/$PACKAGE/receipt; then
2792 pre_install
2793 fi
2794 while read path; do
2795 [ -e $path ] && continue
2796 while true; do
2797 dir=$(dirname $path)
2798 [ -e $dir ] && break
2799 path=$dir
2800 done
2801 ln -s $TARGET_DIR$path $dir
2802 done < $INSTALLED/$PACKAGE/files.list
2803 if grep -q ^post_install $INSTALLED/$PACKAGE/receipt; then
2804 post_install
2805 fi ;;
2808 usage|*)
2809 # Print a short help or give usage for an unknown or empty command.
2810 usage ;;
2811 esac
2813 exit 0