--- trunk/mage/usr/lib/mage/magequery.sh 2006/02/20 00:15:03 332 +++ trunk/mage/usr/lib/mage/magequery.sh 2008/10/05 10:33:04 777 @@ -1,7 +1,7 @@ #!/bin/bash #query mage database for installed packages -# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/magequery.sh,v 1.12 2006-02-20 00:15:03 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 $ print_usage() { @@ -10,8 +10,9 @@ echo " -n NAME searches for name NAME" echo " -v VER searches for version VER, needs -n" echo " -b BUILD searches for build number BUILD, needs -n -v" + echo " -c CAT shows all packages of given categorie" echo " -i shows an inventory of all installed packages" - echo " -f searches packages name in given path" + echo " -f PATH searches packages name in given path" echo echo " Examples:" echo @@ -23,8 +24,9 @@ # default args: GET_INVENTORY=false SEARCH_ONLY_PATH=false +SEARCH_ONLY_CAT=false -while getopts "n:v:b:f:hi-" opt ; do +while getopts "n:v:b:f:c:hi-" opt ; do case "${opt}" in n) S_PNAME="${OPTARG}" @@ -44,6 +46,10 @@ SEARCH_ONLY_PATH="true" SEARCH_PATH="${OPTARG}" ;; + c) + SEARCH_ONLY_CAT="true" + SEARCH_CAT="${OPTARG}" + ;; h) print_usage exit 0 @@ -85,6 +91,20 @@ done exit 0 +fi + +if [[ ${SEARCH_ONLY_CAT} = true ]] +then + # no packages of SEARCH_CAT are installed + [[ ! -d ${MROOT}${INSTALLDB}/${SEARCH_CAT} ]] && exit 1 + + for i in ${INSTALLDB}/${SEARCH_CAT}/* + do + # print categorie and pkgname + echo "$(basename ${i%/*})/$(basename ${i})" + done + + exit 0 fi if [[ ${GET_INVENTORY} = true ]]