tazpkg rev 12
Add command search-file and modified the search output
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed Nov 28 14:47:19 2007 +0100 (2007-11-28) |
parents | a39072973190 |
children | 70a6eb9f231a |
files | tazpkg |
line diff
1.1 --- a/tazpkg Wed Nov 28 13:54:26 2007 +0100 1.2 +++ b/tazpkg Wed Nov 28 14:47:19 2007 +0100 1.3 @@ -66,7 +66,7 @@ 1.4 # Print the usage. 1.5 usage () 1.6 { 1.7 - echo -e "SliTaz packages manager - Version: $VERSION\n 1.8 + echo -e "SliTaz packages manager - Version: $VERSION 1.9 \033[1mUsage: \033[0m tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt] 1.10 \033[1mCommands: \033[0m 1.11 usage Print this short usage. 1.12 @@ -76,6 +76,7 @@ 1.13 desc Print description of a package (if it exist). 1.14 list-files List of files installed with the package. 1.15 search Search for a package by pattern or name. 1.16 + search-file Search for file(s) in all installed packages files. 1.17 install Install a local (*.tazpkg) package (--forced to force). 1.18 install-list Install all packages from a list of packages. 1.19 remove Remove the specified package and all installed files. 1.20 @@ -443,27 +444,67 @@ 1.21 echo -e "\033[42G $CATEGORY" 1.22 packages=$(($packages+1)) 1.23 done 1.24 + # Set correct ending messages. 1.25 if [ "$packages" = "" ]; then 1.26 echo "0 installed packages found for : $2" 1.27 echo "" 1.28 else 1.29 echo "================================================================================" 1.30 - echo "$packages installed packages found for : $2" 1.31 + echo "$packages installed package(s) found for : $2" 1.32 echo "" 1.33 fi 1.34 echo "Available packages" 1.35 echo "================================================================================" 1.36 if [ -f "$LOCALSTATE/packages.list" ]; then 1.37 cat $LOCALSTATE/packages.list | grep $2 1.38 + packages=`cat $LOCALSTATE/packages.list | grep $2 | wc -l` 1.39 else 1.40 echo -e " 1.41 No 'packages.list' found to check for mirrored packages. For more results, 1.42 please run once 'tazpkg recharge' as root before searching.\n" 1.43 fi 1.44 + if [ "$packages" = "0" ]; then 1.45 + echo "0 available packages found for : $2" 1.46 + echo "" 1.47 + else 1.48 + echo "================================================================================" 1.49 + echo "$packages available package(s) found for : $2" 1.50 + echo "" 1.51 + fi 1.52 + ;; 1.53 + search-file) 1.54 + # Search for a file by pattern or name in all files.list. 1.55 + # 1.56 + if [ -z "$2" ]; then 1.57 + echo -e "\nPlease specify a pattern or a file name to search." 1.58 + echo -e "Example : 'tazpkg search-file libnss'. \n" 1.59 + exit 0 1.60 + fi 1.61 + echo "" 1.62 + echo -e "\033[1mSearch result for file :\033[0m $2" 1.63 echo "================================================================================" 1.64 - packages=`cat $LOCALSTATE/packages.list | grep $2 | wc -l` 1.65 - echo "$packages avalaible on the mirror." 1.66 - echo "" 1.67 + # Check all pkg files.list in search match with specify the package 1.68 + # name and the full path to the file(s). 1.69 + for pkg in $INSTALLED/* 1.70 + do 1.71 + if grep -q $2 $pkg/files.list; then 1.72 + . $pkg/receipt 1.73 + echo "" 1.74 + echo -e "\033[1mPackage $PACKAGE :\033[0m" 1.75 + grep $2 $pkg/files.list 1.76 + files=`grep $2 $pkg/files.list | wc -l` 1.77 + match=$(($match+$files)) 1.78 + fi 1.79 + done 1.80 + if [ "$match" = "" ]; then 1.81 + echo "0 file found for : $2" 1.82 + echo "" 1.83 + else 1.84 + echo "" 1.85 + echo "================================================================================" 1.86 + echo "$match file(s) found for : $2" 1.87 + echo "" 1.88 + fi 1.89 ;; 1.90 install) 1.91 # Install .tazpkg packages.