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 || \ |
55 |
# sanity checks |
# sanity checks |
56 |
[ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} |
[ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} |
57 |
|
|
58 |
if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] |
if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] && [[ $1 != update-tarball ]] |
59 |
then |
then |
60 |
echo |
echo |
61 |
echo "Please choose an profile from the mage tree." |
echo "Please choose an profile from the mage tree." |
83 |
echo " install - installs a package" |
echo " install - installs a package" |
84 |
echo " srcinstall - installs a package from source" |
echo " srcinstall - installs a package from source" |
85 |
echo " uninstall - removes a package" |
echo " uninstall - removes a package" |
86 |
echo " update - updates mage-tree" |
echo " update - updates the mage-tree via rsync" |
87 |
|
echo " update-tarball - updates the mage-tree via a tarball" |
88 |
echo " uppretend - pretend dependencies for a system upgrade" |
echo " uppretend - pretend dependencies for a system upgrade" |
89 |
echo " upgrade - runs a complete system upgrade" |
echo " upgrade - runs a complete system upgrade" |
90 |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
echo " srcuppretend - pretend dependencies for a system upgrade from source" |
126 |
[[ ${METHOD} != uppretend ]] && \ |
[[ ${METHOD} != uppretend ]] && \ |
127 |
[[ ${METHOD} != srcuppretend ]] && \ |
[[ ${METHOD} != srcuppretend ]] && \ |
128 |
[[ ${METHOD} != update ]] && \ |
[[ ${METHOD} != update ]] && \ |
129 |
|
[[ ${METHOD} != update-tarball ]] && \ |
130 |
[[ ${METHOD} != clean ]] && \ |
[[ ${METHOD} != clean ]] && \ |
131 |
[[ ${METHOD} != version ]] && \ |
[[ ${METHOD} != version ]] && \ |
132 |
[[ ${METHOD} != search ]] && \ |
[[ ${METHOD} != search ]] && \ |
156 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
157 |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
158 |
|
|
159 |
# package does not exists |
# package is masked |
160 |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
161 |
|
|
162 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
163 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
186 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
187 |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
188 |
|
|
189 |
# package does not exists |
# package is masked |
190 |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
191 |
|
|
192 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
193 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
215 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
216 |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
217 |
|
|
218 |
# package does not exists |
# package is masked |
219 |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
220 |
|
|
221 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
222 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
242 |
;; |
;; |
243 |
|
|
244 |
install) |
install) |
245 |
|
have_root_privileges || die "You must be root to run this operation." |
246 |
|
|
247 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
248 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
249 |
|
|
253 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
254 |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
255 |
|
|
256 |
# package does not exists |
# package is masked |
257 |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
258 |
|
|
259 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
260 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
286 |
;; |
;; |
287 |
|
|
288 |
srcinstall) |
srcinstall) |
289 |
|
have_root_privileges || die "You must be root to run this operation." |
290 |
|
|
291 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
292 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
293 |
|
|
297 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
298 |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
299 |
|
|
300 |
# package does not exists |
# package is masked |
301 |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
302 |
|
|
303 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
304 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
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) |
346 |
;; |
;; |
347 |
|
|
348 |
upgrade) |
upgrade) |
349 |
|
have_root_privileges || die "You must be root to run this operation." |
350 |
|
|
351 |
# get all dependencies of *all* installed packages |
# get all dependencies of *all* installed packages |
352 |
# fake pcat,pname,pver,pbuild ... |
# fake pcat,pname,pver,pbuild ... |
353 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
365 |
;; |
;; |
366 |
|
|
367 |
srcupgrade) |
srcupgrade) |
368 |
|
have_root_privileges || die "You must be root to run this operation." |
369 |
|
|
370 |
# get all dependencies of *all* installed packages |
# get all dependencies of *all* installed packages |
371 |
# fake pcat,pname,pver,pbuild ... |
# fake pcat,pname,pver,pbuild ... |
372 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
384 |
;; |
;; |
385 |
|
|
386 |
unpack) |
unpack) |
387 |
|
have_root_privileges || die "You must be root to run this operation." |
388 |
|
|
389 |
# first of all get the right pkg which going to be installed |
# first of all get the right pkg which going to be installed |
390 |
PCAT="$(pname2pcat ${MAGENAME})" |
PCAT="$(pname2pcat ${MAGENAME})" |
391 |
|
|
395 |
# source the highest magefile of this pkg |
# source the highest magefile of this pkg |
396 |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
397 |
|
|
398 |
# package does not exists |
# package is masked |
399 |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." |
[ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." |
400 |
|
|
401 |
# convert PKGNAME to PNAME/PVER/PBUILD |
# convert PKGNAME to PNAME/PVER/PBUILD |
402 |
# we're working *only* with these three vars from here on |
# we're working *only* with these three vars from here on |
417 |
;; |
;; |
418 |
|
|
419 |
update) |
update) |
420 |
|
have_root_privileges || die "You must be root to run this operation." |
421 |
syncmage |
syncmage |
422 |
;; |
;; |
423 |
|
|
424 |
|
update-tarball) |
425 |
|
have_root_privileges || die "You must be root to run this operation." |
426 |
|
syncmage_tarball |
427 |
|
;; |
428 |
|
|
429 |
clean) |
clean) |
430 |
|
have_root_privileges || die "You must be root to run this operation." |
431 |
cleanpkg |
cleanpkg |
432 |
;; |
;; |
433 |
|
|
437 |
;; |
;; |
438 |
|
|
439 |
regen-mage-tree) |
regen-mage-tree) |
440 |
|
have_root_privileges || die "You must be root to run this operation." |
441 |
|
|
442 |
if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] |
if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] |
443 |
then |
then |
444 |
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." |