--- trunk/mage/usr/lib/mage/mage4.sh 2011/04/26 08:57:30 1269 +++ trunk/mage/usr/lib/mage/mage4.sh 2011/12/27 10:45:33 1550 @@ -22,30 +22,6 @@ 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}" @@ -242,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})" @@ -284,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})" @@ -322,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) @@ -340,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 \ @@ -357,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 \ @@ -374,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})" @@ -405,14 +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 ;; @@ -422,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."