Magellan Linux

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

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

revision 78 by niro, Wed Jun 1 15:48:52 2005 UTC revision 210 by niro, Sun Aug 28 19:17:48 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.7 2005-06-01 15:48:31 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/magequery.sh,v 1.8 2005-08-28 19:17:48 niro Exp $
5    
6  print_usage()  print_usage()
7  {  {
# Line 10  print_usage() Line 10  print_usage()
10   echo "    -n NAME   searches for name NAME"   echo "    -n NAME   searches for name NAME"
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"
14   echo   echo
15   echo " Examples:"   echo " Examples:"
16   echo   echo
# Line 18  print_usage() Line 19  print_usage()
19   echo   echo
20  }  }
21    
22  while getopts "n:v:b:h-" opt ; do  # default args:
23    GET_INVENTORY=false
24    
25    while getopts "n:v:b:hi-" opt ; do
26   case "${opt}" in   case "${opt}" in
27   n)   n)
28   S_PNAME="${OPTARG}"   S_PNAME="${OPTARG}"
# Line 31  while getopts "n:v:b:h-" opt ; do Line 35  while getopts "n:v:b:h-" opt ; do
35   b)   b)
36   S_PBUILD="${OPTARG}"   S_PBUILD="${OPTARG}"
37   ;;   ;;
38     i)
39     GET_INVENTORY="true"
40     ;;
41   h)   h)
42   print_usage   print_usage
43   exit 0   exit 0
# Line 51  shift $(($OPTIND - 1)) Line 58  shift $(($OPTIND - 1))
58  source /etc/mage.rc  source /etc/mage.rc
59  RETVAL=1  RETVAL=1
60    
61    if [[ ${GET_INVENTORY} = true ]]
62    then
63     for package in $(find ${INSTALLDB} -mindepth 2 -maxdepth 2 -type d -printf "%h,%f\n" | sort)
64     do
65     pcat="$(basename $(echo ${package} | cut -d, -f1))"
66     pname="$(echo ${package} | cut -d, -f2)"
67     if [ -z "${invlist}" ]
68     then
69     invlist="${pcat}/${pname}"
70     else
71     invlist="${invlist}
72    ${pcat}/${pname}"
73     fi
74     done
75    
76     # now show the list
77     echo "${invlist}"
78     exit 0
79    fi
80    
81  for i in ${INSTALLDB}/*/*  for i in ${INSTALLDB}/*/*
82  do  do
83   INST_PNAME=no   INST_PNAME=no

Legend:
Removed from v.78  
changed lines
  Added in v.210