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