--- trunk/mage/usr/lib/mage/magequery.sh 2005/01/10 01:59:03 43 +++ trunk/mage/usr/lib/mage/magequery.sh 2005/09/09 16:51:51 229 @@ -1,7 +1,7 @@ #!/bin/bash #query mage database for installed packages -# version: 0.3.6-r11 +# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/magequery.sh,v 1.10 2005-09-09 16:51:51 niro Exp $ print_usage() { @@ -10,6 +10,7 @@ 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 " -i shows an inventory of all installed packages" echo echo " Examples:" echo @@ -18,7 +19,10 @@ echo } -while getopts "n:v:b:h-" opt ; do +# default args: +GET_INVENTORY=false + +while getopts "n:v:b:hi-" opt ; do case "${opt}" in n) S_PNAME="${OPTARG}" @@ -31,6 +35,9 @@ b) S_PBUILD="${OPTARG}" ;; + i) + GET_INVENTORY="true" + ;; h) print_usage exit 0 @@ -51,7 +58,27 @@ source /etc/mage.rc RETVAL=1 -for i in ${INSTALLDB}/*/* +if [[ ${GET_INVENTORY} = true ]] +then + for package in $(find ${MROOT}${INSTALLDB} -mindepth 2 -maxdepth 2 -type d -printf "%h,%f\n" | sort) + do + pcat="$(basename $(echo ${package} | cut -d, -f1))" + pname="$(echo ${package} | cut -d, -f2)" + if [ -z "${invlist}" ] + then + invlist="${pcat}/${pname}" + else + invlist="${invlist} +${pcat}/${pname}" + fi + done + + # now show the list + echo "${invlist}" + exit 0 +fi + +for i in ${MROOT}${INSTALLDB}/*/* do INST_PNAME=no INST_PVER=no