--- trunk/mage/usr/lib/mage/mage4.sh 2005/09/09 17:49:43 230 +++ trunk/mage/usr/lib/mage/mage4.sh 2005/12/04 17:12:07 299 @@ -1,6 +1,6 @@ #!/bin/sh # Magellan Linux Installer (mage.sh) -# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.sh,v 1.2 2005-09-09 17:49:43 niro Exp $ +# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.sh,v 1.11 2005-12-04 17:12:07 niro Exp $ # default die function die() @@ -10,27 +10,26 @@ } # include all needed files -# [ -f ${MLIBDIR}/conf/mage.rc.global ] && \ -# source ${MLIBDIR}/conf/mage.rc.global || \ -# die "${MLIBDIR}/conf/mage.rc.global missing" -# -# [ -f /etc/mage.rc ] && source /etc/mage.rc || \ -# die "Your /etc/mage.rc is missing. Aborting." -# -# [ -f ${MLIBDIR}/mage.functions.sh ] && \ -# source ${MLIBDIR}/mage.functions.sh || \ -# die "mage functions missing" - -# for tests only -source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage.rc.global -source /etc/mage.rc -source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh -MLIBDIR=/home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage +[ -f /etc/mage.rc.global ] && \ + 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 ${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 ]] @@ -41,6 +40,8 @@ COLBLUE="" COLMAGENTA="" COLWHITE="" + COLGRAY="" + COLBOLD="" COLDEFAULT="" fi @@ -62,42 +63,45 @@ fi # default messages -showversion() { +showversion() +{ local MAGEVERSION="$(< ${MLIBDIR}/version)" echo -en "Magellan Package Manager v${MAGEVERSION} " echo -e "-- Niels Rogalla (niro@magellan-linux.de)" } -print_usage(){ - showversion - echo +print_usage() +{ + #showversion + #echo echo "Usage: $(basename $0) [option] pkgname ..." echo "Options:" - echo " pretend - pretends dependencies of a package" - echo " srcpretend - pretends dependencies of a package (build from source)" - echo " install - installs a package" - echo " srcinstall - installs a package from source" - echo " uninstall - removes a package" - echo " update - updates mage-tree" - 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" - echo " srcupgrade - runs a complete system upgrade from source" - echo " search - searches mage-tree for a package" - echo " clean - removes *all* downloaded packages" - echo " unpack - unpacks *all* needed package for 'foo'" - echo " download - downloads *all* needed packages for 'foo'" - echo " version - prints version info" + echo " pretend - pretends dependencies of a package" + echo " srcpretend - pretends dependencies of a package (build from source)" + echo " install - installs a package" + echo " srcinstall - installs a package from source" + echo " uninstall - removes a package" + echo " update - updates mage-tree" + 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" + echo " srcupgrade - runs a complete system upgrade from source" + echo " search - searches mage-tree for a package" + echo " clean - removes *all* downloaded packages" + echo " unpack - unpacks *all* needed package for 'foo'" + echo " download - downloads *all* needed packages for 'foo'" + echo " version - prints version info" + echo " regen-mage-tree - regenerates the whole mage database (for devs only)" echo echo "Other options:" # echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE" # echo "Builds a Package with its dependencies, but won't install anything." # echo - echo "USE_UNSTABLE=true $(basename $0) [src]install PACKAGE" + echo "MAGE_DISTRIBUTION=unstable $(basename $0) [src]install PACKAGE" echo "Overrides stable packages; you can install packages that are marked unstable." echo - echo "USE_TESTING=true $(basename $0) [src]install PACKAGE" + echo "MAGE_DISTRIBUTION=testing $(basename $0) [src]install PACKAGE" echo "Overrides stable packages; you can install packages that are marked testing." echo echo "NOCOLORS=true $(basename $0) [src]install PACKAGE" @@ -121,11 +125,22 @@ if [[ ${METHOD} != upgrade ]] && \ [[ ${METHOD} != srcupgrade ]] && \ [[ ${METHOD} != uppretend ]] && \ - [[ ${METHOD} != srcuppretend ]] + [[ ${METHOD} != srcuppretend ]] && \ + [[ ${METHOD} != update ]] && \ + [[ ${METHOD} != clean ]] && \ + [[ ${METHOD} != version ]] && \ + [[ ${METHOD} != search ]] && \ + [[ ${METHOD} != regen-mage-tree ]] then [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 fi +# set PKGDIR and BUILDDIR to MROOT +if [[ -n ${MROOT} ]] +then + PKGDIR=${MROOT}/${PKGDIR} + BUILDDIR=${MROOT}/${BUILDDIR} +fi case ${METHOD} in download) @@ -136,7 +151,7 @@ [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." # source the highest magefile of this pkg - source $(get_highest_magefile ${PCAT} ${MAGENAME}) + PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) # convert PKGNAME to PNAME/PVER/PBUILD # we're working *only* with these three vars from here on @@ -163,7 +178,7 @@ [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." # source the highest magefile of this pkg - source $(get_highest_magefile ${PCAT} ${MAGENAME}) + PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) # convert PKGNAME to PNAME/PVER/PBUILD # we're working *only* with these three vars from here on @@ -189,7 +204,7 @@ [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." # source the highest magefile of this pkg - source $(get_highest_magefile ${PCAT} ${MAGENAME}) + PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) # convert PKGNAME to PNAME/PVER/PBUILD # we're working *only* with these three vars from here on @@ -222,7 +237,7 @@ [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." # source the highest magefile of this pkg - source $(get_highest_magefile ${PCAT} ${MAGENAME}) + PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) # convert PKGNAME to PNAME/PVER/PBUILD # we're working *only* with these three vars from here on @@ -233,7 +248,7 @@ if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} then echo -en "Package " - echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" + echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" echo -e " already installed." exit 3 fi @@ -261,7 +276,7 @@ [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." # source the highest magefile of this pkg - source $(get_highest_magefile ${PCAT} ${MAGENAME}) + PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) # convert PKGNAME to PNAME/PVER/PBUILD # we're working *only* with these three vars from here on @@ -272,7 +287,7 @@ if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} then echo -en "Package " - echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" + echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" echo -e " already installed." exit 3 fi @@ -306,7 +321,7 @@ --pbuild ${METHOD} ;; - upgrade|srcupgrade) + upgrade) # get all dependencies of *all* installed packages # fake pcat,pname,pver,pbuild ... ALLDEPS="$(${MLIBDIR}/depwalker.sh \ @@ -316,10 +331,28 @@ --pver ${METHOD} \ --pbuild ${METHOD})" - echo "DEBUG: ${ALLDEPS}" + # first fetch all packages + fetch_packages ${ALLDEPS} || die "fetching packages" + md5sum_packages ${ALLDEPS} || die "md5 sum packages" + unpack_packages ${ALLDEPS} || die "unpacking packages" + install_packages ${ALLDEPS} || die "installing packages" ;; + + srcupgrade) + # get all dependencies of *all* installed packages + # fake pcat,pname,pver,pbuild ... + ALLDEPS="$(${MLIBDIR}/depwalker.sh \ + --method ${METHOD} \ + --pcat ${METHOD} \ + --pname ${METHOD} \ + --pver ${METHOD} \ + --pbuild ${METHOD})" + + install_packages --src-install ${ALLDEPS} || die "src-installing packages" + ;; + search) - ${MLIBDIR}/pkgsearch.sh ${MAGENAME} + pkgsearch "${MAGENAME}" ;; unpack) @@ -330,7 +363,7 @@ [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." # source the highest magefile of this pkg - source $(get_highest_magefile ${PCAT} ${MAGENAME}) + PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) # convert PKGNAME to PNAME/PVER/PBUILD # we're working *only* with these three vars from here on @@ -359,7 +392,8 @@ ;; version) - showversion + # showversion + exit 0 ;; regen-mage-tree)