Magellan Linux

Diff of /branches/mage-next/src/magequery.in

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

revision 32 by niro, Thu Jan 6 02:54:09 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.12 2006-02-20 00:15:03 niro Exp $
5    
6  print_usage()  print_usage()
7  {  {
# Line 9  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 "    -f        searches packages name in given path"
15   echo   echo
16   echo " Examples:"   echo " Examples:"
17   echo   echo
# Line 17  print_usage() Line 20  print_usage()
20   echo   echo
21  }  }
22    
23  while getopts "n:v:b:h-" opt ; do  # default args:
24    GET_INVENTORY=false
25    SEARCH_ONLY_PATH=false
26    
27    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 30  while getopts "n:v:b:h-" opt ; do Line 37  while getopts "n:v:b:h-" opt ; do
37   b)   b)
38   S_PBUILD="${OPTARG}"   S_PBUILD="${OPTARG}"
39   ;;   ;;
40     i)
41     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 46  while getopts "n:v:b:h-" opt ; do Line 60  while getopts "n:v:b:h-" 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  for i in ${INSTALLDB}/*/*  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 ]]
91    then
92     for package in $(find ${MROOT}${INSTALLDB} -mindepth 2 -maxdepth 2 -type d -printf "%h,%f\n" | sort)
93     do
94     pcat="$(basename $(echo ${package} | cut -d, -f1))"
95     pname="$(echo ${package} | cut -d, -f2)"
96     if [ -z "${invlist}" ]
97     then
98     invlist="${pcat}/${pname}"
99     else
100     invlist="${invlist}
101    ${pcat}/${pname}"
102     fi
103     done
104    
105     # now show the list
106     echo "${invlist}"
107     exit 0
108    fi
109    
110    for i in ${MROOT}${INSTALLDB}/*/*
111  do  do
112   INST_PNAME=no   INST_PNAME=no
113   INST_PVER=no   INST_PVER=no

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