--- trunk/mage/usr/lib/mage/mage4.sh 2006/04/27 11:52:59 370 +++ trunk/mage/usr/lib/mage/mage4.sh 2011/12/27 10:45:33 1550 @@ -1,10 +1,11 @@ -#!/bin/sh +#!/bin/bash # Magellan Linux Installer (mage.sh) -# $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 $ # default die function die() { + echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} echo -e ${COLRED}"$@"${COLDEFAULT} exit 1 } @@ -14,37 +15,13 @@ source /etc/mage.rc.global || \ die "/etc/mage.rc.global missing" -[ -f /etc/mage.rc ] && source /etc/mage.rc || \ - die "Your /etc/mage.rc is missing. Aborting." +[ -f ${MAGERC} ] && source ${MAGERC} || \ + die "Your ${MAGERC} is missing. Aborting." [ -f ${MLIBDIR}/mage4.functions.sh ] && \ source ${MLIBDIR}/mage4.functions.sh || \ die "mage functions missing" -## 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 - # export default path export PATH="${PATH}:${MLIBDIR}" @@ -54,7 +31,7 @@ # sanity checks [ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} -if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] +if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] && [[ $1 != update-tarball ]] then echo echo "Please choose an profile from the mage tree." @@ -82,7 +59,8 @@ echo " install - installs a package" echo " srcinstall - installs a package from source" echo " uninstall - removes a package" - echo " update - updates mage-tree" + echo " update - updates the mage-tree via rsync" + echo " update-tarball - updates the mage-tree via a tarball" echo " uppretend - pretend dependencies for a system upgrade" echo " upgrade - runs a complete system upgrade" echo " srcuppretend - pretend dependencies for a system upgrade from source" @@ -124,6 +102,7 @@ [[ ${METHOD} != uppretend ]] && \ [[ ${METHOD} != srcuppretend ]] && \ [[ ${METHOD} != update ]] && \ + [[ ${METHOD} != update-tarball ]] && \ [[ ${METHOD} != clean ]] && \ [[ ${METHOD} != version ]] && \ [[ ${METHOD} != search ]] && \ @@ -153,8 +132,8 @@ # source the highest magefile of this pkg PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) - # package does not exists - [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." + # package is masked + [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." # convert PKGNAME to PNAME/PVER/PBUILD # we're working *only* with these three vars from here on @@ -183,8 +162,8 @@ # source the highest magefile of this pkg PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) - # package does not exists - [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." + # package is masked + [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." # convert PKGNAME to PNAME/PVER/PBUILD # we're working *only* with these three vars from here on @@ -212,8 +191,8 @@ # source the highest magefile of this pkg PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) - # package does not exists - [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." + # package is masked + [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." # convert PKGNAME to PNAME/PVER/PBUILD # we're working *only* with these three vars from here on @@ -239,6 +218,8 @@ ;; install) + have_root_privileges || die "You must be root to run this operation." + # first of all get the right pkg which going to be installed PCAT="$(pname2pcat ${MAGENAME})" @@ -248,8 +229,8 @@ # source the highest magefile of this pkg PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) - # package does not exists - [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." + # package is masked + [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." # convert PKGNAME to PNAME/PVER/PBUILD # we're working *only* with these three vars from here on @@ -281,6 +262,8 @@ ;; srcinstall) + have_root_privileges || die "You must be root to run this operation." + # first of all get the right pkg which going to be installed PCAT="$(pname2pcat ${MAGENAME})" @@ -290,8 +273,8 @@ # source the highest magefile of this pkg PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) - # package does not exists - [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." + # package is masked + [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." # convert PKGNAME to PNAME/PVER/PBUILD # we're working *only* with these three vars from here on @@ -319,12 +302,14 @@ ;; uninstall) - ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" - if [ -z "${ALLDEPS}" ] - then - die "No package installed named '${MAGENAME}'." - fi - uninstall_packages ${ALLDEPS} + have_root_privileges || die "You must be root to run this operation." + + ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" + if [ -z "${ALLDEPS}" ] + then + die "No package installed named '${MAGENAME}'." + fi + uninstall_packages ${ALLDEPS} ;; uppretend|srcuppretend) @@ -337,6 +322,8 @@ ;; upgrade) + have_root_privileges || die "You must be root to run this operation." + # get all dependencies of *all* installed packages # fake pcat,pname,pver,pbuild ... ALLDEPS="$(${MLIBDIR}/depwalker.sh \ @@ -354,6 +341,8 @@ ;; srcupgrade) + have_root_privileges || die "You must be root to run this operation." + # get all dependencies of *all* installed packages # fake pcat,pname,pver,pbuild ... ALLDEPS="$(${MLIBDIR}/depwalker.sh \ @@ -371,6 +360,8 @@ ;; unpack) + have_root_privileges || die "You must be root to run this operation." + # first of all get the right pkg which going to be installed PCAT="$(pname2pcat ${MAGENAME})" @@ -380,8 +371,8 @@ # source the highest magefile of this pkg PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) - # package does not exists - [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist." + # package is masked + [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." # convert PKGNAME to PNAME/PVER/PBUILD # we're working *only* with these three vars from here on @@ -402,10 +393,17 @@ ;; update) + have_root_privileges || die "You must be root to run this operation." syncmage ;; + update-tarball) + have_root_privileges || die "You must be root to run this operation." + syncmage_tarball + ;; + clean) + have_root_privileges || die "You must be root to run this operation." cleanpkg ;; @@ -415,6 +413,8 @@ ;; regen-mage-tree) + have_root_privileges || die "You must be root to run this operation." + if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] then echo "SMAGESCRIPTSDIR not found. Check your mage.rc or check out smage repos."