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 304 by niro, Mon Dec 26 23:12:44 2005 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.11 2005-12-26 23:12:44 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 $(grep -irl "${SEARCH_PATH}" ${INSTALLDB})
72     do
73     pkg="$(basename $(dirname ${i}))"
74     if [[ -z $(echo ${S_PACKAGES} | grep ${pkg}) ]]
75     then
76     S_PACKAGES="${S_PACKAGES} ${pkg}"
77     fi
78     done
79    
80     # show packages
81     for pkg in ${S_PACKAGES}
82     do
83     echo "${pkg}"
84     done
85    
86     exit 0
87    fi
88    
89  if [[ ${GET_INVENTORY} = true ]]  if [[ ${GET_INVENTORY} = true ]]
90  then  then
91   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.304