1 |
#!/bin/sh |
#!/bin/bash |
2 |
# Magellan Linux Installer (mage.sh) |
# Magellan Linux Installer (mage.sh) |
3 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.sh,v 1.17 2008-06-16 09:29:57 niro Exp $ |
# $Id$ |
4 |
|
|
5 |
# default die function |
# default die function |
6 |
die() |
die() |
7 |
{ |
{ |
8 |
echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
xtitleclean |
9 |
|
mqueryfeature "debug" && echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
10 |
echo -e ${COLRED}"$@"${COLDEFAULT} |
echo -e ${COLRED}"$@"${COLDEFAULT} |
11 |
exit 1 |
exit 1 |
12 |
} |
} |
23 |
source ${MLIBDIR}/mage4.functions.sh || \ |
source ${MLIBDIR}/mage4.functions.sh || \ |
24 |
die "mage functions missing" |
die "mage functions missing" |
25 |
|
|
|
## only for tests -> normally in /etc/rc.d/init.d/functions |
|
|
COLRED="\033[1;6m\033[31m" |
|
|
COLGREEN="\033[1;6m\033[32m" |
|
|
COLYELLOW="\033[1;6m\033[33m" |
|
|
COLBLUE="\033[1;6m\033[34m" |
|
|
COLMAGENTA="\033[1;6m\033[35m" |
|
|
COLWHITE="\033[1;6m\033[37m" |
|
|
COLGRAY="\033[0;6m\033[37m" |
|
|
COLBOLD="\033[1m" |
|
|
COLDEFAULT="\033[0m" |
|
|
|
|
|
if [[ ${NOCOLORS} = true ]] |
|
|
then |
|
|
COLRED="" |
|
|
COLGREEN="" |
|
|
COLYELLOW="" |
|
|
COLBLUE="" |
|
|
COLMAGENTA="" |
|
|
COLWHITE="" |
|
|
COLGRAY="" |
|
|
COLBOLD="" |
|
|
COLDEFAULT="" |
|
|
fi |
|
|
|
|
26 |
# export default path |
# export default path |
27 |
export PATH="${PATH}:${MLIBDIR}" |
export PATH="${PATH}:${MLIBDIR}" |
28 |
|
|
32 |
# sanity checks |
# sanity checks |
33 |
[ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} |
[ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} |
34 |
|
|
35 |
if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] |
if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] && [[ $1 != update-tarball ]] |
36 |
then |
then |
37 |
echo |
echo |
38 |
echo "Please choose an profile from the mage tree." |
echo "Please choose an profile from the mage tree." |
66 |
echo " upgrade - runs a complete system upgrade" |
echo " upgrade - runs a complete system upgrade" |
67 |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
68 |
echo " srcupgrade - runs a complete system upgrade from source" |
echo " srcupgrade - runs a complete system upgrade from source" |
69 |
|
echo " pretend-build-prerequisites" |
70 |
|
echo " install-build-prerequisites" |
71 |
echo " search - searches mage-tree for a package" |
echo " search - searches mage-tree for a package" |
72 |
echo " clean - removes *all* downloaded packages" |
echo " clean - removes *all* downloaded packages" |
73 |
echo " unpack - unpacks *all* needed package for 'foo'" |
echo " unpack - unpacks *all* needed package for 'foo'" |
74 |
echo " download - downloads *all* needed packages for 'foo'" |
echo " download - downloads *all* needed packages for 'foo'" |
75 |
|
echo " print-features - prints all enabled mage-features" |
76 |
echo " version - prints version info" |
echo " version - prints version info" |
77 |
echo " regen-mage-tree - regenerates the whole mage database (for devs only)" |
echo " regen-mage-tree - regenerates the whole mage database (for devs only)" |
78 |
echo |
echo |
98 |
# install method |
# install method |
99 |
METHOD="$1" |
METHOD="$1" |
100 |
|
|
101 |
# initial unversionized packagename, gets overridden later |
# initial unversionized packagename, gets overridden later on |
102 |
MAGENAME="$2" |
MAGENAME="$2" |
103 |
|
|
104 |
if [[ ${METHOD} != upgrade ]] && \ |
if [[ ${METHOD} != upgrade ]] && |
105 |
[[ ${METHOD} != srcupgrade ]] && \ |
[[ ${METHOD} != srcupgrade ]] && |
106 |
[[ ${METHOD} != uppretend ]] && \ |
[[ ${METHOD} != uppretend ]] && |
107 |
[[ ${METHOD} != srcuppretend ]] && \ |
[[ ${METHOD} != srcuppretend ]] && |
108 |
[[ ${METHOD} != update ]] && \ |
[[ ${METHOD} != update ]] && |
109 |
[[ ${METHOD} != update-tarball ]] && \ |
[[ ${METHOD} != update-tarball ]] && |
110 |
[[ ${METHOD} != clean ]] && \ |
[[ ${METHOD} != clean ]] && |
111 |
[[ ${METHOD} != version ]] && \ |
[[ ${METHOD} != version ]] && |
112 |
[[ ${METHOD} != search ]] && \ |
[[ ${METHOD} != search ]] && |
113 |
[[ ${METHOD} != regen-mage-tree ]] |
[[ ${METHOD} != regen-mage-tree ]] && |
114 |
|
[[ ${METHOD} != print-features ]] |
115 |
then |
then |
116 |
[[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 |
[[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 |
117 |
fi |
fi |
126 |
# before anything run mage_setup |
# before anything run mage_setup |
127 |
mage_setup || die "error in mage_setup()" |
mage_setup || die "error in mage_setup()" |
128 |
|
|
129 |
|
# load supported mage features |
130 |
|
load_mage_features |
131 |
|
|
132 |
|
# query debug mode |
133 |
|
if mqueryfeature "debug" |
134 |
|
then |
135 |
|
depwalker_debug="--debug" |
136 |
|
else |
137 |
|
depwalker_debug="" |
138 |
|
fi |
139 |
|
|
140 |
case ${METHOD} in |
case ${METHOD} in |
141 |
download) |
download) |
142 |
|
have_root_privileges || die "You must be root to run this operation." |
143 |
|
|
144 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
145 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
146 |
|
|
165 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
166 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
167 |
--pver ${PVER} \ |
--pver ${PVER} \ |
168 |
--pbuild ${PBUILD})" |
--pbuild ${PBUILD} \ |
169 |
|
${depwalker_debug})" |
170 |
fetch_packages ${ALLDEPS} || die "fetching packages" |
fetch_packages ${ALLDEPS} || die "fetching packages" |
171 |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
172 |
;; |
;; |
173 |
|
|
174 |
srcdownload) |
srcdownload) |
175 |
|
have_root_privileges || die "You must be root to run this operation." |
176 |
|
|
177 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
178 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
179 |
|
|
198 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
199 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
200 |
--pver ${PVER} \ |
--pver ${PVER} \ |
201 |
--pbuild ${PBUILD})" |
--pbuild ${PBUILD} \ |
202 |
|
${depwalker_debug})" |
203 |
fetch_packages ${ALLDEPS} || die "fetching packages" |
fetch_packages ${ALLDEPS} || die "fetching packages" |
204 |
;; |
;; |
205 |
|
|
206 |
pretend|srcpretend) |
pretend|srcpretend|pretend-build-prerequisites) |
207 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
208 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
209 |
|
|
236 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
237 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
238 |
--pver ${PVER} \ |
--pver ${PVER} \ |
239 |
--pbuild ${PBUILD} |
--pbuild ${PBUILD} \ |
240 |
|
${depwalker_debug} |
241 |
;; |
;; |
242 |
|
|
243 |
install) |
install|install-build-prerequisites) |
244 |
|
have_root_privileges || die "You must be root to run this operation." |
245 |
|
|
246 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
247 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
248 |
|
|
275 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
276 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
277 |
--pver ${PVER} \ |
--pver ${PVER} \ |
278 |
--pbuild ${PBUILD})" |
--pbuild ${PBUILD} \ |
279 |
|
${depwalker_debug})" |
280 |
|
|
281 |
# first fetch all packages |
# first fetch all packages |
282 |
fetch_packages ${ALLDEPS} || die "fetching packages" |
fetch_packages ${ALLDEPS} || die "fetching packages" |
283 |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
|
unpack_packages ${ALLDEPS} || die "unpacking packages" |
|
284 |
install_packages ${ALLDEPS} || die "installing packages" |
install_packages ${ALLDEPS} || die "installing packages" |
285 |
;; |
;; |
286 |
|
|
287 |
srcinstall) |
srcinstall) |
288 |
|
have_root_privileges || die "You must be root to run this operation." |
289 |
|
|
290 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
291 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
292 |
|
|
319 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
320 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
321 |
--pver ${PVER} \ |
--pver ${PVER} \ |
322 |
--pbuild ${PBUILD})" |
--pbuild ${PBUILD} \ |
323 |
|
${depwalker_debug})" |
324 |
|
|
325 |
install_packages --src-install ${ALLDEPS} || die "src-installing packages" |
install_packages --src-install ${ALLDEPS} || die "src-installing packages" |
326 |
;; |
;; |
327 |
|
|
328 |
uninstall) |
uninstall) |
329 |
ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" |
have_root_privileges || die "You must be root to run this operation." |
330 |
if [ -z "${ALLDEPS}" ] |
|
331 |
then |
ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" |
332 |
die "No package installed named '${MAGENAME}'." |
if [ -z "${ALLDEPS}" ] |
333 |
fi |
then |
334 |
uninstall_packages ${ALLDEPS} |
die "No package installed named '${MAGENAME}'." |
335 |
|
fi |
336 |
|
uninstall_packages ${ALLDEPS} |
337 |
;; |
;; |
338 |
|
|
339 |
uppretend|srcuppretend) |
uppretend|srcuppretend) |
342 |
--pcat ${METHOD} \ |
--pcat ${METHOD} \ |
343 |
--pname ${METHOD} \ |
--pname ${METHOD} \ |
344 |
--pver ${METHOD} \ |
--pver ${METHOD} \ |
345 |
--pbuild ${METHOD} |
--pbuild ${METHOD} \ |
346 |
|
${depwalker_debug} |
347 |
;; |
;; |
348 |
|
|
349 |
upgrade) |
upgrade) |
350 |
|
have_root_privileges || die "You must be root to run this operation." |
351 |
|
|
352 |
# get all dependencies of *all* installed packages |
# get all dependencies of *all* installed packages |
353 |
# fake pcat,pname,pver,pbuild ... |
# fake pcat,pname,pver,pbuild ... |
354 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
356 |
--pcat ${METHOD} \ |
--pcat ${METHOD} \ |
357 |
--pname ${METHOD} \ |
--pname ${METHOD} \ |
358 |
--pver ${METHOD} \ |
--pver ${METHOD} \ |
359 |
--pbuild ${METHOD})" |
--pbuild ${METHOD} \ |
360 |
|
${depwalker_debug})" |
361 |
|
|
362 |
# first fetch all packages |
# first fetch all packages |
363 |
fetch_packages ${ALLDEPS} || die "fetching packages" |
fetch_packages ${ALLDEPS} || die "fetching packages" |
364 |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
|
unpack_packages ${ALLDEPS} || die "unpacking packages" |
|
365 |
install_packages ${ALLDEPS} || die "installing packages" |
install_packages ${ALLDEPS} || die "installing packages" |
366 |
;; |
;; |
367 |
|
|
368 |
srcupgrade) |
srcupgrade) |
369 |
|
have_root_privileges || die "You must be root to run this operation." |
370 |
|
|
371 |
# get all dependencies of *all* installed packages |
# get all dependencies of *all* installed packages |
372 |
# fake pcat,pname,pver,pbuild ... |
# fake pcat,pname,pver,pbuild ... |
373 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
375 |
--pcat ${METHOD} \ |
--pcat ${METHOD} \ |
376 |
--pname ${METHOD} \ |
--pname ${METHOD} \ |
377 |
--pver ${METHOD} \ |
--pver ${METHOD} \ |
378 |
--pbuild ${METHOD})" |
--pbuild ${METHOD} \ |
379 |
|
${depwalker_debug})" |
380 |
|
|
381 |
install_packages --src-install ${ALLDEPS} || die "src-installing packages" |
install_packages --src-install ${ALLDEPS} || die "src-installing packages" |
382 |
;; |
;; |
386 |
;; |
;; |
387 |
|
|
388 |
unpack) |
unpack) |
389 |
|
have_root_privileges || die "You must be root to run this operation." |
390 |
|
|
391 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
392 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
393 |
|
|
412 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
413 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
414 |
--pver ${PVER} \ |
--pver ${PVER} \ |
415 |
--pbuild ${PBUILD})" |
--pbuild ${PBUILD} \ |
416 |
|
${depwalker_debug})" |
417 |
|
|
418 |
fetch_packages ${ALLDEPS} || die "fetching packages" |
fetch_packages ${ALLDEPS} || die "fetching packages" |
419 |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
420 |
unpack_packages ${ALLDEPS} || die "unpacking packages" |
unpack_packages ${ALLDEPS} || die "unpacking packages" |
421 |
;; |
;; |
422 |
|
|
423 |
update) |
update) |
424 |
|
have_root_privileges || die "You must be root to run this operation." |
425 |
syncmage |
syncmage |
426 |
;; |
;; |
427 |
|
|
428 |
update-tarball) |
update-tarball) |
429 |
|
have_root_privileges || die "You must be root to run this operation." |
430 |
syncmage_tarball |
syncmage_tarball |
431 |
;; |
;; |
432 |
|
|
433 |
clean) |
clean) |
434 |
|
have_root_privileges || die "You must be root to run this operation." |
435 |
cleanpkg |
cleanpkg |
436 |
;; |
;; |
437 |
|
|
441 |
;; |
;; |
442 |
|
|
443 |
regen-mage-tree) |
regen-mage-tree) |
444 |
|
have_root_privileges || die "You must be root to run this operation." |
445 |
|
|
446 |
if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] |
if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] |
447 |
then |
then |
448 |
echo "SMAGESCRIPTSDIR not found. Check your mage.rc or check out smage repos." |
echo "SMAGESCRIPTSDIR not found. Check your mage.rc or check out smage repos." |
454 |
done |
done |
455 |
;; |
;; |
456 |
|
|
457 |
|
print-features) |
458 |
|
mprintfeatures |
459 |
|
;; |
460 |
|
|
461 |
*) |
*) |
462 |
print_usage |
print_usage |
463 |
;; |
;; |