Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/src/modules/mage/mage.client.class.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2269 by niro, Tue Jan 14 10:34:57 2014 UTC revision 2503 by niro, Fri Sep 11 09:40:21 2015 UTC
# Line 2  Line 2 
2    
3  provide mage  provide mage
4    
 help_mage_inventory()  
 {  
  mecho "get mage.inventory"  
  mecho " prints all installed packages."  
 }  
   
 get_mage_inventory()  
 {  
  magequery -i && mecho "done" || mecho "failed"  
 }  
   
5  help_mage_update()  help_mage_update()
6  {  {
7   mecho "set mage.update [rsync|tarball]"   mecho "set mage.update [rsync|tarball]"
# Line 101  set_mage_clean() Line 90  set_mage_clean()
90  {  {
91   mage clean && mecho "done" || mecho "failed"   mage clean && mecho "done" || mecho "failed"
92  }  }
93    
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    }

Legend:
Removed from v.2269  
changed lines
  Added in v.2503