Magellan Linux

Diff of /trunk/mage/usr/lib/mage/magequery.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 229 by niro, Fri Sep 9 16:51:51 2005 UTC revision 332 by niro, Mon Feb 20 00:15:03 2006 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    
3  #query mage database for installed packages  #query mage database for installed packages
4  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/magequery.sh,v 1.10 2005-09-09 16:51:51 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/magequery.sh,v 1.12 2006-02-20 00:15:03 niro Exp $
5    
6  print_usage()  print_usage()
7  {  {
# Line 11  print_usage() Line 11  print_usage()
11   echo "    -v VER    searches for version VER, needs -n"   echo "    -v VER    searches for version VER, needs -n"
12   echo "    -b BUILD  searches for build number BUILD, needs -n -v"   echo "    -b BUILD  searches for build number BUILD, needs -n -v"
13   echo "    -i        shows an inventory of all installed packages"   echo "    -i        shows an inventory of all installed packages"
14     echo "    -f        searches packages name in given path"
15   echo   echo
16   echo " Examples:"   echo " Examples:"
17   echo   echo
# Line 21  print_usage() Line 22  print_usage()
22    
23  # default args:  # default args:
24  GET_INVENTORY=false  GET_INVENTORY=false
25    SEARCH_ONLY_PATH=false
26    
27  while getopts "n:v:b:hi-" opt ; do  while getopts "n:v:b:f:hi-" opt ; do
28   case "${opt}" in   case "${opt}" in
29   n)   n)
30   S_PNAME="${OPTARG}"   S_PNAME="${OPTARG}"
# Line 38  while getopts "n:v:b:hi-" opt ; do Line 40  while getopts "n:v:b:hi-" opt ; do
40   i)   i)
41   GET_INVENTORY="true"   GET_INVENTORY="true"
42   ;;   ;;
43     f)
44     SEARCH_ONLY_PATH="true"
45     SEARCH_PATH="${OPTARG}"
46     ;;
47   h)   h)
48   print_usage   print_usage
49   exit 0   exit 0
# Line 54  while getopts "n:v:b:hi-" opt ; do Line 60  while getopts "n:v:b:hi-" opt ; do
60  done  done
61  shift $(($OPTIND - 1))  shift $(($OPTIND - 1))
62    
63    source /etc/mage.rc.global
64  source /etc/mage.rc  source /etc/mage.rc
65  RETVAL=1  RETVAL=1
66    
67    if [[ ${SEARCH_ONLY_PATH} = true ]]
68    then
69     unset S_PACKAGES
70     unset i pkg
71     for i in $(fgrep -rl "${SEARCH_PATH}" ${INSTALLDB})
72     do
73     # print categorie and pkgname
74     pkg="$(basename ${i%/*/*})/$(basename ${i%/*})"
75     if [[ -z $(echo ${S_PACKAGES} | grep ${pkg}) ]]
76     then
77     S_PACKAGES="${S_PACKAGES} ${pkg}"
78     fi
79     done
80    
81     # show packages
82     for pkg in ${S_PACKAGES}
83     do
84     echo "${pkg}"
85     done
86    
87     exit 0
88    fi
89    
90  if [[ ${GET_INVENTORY} = true ]]  if [[ ${GET_INVENTORY} = true ]]
91  then  then
92   for package in $(find ${MROOT}${INSTALLDB} -mindepth 2 -maxdepth 2 -type d -printf "%h,%f\n" | sort)   for package in $(find ${MROOT}${INSTALLDB} -mindepth 2 -maxdepth 2 -type d -printf "%h,%f\n" | sort)

Legend:
Removed from v.229  
changed lines
  Added in v.332