Annotation of /mcore-src/trunk/mcore-tools/src/modules/mage/mage.client.class.in
Parent Directory | Revision Log
Revision 2503 -
(hide annotations)
(download)
Fri Sep 11 09:40:21 2015 UTC (8 years, 8 months ago) by niro
File size: 4066 byte(s)
Fri Sep 11 09:40:21 2015 UTC (8 years, 8 months ago) by niro
File size: 4066 byte(s)
-removed *_mage_iventory() functions and provide a full featured mage_query() function instead
1 | niro | 1248 | # $Id$ |
2 | |||
3 | provide mage | ||
4 | |||
5 | help_mage_update() | ||
6 | { | ||
7 | niro | 2096 | mecho "set mage.update [rsync|tarball]" |
8 | niro | 1248 | mecho " fetches updates of the package database." |
9 | } | ||
10 | |||
11 | set_mage_update() | ||
12 | { | ||
13 | niro | 2096 | local method |
14 | case $1 in | ||
15 | tarball) method="update-tarball" ;; | ||
16 | rsync) method="update" ;; | ||
17 | *) method="update" ;; | ||
18 | esac | ||
19 | |||
20 | mage "${method}" && mecho "done" || mecho "failed" | ||
21 | niro | 1248 | } |
22 | |||
23 | niro | 1347 | get_mage_upgrade() |
24 | niro | 1248 | { |
25 | mage uppretend && mecho "done" || mecho "failed" | ||
26 | } | ||
27 | |||
28 | help_mage_upgrade() | ||
29 | { | ||
30 | niro | 1347 | mecho "get mage.upgrade" |
31 | mecho " shows possible updates missing on this system." | ||
32 | mecho "or" | ||
33 | niro | 1248 | mecho "set mage.upgrade" |
34 | mecho " upgrades the whole system." | ||
35 | } | ||
36 | |||
37 | set_mage_upgrade() | ||
38 | { | ||
39 | mage upgrade && mecho "done" || mecho "failed" | ||
40 | } | ||
41 | |||
42 | help_mage_package() | ||
43 | { | ||
44 | mecho "set mage.package [method] [package]" | ||
45 | mecho " package install operations on this system" | ||
46 | mecho " methods:" | ||
47 | mecho " install - installs given package" | ||
48 | mecho " uninstall - uninstalls given package" | ||
49 | mecho "or" | ||
50 | mecho "get mage.package [method] [package]" | ||
51 | mecho " package information operations" | ||
52 | mecho " methods:" | ||
53 | mecho " pretend - pretend dependencies of given package" | ||
54 | mecho " search - searches the database for matching packages" | ||
55 | } | ||
56 | |||
57 | set_mage_package() | ||
58 | { | ||
59 | niro | 2269 | local method="${CLASS_ARGV[0]}" |
60 | local package="${CLASS_ARGV[1]}" | ||
61 | niro | 1248 | [[ -z ${method} ]] && help_mage_package && return 1 |
62 | niro | 1347 | [[ -z ${package} ]] && help_mage_package && return 1 |
63 | niro | 1248 | |
64 | case ${method} in | ||
65 | niro | 1347 | install|uninstall) mage "${method}" "${package}" && mecho "done" || mecho "failed" ;; |
66 | niro | 1248 | *) help_mage_package && return 1 ;; |
67 | esac | ||
68 | } | ||
69 | |||
70 | get_mage_package() | ||
71 | { | ||
72 | niro | 2269 | local method="${CLASS_ARGV[0]}" |
73 | local package="${CLASS_ARGV[1]}" | ||
74 | niro | 1248 | [[ -z ${method} ]] && help_mage_package && return 1 |
75 | niro | 1347 | [[ -z ${package} ]] && help_mage_package && return 1 |
76 | niro | 1248 | |
77 | case ${method} in | ||
78 | niro | 1347 | pretend|search) mage "${method}" "${package}" && mecho "done" || mecho "failed" ;; |
79 | niro | 1248 | *) help_mage_package && return 1 ;; |
80 | esac | ||
81 | } | ||
82 | |||
83 | help_mage_clean() | ||
84 | { | ||
85 | mecho "set mage.clean" | ||
86 | mecho " deletes all downloaded packages from the system" | ||
87 | } | ||
88 | |||
89 | set_mage_clean() | ||
90 | { | ||
91 | mage clean && mecho "done" || mecho "failed" | ||
92 | } | ||
93 | niro | 2503 | |
94 | help_mage_query() | ||
95 | { | ||
96 | mecho "get mage.query [method] [arguments]" | ||
97 | mecho " queries the mage install database for packages and files" | ||
98 | mecho " methods:" | ||
99 | mecho " package - search an installed package" | ||
100 | mecho " get mage.query package [name]" | ||
101 | mecho " get mage.query package [name] [version]" | ||
102 | mecho " get mage.query package [name] [version] [build]" | ||
103 | mecho " category - search for all packages of a category" | ||
104 | mecho " get mage.query category [category]" | ||
105 | mecho " inventory - prints the whole inventory of all installed packages" | ||
106 | mecho " file - searches for a package which owns file name" | ||
107 | mecho " get mage.query file [filename]" | ||
108 | mecho " path - search for a package which owns an exact path to a file" | ||
109 | mecho " get mage.query path [path_to_file]" | ||
110 | } | ||
111 | |||
112 | get_mage_query() | ||
113 | { | ||
114 | local method="${CLASS_ARGV[0]}" | ||
115 | local value="${CLASS_ARGV[1]}" | ||
116 | local pname | ||
117 | local pver | ||
118 | local pbuild | ||
119 | local cmd | ||
120 | local retval | ||
121 | |||
122 | cmd="magequery" | ||
123 | |||
124 | case "${method}" in | ||
125 | package) | ||
126 | pname="${CLASS_ARGV[1]}" | ||
127 | pver="${CLASS_ARGV[2]}" | ||
128 | pbuild="${CLASS_ARGV[3]}" | ||
129 | if [[ -z ${pname} ]] | ||
130 | then | ||
131 | echo "at least a package name must be given with method package" | ||
132 | return 1 | ||
133 | else | ||
134 | cmd+=" -n ${pname}" | ||
135 | fi | ||
136 | [[ -n ${pver} ]] && cmd+=" -v ${pver}" | ||
137 | [[ -n ${pbuild} ]] && cmd+=" -b ${pbuild}" | ||
138 | ;; | ||
139 | |||
140 | category) | ||
141 | if [[ -z ${value} ]] | ||
142 | then | ||
143 | eecho "a category name must be given with method category" | ||
144 | return 1 | ||
145 | else | ||
146 | cmd+="-c ${value}" | ||
147 | fi | ||
148 | ;; | ||
149 | |||
150 | inventory) cmd+="-i" ;; | ||
151 | |||
152 | file) | ||
153 | if [[ -z ${value} ]] | ||
154 | then | ||
155 | eecho "a filename must be given with method file" | ||
156 | return 1 | ||
157 | else | ||
158 | cmd+="-f ${file}" | ||
159 | fi | ||
160 | ;; | ||
161 | |||
162 | path) | ||
163 | if [[ -z ${value} ]] | ||
164 | then | ||
165 | eecho "a path must be given with method path" | ||
166 | return 1 | ||
167 | else | ||
168 | cmd+="-e ${path}" | ||
169 | fi | ||
170 | ;; | ||
171 | |||
172 | *) | ||
173 | eecho "Unknown method '${method}'" | ||
174 | return 1 | ||
175 | ;; | ||
176 | esac | ||
177 | |||
178 | retval="$(${cmd})" | ||
179 | if [[ $? = 0 ]] | ||
180 | then | ||
181 | rvecho "${retval}" | ||
182 | fi | ||
183 | } |