Contents of /branches/mage-next/usr/lib/mage/mage4.sh
Parent Directory | Revision Log
Revision 2358 -
(show annotations)
(download)
(as text)
Mon Jan 6 12:31:51 2014 UTC (10 years, 4 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/mage4.sh
File MIME type: application/x-sh
File size: 13970 byte(s)
Mon Jan 6 12:31:51 2014 UTC (10 years, 4 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/mage4.sh
File MIME type: application/x-sh
File size: 13970 byte(s)
-fixed usage description of install/pretend-build-prerequisites
1 | #!/bin/bash |
2 | # Magellan Linux Installer (mage.sh) |
3 | # $Id$ |
4 | |
5 | # default die function |
6 | die() |
7 | { |
8 | xtitleclean |
9 | mqueryfeature "debug" && echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
10 | echo -e ${COLRED}"$@"${COLDEFAULT} |
11 | exit 1 |
12 | } |
13 | |
14 | # include all needed files |
15 | [ -f /etc/mage.rc.global ] && \ |
16 | source /etc/mage.rc.global || \ |
17 | die "/etc/mage.rc.global missing" |
18 | |
19 | [ -f ${MAGERC} ] && source ${MAGERC} || \ |
20 | die "Your ${MAGERC} is missing. Aborting." |
21 | |
22 | [ -f ${MLIBDIR}/mage4.functions.sh ] && \ |
23 | source ${MLIBDIR}/mage4.functions.sh || \ |
24 | die "mage functions missing" |
25 | |
26 | # export default path |
27 | export PATH="${PATH}:${MLIBDIR}" |
28 | |
29 | # export the default C locale |
30 | export LC_ALL=C |
31 | |
32 | # sanity checks |
33 | [ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} |
34 | |
35 | if [ ! -e ${VIRTUALDB_DEFAULTS} ] && |
36 | [[ $1 != update ]] && |
37 | [[ $1 != update-rsync ]] && |
38 | [[ $1 != update-tarball ]] |
39 | then |
40 | echo |
41 | echo "Please choose an profile from the mage tree." |
42 | echo "ln -snf ${MAGEDIR}/profiles/profilename /etc/mage-profile" |
43 | exit 1 |
44 | fi |
45 | |
46 | # default messages |
47 | showversion() |
48 | { |
49 | local MAGEVERSION="$(< ${MLIBDIR}/version)" |
50 | |
51 | echo -en "Magellan Package Manager v${MAGEVERSION} " |
52 | echo -e "-- Niels Rogalla (niro@magellan-linux.de)" |
53 | } |
54 | |
55 | print_usage() |
56 | { |
57 | #showversion |
58 | #echo |
59 | echo "Usage: $(basename $0) [option] pkgname ..." |
60 | echo "Options:" |
61 | echo " pretend - pretends dependencies of a package" |
62 | echo " srcpretend - pretends dependencies of a package (build from source)" |
63 | echo " install - installs a package" |
64 | echo " srcinstall - installs a package from source" |
65 | echo " uninstall - removes a package" |
66 | echo " update - updates the mage-tree via default sync method" |
67 | echo " update-rsync - updates the mage-tree via rsync" |
68 | echo " update-tarball - updates the mage-tree via a tarball" |
69 | echo " uppretend - pretend dependencies for a system upgrade" |
70 | echo " upgrade - runs a complete system upgrade" |
71 | echo " srcuppretend - pretend dependencies for a system upgrade from source" |
72 | echo " srcupgrade - runs a complete system upgrade from source" |
73 | echo " pretend-build-prerequisites - prints build prerequisites" |
74 | echo " install-build-prerequisites - install build prerequisites" |
75 | echo " search - searches mage-tree for a package" |
76 | echo " clean - removes *all* downloaded packages" |
77 | echo " unpack - unpacks *all* needed package for 'foo'" |
78 | echo " download - downloads *all* needed packages for 'foo'" |
79 | echo " print-features - prints all enabled mage-features" |
80 | echo " version - prints version info" |
81 | echo " regen-mage-tree - regenerates the whole mage database (for devs only)" |
82 | echo |
83 | echo "Other options:" |
84 | # echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE" |
85 | # echo "Builds a Package with its dependencies, but won't install anything." |
86 | # echo |
87 | echo "MAGE_DISTRIBUTION=unstable $(basename $0) [src]install PACKAGE" |
88 | echo "Overrides stable packages; you can install packages that are marked unstable." |
89 | echo |
90 | echo "MAGE_DISTRIBUTION=testing $(basename $0) [src]install PACKAGE" |
91 | echo "Overrides stable packages; you can install packages that are marked testing." |
92 | echo |
93 | echo "NOCOLORS=true $(basename $0) [src]install PACKAGE" |
94 | echo "Disables all colors in the messages." |
95 | echo |
96 | } |
97 | |
98 | |
99 | showversion |
100 | echo |
101 | |
102 | # install method |
103 | METHOD="$1" |
104 | |
105 | # initial unversionized packagename, gets overridden later on |
106 | MAGENAME="$2" |
107 | |
108 | if [[ ${METHOD} != upgrade ]] && |
109 | [[ ${METHOD} != srcupgrade ]] && |
110 | [[ ${METHOD} != uppretend ]] && |
111 | [[ ${METHOD} != srcuppretend ]] && |
112 | [[ ${METHOD} != update ]] && |
113 | [[ ${METHOD} != update-rsync ]] && |
114 | [[ ${METHOD} != update-tarball ]] && |
115 | [[ ${METHOD} != clean ]] && |
116 | [[ ${METHOD} != version ]] && |
117 | [[ ${METHOD} != search ]] && |
118 | [[ ${METHOD} != regen-mage-tree ]] && |
119 | [[ ${METHOD} != print-features ]] |
120 | then |
121 | [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 |
122 | fi |
123 | |
124 | # set PKGDIR and BUILDDIR to MROOT |
125 | if [[ -n ${MROOT} ]] |
126 | then |
127 | PKGDIR=${MROOT}/${PKGDIR} |
128 | BUILDDIR=${MROOT}/${BUILDDIR} |
129 | fi |
130 | |
131 | # before anything run mage_setup |
132 | mage_setup || die "error in mage_setup()" |
133 | |
134 | # load supported mage features |
135 | load_mage_features |
136 | |
137 | # query debug mode |
138 | if mqueryfeature "debug" |
139 | then |
140 | depwalker_debug="--debug" |
141 | else |
142 | depwalker_debug="" |
143 | fi |
144 | |
145 | case ${METHOD} in |
146 | download) |
147 | have_root_privileges || die "You must be root to run this operation." |
148 | |
149 | # first of all get the right pkg which going to be installed |
150 | PCAT="$(pname2pcat ${MAGENAME})" |
151 | |
152 | # package does not exists |
153 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
154 | |
155 | # source the highest magefile of this pkg |
156 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
157 | |
158 | # package is masked |
159 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
160 | |
161 | # convert PKGNAME to PNAME/PVER/PBUILD |
162 | # we're working *only* with these three vars from here on |
163 | PNAME="$(pkgname2pname ${PKGNAME})" |
164 | PVER="$(pkgname2pver ${PKGNAME})" |
165 | PBUILD="$(pkgname2pbuild ${PKGNAME})" |
166 | |
167 | # get all dependencies of this package |
168 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
169 | --method install \ |
170 | --pcat ${PCAT} \ |
171 | --pname ${PNAME} \ |
172 | --pver ${PVER} \ |
173 | --pbuild ${PBUILD} \ |
174 | ${depwalker_debug})" |
175 | fetch_packages ${ALLDEPS} || die "fetching packages" |
176 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
177 | ;; |
178 | |
179 | srcdownload) |
180 | have_root_privileges || die "You must be root to run this operation." |
181 | |
182 | # first of all get the right pkg which going to be installed |
183 | PCAT="$(pname2pcat ${MAGENAME})" |
184 | |
185 | # package does not exists |
186 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
187 | |
188 | # source the highest magefile of this pkg |
189 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
190 | |
191 | # package is masked |
192 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
193 | |
194 | # convert PKGNAME to PNAME/PVER/PBUILD |
195 | # we're working *only* with these three vars from here on |
196 | PNAME="$(pkgname2pname ${PKGNAME})" |
197 | PVER="$(pkgname2pver ${PKGNAME})" |
198 | PBUILD="$(pkgname2pbuild ${PKGNAME})" |
199 | |
200 | # get all dependencies of this package |
201 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
202 | --method srcinstall \ |
203 | --pcat ${PCAT} \ |
204 | --pname ${PNAME} \ |
205 | --pver ${PVER} \ |
206 | --pbuild ${PBUILD} \ |
207 | ${depwalker_debug})" |
208 | fetch_packages ${ALLDEPS} || die "fetching packages" |
209 | ;; |
210 | |
211 | pretend|srcpretend|pretend-build-prerequisites) |
212 | # first of all get the right pkg which going to be installed |
213 | PCAT="$(pname2pcat ${MAGENAME})" |
214 | |
215 | # package does not exists |
216 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
217 | |
218 | # source the highest magefile of this pkg |
219 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
220 | |
221 | # package is masked |
222 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
223 | |
224 | # convert PKGNAME to PNAME/PVER/PBUILD |
225 | # we're working *only* with these three vars from here on |
226 | PNAME="$(pkgname2pname ${PKGNAME})" |
227 | PVER="$(pkgname2pver ${PKGNAME})" |
228 | PBUILD="$(pkgname2pbuild ${PKGNAME})" |
229 | |
230 | # abort if already installed |
231 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
232 | then |
233 | echo -en "Package " |
234 | echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
235 | echo -e " already installed." |
236 | exit 3 |
237 | fi |
238 | # get all dependencies of this package |
239 | ${MLIBDIR}/depwalker.sh \ |
240 | --method ${METHOD} \ |
241 | --pcat ${PCAT} \ |
242 | --pname ${PNAME} \ |
243 | --pver ${PVER} \ |
244 | --pbuild ${PBUILD} \ |
245 | ${depwalker_debug} |
246 | ;; |
247 | |
248 | install|install-build-prerequisites) |
249 | have_root_privileges || die "You must be root to run this operation." |
250 | |
251 | # first of all get the right pkg which going to be installed |
252 | PCAT="$(pname2pcat ${MAGENAME})" |
253 | |
254 | # package does not exists |
255 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
256 | |
257 | # source the highest magefile of this pkg |
258 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
259 | |
260 | # package is masked |
261 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
262 | |
263 | # convert PKGNAME to PNAME/PVER/PBUILD |
264 | # we're working *only* with these three vars from here on |
265 | PNAME="$(pkgname2pname ${PKGNAME})" |
266 | PVER="$(pkgname2pver ${PKGNAME})" |
267 | PBUILD="$(pkgname2pbuild ${PKGNAME})" |
268 | |
269 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
270 | then |
271 | echo -en "Package " |
272 | echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
273 | echo -e " already installed." |
274 | exit 3 |
275 | fi |
276 | |
277 | # get all dependencies of this package |
278 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
279 | --method ${METHOD} \ |
280 | --pcat ${PCAT} \ |
281 | --pname ${PNAME} \ |
282 | --pver ${PVER} \ |
283 | --pbuild ${PBUILD} \ |
284 | ${depwalker_debug})" |
285 | |
286 | # first fetch all packages |
287 | fetch_packages ${ALLDEPS} || die "fetching packages" |
288 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
289 | install_packages ${ALLDEPS} || die "installing packages" |
290 | ;; |
291 | |
292 | srcinstall) |
293 | have_root_privileges || die "You must be root to run this operation." |
294 | |
295 | # first of all get the right pkg which going to be installed |
296 | PCAT="$(pname2pcat ${MAGENAME})" |
297 | |
298 | # package does not exists |
299 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
300 | |
301 | # source the highest magefile of this pkg |
302 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
303 | |
304 | # package is masked |
305 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
306 | |
307 | # convert PKGNAME to PNAME/PVER/PBUILD |
308 | # we're working *only* with these three vars from here on |
309 | PNAME="$(pkgname2pname ${PKGNAME})" |
310 | PVER="$(pkgname2pver ${PKGNAME})" |
311 | PBUILD="$(pkgname2pbuild ${PKGNAME})" |
312 | |
313 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
314 | then |
315 | echo -en "Package " |
316 | echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
317 | echo -e " already installed." |
318 | exit 3 |
319 | fi |
320 | |
321 | # get all dependencies of this package |
322 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
323 | --method ${METHOD} \ |
324 | --pcat ${PCAT} \ |
325 | --pname ${PNAME} \ |
326 | --pver ${PVER} \ |
327 | --pbuild ${PBUILD} \ |
328 | ${depwalker_debug})" |
329 | |
330 | install_packages --src-install ${ALLDEPS} || die "src-installing packages" |
331 | ;; |
332 | |
333 | uninstall) |
334 | have_root_privileges || die "You must be root to run this operation." |
335 | |
336 | ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" |
337 | if [ -z "${ALLDEPS}" ] |
338 | then |
339 | die "No package installed named '${MAGENAME}'." |
340 | fi |
341 | uninstall_packages ${ALLDEPS} |
342 | ;; |
343 | |
344 | uppretend|srcuppretend) |
345 | ${MLIBDIR}/depwalker.sh \ |
346 | --method ${METHOD} \ |
347 | --pcat ${METHOD} \ |
348 | --pname ${METHOD} \ |
349 | --pver ${METHOD} \ |
350 | --pbuild ${METHOD} \ |
351 | ${depwalker_debug} |
352 | ;; |
353 | |
354 | upgrade) |
355 | have_root_privileges || die "You must be root to run this operation." |
356 | |
357 | # get all dependencies of *all* installed packages |
358 | # fake pcat,pname,pver,pbuild ... |
359 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
360 | --method ${METHOD} \ |
361 | --pcat ${METHOD} \ |
362 | --pname ${METHOD} \ |
363 | --pver ${METHOD} \ |
364 | --pbuild ${METHOD} \ |
365 | ${depwalker_debug})" |
366 | |
367 | # first fetch all packages |
368 | fetch_packages ${ALLDEPS} || die "fetching packages" |
369 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
370 | install_packages ${ALLDEPS} || die "installing packages" |
371 | ;; |
372 | |
373 | srcupgrade) |
374 | have_root_privileges || die "You must be root to run this operation." |
375 | |
376 | # get all dependencies of *all* installed packages |
377 | # fake pcat,pname,pver,pbuild ... |
378 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
379 | --method ${METHOD} \ |
380 | --pcat ${METHOD} \ |
381 | --pname ${METHOD} \ |
382 | --pver ${METHOD} \ |
383 | --pbuild ${METHOD} \ |
384 | ${depwalker_debug})" |
385 | |
386 | install_packages --src-install ${ALLDEPS} || die "src-installing packages" |
387 | ;; |
388 | |
389 | search) |
390 | pkgsearch "${MAGENAME}" |
391 | ;; |
392 | |
393 | unpack) |
394 | have_root_privileges || die "You must be root to run this operation." |
395 | |
396 | # first of all get the right pkg which going to be installed |
397 | PCAT="$(pname2pcat ${MAGENAME})" |
398 | |
399 | # package does not exists |
400 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." |
401 | |
402 | # source the highest magefile of this pkg |
403 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
404 | |
405 | # package is masked |
406 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
407 | |
408 | # convert PKGNAME to PNAME/PVER/PBUILD |
409 | # we're working *only* with these three vars from here on |
410 | PNAME="$(pkgname2pname ${PKGNAME})" |
411 | PVER="$(pkgname2pver ${PKGNAME})" |
412 | PBUILD="$(pkgname2pbuild ${PKGNAME})" |
413 | |
414 | # get all dependencies of this package |
415 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
416 | --method install \ |
417 | --pcat ${PCAT} \ |
418 | --pname ${PNAME} \ |
419 | --pver ${PVER} \ |
420 | --pbuild ${PBUILD} \ |
421 | ${depwalker_debug})" |
422 | |
423 | fetch_packages ${ALLDEPS} || die "fetching packages" |
424 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
425 | unpack_packages ${ALLDEPS} || die "unpacking packages" |
426 | ;; |
427 | |
428 | update) |
429 | have_root_privileges || die "You must be root to run this operation." |
430 | # default to tarball |
431 | [[ -z ${MAGE_UPDATE_METHOD} ]] && MAGE_UPDATE_METHOD="tarball" |
432 | case ${MAGE_UPDATE_METHOD} in |
433 | rsync) syncmage ;; |
434 | tarball) syncmage_tarball ;; |
435 | *) die "Unknown MAGE_UPDATE_METHOD defined." ;; |
436 | esac |
437 | ;; |
438 | |
439 | update-rsync) |
440 | have_root_privileges || die "You must be root to run this operation." |
441 | syncmage |
442 | ;; |
443 | |
444 | update-tarball) |
445 | have_root_privileges || die "You must be root to run this operation." |
446 | syncmage_tarball |
447 | ;; |
448 | |
449 | clean) |
450 | have_root_privileges || die "You must be root to run this operation." |
451 | cleanpkg |
452 | ;; |
453 | |
454 | version) |
455 | # showversion |
456 | exit 0 |
457 | ;; |
458 | |
459 | regen-mage-tree) |
460 | have_root_privileges || die "You must be root to run this operation." |
461 | |
462 | if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] |
463 | then |
464 | echo "SMAGESCRIPTSDIR not found. Check your mage.rc or check out smage repos." |
465 | exit 1 |
466 | fi |
467 | for i in $(find ${SMAGESCRIPTSDIR} -type f -name "*.smage2") |
468 | do |
469 | smage2 only-regen-tree "${i}" |
470 | done |
471 | ;; |
472 | |
473 | print-features) |
474 | mprintfeatures |
475 | ;; |
476 | |
477 | *) |
478 | print_usage |
479 | ;; |
480 | esac |
Properties
Name | Value |
---|---|
svn:executable | * |