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 $ |
# $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 |
{ |
{ |
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 searches packages name in given path" |
echo " -f PATH searches packages name in given path" |
16 |
echo |
echo |
17 |
echo " Examples:" |
echo " Examples:" |
18 |
echo |
echo |
24 |
# default args: |
# default args: |
25 |
GET_INVENTORY=false |
GET_INVENTORY=false |
26 |
SEARCH_ONLY_PATH=false |
SEARCH_ONLY_PATH=false |
27 |
|
SEARCH_ONLY_CAT=false |
28 |
|
|
29 |
while getopts "n:v:b:f: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}" |
46 |
SEARCH_ONLY_PATH="true" |
SEARCH_ONLY_PATH="true" |
47 |
SEARCH_PATH="${OPTARG}" |
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 |
91 |
done |
done |
92 |
|
|
93 |
exit 0 |
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 |
fi |
109 |
|
|
110 |
if [[ ${GET_INVENTORY} = true ]] |
if [[ ${GET_INVENTORY} = true ]] |