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.13 2006-04-27 11:52:59 niro Exp $ |
# $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 |
|
|
5 |
# default die function |
# default die function |
6 |
die() |
die() |
7 |
{ |
{ |
8 |
|
echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
9 |
echo -e ${COLRED}"$@"${COLDEFAULT} |
echo -e ${COLRED}"$@"${COLDEFAULT} |
10 |
exit 1 |
exit 1 |
11 |
} |
} |
15 |
source /etc/mage.rc.global || \ |
source /etc/mage.rc.global || \ |
16 |
die "/etc/mage.rc.global missing" |
die "/etc/mage.rc.global missing" |
17 |
|
|
18 |
[ -f /etc/mage.rc ] && source /etc/mage.rc || \ |
[ -f ${MAGERC} ] && source ${MAGERC} || \ |
19 |
die "Your /etc/mage.rc is missing. Aborting." |
die "Your ${MAGERC} is missing. Aborting." |
20 |
|
|
21 |
[ -f ${MLIBDIR}/mage4.functions.sh ] && \ |
[ -f ${MLIBDIR}/mage4.functions.sh ] && \ |
22 |
source ${MLIBDIR}/mage4.functions.sh || \ |
source ${MLIBDIR}/mage4.functions.sh || \ |
23 |
die "mage functions missing" |
die "mage functions missing" |
24 |
|
|
|
## 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 |
|
|
|
|
25 |
# export default path |
# export default path |
26 |
export PATH="${PATH}:${MLIBDIR}" |
export PATH="${PATH}:${MLIBDIR}" |
27 |
|
|
31 |
# sanity checks |
# sanity checks |
32 |
[ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} |
[ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} |
33 |
|
|
34 |
if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] |
if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] && [[ $1 != update-tarball ]] |
35 |
then |
then |
36 |
echo |
echo |
37 |
echo "Please choose an profile from the mage tree." |
echo "Please choose an profile from the mage tree." |
59 |
echo " install - installs a package" |
echo " install - installs a package" |
60 |
echo " srcinstall - installs a package from source" |
echo " srcinstall - installs a package from source" |
61 |
echo " uninstall - removes a package" |
echo " uninstall - removes a package" |
62 |
echo " update - updates mage-tree" |
echo " update - updates the mage-tree via rsync" |
63 |
|
echo " update-tarball - updates the mage-tree via a tarball" |
64 |
echo " uppretend - pretend dependencies for a system upgrade" |
echo " uppretend - pretend dependencies for a system upgrade" |
65 |
echo " upgrade - runs a complete system upgrade" |
echo " upgrade - runs a complete system upgrade" |
66 |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
69 |
echo " clean - removes *all* downloaded packages" |
echo " clean - removes *all* downloaded packages" |
70 |
echo " unpack - unpacks *all* needed package for 'foo'" |
echo " unpack - unpacks *all* needed package for 'foo'" |
71 |
echo " download - downloads *all* needed packages for 'foo'" |
echo " download - downloads *all* needed packages for 'foo'" |
72 |
|
echo " print-features - prints all enabled mage-features" |
73 |
echo " version - prints version info" |
echo " version - prints version info" |
74 |
echo " regen-mage-tree - regenerates the whole mage database (for devs only)" |
echo " regen-mage-tree - regenerates the whole mage database (for devs only)" |
75 |
echo |
echo |
95 |
# install method |
# install method |
96 |
METHOD="$1" |
METHOD="$1" |
97 |
|
|
98 |
# initial unversionized packagename, gets overridden later |
# initial unversionized packagename, gets overridden later on |
99 |
MAGENAME="$2" |
MAGENAME="$2" |
100 |
|
|
101 |
if [[ ${METHOD} != upgrade ]] && \ |
if [[ ${METHOD} != upgrade ]] && |
102 |
[[ ${METHOD} != srcupgrade ]] && \ |
[[ ${METHOD} != srcupgrade ]] && |
103 |
[[ ${METHOD} != uppretend ]] && \ |
[[ ${METHOD} != uppretend ]] && |
104 |
[[ ${METHOD} != srcuppretend ]] && \ |
[[ ${METHOD} != srcuppretend ]] && |
105 |
[[ ${METHOD} != update ]] && \ |
[[ ${METHOD} != update ]] && |
106 |
[[ ${METHOD} != clean ]] && \ |
[[ ${METHOD} != update-tarball ]] && |
107 |
[[ ${METHOD} != version ]] && \ |
[[ ${METHOD} != clean ]] && |
108 |
[[ ${METHOD} != search ]] && \ |
[[ ${METHOD} != version ]] && |
109 |
[[ ${METHOD} != regen-mage-tree ]] |
[[ ${METHOD} != search ]] && |
110 |
|
[[ ${METHOD} != regen-mage-tree ]] && |
111 |
|
[[ ${METHOD} != print-features ]] |
112 |
then |
then |
113 |
[[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 |
[[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 |
114 |
fi |
fi |
123 |
# before anything run mage_setup |
# before anything run mage_setup |
124 |
mage_setup || die "error in mage_setup()" |
mage_setup || die "error in mage_setup()" |
125 |
|
|
126 |
|
# load supported mage features |
127 |
|
load_mage_features |
128 |
|
|
129 |
case ${METHOD} in |
case ${METHOD} in |
130 |
download) |
download) |
131 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
137 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
138 |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
139 |
|
|
140 |
# package does not exists |
# package is masked |
141 |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
142 |
|
|
143 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
144 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
167 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
168 |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
169 |
|
|
170 |
# package does not exists |
# package is masked |
171 |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
172 |
|
|
173 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
174 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
196 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
197 |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
198 |
|
|
199 |
# package does not exists |
# package is masked |
200 |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
201 |
|
|
202 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
203 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
223 |
;; |
;; |
224 |
|
|
225 |
install) |
install) |
226 |
|
have_root_privileges || die "You must be root to run this operation." |
227 |
|
|
228 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
229 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
230 |
|
|
234 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
235 |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
236 |
|
|
237 |
# package does not exists |
# package is masked |
238 |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
239 |
|
|
240 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
241 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
262 |
# first fetch all packages |
# first fetch all packages |
263 |
fetch_packages ${ALLDEPS} || die "fetching packages" |
fetch_packages ${ALLDEPS} || die "fetching packages" |
264 |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
|
unpack_packages ${ALLDEPS} || die "unpacking packages" |
|
265 |
install_packages ${ALLDEPS} || die "installing packages" |
install_packages ${ALLDEPS} || die "installing packages" |
266 |
;; |
;; |
267 |
|
|
268 |
srcinstall) |
srcinstall) |
269 |
|
have_root_privileges || die "You must be root to run this operation." |
270 |
|
|
271 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
272 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
273 |
|
|
277 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
278 |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
279 |
|
|
280 |
# package does not exists |
# package is masked |
281 |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
282 |
|
|
283 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
284 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
306 |
;; |
;; |
307 |
|
|
308 |
uninstall) |
uninstall) |
309 |
ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" |
have_root_privileges || die "You must be root to run this operation." |
310 |
if [ -z "${ALLDEPS}" ] |
|
311 |
then |
ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" |
312 |
die "No package installed named '${MAGENAME}'." |
if [ -z "${ALLDEPS}" ] |
313 |
fi |
then |
314 |
uninstall_packages ${ALLDEPS} |
die "No package installed named '${MAGENAME}'." |
315 |
|
fi |
316 |
|
uninstall_packages ${ALLDEPS} |
317 |
;; |
;; |
318 |
|
|
319 |
uppretend|srcuppretend) |
uppretend|srcuppretend) |
326 |
;; |
;; |
327 |
|
|
328 |
upgrade) |
upgrade) |
329 |
|
have_root_privileges || die "You must be root to run this operation." |
330 |
|
|
331 |
# get all dependencies of *all* installed packages |
# get all dependencies of *all* installed packages |
332 |
# fake pcat,pname,pver,pbuild ... |
# fake pcat,pname,pver,pbuild ... |
333 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
340 |
# first fetch all packages |
# first fetch all packages |
341 |
fetch_packages ${ALLDEPS} || die "fetching packages" |
fetch_packages ${ALLDEPS} || die "fetching packages" |
342 |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
|
unpack_packages ${ALLDEPS} || die "unpacking packages" |
|
343 |
install_packages ${ALLDEPS} || die "installing packages" |
install_packages ${ALLDEPS} || die "installing packages" |
344 |
;; |
;; |
345 |
|
|
346 |
srcupgrade) |
srcupgrade) |
347 |
|
have_root_privileges || die "You must be root to run this operation." |
348 |
|
|
349 |
# get all dependencies of *all* installed packages |
# get all dependencies of *all* installed packages |
350 |
# fake pcat,pname,pver,pbuild ... |
# fake pcat,pname,pver,pbuild ... |
351 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
363 |
;; |
;; |
364 |
|
|
365 |
unpack) |
unpack) |
366 |
|
have_root_privileges || die "You must be root to run this operation." |
367 |
|
|
368 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
369 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
370 |
|
|
374 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
375 |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
376 |
|
|
377 |
# package does not exists |
# package is masked |
378 |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
379 |
|
|
380 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
381 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
396 |
;; |
;; |
397 |
|
|
398 |
update) |
update) |
399 |
|
have_root_privileges || die "You must be root to run this operation." |
400 |
syncmage |
syncmage |
401 |
;; |
;; |
402 |
|
|
403 |
|
update-tarball) |
404 |
|
have_root_privileges || die "You must be root to run this operation." |
405 |
|
syncmage_tarball |
406 |
|
;; |
407 |
|
|
408 |
clean) |
clean) |
409 |
|
have_root_privileges || die "You must be root to run this operation." |
410 |
cleanpkg |
cleanpkg |
411 |
;; |
;; |
412 |
|
|
416 |
;; |
;; |
417 |
|
|
418 |
regen-mage-tree) |
regen-mage-tree) |
419 |
|
have_root_privileges || die "You must be root to run this operation." |
420 |
|
|
421 |
if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] |
if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] |
422 |
then |
then |
423 |
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." |
429 |
done |
done |
430 |
;; |
;; |
431 |
|
|
432 |
|
print-features) |
433 |
|
mprintfeatures |
434 |
|
;; |
435 |
|
|
436 |
*) |
*) |
437 |
print_usage |
print_usage |
438 |
;; |
;; |