1 |
#!/bin/bash |
#!/bin/bash |
2 |
|
|
3 |
#query mage database for installed packages |
#query mage database for installed packages |
4 |
# version: 0.3.6-r11 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/magequery.sh,v 1.9 2005-09-09 16:51:17 niro Exp $ |
5 |
|
|
6 |
print_usage() |
print_usage() |
7 |
{ |
{ |
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 |
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}" |
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 |
55 |
shift $(($OPTIND - 1)) |
shift $(($OPTIND - 1)) |
56 |
|
|
57 |
|
|
58 |
source /etc/mage.rc |
source ${MROOT}/etc/mage.rc |
59 |
RETVAL=1 |
RETVAL=1 |
60 |
|
|
61 |
for i in ${INSTALLDB}/*/* |
if [[ ${GET_INVENTORY} = true ]] |
62 |
|
then |
63 |
|
for package in $(find ${MROOT}${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 ${MROOT}${INSTALLDB}/*/* |
82 |
do |
do |
83 |
INST_PNAME=no |
INST_PNAME=no |
84 |
INST_PVER=no |
INST_PVER=no |