tazpkg view tazpkg @ rev 703

Fix VERSION in Makefile
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Dec 05 09:46:42 2014 +0100 (2014-12-05)
parents 0e50306e492a
children 79096c6ac28e
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.3
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 # Translate category names (must be last in line)
60 translate_category()
61 {
62 sed "s|base-system$|$(_ base-system)|g; s|x-window$|$(_ x-window)|g;
63 s|utilities$|$(_ utilities)|g; s|network$|$(_ network)|g;
64 s|graphics$|$(_ graphics)|g; s|multimedia$|$(_ multimedia)|g;
65 s|office$|$(_ office)|g; s|development$|$(_ development)|g;
66 s|system-tools$|$(_ system-tools)|g; s|security$|$(_ security)|g;
67 s|games$|$(_ games)|g; s|misc$|$(_ misc)|g; s|meta$|$(_ meta)|g;
68 s|non-free$|$(_ non-free)|g"
69 }
72 # If category is not one of those translated in native language, keep it
73 # untranslated. This allows both native and english language support.
74 # This also supports custom categories.
75 # And now we support spaces in translated categories
77 reverse_translate_category()
78 {
79 echo "$cat_i18n" | awk "BEGIN{FS=\" \"}{if (/^$@ /) a=\$2}END{if (a==\"\") a=\"$@\"; print a}"
80 }
84 #
85 # TazPKG output functions
86 #
89 # Print localized title
91 title() { newline; boldify "$(_ "$@")"; separator; }
94 # Print footer
96 footer() { separator; echo "$1"; [ -n "$1" ] && newline; }
99 # Print current action in brown color (separate from any other msgs)
101 action() {
102 case $output in
103 raw|gtk|html) _ "$@" ;;
104 *) echo -ne "\033[0;33m"$(_ "$@")"\033[0m" ;;
105 esac
106 }
109 # Initialize some variables to use words rather than numbers for functions
110 # and actions.
111 COMMAND=$1
112 PACKAGE=${2%/}
113 PACKAGE_DIR="$(cd $(dirname $PACKAGE 2>/dev/null) 2>/dev/null; pwd)"
114 [ -n "$PACKAGE" ] && PACKAGE_FILE="$PACKAGE_DIR/${PACKAGE##*/}"
115 if [ -f "$PACKAGE" ]; then
116 # Set pkg basename for install, extract
117 PACKAGE=$(basename $PACKAGE .tazpkg 2>/dev/null)
118 else
119 # Pkg name for remove, search and all other cmds
120 PACKAGE=${PACKAGE%.tazpkg}
121 fi
122 TARGET_DIR=$3
123 TOP_DIR=$(pwd)
124 TMP_DIR=/tmp/$RANDOM
125 INSTALL_LIST=""
126 SAVE_CACHE_DIR="$CACHE_DIR"
128 # Path to tazpkg used dir and configuration files
129 MIRROR=$PKGS_DB/mirror
130 BLOCKED=$PKGS_DB/blocked-packages.list
131 UP_LIST=$PKGS_DB/packages.up
132 DEFAULT_MIRROR="$ONLINE_PKGS"
137 ####################
138 # Script functions #
139 ####################
142 # Print the usage.
144 usage () {
145 cat << EOT
147 $(_ 'SliTaz package manager - Version: %s' $(colorize 34 $VERSION))
149 $(boldify "$(_ 'Usage:')")
150 $(_ 'tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]')
152 $(boldify "$(_ 'SHell:')") tazpkg shell
154 $(boldify "$(_ 'Commands:')")
155 usage $(_ 'Print this short usage')
156 bugs $(_ 'Show known bugs in packages')
157 activity|-a $(_ 'Show TazPKG activity log')
158 list|-l $(_ 'List installed packages on the system by category or all')
159 list-mirror|-lm $(_ 'List all available packages on the mirror (--diff for new)')
160 info $(_ 'Print information about a package')
161 desc $(_ 'Print description of a package (if it exists)')
162 list-files|-lf $(_ 'List the files installed with a package')
163 list-config $(_ 'List the configuration files')
164 search|-s $(_ 'Search for a package by pattern or name (options: -i|-l|-m)')
165 search-pkgname $(_ 'Search on mirror for package having a particular file')
166 search-file|-sf $(_ 'Search for file(s) in all installed packages files')
167 install|-i $(_ 'Install a local (*.tazpkg) package (--forced to force)')
168 install-list $(_ 'Install all packages from a list of packages.')
169 remove|-r $(_ 'Remove the specified package and all installed files')
170 extract|-e $(_ 'Extract a (*.tazpkg) package into a directory')
171 pack $(_ 'Pack an unpacked or prepared package tree')
172 recharge $(_ 'Recharge your packages.list from the mirror')
173 up|help-up $(_ 'Check packages %s to list and install latest upgrades' $CHECKSUM)
174 repack $(_ 'Create a package archive from an installed package')
175 repack-config $(_ 'Create a package archive with configuration files')
176 recompress $(_ 'Rebuild a package with a better compression ratio')
177 block|unblock $(_ 'Block an installed package version or unblock it for upgrade')
178 get $(_ 'Download a package into the current directory')
179 get-install|-gi $(_ 'Download and install a package from the mirror')
180 get-install-list $(_ 'Download and install a list of packages from the mirror')
181 check $(_ 'Verify consistency of installed packages')
182 add-flavor $(_ 'Install the flavor list of packages')
183 install-flavor $(_ 'Install the flavor list of packages and remove other ones')
184 set-release $(_ 'Change release and update packages')
185 clean-cache|-cc $(_ 'Clean all packages downloaded in cache directory')
186 depends $(_ 'Display dependencies tree')
187 rdepends $(_ 'Display reverse dependencies tree')
188 convert $(_ 'Convert alien package to tazpkg')
189 link $(_ 'Link a package from another slitaz installation')
190 setup-mirror|-sm $(_ 'Change the mirror url configuration')
191 list-undigest $(_ 'List undigest mirrors')
192 remove-undigest $(_ 'Remove an undigest mirror')
193 add-undigest $(_ 'Add an undigest mirror')
194 setup-undigest $(_ 'Update an undigest mirror')
195 reconfigure $(_ 'Replay post install script from package')
197 EOT
198 }
201 usage_up() {
202 cat << EOT
203 $(emsg "<b>$(_ 'Usage for command up:')</b>") tazpkg up [$(_ 'option')]
205 * $(_ 'Without options run in interactive mode and ask before install')
207 $(boldify "$(_ 'Where options are:')")
208 --check |-c $(_ 'Check only for available upgrades')
209 --recharge |-r $(_ 'Force recharge of packages list and check')
210 --install |-i $(_ 'Check for upgrades and install them all')
212 $(boldify "$(_ 'Example:')")
213 tazpkg up --recharge --install
214 tazpkg up -c -r
215 EOT
216 }
219 # Check if dir exists
221 check_dir()
222 {
223 if ! [ -d "$1" ]; then
224 FOLDER=$1
225 action 'Creating folder "%s"...' $FOLDER
226 mkdir -p "$FOLDER"
227 status
228 return 1
229 fi
230 }
233 # Check if the directories and files used by TazPKG
234 # exist. If not and user is root we create them.
236 check_base_dir()
237 {
238 if [ "$(id -u)" = "0" ]; then
239 check_dir $1$CACHE_DIR
240 check_dir $1$INSTALLED
241 check_dir $1$SLITAZ_LOGS
242 if [ ! -f "$1$PKGS_DB/mirror" ]; then
243 echo "${DEFAULT_MIRROR%/}/" > $1$PKGS_DB/mirror
244 [ -n "$1" ] && cp $PKGS_DB/packages.* $1$PKGS_DB/
245 fi
246 fi
247 }
248 check_base_dir
251 # Check for a package name on cmdline.
253 check_for_package_on_cmdline()
254 {
255 if [ -z "$PACKAGE" ]; then
256 newline
257 _ 'Please specify a package name on the command line.'
258 newline
259 exit 0
260 fi
261 }
264 # Check if the package (*.tazpkg) exists before installing or extracting.
266 check_for_package_file()
267 {
268 if [ ! -f "$PACKAGE_FILE" ]; then
269 newline
270 _ 'Unable to find file "%s"' $PACKAGE_FILE
271 newline
272 exit 0
273 fi
274 }
277 # Check for the receipt of an installed package.
279 check_for_receipt()
280 {
281 receipt_path="$1$INSTALLED/$PACKAGE/receipt"
282 if [ ! -f $receipt_path ]; then
283 newline
284 _ 'Unable to find the receipt "%s"' $receipt_path
285 newline
286 exit 0
287 fi
288 }
291 # Get repositories priority using $PKGS_DB/priority.
292 # In this files, undigest are called by their name and main mirror
293 # by main. Sort order: priority
295 look_for_priority()
296 {
297 [ -s $PKGS_DB/priority ] && priority=$(cat $PKGS_DB/priority)
298 for rep in main $(ls $PKGS_DB/undigest 2>/dev/null); do
299 if [ ! -s $PKGS_DB/priority ] || \
300 ! grep -q ^$rep$ $PKGS_DB/priority; then
301 priority=$(echo -e "$priority\n$rep")
302 fi
303 done
304 priority=$(echo "$priority" | sed '/^$/d' | \
305 while read line; do
306 if [ "$line" = main ]; then
307 echo $PKGS_DB
308 else
309 echo $PKGS_DB/undigest/$line
310 fi
311 done)
312 }
315 # Get package name in a directory
317 package_fullname_in_dir()
318 {
319 [ -f $1/receipt ] || return
320 EXTRAVERSION=""
321 . $1/receipt
322 echo $PACKAGE-$VERSION$EXTRAVERSION
323 }
326 # Get package name that is already installed.
328 get_installed_package_pathname()
329 {
330 for i in $2$INSTALLED/${1%%-*}*; do
331 [ -d $i ] || continue
332 if [ "$1" = "$(package_fullname_in_dir $i)" ]; then
333 echo $i
334 return
335 fi
336 done
337 }
340 # Check if a package is already installed.
342 check_for_installed_package()
343 {
344 if [ -n "$(get_installed_package_pathname $PACKAGE $1)" ]; then
345 newline
346 _ '"%s" package is already installed.' $(colorize 34 $PACKAGE)
347 _ 'You can use the --forced option to force installation.'
348 newline
349 exit 0
350 fi
351 }
354 # Check for packages.list to download and install packages.
356 check_for_packages_list()
357 {
358 list_path="$PKGS_DB/packages.list"
359 if [ ! -f "$list_path" ]; then
360 if test $(id -u) = 0 ; then
361 tazpkg recharge
362 else
363 newline
364 _ 'Unable to find the list "%s"' $list_path
365 _ \
366 "You must probably run 'tazpkg recharge' as root to get the latest list of
367 packages available on the mirror."
368 newline
369 exit 0
370 fi
371 fi
372 }
375 # Check for installed.info - local file with format of packages.info
376 # It absent on not clean installs; check it and re-generate if needed.
378 check_for_installed_info()
379 {
380 info_path="$PKGS_DB/installed.info"
381 if [ ! -f "$info_path" ]; then
382 if [ "$(id -u)" == "0" ]; then
383 _ 'File "%s" generated. Please wait...' installed.info
384 for pkg in $PKGS_DB/installed/*/receipt; do
385 unset_receipt
386 . $pkg
387 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
388 DEPENDS=$(echo $DEPENDS) # remove newlines from some receipts
389 cat >> $info_path << EOT
390 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS
391 EOT
392 done
393 else
394 _ 'Unable to find file "%s"' installed.info
395 _ 'Please run tazpkg as root.'
396 exit 1
397 fi
398 fi
399 }
402 get_cache_dir()
403 {
404 echo $rep > $tmp/rep
405 if [ "$rep" = "$PKGS_DB" ]; then
406 CACHE_DIR="$SAVE_CACHE_DIR/$SLITAZ_RELEASE/packages"
407 elif [ "${rep%-incoming}" = "$rep" ]; then
408 CACHE_DIR="$SAVE_CACHE_DIR/${rep##*/}/packages"
409 else
410 rep="${rep%-incoming}"
411 CACHE_DIR="$SAVE_CACHE_DIR/${rep##*/}/packages-incoming"
412 fi
413 [ -d "$CACHE_DIR" ] || mkdir -p $CACHE_DIR
414 echo $CACHE_DIR > $tmp/cachedir
415 }
418 # get an already installed package from packages.equiv
420 equivalent_pkg()
421 {
422 for i in $(grep -hs "^$1=" $PKGS_DB/packages.equiv \
423 $PKGS_DB/undigest/*/packages.equiv | sed "s/^$1=//"); do
424 if echo $i | fgrep -q : ; then
425 # format 'alternative:newname'
426 # if alternative is installed then substitute newname
427 if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
428 # substitute package dependency
429 echo ${i#*:}
430 return
431 fi
432 else
433 # if alternative is installed then nothing to install
434 if [ -f $2$INSTALLED/$i/receipt ]; then
435 # substitute installed package
436 echo $i
437 return
438 fi
439 fi
440 done
441 # if not found in packages.equiv then no substitution
442 echo $1
443 }
446 # get a virtual package from packages.equiv
448 virtual_pkg()
449 {
450 for i in $(for rep in $priority; do
451 grep -hs "^$1=" $rep/packages.equiv
452 done | sed "s/^$1=//"); do
453 if echo $i | fgrep -q : ; then
454 # format 'alternative:newname'
455 # if alternative is installed then substitute newname
456 if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
457 # substitute package dependency
458 echo ${i#*:}
459 return
460 fi
461 else
462 # unconditional substitution
463 echo $i
464 return
465 fi
466 done
467 }
470 # Get package filename available on the mirror
472 get_package_filename()
473 {
474 local pkg
475 for rep in $priority; do
476 pkg=$(grep -A 1 -sh "^$1$" $rep/packages.txt | tail -1 | sed 's/^ *//')
477 [ "$pkg" ] && pkg=$(grep -sh "^$1-$pkg" $rep/packages.list | head -1)
479 # Allow user to call a package with his version number.
480 [ "$pkg" ] || pkg=$(grep -sh "^$1$" $rep/packages.list | head -1)
482 [ "$pkg" ] || pkg=$(grep -sh "^$1-[0-9]" $rep/packages.list | head -1)
483 [ "$pkg" ] || pkg=$(grep -sh "^$1-.[\.0-9]" $rep/packages.list | head -1)
484 [ "$pkg" ] && get_cache_dir && break
485 done
486 if [ -z "$pkg" ]; then
487 # Check for virtual package
488 local equiv
489 equiv=$(virtual_pkg $1)
490 if [ "$equiv" != "$1" ]; then
491 PACKAGE=$equiv
492 get_package_filename $PACKAGE
493 return
494 fi
495 fi
496 echo $pkg
497 }
500 # Check for a package in packages.list. Used by get and get-install to grep
501 # package basename.
503 check_for_package_in_list()
504 {
505 local filename
506 local check_only
507 check_only="$1"
508 filename=$(get_package_filename $PACKAGE)
509 if [ "$filename" ]; then
510 PACKAGE=$filename
511 CACHE_DIR=$(cat $tmp/cachedir)
512 rep=$(cat $tmp/rep)
513 rm -f $tmp/rep $tmp/cachedir
514 else
515 newline
516 _ 'Unable to find package "%s" in the mirrored packages list.' $PACKAGE
517 newline
518 [ -n "$check_only" ] && return 1
519 exit 0
520 fi
521 }
524 # Log this activity
525 # (there log_pkg because we have log() in libtaz.sh)
527 log_pkg()
528 {
529 local extra
531 [ "$1" = "Installed" ] && \
532 extra=" - $(fgrep $PACKAGE-$VERSION $PKGS_DB/installed.$SUM | awk '{ print $1 }')"
534 [ -e $LOG ] || touch $LOG
536 [ -w $LOG ] &&
537 echo "$(date +'%F %T') - $1 - $PACKAGE ($VERSION$EXTRAVERSION)$extra" >> $LOG
538 }
541 # Download a get-package script from this mirror
543 download_get_script()
544 {
545 local p
546 for p in $priority ; do
547 local i
548 for i in $(cat $p/mirror) ; do
549 case "$i" in
550 http://*|ftp://*)
551 wget -O $2 ${i%packages/*}packages/get/$1 && return 0 ;;
552 esac
553 done
554 done
555 return 1
556 }
559 # Download a file from this mirror
561 download_from()
562 {
563 local i
564 local mirrors
565 mirrors="$1"
566 shift
567 for i in $mirrors; do
568 case "$i" in
569 # Mirror URL can have a trailing slash or not.
570 http://*|ftp://*)
571 busybox wget -c ${i%/}/$@ && break ;;
572 https://*)
573 echo 'Sorry, https not supported' ;;
574 *)
575 ln -sf $i/$1 . && break ;;
576 esac
577 done
578 }
581 # Download a file trying all mirrors
583 download()
584 {
585 local i
586 case "$1" in
587 *.tazpkg)
588 for i in $priority ; do
589 grep -q "^${1%.tazpkg}$" $i/packages.list 2>/dev/null || continue
590 download_from "$(cat $i/mirror)" "$@" && return
591 done
592 esac
593 for i in $(cat $(for rep in $priority; do echo $rep/mirror; done) 2>/dev/null); do
594 download_from "$i" "$@" && break
595 done
596 }
599 # Extract a package with cpio and gzip/lzma.
601 extract_package()
602 {
603 action 'Extracting package...'
604 cpio -idm --quiet < ${PACKAGE_FILE##*/} && rm -f ${PACKAGE_FILE##*/}
605 status
606 if [ -f fs.cpio.lzma ]; then
607 unlzma -c fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
608 elif [ -f fs.cpio.gz ]; then
609 zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz
610 fi
611 }
614 remove_with_path()
615 {
616 # Avoid dirname errors by checking for argument.
617 [ "$1" ] || return
619 local dir
620 rm -f $1 2>/dev/null
621 dir="$1"
622 while [ "$dir" != "/" ]; do
623 dir="$(dirname $dir)"
624 rmdir $dir 2> /dev/null || break
625 done
626 }
629 grepesc()
630 {
631 sed 's/\[/\\[/g'
632 }
635 # This function installs a package in the rootfs.
637 install_package()
638 {
639 ROOT=$1
640 if [ -n "$ROOT" ]; then
641 # Get absolute path
642 ROOT=$(realpath $ROOT)
643 fi
644 {
645 # Create package path early to avoid dependencies loop
646 mkdir -p $TMP_DIR
647 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $PACKAGE_FILE
648 . $TMP_DIR/receipt
649 # FIXME: legacy?
650 if grep -q ^pre_depends $TMP_DIR/receipt; then
651 pre_depends $ROOT
652 fi
654 # Keep modifiers and file list on upgrade
655 cp $ROOT$INSTALLED/$PACKAGE/modifiers \
656 $ROOT$INSTALLED/$PACKAGE/files.list $TMP_DIR 2> /dev/null
657 rm -rf $ROOT$INSTALLED/$PACKAGE 2> /dev/null
659 # Make the installed package data dir to store
660 # the receipt and the files list.
661 mkdir -p $ROOT$INSTALLED/$PACKAGE
662 cp $TMP_DIR/modifiers $ROOT$INSTALLED/$PACKAGE 2> /dev/null
663 cp $TMP_DIR/files.list $ROOT$INSTALLED/$PACKAGE 2> /dev/null
664 rm -rf $TMP_DIR 2> /dev/null
665 sed -i "/ $(basename $PACKAGE_FILE)$/d" \
666 $ROOT$PKGS_DB/installed.$SUM 2> /dev/null
667 cd $(dirname $PACKAGE_FILE)
668 $CHECKSUM $(basename $PACKAGE_FILE) >> $ROOT$PKGS_DB/installed.$SUM
669 }
671 # Resolve package deps.
672 check_for_deps $ROOT
673 if [ -n "$MISSING_PACKAGE" ]; then
674 install_deps $ROOT
675 fi
676 mkdir -p $TMP_DIR
677 [ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> $ROOT$PKGS_DB/$INSTALL_LIST-processed
679 title 'Installation of package "%s"' $PACKAGE
681 action 'Copying package...'
682 cp $PACKAGE_FILE $TMP_DIR
683 status
685 cd $TMP_DIR
686 extract_package
687 SELF_INSTALL=0
688 EXTRAVERSION=""
689 CONFIG_FILES=""
691 # Include temporary receipt to get the right variables.
692 . $PWD/receipt
693 cd $ROOT$INSTALLED
695 # FIXME: legacy?
696 if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then
697 action "Checking post install dependencies..."
698 [ -f $INSTALLED/$PACKAGE/receipt ]
699 if ! status; then
700 _ 'Please run "%s" in / and retry.' "tazpkg install $PACKAGE_FILE"
701 rm -rf $TMP_DIR
702 exit 1
703 fi
704 fi
706 # Get files to remove if upgrading
707 if [ -f $PACKAGE/files.list ]; then
708 while read file; do
709 grep -q "^$(echo $file | grepesc)$" $TMP_DIR/files.list && continue
710 for i in $(cat $PACKAGE/modifiers 2> /dev/null ;
711 fgrep -sl $PACKAGE */modifiers | cut -d/ -f1 ); do
712 grep -qs "^$(echo $file | grepesc)$" $i/files.list && continue 2
713 done
714 echo $file
715 done < $PACKAGE/files.list > $TMP_DIR/files2remove.list
716 fi
718 # Remember modified packages
719 {
720 check=false
721 for i in $(fgrep -v [ $TMP_DIR/files.list); do
722 [ -e "$ROOT$i" ] || continue
723 [ -d "$ROOT$i" ] && continue
724 echo "- $i"
725 check=true
726 done ;
727 $check && \
728 for i in *; do
729 [ "$i" == "$PACKAGE" ] && continue
730 [ -s $i/files.list ] || continue
731 awk "{ printf \"$i %s\\n\",\$1 }" < $i/files.list
732 done;
733 } | awk '
734 {
735 if ($1 == "-" || file[$2] != "") {
736 file[$2] = file[$2] " " $1
737 if ($1 != "-") {
738 if (pkg[$1] == "") all = all " " $1
739 pkg[$1] = pkg[$1] " " $2
740 }
741 }
742 }
743 END {
744 for (i = split(all, p, " "); i > 0; i--)
745 for (j = split(pkg[p[i]], f, " "); j > 0; j--)
746 printf "%s %s\n",p[i],f[j];
747 }
748 ' | while read dir file; do
749 if grep -qs ^$dir$ $PACKAGE/modifiers; then
750 # Do not overload an overloaded file !
751 rm $TMP_DIR$file 2> /dev/null
752 continue
753 fi
754 grep -qs ^$PACKAGE$ $dir/modifiers && continue
755 if [ -s "$dir/volatile.cpio.gz" ]; then
756 # We can modify backed up files without notice
757 zcat $dir/volatile.cpio.gz | cpio -t --quiet | \
758 grep -q "^${file#/}$" && continue
759 fi
760 echo "$PACKAGE" >> $dir/modifiers
761 done
763 cd $TMP_DIR
764 cp receipt files.list $ROOT$INSTALLED/$PACKAGE
766 # Copy the description if found.
767 if [ -f "description.txt" ]; then
768 cp description.txt $ROOT$INSTALLED/$PACKAGE
769 fi
771 # Copy the md5sum if found.
772 if [ -f "$CHECKSUM" ]; then
773 cp $CHECKSUM $ROOT$INSTALLED/$PACKAGE
774 fi
776 # Pre install commands.
777 if grep -q ^pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then
778 pre_install $ROOT
779 fi
780 if [ -n "$CONFIG_FILES" ]; then
781 # save 'official' configuration files
782 action 'Saving configuration files...'
783 for i in $CONFIG_FILES; do
784 { cd fs ; find ${i#/} -type f 2> /dev/null; cd ..; }
785 done | { cd fs ; cpio -o -H newc --quiet | gzip -9; cd ..; } > \
786 $ROOT$INSTALLED/$PACKAGE/volatile.cpio.gz
788 # keep user configuration files
789 for i in $CONFIG_FILES; do
790 { cd fs ; find ${i#/} -type f 2> /dev/null; cd ..; }
791 done | while read i; do
792 [ -e $ROOT/$i ] || continue
793 cp -a $ROOT/$i fs/$i
794 done
795 status
796 fi
798 action 'Installing package...'
799 [ "$(busybox ls fs/* 2> /dev/null)" ] && cp -a fs/* $ROOT/
800 status
802 if [ -s files2remove.list ]; then
803 action 'Removing old package...'
804 while read file; do
805 remove_with_path $ROOT$file
806 done < files2remove.list
807 true
808 status
809 fi
811 # Remove the temporary random directory.
812 action "Removing all tmp files..."
813 cd ..; rm -rf $TMP_DIR
814 status
816 # Post install commands.
817 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
818 post_install $ROOT
819 fi
821 # Update-desktop-database if needed.
822 if [ "$(fgrep .desktop $ROOT$INSTALLED/$PACKAGE/files.list | fgrep /usr/share/applications/)" ]; then
823 updatedesktopdb=yes
824 fi
826 # Update-mime-database if needed.
827 if [ "$(fgrep /usr/share/mime $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
828 updatemimedb=yes
829 fi
831 # Update-icon-database
832 if [ "$(fgrep /usr/share/icon/hicolor $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
833 updateicondb=yes
834 fi
836 # Compile glib schemas if needed.
837 if [ "$(fgrep /usr/share/glib-2.0/schemas $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
838 compile_schemas=yes
839 fi
841 # Update depmod list
842 if [ "$(fgrep /lib/modules $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
843 updatedepmod=yes
844 fi
846 # Update installed.info
847 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
848 DEPENDS=$(echo $DEPENDS) # remove newlines from some receipts
849 cat >> $PKGS_DB/installed.info << EOT
850 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS
851 EOT
853 cd $TOP_DIR
854 footer "$(_ 'Package "%s" (%s) is installed.' $PACKAGE $VERSION$EXTRAVERSION)"
856 # Log this activity
857 [ -n "$ROOT" ] || log_pkg Installed
858 }
861 # This function may be called by a get script.
863 abort_package()
864 {
865 cd $CUR_DIR
866 rm -rf $TMP_DIR
867 echo "${1:-Abort $PACKAGE.}"
868 exit 1
869 }
872 # This function installs a package from a get script in the rootfs.
874 install_package_from_get_script()
875 {
876 SCRIPT="$1"
877 ROOT="$2"
878 [ -d $ROOT$INSTALLED/$PACKAGE ] && exit 1
880 grep -q no-check-certificate $SCRIPT &&
881 [ ! -d $INSTALLED/wget ] && tazpkg get-install wget
883 mkdir -p $TMP_DIR && cd $TMP_DIR
884 saved=$PACKAGE
885 unset_receipt
886 PACKAGE=$saved
888 set -e
889 . $SCRIPT
890 set +e
891 cd $TMP_DIR
892 [ -d $PACKAGE-$VERSION ] || abort_package \
893 "$(_ 'Could not download "%s" from "%s". Exiting.' ${TARBALL:-$PACKAGE} ${WGET_URL:-$WEB_SITE})"
895 if [ ! -s $PACKAGE-$VERSION/receipt ]; then
896 cat > $PACKAGE-$VERSION/receipt <<EOT
897 # SliTaz package receipt.
899 PACKAGE="$PACKAGE"
900 VERSION="${VERSION:-unknown}"
901 CATEGORY="${CATEGORY:-non-free}"
902 WEB_SITE="$WEB_SITE"
903 SHORT_DESC="${SHORT_DESC:-$PACKAGE}"
904 MAINTAINER="${MAINTAINER:-nobody@slitaz.org}"
905 EOT
906 for i in LICENSE TARBALL WGET_URL CONFIG_FILES SUGGESTED \
907 PROVIDE DEPENDS HOST_ARCH TAGS EXTRA_SOURCE_FILES ; do
908 eval "[ -n \"\$$i\" ] && echo \"$i=\\\"\$$i\\\"\""
909 done >> $PACKAGE-$VERSION/receipt
910 fi
912 DEPENDS="$(unset DEPENDS; . $PACKAGE-$VERSION/receipt ; echo $DEPENDS)"
913 for i in $(find_depends $PACKAGE-$VERSION/fs); do
914 case " $DEPENDS " in
915 *\ $i\ *) continue;;
916 esac
917 grep -q '^DEPENDS="' $PACKAGE-$VERSION/receipt ||
918 echo 'DEPENDS=""' >> $PACKAGE-$VERSION/receipt
919 sed -i "s/^DEPENDS=\"/&$i /" $PACKAGE-$VERSION/receipt
920 done
922 tazpkg pack $PACKAGE-$VERSION
924 # Clean to save RAM memory before installation
925 rm -rf $PACKAGE-$VERSION
927 # Install pseudo package
928 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
929 mv $PACKAGE-$VERSION.tazpkg $CACHE_DIR
931 # Clean
932 cd $TOP_DIR
933 rm -rf $TMP_DIR
934 }
937 # Check for loop in deps tree.
939 check_for_deps_loop()
940 {
941 local list
942 local pkg
943 local deps
944 pkg=$1
945 shift
946 [ -n "$1" ] || return
947 list=""
949 # Filter out already processed deps
950 for i in $@; do
951 case " $ALL_DEPS" in
952 *\ $i\ *) ;;
953 *) list="$list $i";;
954 esac
955 done
956 ALL_DEPS="$ALL_DEPS$list "
957 for i in $list; do
958 [ -f $i/receipt ] || continue
959 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
960 case " $deps " in
961 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
962 *) check_for_deps_loop $pkg $deps;;
963 esac
964 done
965 }
968 # Check for missing deps listed in a receipt packages.
970 check_for_deps()
971 {
972 local saved;
973 saved=$PACKAGE
974 mkdir -p $TMP_DIR
975 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $PACKAGE_FILE
976 . $TMP_DIR/receipt
977 PACKAGE=$saved
978 rm -rf $TMP_DIR
980 num=0
981 for pkgorg in $DEPENDS; do
982 i=$(equivalent_pkg $pkgorg $1)
983 if [ ! -d "$1$INSTALLED/$i" ]; then
984 MISSING_PACKAGE=$i
985 num=$(($num+1))
986 elif [ ! -f "$1$INSTALLED/$i/receipt" ]; then
987 _ 'WARNING! Dependency loop between "%s" and "%s".' $PACKAGE $i
988 fi
989 done
991 if [ ! "$MISSING_PACKAGE" = "" ]; then
992 title "$(_ 'Tracking dependencies for package "%s"' $PACKAGE)"
993 for pkgorg in $DEPENDS; do
994 i=$(equivalent_pkg $pkgorg $1)
995 if [ ! -d "$1$INSTALLED/$i" ]; then
996 MISSING_PACKAGE=$i
997 _ 'Missing package "%s"' $MISSING_PACKAGE
998 fi
999 done
1000 footer "$(eval_ngettext \
1001 '$num missing package to install.' \
1002 '$num missing packages to install.' $num)"
1003 fi
1007 # Install all missing deps. Auto install or ask user then install all missing
1008 # deps from local dir, cdrom, media or from the mirror. In case we want to
1009 # install packages from local, we need a packages.list to find the version.
1011 install_deps()
1013 local root
1014 root=""
1015 [ -n "$1" ] && root="--root=$1"
1016 if [ "$AUTO_INSTALL_DEPS" == "yes" ]; then
1017 answer=0
1018 else
1019 newline
1020 confirm "$(_ 'Install all missing dependencies? (y/N)')"
1021 answer=$?
1022 newline
1023 fi
1024 if [ $answer = 0 ]; then
1025 for pkgorg in $DEPENDS; do
1026 pkg=$(equivalent_pkg $pkgorg $1)
1027 if [ ! -d "$1$INSTALLED/$pkg" ]; then
1028 local list
1029 list="$INSTALL_LIST"
1030 [ -n "$list" ] || list="$TOP_DIR/packages.list"
1031 # We can install packages from a local dir by greping
1032 # the TAZPKG_BASENAME in the local packages.list.
1033 found=0
1034 if [ -f "$list" ]; then
1035 _ 'Checking if package "%s" exists in local list...' $pkg
1036 mkdir $TMP_DIR
1037 for i in $pkg-*.tazpkg; do
1038 [ -f $i ] || continue
1039 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $i
1040 [ "$(. $TMP_DIR/receipt; echo $PACKAGE)" = "$pkg" ] || continue
1041 if grep -q ^$(package_fullname_in_dir $TMP_DIR).tazpkg$ $list
1042 then
1043 found=1
1044 tazpkg install $i $root --list=$list
1045 break
1046 fi
1047 done
1048 rm -rf $TMP_DIR
1049 fi
1050 # Install deps from the mirror.
1051 if [ $found -eq 0 ]; then
1052 if [ ! -f "$PKGS_DB/packages.list" ]; then
1053 tazpkg recharge
1054 fi
1055 tazpkg get-install $pkg $root
1056 fi
1057 fi
1058 done
1059 else
1060 newline
1061 _ 'Leaving dependencies for package "%s" unresolved.' $PACKAGE
1062 _ 'The package is installed but will probably not work.'
1063 newline
1064 fi
1068 # Search pattern in installed packages.
1070 search_in_installed_packages()
1072 _ 'Installed packages'
1073 separator
1074 num=0
1075 for pkg in $(ls -1 $INSTALLED | grep -i "$PATTERN"); do
1076 EXTRAVERSION=""
1077 [ -f $INSTALLED/$pkg/receipt ] || continue
1078 . $INSTALLED/$pkg/receipt
1079 emsg "$PACKAGE<i 24> $VERSION$EXTRAVERSION<i 42> $(_n $CATEGORY)"
1080 num=$(($num+1))
1081 done
1083 footer "$(eval_ngettext \
1084 '$num installed package found for: $PATTERN' \
1085 '$num installed packages found for: $PATTERN' $num)"
1089 # Search in packages.list for available pkgs.
1091 search_in_packages_list()
1093 _ 'Available packages name-version'
1094 separator
1095 num=0
1096 BPATTERN="$(emsg "<b>$PATTERN</b>")"
1097 for i in $PKGS_DB/packages.list $PKGS_DB/undigest/*/packages.list; do
1098 grep -is "$PATTERN" $i | sed "s|$PATTERN|$BPATTERN|"
1099 num=$(($num + `grep -is "$PATTERN" $i | wc -l`))
1100 done
1101 if [ ! -f "$PKGS_DB/packages.list" ]; then
1102 newline
1103 _ \
1104 "No 'packages.list' found to check for mirrored packages. For more results,
1105 please run 'tazpkg recharge' once as root before searching."
1106 newline
1107 fi
1108 footer "$(eval_ngettext \
1109 '$num available package found for: $PATTERN' \
1110 '$num available packages found for: $PATTERN' $packages)"
1114 # search --mirror: Search in packages.txt for available pkgs and give more
1115 # info than --list or default.
1117 search_in_packages_txt()
1119 _ 'Matching packages name with version and desc'
1120 separator
1121 num=0
1122 for i in $PKGS_DB/packages.txt $PKGS_DB/undigest/*/packages.txt; do
1123 grep -is -A 2 "^$PATTERN" $i
1124 num=$(($num + `grep -is "^$PATTERN" $i | wc -l`))
1125 done
1126 if [ ! -f "$PKGS_DB/packages.txt" ]; then
1127 newline
1128 _ \
1129 "No 'packages.txt' found to check for mirrored packages. For more results,
1130 please run 'tazpkg recharge' once as root before searching."
1131 newline
1132 fi
1133 footer "$(eval_ngettext \
1134 '$num available package found for: $PATTERN' \
1135 '$num available packages found for: $PATTERN' $packages)"
1139 # Install package-list from a flavor
1141 install_flavor()
1143 check_root $@
1145 # Get repositories priority list.
1146 look_for_priority
1148 FLAVOR=$1
1149 ARG=$2
1150 mkdir -p $TMP_DIR
1151 [ -f $FLAVOR.flavor ] && cp $FLAVOR.flavor $TMP_DIR
1152 cd $TMP_DIR
1153 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
1154 zcat < $FLAVOR.flavor | cpio --quiet -i >/dev/null
1156 while read file; do
1157 for pkg in $(ls -d $INSTALLED/${file%%-*}*); do
1158 [ -f $pkg/receipt ] || continue
1159 EXTRAVERSION=""
1160 . $pkg/receipt
1161 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && break
1162 done
1163 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && continue
1164 cd $CACHE_DIR
1165 download $file.tazpkg
1166 cd $TMP_DIR
1167 tazpkg install $CACHE_DIR/$file.tazpkg --forced
1168 done < $FLAVOR.pkglist
1170 [ -f $FLAVOR.nonfree ] && while read pkg; do
1171 [ -d $INSTALLED/$pkg ] || continue
1172 [ -d $INSTALLED/get-$pkg ] && tazpkg get-install get-$pkg
1173 get-$pkg
1174 done < $FLAVOR.nonfree
1176 [ "$ARG" == "--purge" ] && for pkg in $(ls $INSTALLED); do
1177 [ -f $INSTALLED/$pkg/receipt ] || continue
1178 EXTRAVERSION=""
1179 . $INSTALLED/$pkg/receipt
1180 grep -q ^$PACKAGE-$VERSION$EXTRAVERSION$ $FLAVOR.pkglist && continue
1181 grep -qs ^$PACKAGE$ $FLAVOR.nonfree && continue
1182 tazpkg remove $PACKAGE
1183 done
1184 else
1185 _ "Can't find flavor \"%s\". Abort." $FLAVOR
1186 fi
1187 cd $TOP_DIR
1188 rm -rf $TMP_DIR
1192 # Update mirror urls
1194 setup_mirror()
1196 # Backup old list.
1197 if [ -f "$1/mirror" ]; then
1198 cp -f $1/mirror $1/mirror.bak
1199 fi
1200 title 'Current mirror(s)'
1201 echo " `cat $1/mirror 2> /dev/null`"
1202 _ \
1203 "Please enter URL of the new mirror (http, ftp or local path). You must specify
1204 the complete address to the directory of the packages and packages.list file."
1205 newline
1206 _n 'New mirror(s) URL: '
1207 NEW_MIRROR_URL=$2
1208 if [ -n "$NEW_MIRROR_URL" ]; then
1209 echo $NEW_MIRROR_URL
1210 else
1211 read NEW_MIRROR_URL
1212 fi
1213 if [ "$NEW_MIRROR_URL" = "" ]; then
1214 _ 'Nothing has been changed.'
1215 else
1216 _ 'Setting mirror(s) to: "%s"' $NEW_MIRROR_URL
1217 rm -f $1/mirror
1218 for i in $NEW_MIRROR_URL; do
1219 echo "${i%/}/" >> $1/mirror
1220 done
1221 fi
1222 newline
1226 # recursive dependencies scan
1228 dep_scan()
1230 for i in $1; do
1231 case " $ALL_DEPS " in
1232 *\ $i\ *) continue;;
1233 esac
1234 ALL_DEPS="$ALL_DEPS $i"
1235 [ -n "$2" ] && echo "$2$i ($(fgrep -A 3 $i $PKGS_DB/packages.txt | \
1236 tail -1 | sed 's/.*(\([^ ]*\).*/\1/'))"
1237 [ -f $i/receipt ] || continue
1238 DEPENDS=""
1239 . $i/receipt
1240 [ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2 "
1241 done
1245 # recursive reverse dependencies scan
1247 rdep_scan()
1249 SEARCH=$1
1251 for i in * ; do
1252 DEPENDS=""
1253 . $i/receipt
1254 echo "$i $(echo $DEPENDS)"
1255 done | busybox awk -v search=$SEARCH '
1256 function show_deps(deps, all_deps, pkg, space)
1258 if (all_deps[pkg] == 1) return
1259 all_deps[pkg] = 1
1260 if (space != "") printf "%s %s\n",space,pkg
1261 for (i = 1, n = split(deps[pkg], mydeps, " "); i <= n; i++) {
1262 show_deps(deps, all_deps, mydeps[i],"==" space)
1267 all_deps[$1] = 0
1268 for (i = 2; i <= NF; i++)
1269 deps[$i] = deps[$i] " " $1
1272 END {
1273 show_deps(deps, all_deps, search, "")
1275 ' | while read spc pkg; do
1276 echo -n $spc | sed 's/=/ /g'
1277 echo -n $pkg
1278 echo -n ' ('
1279 fgrep -A 3 $pkg $PKGS_DB/packages.txt | tail -1 | \
1280 sed 's/.*(\([^ ]*\).*/\1)/'
1281 done
1285 update_desktop_database()
1287 if [ -f $1/usr/bin/update-desktop-database ] && [ -n "$updatedesktopdb" ]; then
1288 chroot "$1/" /usr/bin/update-desktop-database /usr/share/applications 2>/dev/null
1289 fi
1293 update_mime_database()
1295 if [ -f $1/usr/bin/update-mime-database ] && [ -n "$updatemimedb" ]; then
1296 chroot "$1/" /usr/bin/update-mime-database /usr/share/mime
1297 fi
1301 update_icon_database()
1303 if [ -f $1/usr/bin/gtk-update-icon-cache ] && [ -n "$updateicondb" ]; then
1304 chroot "$1/" /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor
1305 fi
1309 compile_glib_schemas()
1311 if [ -f $1/usr/bin/glib-compile-schemas ] && [ -n "$compile_schemas" ]; then
1312 chroot "$1/" /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas
1313 fi
1317 update_kernel_modules()
1319 if [ -f $1/sbin/depmod ] && [ -n "$updatedepmod" ]; then
1320 chroot "$1/" /sbin/depmod -a
1321 fi
1328 ###################
1329 # TazPKG commands #
1330 ###################
1332 case "$COMMAND" in
1333 list|-l)
1334 # List all installed packages or a specific category.
1335 shift
1336 check_for_installed_info
1338 case $1 in
1339 b|blocked)
1340 # Display the list of blocked packages.
1341 title 'Blocked packages'
1342 if [ -s "$BLOCKED" ];then
1343 cat $BLOCKED
1344 else
1345 _ 'No blocked packages found.'
1346 fi
1347 newline; exit 0
1348 ;;
1349 c|cat|categories)
1350 # Display the list of categories.
1351 title 'Packages categories'
1352 echo "$PKGS_CATEGORIES" | sed 's|[^a-z-]|\n|g; /^$/d' | \
1353 sed 's|\(.*\)|\1'$'\033''[15G \1|' | translate_category
1354 num=$(echo -n "$PKGS_CATEGORIES" | wc -l)
1355 footer "$(eval_ngettext '$num category' '$num categories' $num)"; echo
1356 exit 0
1357 ;;
1358 '')
1359 # By default list all packages and versions.
1360 title 'List of all installed packages'
1361 TMPLIST=$(mktemp)
1362 awk -F$'\t' '{print $1"\033[35G "$2"\033[53G "$3}' \
1363 $PKGS_DB/installed.info | tee $TMPLIST | translate_category
1365 packages=$(wc -l $TMPLIST | awk '{print $1}'); rm $TMPLIST
1366 num="<c 32>$packages</c>"
1367 footer "$(emsg $(eval_ngettext \
1368 '$num package installed.' \
1369 '$num packages installed.' $packages))"
1370 ;;
1371 *)
1372 # Check for an asked category.
1373 ASKED_CATEGORY_I18N="$@"
1374 ASKED_CATEGORY=$(reverse_translate_category "$ASKED_CATEGORY_I18N")
1375 title 'Installed packages of category "%s"' $ASKED_CATEGORY_I18N
1376 TMPLIST=$(mktemp)
1377 awk -F$'\t' '
1379 if ($3 == "'$ASKED_CATEGORY'")
1380 print $1"\033[35G "$2
1381 }' \
1382 $PKGS_DB/installed.info | tee $TMPLIST | translate_category
1384 packages=$(wc -l $TMPLIST | awk '{print $1}'); rm $TMPLIST
1385 num="<c 32>$packages</c>"
1386 cat_name="<c 34>$ASKED_CATEGORY_I18N</c>"
1387 footer "$(emsg $(eval_ngettext \
1388 '$num package installed of category $cat_name.' \
1389 '$num packages installed of category $cat_name.' \
1390 $packages))"; echo
1391 ;;
1392 esac ;;
1394 list-mirror|-lm)
1395 # List all available packages on the mirror. Option --diff displays
1396 # last mirrored packages diff (see recharge).
1397 check_for_packages_list
1398 case $2 in
1399 --diff)
1400 if [ -f "$PKGS_DB/packages.diff" ]; then
1401 title 'Mirrored packages diff'
1402 cat $PKGS_DB/packages.diff
1403 num=$(wc -l < $PKGS_DB/packages.diff)
1404 footer "$(eval_ngettext \
1405 '$num new package listed on the mirror.' \
1406 '$num new packages listed on the mirror.' $num)"
1407 else
1408 newline
1409 _ 'Unable to list anything, no packages.diff found.'
1410 _ 'Recharge your current list to create a first diff.'
1411 newline
1412 fi; exit 0 ;;
1413 --text|--txt|--raw|*)
1414 title 'List of available packages on the mirror'
1415 cat $PKGS_DB/packages.txt ;;
1416 esac
1417 pkgs=$(wc -l < $PKGS_DB/packages.list)
1418 num=$(emsg "<c 32>$pkgs</c>")
1419 footer "$(eval_ngettext \
1420 '$num package in the last recharged list.' \
1421 '$num packages in the last recharged list.' $pkgs)"
1422 ;;
1425 list-files|-lf)
1426 # List files installed with the package.
1427 check_for_package_on_cmdline
1428 check_for_receipt
1429 title 'Installed files by "%s"' $PACKAGE
1430 sort < $INSTALLED/$PACKAGE/files.list
1431 files=$(wc -l < $INSTALLED/$PACKAGE/files.list)
1432 num=$(emsg "<c 32>$files</c>")
1433 footer "$(eval_ngettext \
1434 '$num file installed with $PACKAGE' \
1435 '$num files installed with $PACKAGE' $files)"
1436 ;;
1439 info)
1440 # Information about package.
1441 check_for_package_on_cmdline
1442 check_for_receipt
1443 EXTRAVERSION=""
1444 . $INSTALLED/$PACKAGE/receipt
1445 title 'TazPKG information'
1446 # Display localized short description
1447 for LC in $LANG ${LANG%_*}; do
1448 if [ -e "$PKGS_DB/packages-desc.$LC" ]; then
1449 LOCDESC=$(grep -e "^$PACKAGE " $PKGS_DB/packages-desc.$LC | cut -d' ' -f2)
1450 [ -n "$LOCDESC" ] && SHORT_DESC="$LOCDESC"
1451 fi
1452 done
1453 emsg "$(
1455 _ 'Package : %s' "$PACKAGE"
1456 _ 'Version : %s' "$VERSION$EXTRAVERSION"
1457 _ 'Category : %s' "$(_ $CATEGORY)"
1458 _ 'Short desc : %s' "$SHORT_DESC"
1459 _ 'Maintainer : %s' "$MAINTAINER"
1460 _ 'License : %s' "$LICENSE"
1461 _ 'Depends : %s' "$DEPENDS"
1462 _ 'Suggested : %s' "$SUGGESTED"
1463 _ 'Build deps : %s' "$BUILD_DEPENDS"
1464 _ 'Wanted src : %s' "$WANTED"
1465 _ 'Web site : %s' "$WEB_SITE"
1466 _ 'Tags : %s' "$TAGS"
1467 } | sed '/: $/d; s|^\([^:]*\):|<b>\1:</b>|')"
1468 footer ;;
1471 desc)
1472 # Display package description.txt if available.
1473 if [ -f "$INSTALLED/$PACKAGE/description.txt" ]; then
1474 title 'Description of package "%s"' $PACKAGE
1475 cat $INSTALLED/$PACKAGE/description.txt
1476 footer
1477 else
1478 newline
1479 _ 'Sorry, no description available for this package.'
1480 newline
1481 fi ;;
1484 activity|log|-a)
1485 # Show activity log
1486 [ "$nb" ] || nb=18
1487 title 'TazPKG Activity'
1488 IFS=" "
1489 tail -n ${nb} ${LOG} | \
1490 while read date hour none action none pkg vers none; do
1491 case $action in
1492 Installed)
1493 action=$(colorize 32 $action) ;;
1494 Removed)
1495 action=$(colorize 31 $action) ;;
1496 *)
1497 action=$(boldify $action) ;;
1498 esac
1499 echo "$date $hour : $action $pkg $vers"
1500 done
1501 unset IFS
1502 footer ;;
1505 search|-s)
1506 # Search for a package by pattern or name.
1507 PATTERN="$2"
1508 if [ -z "$PATTERN" ]; then
1509 newline
1510 _ 'Please specify a pattern or package name to search for.'
1511 echo "$(_ 'Example:') 'tazpkg search paint'"
1512 newline
1513 exit 0
1514 fi
1515 title 'Search result for "%s"' $PATTERN
1516 # Default is to search in installed pkgs and the raw list.
1517 case "$3" in
1518 -i|--installed)
1519 search_in_installed_packages ;;
1520 -l|--list)
1521 search_in_packages_list ;;
1522 -m|--mirror)
1523 search_in_packages_txt ;;
1524 *)
1525 search_in_installed_packages
1526 search_in_packages_list ;;
1527 esac ;;
1530 search-file|-sf)
1531 # Search for a file by pattern or name in all files.list.
1532 if [ -z "$2" ]; then
1533 newline
1534 _ 'Please specify a pattern or file name to search for.'
1535 echo "$(_ 'Example:') 'tazpkg search-file libnss'"
1536 newline
1537 exit 0
1538 fi
1539 title 'Search result for file "%s"' $2
1541 TMPLIST=$(mktemp)
1542 if [ "$3" == "--mirror" ]; then
1544 for i in $PKGS_DB/files.list.lzma $PKGS_DB/undigest/*/files.list.lzma; do
1545 [ -f $i ] || continue
1546 lzcat $i | awk -F: -vP="$(gettext 'Package %s:')" '
1547 BEGIN { last="" }
1548 $2 ~ /'$2'/ {
1549 if (last != $1) {
1550 last = $1;
1551 PP = P;
1552 sub(/%s/, $1, PP);
1553 printf("\n\e[1;33m%s\e[0;39m\n", PP);
1555 gsub(/'$2'/, "\e[0;32m'$2'\e[0;39m", $2);
1556 print $2
1557 }' | tee -a $TMPLIST
1558 done
1560 else
1562 # Check all pkg files.list in search match which specify the package
1563 # name and the full path to the file(s).
1564 for pkg in $INSTALLED/*; do
1565 if grep -qs "$2" $pkg/files.list; then
1566 . $pkg/receipt
1567 newline
1568 emsg "<c 33>$(_ 'Package %s:' $PACKAGE)</c>"
1569 awk '
1570 /'$2'/ {
1571 gsub(/'$2'/, "\e[0;32m'$2'\e[0;39m", $0);
1572 print " "$0
1574 ' $pkg/files.list | tee -a $TMPLIST
1575 fi
1576 done
1578 fi
1580 match=$(sed '/^ /!d' $TMPLIST | wc -l)
1581 rm $TMPLIST
1583 pkg=$2
1584 num=$(emsg "<c 32>$match</c>")
1585 footer "$(eval_ngettext \
1586 '$num file found for: $pkg' \
1587 '$num files found for: $pkg' $match)"
1588 ;;
1591 search-pkgname)
1592 # Search for a package name
1593 if [ -z "$2" ]; then
1594 newline
1595 _ 'Please specify a pattern or file name to search for.'
1596 echo "$(_ 'Example:') 'tazpkg search-pkgname libnss'"
1597 newline
1598 exit 0
1599 fi
1600 title 'Search result for package "%s"' $2
1602 # Search for a file on mirror and output only the package name
1603 match=0
1604 for i in $PKGS_DB/files.list.lzma \
1605 $PKGS_DB/undigest/*/files.list.lzma; do
1606 [ -f $i ] || continue
1607 unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | awk '{ print $1 }'
1608 match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | wc -l`))
1609 done
1610 file=$2
1611 if [ "$match" = "0" ]; then
1612 _ 'No file found for: $file'
1613 newline
1614 else
1615 num=$(emsg "<c 32>$files</c>")
1616 footer "$(eval_ngettext \
1617 '$num package found with file: $file' \
1618 '$num packages found with file: $file' $match)"
1619 fi
1620 ;;
1623 install|-i)
1624 # Install .tazpkg packages.
1625 check_root $@
1626 check_for_package_on_cmdline
1627 check_for_package_file
1628 check_for_installed_info
1630 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
1631 [ "$list" ] && INSTALL_LIST="$list"
1632 if [ "$rootconfig" ]; then
1633 if [ "$root" ]; then
1634 CACHE_DIR=$root/$CACHE_DIR
1635 SAVE_CACHE_DIR=$CACHE_DIR
1636 PKGS_DB=$root/$PKGS_DB
1637 else
1638 echo "rootconfig needs --root= option used." >&2
1639 exit 1
1640 fi
1641 fi
1643 # Get repositories priority list.
1644 look_for_priority
1646 # Check if forced install.
1647 if ! [ "$forced" ]; then
1648 check_for_installed_package $ROOT
1649 fi
1650 install_package $ROOT
1651 update_desktop_database $ROOT
1652 update_mime_database $ROOT
1653 update_icon_database $ROOT
1654 compile_glib_schemas $ROOT ;;
1657 install-list|get-install-list)
1658 # Install a set of packages from a list.
1659 check_root $@
1660 if [ -z "$2" ]; then
1661 newline
1662 _ \
1663 "Please change directory (cd) to the packages repository and specify the
1664 list of packages to install. Example: tazpkg install-list packages.list"
1665 exit 0
1666 fi
1667 # Check if the packages list exist.
1668 list_file=$2
1669 if [ ! -f "$list_file" ]; then
1670 _ 'Unable to find: $list_file'
1671 exit 0
1672 else
1673 LIST=$(cat $2)
1674 fi
1676 # Remember processed list
1677 export INSTALL_LIST="$2"
1679 # Set $COMMAND and install all packages.
1680 if [ "$1" = "get-install-list" ]; then
1681 COMMAND=get-install
1682 else
1683 COMMAND=install
1684 fi
1685 touch $2-processed
1687 # Upgrade tazpkg first. It may handle new features/formats...
1688 # then upgrade essential packages early
1689 for pkg in busybox-pam busybox gcc-lib-base glibc-base \
1690 slitaz-base-files tazpkg ; do
1691 pkg=$(egrep $pkg-[0-9] $INSTALL_LIST)
1692 [ -n "$pkg" ] || continue
1693 _ 'Adding implicit depends $pkg...'
1694 LIST="$pkg
1695 $LIST"
1696 done
1698 for pkg in $LIST; do
1699 grep -qs ^$pkg$ $2-processed && continue
1700 [ -d "$root/var/lib/tazpkg/installed" ] && continue
1701 tazpkg $COMMAND $pkg --list="$2" "$3" "$4" "$5"
1702 done
1703 rm -f $2-processed ;;
1706 add-flavor)
1707 # Install a set of packages from a flavor.
1708 install_flavor $2 ;;
1711 install-flavor)
1712 # Install a set of packages from a flavor and purge other ones.
1713 install_flavor $2 --purge ;;
1716 set-release)
1717 # Change current release and upgrade packages.
1718 RELEASE=$2
1719 if [ -z "$RELEASE" ]; then
1720 newline
1721 _ 'Please specify the release you want on the command line.'
1722 echo "$(_ 'Example:') tazpkg set-release cooking"
1723 newline
1724 exit 0
1725 fi
1726 rm $PKGS_DB/mirror
1727 echo "$RELEASE" > /etc/slitaz-release
1728 tazpkg recharge && tazpkg upgrade
1730 # Install missing depends
1731 cd $INSTALLED
1732 for i in * ; do
1733 DEPENDS=""
1734 . $i/receipt
1735 for j in $DEPENDS ; do
1736 [ -d $j ] || tazpkg get-install $j
1737 done
1738 done ;;
1741 remove|-r)
1742 # Remove packages.
1743 check_root $@
1744 check_for_package_on_cmdline
1745 check_for_installed_info
1747 [ -n "$root" ] && ROOT="$root"
1748 if [ ! -f "$ROOT$INSTALLED/$PACKAGE/receipt" ]; then
1749 newline
1750 _ '$PACKAGE is not installed.'
1751 exit 0
1752 else
1753 ALTERED=""
1754 THE_PACKAGE=$PACKAGE # altered by receipt
1755 for i in $(cd $ROOT$INSTALLED ; ls); do
1756 [ -f $ROOT$INSTALLED/$i/receipt ] || continue
1757 DEPENDS=""
1758 . $ROOT$INSTALLED/$i/receipt
1759 case " $(echo $DEPENDS) " in
1760 *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
1761 esac
1762 done
1763 EXTRAVERSION=""
1764 . $ROOT$INSTALLED/$THE_PACKAGE/receipt
1765 fi
1766 newline
1767 if [ -n "$ALTERED" ]; then
1768 _ 'The following packages depend on $PACKAGE:'
1769 for i in $ALTERED; do
1770 echo " $i"
1771 done
1772 fi
1773 REFRESH=$(cd $ROOT$INSTALLED ; grep -sl ^$PACKAGE$ */modifiers)
1774 if [ -n "$REFRESH" ]; then
1775 _ 'The following packages have been modified by $PACKAGE:'
1776 for i in $REFRESH; do
1777 echo " ${i%/modifiers}"
1778 done
1779 fi
1780 if [ "$auto" ]; then
1781 answer=0
1782 else
1783 confirm "$(_ 'Remove $PACKAGE ($VERSION$EXTRAVERSION)? (y/N)')"
1784 answer=$?
1785 fi
1786 if [ $answer = 0 ]; then
1787 title 'Removing: $PACKAGE'
1788 # Pre remove commands.
1789 if grep -q ^pre_remove $ROOT$INSTALLED/$PACKAGE/receipt; then
1790 pre_remove $ROOT
1791 fi
1792 action "Removing all files installed..."
1793 if [ -f $ROOT$INSTALLED/$PACKAGE/modifiers ]; then
1794 for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do
1795 for mod in $(cat $ROOT$INSTALLED/$PACKAGE/modifiers); do
1796 [ -f $ROOT$INSTALLED/$mod/files.list ] && [ $(grep "^$(echo $file | grepesc)$" $ROOT$INSTALLED/$mod/files.list | wc -l) -gt 1 ] && continue 2
1797 done
1798 remove_with_path $ROOT$file
1799 done
1800 else
1801 for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do
1802 remove_with_path $ROOT$file
1803 done
1804 fi
1805 status
1806 if grep -q ^post_remove $ROOT$INSTALLED/$PACKAGE/receipt; then
1807 post_remove $ROOT
1808 fi
1810 # Remove package receipt.
1811 action "Removing package receipt..."
1812 rm -rf $ROOT$INSTALLED/$PACKAGE
1813 status
1815 sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION$/d" \
1816 $PKGS_DB/installed.$SUM 2> /dev/null
1818 # Update installed.info
1819 sed -i "/^$PACKAGE /d" $PKGS_DB/installed.info
1821 # Log this activity
1822 log_pkg Removed
1824 if [ "$ALTERED" ]; then
1825 if [ "$auto" ]; then
1826 answer=0
1827 else
1828 confirm "$(_ 'Remove packages depending on $PACKAGE? (y/N)')"
1829 answer=$?
1830 fi
1831 if [ $answer = 0 ]; then
1832 for i in $ALTERED; do
1833 if [ -d "$ROOT$INSTALLED/$i" ]; then
1834 tazpkg remove $i $ROOTOPTS
1835 fi
1836 done
1837 fi
1838 fi
1839 if [ "$REFRESH" ]; then
1840 if [ "$auto" ]; then
1841 answer=0
1842 else
1843 confirm "$(_ 'Reinstall packages modified by $PACKAGE? (y/N)')"
1844 answer=$?
1845 fi
1846 if [ $answer = 0 ]; then
1847 for i in $REFRESH; do
1848 if [ $(wc -l < $ROOT$INSTALLED/$i) -gt 1 ]; then
1849 _ 'Check $INSTALLED/$i for reinstallation'
1850 continue
1851 fi
1852 rm -r $ROOT$INSTALLED/$i
1853 tazpkg get-install ${i%/modifiers} $ROOTOPTS --forced
1854 done
1855 fi
1856 fi
1857 else
1858 newline
1859 _ 'Uninstallation of $PACKAGE cancelled.'
1860 fi
1861 newline ;;
1864 extract|-e)
1865 # Extract .tazpkg cpio archive into a directory.
1866 check_for_package_on_cmdline
1867 check_for_package_file
1868 title 'Extracting: $PACKAGE'
1870 # If no directory destination is found on the cmdline
1871 # we create one in the current dir using the package name.
1872 if [ -n "$TARGET_DIR" ]; then
1873 DESTDIR=$TARGET_DIR/$PACKAGE
1874 else
1875 DESTDIR=$PACKAGE
1876 fi
1877 mkdir -p $DESTDIR
1879 action "Copying original package..."
1880 cp $PACKAGE_FILE $DESTDIR
1881 status
1883 cd $DESTDIR
1884 extract_package
1885 [ -e "receipt" ] && footer "$(_ '$PACKAGE is extracted to: $DESTDIR')"
1886 ;;
1889 recompress)
1890 # Recompress .tazpkg cpio archive with lzma.
1891 check_for_package_on_cmdline
1892 check_for_package_file
1893 title 'Recompressing: $PACKAGE'
1894 mkdir -p $TMP_DIR
1896 action "Copying original package..."
1897 cp $PACKAGE_FILE $TMP_DIR
1898 status
1900 cd $TMP_DIR
1901 extract_package
1903 action "Recompressing the fs..."
1904 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
1905 rm -rf fs
1906 status
1908 action "Creating new package..."
1909 find . -print | cpio -o -H newc --quiet > \
1910 $TOP_DIR/$(basename $PACKAGE_FILE).$$ && mv -f \
1911 $TOP_DIR/$(basename $PACKAGE_FILE).$$ \
1912 $TOP_DIR/$(basename $PACKAGE_FILE)
1913 status
1915 cd $TOP_DIR
1916 rm -rf $TMP_DIR
1917 separator; newline ;;
1920 list-config)
1921 # List configuration files installed.
1922 if [ "$2" = "--box" ]; then
1923 mkdir -p $TMP_DIR && cd $TMP_DIR
1924 FILES="$INSTALLED/*/volatile.cpio.gz"
1925 [ -n "$3" ] && FILES="$INSTALLED/$3/volatile.cpio.gz"
1926 for i in $FILES; do
1927 zcat $i | cpio -idm --quiet > /dev/null
1928 find * -type f 2>/dev/null | while read file; do
1929 if [ ! -e /$file ]; then
1930 echo -n "----------|----|----|$(_n 'File lost')"
1931 else
1932 echo -n "$(stat -c "%A|%U|%G|%s|" /$file)"
1933 cmp $file /$file > /dev/null 2>&1 || \
1934 echo -n "$(stat -c "%.16y" /$file)"
1935 fi
1936 echo "|/$file"
1937 done
1938 rm -rf *
1939 done
1940 cd $TOP_DIR
1941 rm -rf $TMP_DIR
1942 else
1943 title 'Configuration files'
1944 for i in $INSTALLED/*/volatile.cpio.gz; do
1945 [ -n "$2" -a "$i" != "$INSTALLED/$2/volatile.cpio.gz" ] && continue
1946 [ -f "$i" ] || continue
1947 zcat $i | cpio -t --quiet
1948 done | sed 's|^|/|' | sort
1949 separator
1950 newline
1951 fi ;;
1954 repack-config)
1955 # Create SliTaz package archive from configuration files.
1956 mkdir -p $TMP_DIR && cd $TMP_DIR
1957 CONFIG_VERSION=1.0
1958 mkdir config-$CONFIG_VERSION
1959 cd config-$CONFIG_VERSION
1960 for i in $INSTALLED/*/volatile.cpio.gz; do
1961 zcat $i | cpio -t --quiet
1962 done > files.list
1963 mkdir fs
1964 cd fs
1965 ( cd / ; cpio -o -H newc --quiet ) < ../files.list | cpio -idm --quiet > /dev/null
1966 mkdir -p etc/tazlito
1967 for i in $INSTALLED/*/receipt; do
1968 EXTRAVERSION=""
1969 . $i
1970 echo "$PACKAGE-$VERSION$EXTRAVERSION"
1971 done > etc/tazlito/config-packages.list
1972 cd ..
1973 echo "etc/tazlito/config-packages.list" >> files.list
1974 pkg_date=$(date +"%x %X")
1975 cat > receipt <<EOT
1976 # SliTaz package receipt.
1978 PACKAGE="config"
1979 VERSION="$CONFIG_VERSION"
1980 CATEGORY="base-system"
1981 SHORT_DESC="$(_n 'User configuration backup on $pkg_date')"
1982 DEPENDS="$(ls $INSTALLED)"
1983 EOT
1984 cd ..
1985 tazpkg pack config-$CONFIG_VERSION
1986 cp config-$CONFIG_VERSION.tazpkg $TOP_DIR
1987 cd $TOP_DIR
1988 rm -rf $TMP_DIR
1989 ;;
1992 repack)
1993 # Create SliTaz package archive from an installed package.
1994 check_for_package_on_cmdline
1995 check_for_receipt
1996 EXTRAVERSION=""
1997 . $INSTALLED/$PACKAGE/receipt
1998 title 'Repacking: $PACKAGE-$VERSION$EXTRAVERSION.tazpkg'
1999 if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then
2000 _ "Can't repack \$PACKAGE"
2001 exit 1
2002 fi
2003 if [ -s $INSTALLED/$PACKAGE/modifiers ]; then
2004 _ "Can't repack, \$PACKAGE files have been modified by:"
2005 for i in $(cat $INSTALLED/$PACKAGE/modifiers); do
2006 echo " $i"
2007 done
2008 exit 1
2009 fi
2010 MISSING=""
2011 while read i; do
2012 [ -e "$i" ] && continue
2013 [ -L "$i" ] || MISSING="$MISSING\n $i"
2014 done < $INSTALLED/$PACKAGE/files.list
2015 if [ -n "$MISSING" ]; then
2016 _n "Can't repack, the following files are lost:"
2017 echo -e "$MISSING"
2018 exit 1
2019 fi
2020 mkdir -p $TMP_DIR && cd $TMP_DIR
2021 FILES="fs.cpio.lzma\n"
2022 for i in $(ls $INSTALLED/$PACKAGE) ; do
2023 [ "$i" = "volatile.cpio.gz" ] && continue
2024 [ "$i" = "modifiers" ] && continue
2025 cp $INSTALLED/$PACKAGE/$i . && FILES="$FILES$i\n"
2026 done
2027 ln -s / rootfs
2028 mkdir tmp
2029 sed 's/^/rootfs/' < files.list | cpio -o -H newc --quiet |\
2030 { cd tmp ; cpio -idm --quiet >/dev/null; cd ..; }
2031 mv tmp/rootfs fs
2032 if [ -f $INSTALLED/$PACKAGE/volatile.cpio.gz ]; then
2033 zcat $INSTALLED/$PACKAGE/volatile.cpio.gz | \
2034 { cd fs; cpio -idm --quiet; cd ..; }
2035 fi
2036 if fgrep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then
2037 . $INSTALLED/$PACKAGE/receipt
2038 repack_cleanup fs
2039 fi
2040 if [ -f $INSTALLED/$PACKAGE/$CHECKSUM ]; then
2041 sed 's, , fs,' < $INSTALLED/$PACKAGE/$CHECKSUM | \
2042 $CHECKSUM -s -c || {
2043 _ "Can't repack, \$CHECKSUM error."
2044 cd $TOP_DIR
2045 rm -rf $TMP_DIR
2046 exit 1
2048 fi
2049 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
2050 echo -e "$FILES" | cpio -o -H newc --quiet > \
2051 $TOP_DIR/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
2052 cd $TOP_DIR
2053 \rm -R $TMP_DIR
2054 _ 'Package $PACKAGE repacked successfully.'
2055 pkg_size=$(du -sh $PACKAGE-$VERSION$EXTRAVERSION.tazpkg)
2056 _ 'Size: $pkg_size'
2057 newline ;;
2060 pack)
2061 # Create SliTaz package archive using cpio and lzma.
2062 # TODO: Cook also pack packages, we should share code in libpkg.sh
2063 check_for_package_on_cmdline
2064 cd $PACKAGE
2065 if [ ! -f "receipt" ]; then
2066 _ 'Receipt is missing. Please read the documentation.'
2067 exit 0
2068 else
2069 title 'Packing: $PACKAGE'
2070 # Create files.list with redirecting find outpout.
2071 action "Creating the list of files..."
2072 cd fs
2073 find . -type f -print > ../files.list
2074 find . -type l -print >> ../files.list
2075 cd .. && sed -i s/'^.'/''/ files.list
2076 status
2077 action 'Creating $CHECKSUM of files...'
2078 while read file; do
2079 [ -L "fs$file" ] && continue
2080 [ -f "fs$file" ] || continue
2081 case "$file" in
2082 /lib/modules/*/modules.*|*.pyc) continue;;
2083 esac
2084 $CHECKSUM "fs$file" | sed 's/ fs/ /'
2085 done < files.list > $CHECKSUM
2086 status
2087 UNPACKED_SIZE=$(du -chs fs receipt files.list $CHECKSUM \
2088 description.txt 2> /dev/null | awk \
2089 '{ sz=$1 } END { print sz }')
2090 # Build cpio archives.
2091 action "Compressing the fs..."
2092 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
2093 rm -rf fs
2094 status
2095 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
2096 $CHECKSUM description.txt 2> /dev/null | awk \
2097 '{ sz=$1 } END { print sz }')
2098 action "Updating receipt sizes..."
2099 sed -i s/^PACKED_SIZE.*$// receipt
2100 sed -i s/^UNPACKED_SIZE.*$// receipt
2101 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
2102 status
2103 action "Creating full cpio archive..."
2104 find . -print | cpio -o -H newc --quiet > ../$PACKAGE.tazpkg
2105 status
2106 action "Restoring original package tree..."
2107 unlzma -c fs.cpio.lzma | cpio -idm --quiet
2108 status
2109 rm fs.cpio.lzma && cd ..
2110 footer "$(_ 'Package $PACKAGE compressed successfully.')"
2111 pkg_size=$(du -sh $PACKAGE.tazpkg)
2112 _ 'Size: $pkg_size'
2113 newline
2114 fi ;;
2117 recharge)
2118 # Recharge packages.list from a mirror.
2120 # WARNING: The 'mirrors' file has all SliTaz mirrors but 'mirror'
2121 # must have only the chosen main mirror.
2123 check_root $@
2125 ARG=$2
2126 if [ "$root" ]; then
2127 PKGS_DB=$root$PKGS_DB
2128 [ "${2#--}" != "$2" ] && ARG=$3
2129 fi
2130 if [ "$ARG" = main ]; then
2131 repository_to_recharge=$PKGS_DB
2132 elif [ "$ARG" ]; then
2133 if [ -d "$PKGS_DB/undigest/$ARG" ]; then
2134 repository_to_recharge=$PKGS_DB/undigest/$ARG
2135 else
2136 repo="$PKGS_DB/undigest/$ARG"
2137 _ "\$repo doesn't exist." >&2
2138 exit 1
2139 fi
2140 else
2141 repository_to_recharge="$PKGS_DB $PKGS_DB/undigest/*"
2142 fi
2143 for path in $repository_to_recharge; do
2144 [ -f $path/mirror ] || continue
2145 cd $path
2147 # Quietly check if recharging is needed.
2148 [ -f ID ] && mv ID ID.bak
2149 download_from "$(cat mirror)" ID >/dev/null 2>/dev/null
2150 if [ -f ID ] && fgrep -q $(cat ID.bak 2>/dev/null || echo "null") ID; then
2151 if [ "$path" = "$PKGS_DB" ]; then
2152 repository_name=Main
2153 else
2154 base_path="$(basename $path)"
2155 repository_name="$(_n 'Undigest $base_path')"
2156 fi
2157 _ '$repository_name is up to date.'
2158 rm ID.bak
2159 continue
2160 fi
2162 # Don't let ID be a symlink when using local repository.
2163 if [ -f ID ]; then
2164 mv -f ID ID.bak
2165 cat ID.bak > ID
2166 rm ID.bak
2167 fi
2169 newline
2170 if [ "$path" != "$PKGS_DB" ]; then
2171 base_path="$(basename $path)"
2172 _ 'Recharging undigest $base_path:'
2173 fi
2175 if [ -f "packages.list" ]; then
2176 action "Creating backup of the last packages list..."
2177 for i in packages.desc packages.$SUM packages.txt \
2178 packages.list packages.equiv files.list.lzma \
2179 extra.list mirrors packages.info
2180 do
2181 mv -f $i $i.bak 2>/dev/null
2182 done
2183 status
2184 fi
2186 for i in desc $SUM txt list equiv; do
2187 download_from "$(cat mirror)" packages.$i
2188 done
2189 download_from "$(cat mirror)" files.list.lzma
2190 download_from "$(cat mirror)" extra.list
2191 download_from "$(sed 's|packages/.*||' mirror)" mirrors
2193 # packages.info
2194 download_from "$(cat mirror)" packages.info.lzma
2195 lzma d packages.info.lzma packages.info
2196 rm packages.info.lzma
2198 if [ -f "packages.list.bak" ]; then
2199 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
2200 [ -f "extra.list.bak" ] &&
2201 diff -u extra.list.bak extra.list | grep ^+[a-z] >> packages.diff
2202 sed -i s/+// packages.diff
2203 title 'Mirrored packages diff'
2204 cat packages.diff
2205 new_pkgs=$(wc -l < packages.diff)
2206 if [ "$new_pkgs" != 0 ]; then
2207 num=$(emsg "<c 32>$new_pkgs</c>")
2208 footer "$(eval_ngettext \
2209 '$num new package on the mirror.' \
2210 '$num new packages on the mirror.' $new_pkgs)"
2211 else
2212 _ 'No new packages on the mirror.'
2213 newline
2214 fi
2215 else
2216 footer "$(_ \
2217 'Last packages.list is ready to use. Note that next time you recharge the
2218 list, a list of differences will be displayed to show new and upgradeable
2219 packages.')"
2220 fi
2221 done ;;
2224 help-up)
2225 # Options available for the command: up
2226 newline; usage_up; newline
2227 exit 1 ;;
2230 up|upgrade)
2232 # This is the new way to upgrade packages making 'upgrade' and
2233 # upgradeable out-of-date. This new way is much, much more faster!
2234 # Look into installed packages and get data from receipt, it is fast
2235 # and easy to handle vars after using only md5sum to compare packages
2237 for opt in $@; do
2238 case "$opt" in
2239 --recharge|-r) tazpkg recharge ;;
2240 --install|-i) install="y" ;;
2241 --check|-c) install="n" ;;
2242 esac
2243 done
2244 time=$(date +%s)
2245 installed_sum=$PKGS_DB/installed.$SUM
2246 look_for_priority
2247 for repo in $priority; do
2248 pkg_list=$repo/packages.list
2249 mtime=$(find $pkg_list -mtime +7)
2250 if [ "$mtime" ]; then
2251 if [ "$repo" = "$PKGS_DB" ]; then
2252 repo_name=main
2253 else
2254 repo_name="${repo##*/}"
2255 fi
2256 _ '$pkg_list is older than one week... recharging'
2257 tazpkg recharge $repo_name
2258 fi
2259 done
2260 emsg "<n><b>$(_ 'Package')</b><i 28> $(_ 'Version')<i 48> $(_ 'Status')<->"
2261 cd $INSTALLED
2262 newline > $UP_LIST
2263 blocked_count=0
2264 for pkg in *; do
2265 [ ! -d $pkg ] && continue
2266 unset VERSION EXTRAVERSION
2267 . $pkg/receipt
2268 md5=$(fgrep " $PACKAGE-${VERSION}$EXTRAVERSION.tazpkg" \
2269 $installed_sum | awk '{print $1}')
2270 for repo in $priority; do
2271 pkg_desc=$repo/packages.desc
2272 pkg_list=$repo/packages.list
2273 pkg_sum=$repo/packages.$SUM
2275 if ! fgrep -q "$md5 $PACKAGE-" $pkg_sum; then
2276 # Jump to next repository in priority if pkg doesn't exist
2277 # in this one.
2278 grep -q ^$PACKAGE- $pkg_list || continue
2280 emsg -n "$PACKAGE<i 28> $VERSION"
2282 # Skip pkgs listed in $PKGS_DB/blocked-packages.list
2283 if $(grep -qs "^$PACKAGE" $BLOCKED); then
2284 blocked_count=$(($blocked_count + 1))
2285 emsg "<i 48><c 31> $(_ 'Blocked')</c>"
2286 break
2287 fi
2289 new=$(grep "^$PACKAGE |" $pkg_desc | awk '{print $3}')
2291 if [ "$VERSION" == "$new" ]; then
2292 emsg "<i 48><c 34> $(_ 'New build')</c>"
2293 else
2294 emsg "<i 48><c 32> $(_ 'New version $new')</c>"
2295 fi
2296 echo "$PACKAGE" >> $UP_LIST
2297 break
2298 fi
2299 done
2300 done
2301 sed -i /^$/d $UP_LIST
2302 upnb=$(wc -l < $UP_LIST)
2303 pkgs=$(ls | wc -l)
2304 time=$(($(date +%s) - $time))
2305 if [ "$upnb" = 0 ]; then
2306 install="n"
2307 _ 'System is up-to-date...'
2308 fi
2309 num=$(emsg "<c 32>$pkgs</c>")
2310 footer "$(eval_ngettext \
2311 '$num installed package scanned in ${time}s' \
2312 '$num installed packages scanned in ${time}s' $pkgs)"
2313 if [ "$upnb" != 0 ]; then
2314 if [ "$blocked_count" -gt 0 ]; then
2315 num=$blocked_count
2316 blocked=$(eval_ngettext '$num blocked' '$num blocked' $num)
2317 else
2318 # FIXME
2319 blocked="$(_ '0 blocked')"
2320 fi
2321 num=$upnb
2322 boldify "$(eval_ngettext \
2323 'You have $num available upgrade ($blocked)' \
2324 'You have $num available upgrades ($blocked)' $num)"
2325 newline
2326 fi
2327 # Pkgs to upgrade ? Skip, let install them all or ask user
2328 [ "$install" == "n" ] && exit 0
2329 if [ "$upnb" -gt 0 ]; then
2330 if [ "$install" == "y" ]; then
2331 continue
2332 else
2333 _n 'Do you wish to install them now: y/n ? '
2334 read install
2335 fi
2336 case "$install" in
2337 y|Y|yes|YES|Yes)
2338 for pkg in $(cat $UP_LIST); do
2339 echo 'y' | tazpkg get-install $pkg --forced
2340 done
2341 # List is generated each time and must be cleaned so
2342 # tazpkg-notify doesn't find upgrades anymore.
2343 rm $UP_LIST && touch $UP_LIST ;;
2344 *)
2345 _ 'Leaving without any upgrades installed.'
2346 newline
2347 exit 0 ;;
2348 esac
2349 fi
2350 newline ;;
2353 bugs)
2354 # Show known bugs in package(s)
2355 cd $INSTALLED
2356 shift
2357 LIST=$@
2358 [ -n "$LIST" ] || LIST=$(ls)
2359 MSG=$(_n 'No known bugs.')
2360 for PACKAGE in $LIST; do
2361 BUGS=""
2362 EXTRAVERSION=""
2363 . $PACKAGE/receipt
2364 if [ -n "$BUGS" ]; then
2365 MSG=$(_n 'Bug list completed')
2366 newline
2367 _ 'Bugs in package $PACKAGE version $VERSION$EXTRAVERSION:'
2368 cat <<EOT
2369 $BUGS
2370 EOT
2371 fi
2372 done
2373 echo "$MSG" ;;
2376 check)
2377 # Check installed packages set.
2378 check_root $@
2380 # Get repositories priority list.
2381 look_for_priority
2383 cd $INSTALLED
2384 for PACKAGE in $(ls); do
2385 if [ ! -f $PACKAGE/receipt ]; then
2386 _ 'The package $PACKAGE installation has not completed'
2387 continue
2388 fi
2389 DEPENDS=""
2390 EXTRAVERSION=""
2391 . $PACKAGE/receipt
2392 if [ -s $PACKAGE/modifiers ]; then
2393 _ 'The package $PACKAGE-$VERSION$EXTRAVERSION has been modified by:'
2394 for i in $(cat $PACKAGE/modifiers); do
2395 echo " $i"
2396 done
2397 fi
2398 MSG="$(_n 'Files lost from $PACKAGE-$VERSION$EXTRAVERSION:')\n"
2399 while read file; do
2400 [ -e "$file" ] && continue
2401 if [ -L "$file" ]; then
2402 MSG="$MSG $(_n 'target of symlink')"
2403 fi
2404 echo -e "$MSG $file"
2405 MSG=""
2406 done < $PACKAGE/files.list
2407 MSG="$(_n 'Missing dependencies for $PACKAGE-$VERSION$EXTRAVERSION:')\n"
2408 for i in $DEPENDS; do
2409 [ -d $i ] && continue
2410 [ -d $(equivalent_pkg $i) ] && continue
2411 echo -e "$MSG $i"
2412 MSG=""
2413 done
2414 MSG="$(_n 'Dependencies loop between $PACKAGE and:')\n"
2415 ALL_DEPS=""
2416 check_for_deps_loop $PACKAGE $DEPENDS
2417 done
2419 _ 'Looking for known bugs...'
2420 tazpkg bugs
2422 if [ "$PACKAGE_FILE" = "--full" ]; then
2423 for file in */$CHECKSUM; do
2424 CONFIG_FILES=""
2425 . $(dirname "$file")/receipt
2426 [ -s "$file" ] || continue
2427 while read md5 f; do
2428 [ -f $f ] || continue
2429 for i in $CONFIG_FILES; do
2430 case "$f" in
2431 $i|$i/*) continue 2;;
2432 esac
2433 done
2434 echo "$md5 $f"
2435 done < "$file" | $CHECKSUM -c - 2> /dev/null | \
2436 grep -v OK$ | sed 's/FAILED$/$CHECKSUM MISMATCH/'
2437 done
2438 FILES=" "
2439 for file in $(cat */files.list); do
2440 [ -d "$file" ] && continue
2441 case "$FILES" in *\ $file\ *) continue;; esac
2442 [ $(grep "^$(echo $file | grepesc)$" */files.list 2> /dev/null | \
2443 wc -l) -gt 1 ] || continue
2444 FILES="$FILES$file "
2445 _ 'The following packages provide $file:'
2446 grep -l "^$(echo $file | grepesc)$" */files.list | \
2447 while read f; do
2448 pkg=${f%/files.list}
2449 if [ -f $pkg/modifiers ]; then
2450 pkg_list="$(cat $pkg/modifiers)"
2451 overriders=$(_n '(overridden by $pkg_list)')
2452 else
2453 overriders=''
2454 fi
2455 echo -n " $pkg $overriders"
2456 newline
2457 done
2458 done
2459 MSG="$(_n 'No package has installed the following files:')\n"
2460 find /etc /bin /sbin /lib /usr /var/www -not -type d 2>/dev/null | \
2461 while read file; do
2462 case "$file" in *\[*) continue;; esac
2463 grep -q "^$(echo $file | grepesc)$" */files.list && continue
2464 echo -e "$MSG $file"
2465 MSG=""
2466 done
2467 fi
2468 _ 'Check completed.'; echo ;;
2471 block)
2472 # Add a pkg name to the list of blocked packages.
2473 check_root $@
2474 check_for_package_on_cmdline
2475 newline
2476 if grep -qs "^$PACKAGE" $BLOCKED; then
2477 _ '$PACKAGE is already in the blocked packages list.'
2478 else
2479 action 'Add $PACKAGE to: $BLOCKED...'
2480 echo $PACKAGE >> $BLOCKED
2481 status
2482 # Log this activity
2483 . $INSTALLED/$PACKAGE/receipt
2484 log_pkg Blocked
2485 fi
2486 newline ;;
2489 unblock)
2490 # Remove a pkg name from the list of blocked packages.
2491 check_root $@
2492 check_for_package_on_cmdline
2493 newline
2494 if grep -qs "^$PACKAGE" $BLOCKED; then
2495 action 'Removing $PACKAGE from: $BLOCKED...'
2496 sed -i s/$PACKAGE/''/ $BLOCKED
2497 sed -i '/^$/d' $BLOCKED
2498 status
2499 # Log this activity
2500 . $INSTALLED/$PACKAGE/receipt
2501 log_pkg Unblocked
2502 else
2503 _ '$PACKAGE is not in the blocked packages list.'
2504 fi
2505 newline ;;
2508 get)
2509 # Download a package with wget.
2510 check_root $@
2511 check_for_package_on_cmdline
2512 check_for_packages_list
2514 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
2515 if [ "$rootconfig" ]; then
2516 if [ "$root" ]; then
2517 CACHE_DIR=$root/$CACHE_DIR
2518 SAVE_CACHE_DIR=$CACHE_DIR
2519 PKGS_DB=$root/$PKGS_DB
2520 else
2521 _ 'rootconfig needs --root= option used.' >&2
2522 exit 1
2523 fi
2524 fi
2526 # Get repositories priority list.
2527 look_for_priority
2529 CURRENT_DIR=$PWD
2530 check_for_package_in_list
2531 cd $CACHE_DIR
2532 if [ -f "$PACKAGE.tazpkg" ]; then
2533 _ '$PACKAGE already in the cache'
2534 # Check package download was finished
2535 tail -c 2k $PACKAGE.tazpkg | fgrep -q 00000000TRAILER || {
2536 _ 'Continuing $PACKAGE download'
2537 download $PACKAGE.tazpkg
2539 if [ "$($CHECKSUM $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.$SUM)" ]; then
2540 rm -f $PACKAGE.tazpkg
2541 download $PACKAGE.tazpkg
2542 fi
2543 else
2544 download $PACKAGE.tazpkg
2545 fi
2546 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
2547 cp -a $PACKAGE_FILE $CURRENT_DIR ;;
2550 get-install|-gi)
2551 # Download and install a package.
2552 check_root $@
2553 check_for_package_on_cmdline
2554 check_for_packages_list
2556 DO_CHECK=""
2557 [ "$forced" ] && DO_CHECK=no
2558 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
2559 [ "$list" ] && INSTALL_LIST="$list"
2560 if [ "$rootconfig" ]; then
2561 if [ "$root" ]; then
2562 CACHE_DIR=$root/$CACHE_DIR
2563 SAVE_CACHE_DIR=$CACHE_DIR
2564 PKGS_DB=$root/$PKGS_DB
2565 else
2566 _ 'rootconfig needs --root= option used.' >&2
2567 exit 1
2568 fi
2569 fi
2571 # Get repositories priority list.
2572 look_for_priority
2574 AUTOEXEC="no"
2575 if ! check_for_package_in_list check; then
2576 CACHE_DIR="${CACHE_DIR%/*}/get"
2577 [ -d "$CACHE_DIR" ] || mkdir -p $CACHE_DIR
2578 if download_get_script $PACKAGE /tmp/$PACKAGE.$$ ; then
2579 install_package_from_get_script /tmp/$PACKAGE.$$ $ROOT
2580 exit 0
2581 else
2582 PACKAGE=get-$PACKAGE
2583 AUTOEXEC=$PACKAGE
2584 check_for_package_in_list
2585 if [ -n "$(get_installed_package_pathname $PACKAGE $ROOT)" ]; then
2586 $AUTOEXEC $ROOT
2587 exit 0
2588 fi
2589 fi
2590 fi
2591 # Check if forced install.
2592 if ! [ "$forced" ]; then
2593 check_for_installed_package $ROOT
2594 fi
2595 cd $CACHE_DIR
2596 if [ -f "$PACKAGE.tazpkg" ]; then
2597 _ '$PACKAGE already in the cache: $CACHE_DIR'
2598 # Check package download was finished
2599 tail -c 2k $PACKAGE.tazpkg | fgrep -q 00000000TRAILER || {
2600 _ 'Continuing $PACKAGE download'
2601 download $PACKAGE.tazpkg
2603 if [ "$($CHECKSUM $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.$SUM)" ]; then
2604 rm -f $PACKAGE.tazpkg
2605 download $PACKAGE.tazpkg
2606 fi
2607 else
2608 newline
2609 download $PACKAGE.tazpkg
2610 fi
2611 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
2612 [ "$rootconfig" ] && PKGS_DB=${PKGS_DB#$root}
2613 install_package $ROOT
2614 [ "$AUTOEXEC" != "no" ] && $PACKAGE $ROOT
2615 update_desktop_database $ROOT
2616 update_mime_database $ROOT ;;
2619 clean-cache|-cc)
2620 # Remove all downloaded packages.
2621 check_root $@
2622 files=$(find $CACHE_DIR -name *.tazpkg | wc -l)
2623 title 'Path: $CACHE_DIR'
2624 action "Cleaning cache directory..."
2625 rm -rf $CACHE_DIR/*
2626 status
2627 num=$(colorize 32 "$files")
2629 footer "$(eval_ngettext \
2630 '$num file removed from cache.' \
2631 '$num files removed from cache.' \
2632 $files)"
2633 ;;
2636 list-undigest)
2637 # list undigest URLs.
2638 if [ "$2" = "--box" ]; then
2639 for i in $PKGS_DB/undigest/*/mirror; do
2640 [ -f $i ] || continue
2641 echo "$(basename $(dirname $i))|$(cat $i)"
2642 done
2643 else
2644 title 'Current undigest(s)'
2645 for i in $PKGS_DB/undigest/*/mirror; do
2646 if [ ! -f $i ]; then
2647 _ 'No undigest mirror found.'
2648 exit 1
2649 fi
2650 echo "$(basename $(dirname $i)) $(cat $i)"
2651 done
2652 newline
2653 fi ;;
2656 remove-undigest)
2657 # remove undigest URL.
2658 check_root $@
2659 undigest="$2"
2660 if [ -d $PKGS_DB/undigest/$2 ]; then
2661 confirm "$(_ 'Remove $undigest undigest? (y/N)')"
2662 if [ $? = 0 ]; then
2663 action 'Removing $undigest undigest...'
2664 rm -rf $PKGS_DB/undigest/$2
2665 status
2666 rmdir $PKGS_DB/undigest 2> /dev/null
2667 fi
2668 else
2669 _ 'Undigest $undigest not found'
2670 fi ;;
2673 add-undigest|setup-undigest)
2674 # Add undigest URL.
2675 check_root $@
2676 undigest=$2
2677 [ -d $PKGS_DB/undigest ] || mkdir $PKGS_DB/undigest
2678 if [ -z "$undigest" ]; then
2679 i=1
2680 while [ -d $PKGS_DB/undigest/$i ]; do
2681 i=$(($i+1))
2682 done
2683 undigest=$i
2684 fi
2685 if [ ! -d $PKGS_DB/undigest/$undigest ]; then
2686 _ 'Creating new undigest $undigest.'
2687 mkdir $PKGS_DB/undigest/$undigest
2688 fi
2689 setup_mirror $PKGS_DB/undigest/$undigest $3 ;;
2692 setup-mirror|-sm)
2693 # Change mirror URL.
2694 check_root $@
2695 setup_mirror $PKGS_DB $2 ;;
2698 reconfigure)
2699 # Replay post_install from receipt
2700 check_for_package_on_cmdline
2701 check_root $@
2702 ROOT=""
2703 while [ -n "$3" ]; do
2704 case "$3" in
2705 --root=*)
2706 ROOT="${3#--root=}/" ;;
2707 *)
2708 shift 2
2709 u_opt="$*"
2710 newline >&2
2711 _ 'Unknown option $u_opt.' >&2
2712 exit 1 ;;
2713 esac
2714 shift
2715 done
2716 if [ -d "$ROOT$INSTALLED/$PACKAGE" ]; then
2717 check_for_receipt $ROOT
2718 # Check for post_install
2719 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
2720 . $ROOT$INSTALLED/$PACKAGE/receipt
2721 post_install $ROOT
2722 # Log this activity
2723 [ -n "$ROOT" ] || log_pkg Reconfigured
2724 else
2725 newline
2726 _ 'Nothing to do for $PACKAGE.'
2727 fi
2728 else
2729 newline
2730 _ 'Package $PACKAGE is not installed.'
2731 _ "Install package with 'tazpkg install' or 'tazpkg get-install'"
2732 newline
2733 fi ;;
2736 shell)
2737 # TazPKG SHell
2738 if test $(id -u) = 0 ; then
2739 PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
2740 else
2741 PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
2742 fi
2743 if [ ! "$2" = "--noheader" ]; then
2744 clear
2745 title 'TazPKG SHell.'
2746 _ "Type 'usage' to list all available commands or 'quit' or 'q' to exit."
2747 newline
2748 fi
2749 while true; do
2750 echo -en "$PROMPT"; read cmd
2751 case $cmd in
2752 q|quit)
2753 break ;;
2754 shell)
2755 _ 'You are already running a TazPKG SHell.' ;;
2756 su)
2757 su -c 'exec tazpkg shell --noheader' && break ;;
2758 "")
2759 continue ;;
2760 *)
2761 tazpkg $cmd ;;
2762 esac
2763 done ;;
2766 depends)
2767 # Display dependencies tree
2768 cd $INSTALLED
2769 ALL_DEPS=""
2770 if [ -f $2/receipt ]; then
2771 dep_scan $2 ""
2772 fi ;;
2775 rdepends)
2776 # Display reverse dependencies tree
2777 cd $INSTALLED
2778 ALL_DEPS=""
2779 if [ -f $2/receipt ]; then
2780 rdep_scan $2
2781 fi ;;
2784 convert|-c)
2785 # convert misc package format to .tazpkg
2786 check_for_package_file
2787 tazpkg-convert $@
2788 ;;
2791 link)
2792 # link a package from another slitaz installation
2793 PACKAGE=$2
2794 if [ ! -d "$TARGET_DIR" -o \
2795 ! -d "$TARGET_DIR$INSTALLED/$PACKAGE" ]; then
2796 _n "
2797 usage: tazpkg link package_name slitaz_root
2798 example: 'tazpkg link openoffice /mnt' will use less than 100k in
2799 your running system ram.
2801 exit 1
2802 fi
2803 if [ -e "$INSTALLED/$PACKAGE" ]; then
2804 _ '$PACKAGE is already installed.'
2805 exit 1
2806 fi
2807 ln -s $TARGET_DIR$INSTALLED/$PACKAGE $INSTALLED
2808 DEPENDS="$(. $INSTALLED/$PACKAGE/receipt ; echo $DEPENDS)"
2809 MISSING=""
2810 for i in $DEPENDS; do
2811 [ -e $INSTALLED/$i ] && continue
2812 MISSING="$MISSING$i "
2813 _ 'Missing: $i'
2814 done
2815 if [ -n "$MISSING" ]; then
2816 newline
2817 confirm "$(_ 'Link all missing dependencies? (y/N)')"
2818 answer=$?
2819 newline
2820 if [ $answer = 0 ]; then
2821 for i in $MISSING; do
2822 tazpkg link $i $TARGET_DIR
2823 done
2824 else
2825 newline
2826 _ 'Leaving dependencies unresolved for: $PACKAGE'
2827 _ 'The package is installed but probably will not work.'
2828 newline
2829 fi
2830 fi
2831 . $INSTALLED/$PACKAGE/receipt
2832 if grep -q ^pre_install $INSTALLED/$PACKAGE/receipt; then
2833 pre_install
2834 fi
2835 while read path; do
2836 [ -e $path ] && continue
2837 while true; do
2838 dir=$(dirname $path)
2839 [ -e $dir ] && break
2840 path=$dir
2841 done
2842 ln -s $TARGET_DIR$path $dir
2843 done < $INSTALLED/$PACKAGE/files.list
2844 if grep -q ^post_install $INSTALLED/$PACKAGE/receipt; then
2845 post_install
2846 fi ;;
2849 usage|*)
2850 # Print a short help or give usage for an unknown or empty command.
2851 usage ;;
2852 esac
2854 exit 0