tazpkg rev 318

add search-pkgname option: like search-file but outputs only pkg names
author Rohit Joshi <jozee@slitaz.org>
date Tue Feb 16 10:20:13 2010 +0000 (2010-02-16)
parents f5e5f9ee5a76
children 9a3121405428
files tazpkg
line diff
     1.1 --- a/tazpkg	Thu Feb 11 11:12:05 2010 +0100
     1.2 +++ b/tazpkg	Tue Feb 16 10:20:13 2010 +0000
     1.3 @@ -13,8 +13,9 @@
     1.4  #           Pascal Bellard <pascal.bellard@slitaz.org>
     1.5  #           Eric Joseph-Alexandre <erjo@slitaz.org>
     1.6  #           Paul Issott <paul@slitaz.org>
     1.7 +#           Rohit Joshi <jozee@slitaz.org>
     1.8  #
     1.9 -VERSION=3.2.1
    1.10 +VERSION=3.2.2
    1.11  
    1.12  ####################
    1.13  # Script variables #
    1.14 @@ -100,6 +101,7 @@
    1.15    list-files       List the files installed with a package.
    1.16    list-config      List the configuration files.
    1.17    search           Search for a package by pattern or name (options: -i|-l|-m).
    1.18 +  search-pkgname   Search on mirror for package having a particular file.
    1.19    search-file	   Search for file(s) in all installed packages files.
    1.20    install          Install a local (*.tazpkg) package (--forced to force).
    1.21    install-list     Install all packages from a list of packages.
    1.22 @@ -1561,6 +1563,36 @@
    1.23  			echo "$match file(s) found for : $2"
    1.24  			echo ""
    1.25  		fi ;;
    1.26 +	search-pkgname) 
    1.27 +		#
    1.28 +		if [ -z "$2" ]; then
    1.29 +			echo -e "\nPlease specify a pattern or file name to search for."
    1.30 +			echo -e "Example : 'tazpkg search-pkgname libnss'. \n"
    1.31 +			exit 0
    1.32 +		fi
    1.33 +		echo ""
    1.34 +		echo -e "\033[1mSearch result for file :\033[0m $2"
    1.35 +		echo "================================================================================"
    1.36 +       
    1.37 +	 # Search for a file on mirror and output only the package name
    1.38 +		match=0
    1.39 +		for i in $LOCALSTATE/files.list.lzma \
    1.40 +				 $LOCALSTATE/undigest/*/files.list.lzma; do
    1.41 +				 [ -f $i ] || continue
    1.42 +				unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | awk '{ print $1 }'
    1.43 +				match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | wc -l`))
    1.44 +		done
    1.45 +			
    1.46 +		if [ "$match" = "" ]; then
    1.47 +			echo "0 file found for : $2"
    1.48 +			echo ""
    1.49 +		else
    1.50 +			echo ""
    1.51 +			echo "================================================================================"
    1.52 +			echo "$match pkg(s) found with file : $2"
    1.53 +			echo ""
    1.54 +		fi
    1.55 +		;;
    1.56  	install)
    1.57  		# Install .tazpkg packages.
    1.58  		#