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