Magellan Linux

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

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

revision 229 by niro, Fri Sep 9 16:51:51 2005 UTC revision 777 by niro, Sun Oct 5 10:33:04 2008 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.13 2008-10-05 10:33:04 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 "    -c CAT    shows all packages of given categorie"
14   echo "    -i        shows an inventory of all installed packages"   echo "    -i        shows an inventory of all installed packages"
15     echo "    -f PATH   searches packages name in given path"
16   echo   echo
17   echo " Examples:"   echo " Examples:"
18   echo   echo
# Line 21  print_usage() Line 23  print_usage()
23    
24  # default args:  # default args:
25  GET_INVENTORY=false  GET_INVENTORY=false
26    SEARCH_ONLY_PATH=false
27    SEARCH_ONLY_CAT=false
28    
29  while getopts "n:v:b:hi-" opt ; do  while getopts "n:v:b:f:c:hi-" opt ; do
30   case "${opt}" in   case "${opt}" in
31   n)   n)
32   S_PNAME="${OPTARG}"   S_PNAME="${OPTARG}"
# Line 38  while getopts "n:v:b:hi-" opt ; do Line 42  while getopts "n:v:b:hi-" opt ; do
42   i)   i)
43   GET_INVENTORY="true"   GET_INVENTORY="true"
44   ;;   ;;
45     f)
46     SEARCH_ONLY_PATH="true"
47     SEARCH_PATH="${OPTARG}"
48     ;;
49     c)
50     SEARCH_ONLY_CAT="true"
51     SEARCH_CAT="${OPTARG}"
52     ;;
53   h)   h)
54   print_usage   print_usage
55   exit 0   exit 0
# Line 54  while getopts "n:v:b:hi-" opt ; do Line 66  while getopts "n:v:b:hi-" opt ; do
66  done  done
67  shift $(($OPTIND - 1))  shift $(($OPTIND - 1))
68    
69    source /etc/mage.rc.global
70  source /etc/mage.rc  source /etc/mage.rc
71  RETVAL=1  RETVAL=1
72    
73    if [[ ${SEARCH_ONLY_PATH} = true ]]
74    then
75     unset S_PACKAGES
76     unset i pkg
77     for i in $(fgrep -rl "${SEARCH_PATH}" ${INSTALLDB})
78     do
79     # print categorie and pkgname
80     pkg="$(basename ${i%/*/*})/$(basename ${i%/*})"
81     if [[ -z $(echo ${S_PACKAGES} | grep ${pkg}) ]]
82     then
83     S_PACKAGES="${S_PACKAGES} ${pkg}"
84     fi
85     done
86    
87     # show packages
88     for pkg in ${S_PACKAGES}
89     do
90     echo "${pkg}"
91     done
92    
93     exit 0
94    fi
95    
96    if [[ ${SEARCH_ONLY_CAT} = true ]]
97    then
98     # no packages of SEARCH_CAT are installed
99     [[ ! -d ${MROOT}${INSTALLDB}/${SEARCH_CAT} ]] && exit 1
100    
101     for i in ${INSTALLDB}/${SEARCH_CAT}/*
102     do
103     # print categorie and pkgname
104     echo "$(basename ${i%/*})/$(basename ${i})"
105     done
106    
107     exit 0
108    fi
109    
110  if [[ ${GET_INVENTORY} = true ]]  if [[ ${GET_INVENTORY} = true ]]
111  then  then
112   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.777