Magellan Linux

Diff of /trunk/mage/usr/lib/mage/mage4.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 233 by niro, Fri Sep 9 18:05:45 2005 UTC revision 370 by niro, Thu Apr 27 11:52:59 2006 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
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.4 2005-09-09 18:05:45 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.sh,v 1.13 2006-04-27 11:52:59 niro Exp $
4    
5  # default die function  # default die function
6  die()  die()
# Line 10  die() Line 10  die()
10  }  }
11    
12  # include all needed files  # include all needed files
13  [ -f ${MLIBDIR}/conf/mage.rc.global ] &&  \  [ -f /etc/mage.rc.global ] &&  \
14   source ${MLIBDIR}/conf/mage.rc.global || \   source /etc/mage.rc.global || \
15   die "${MLIBDIR}/conf/mage.rc.global missing"   die "/etc/mage.rc.global missing"
16    
17  [ -f /etc/mage.rc ] && source /etc/mage.rc || \  [ -f /etc/mage.rc ] && source /etc/mage.rc || \
18   die "Your /etc/mage.rc is missing. Aborting."   die "Your /etc/mage.rc is missing. Aborting."
19    
20  [ -f ${MLIBDIR}/mage.functions.sh ] && \  [ -f ${MLIBDIR}/mage4.functions.sh ] && \
21   source ${MLIBDIR}/mage.functions.sh || \   source ${MLIBDIR}/mage4.functions.sh || \
22   die "mage functions missing"   die "mage functions missing"
23    
 # 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  
   
24  ## only for tests -> normally in /etc/rc.d/init.d/functions  ## only for tests -> normally in /etc/rc.d/init.d/functions
25  COLRED="\033[1;6m\033[31m"  COLRED="\033[1;6m\033[31m"
26  COLGREEN="\033[1;6m\033[32m"  COLGREEN="\033[1;6m\033[32m"
27    COLYELLOW="\033[1;6m\033[33m"
28  COLBLUE="\033[1;6m\033[34m"  COLBLUE="\033[1;6m\033[34m"
29    COLMAGENTA="\033[1;6m\033[35m"
30    COLWHITE="\033[1;6m\033[37m"
31    COLGRAY="\033[0;6m\033[37m"
32    COLBOLD="\033[1m"
33  COLDEFAULT="\033[0m"  COLDEFAULT="\033[0m"
34    
35  if [[ ${NOCOLORS} = true ]]  if [[ ${NOCOLORS} = true ]]
# Line 41  then Line 40  then
40   COLBLUE=""   COLBLUE=""
41   COLMAGENTA=""   COLMAGENTA=""
42   COLWHITE=""   COLWHITE=""
43     COLGRAY=""
44     COLBOLD=""
45   COLDEFAULT=""   COLDEFAULT=""
46  fi  fi
47    
# Line 62  then Line 63  then
63  fi  fi
64    
65  # default messages  # default messages
66  showversion() {  showversion()
67    {
68   local MAGEVERSION="$(< ${MLIBDIR}/version)"   local MAGEVERSION="$(< ${MLIBDIR}/version)"
69    
70   echo -en "Magellan Package Manager v${MAGEVERSION} "   echo -en "Magellan Package Manager v${MAGEVERSION} "
71   echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"   echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"
72  }  }
73    
74  print_usage(){  print_usage()
75   showversion  {
76   echo   #showversion
77     #echo
78   echo "Usage: $(basename $0) [option] pkgname ..."   echo "Usage: $(basename $0) [option] pkgname ..."
79   echo "Options:"   echo "Options:"
80   echo "     pretend        - pretends dependencies of a package"   echo "    pretend         - pretends dependencies of a package"
81   echo "     srcpretend     - pretends dependencies of a package (build from source)"   echo "    srcpretend      - pretends dependencies of a package (build from source)"
82   echo "     install        - installs a package"   echo "    install         - installs a package"
83   echo "     srcinstall     - installs a package from source"   echo "    srcinstall      - installs a package from source"
84   echo "     uninstall      - removes a package"   echo "    uninstall       - removes a package"
85   echo "     update         - updates mage-tree"   echo "    update          - updates mage-tree"
86   echo "     uppretend      - pretend dependencies for a system upgrade"   echo "    uppretend       - pretend dependencies for a system upgrade"
87   echo "     upgrade        - runs a complete system upgrade"   echo "    upgrade         - runs a complete system upgrade"
88   echo "     srcuppretend   - pretend dependencies for a system upgrade from source"   echo "    srcuppretend    - pretend dependencies for a system upgrade from source"
89   echo "     srcupgrade     - runs a complete system upgrade from source"   echo "    srcupgrade      - runs a complete system upgrade from source"
90   echo "     search         - searches mage-tree for a package"   echo "    search          - searches mage-tree for a package"
91   echo "     clean          - removes *all* downloaded packages"   echo "    clean           - removes *all* downloaded packages"
92   echo "     unpack         - unpacks *all* needed package for 'foo'"   echo "    unpack          - unpacks *all* needed package for 'foo'"
93   echo "     download       - downloads *all* needed packages for 'foo'"   echo "    download        - downloads *all* needed packages for 'foo'"
94   echo "     version        - prints version info"   echo "    version         - prints version info"
95     echo "    regen-mage-tree - regenerates the whole mage database (for devs only)"
96   echo   echo
97   echo "Other options:"   echo "Other options:"
98  # echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE"  # echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE"
99  # echo "Builds a Package with its dependencies, but won't install anything."  # echo "Builds a Package with its dependencies, but won't install anything."
100  # echo  # echo
101   echo "USE_UNSTABLE=true $(basename $0) [src]install PACKAGE"   echo "MAGE_DISTRIBUTION=unstable $(basename $0) [src]install PACKAGE"
102   echo "Overrides stable packages; you can install packages that are marked unstable."   echo "Overrides stable packages; you can install packages that are marked unstable."
103   echo   echo
104   echo "USE_TESTING=true $(basename $0) [src]install PACKAGE"   echo "MAGE_DISTRIBUTION=testing $(basename $0) [src]install PACKAGE"
105   echo "Overrides stable packages; you can install packages that are marked testing."   echo "Overrides stable packages; you can install packages that are marked testing."
106   echo   echo
107   echo "NOCOLORS=true $(basename $0) [src]install PACKAGE"   echo "NOCOLORS=true $(basename $0) [src]install PACKAGE"
# Line 109  print_usage(){ Line 113  print_usage(){
113  showversion  showversion
114  echo  echo
115    
 # before anything run mage_setup  
 mage_setup || die "error in mage_setup()"  
   
116  # install method  # install method
117  METHOD="$1"  METHOD="$1"
118    
# Line 131  then Line 132  then
132   [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1   [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1
133  fi  fi
134    
135    # set PKGDIR and BUILDDIR to MROOT
136    if [[ -n ${MROOT} ]]
137    then
138     PKGDIR=${MROOT}/${PKGDIR}
139     BUILDDIR=${MROOT}/${BUILDDIR}
140    fi
141    
142    # before anything run mage_setup
143    mage_setup || die "error in mage_setup()"
144    
145  case ${METHOD} in  case ${METHOD} in
146   download)   download)
# Line 141  case ${METHOD} in Line 151  case ${METHOD} in
151   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
152    
153   # source the highest magefile of this pkg   # source the highest magefile of this pkg
154   source $(get_highest_magefile ${PCAT} ${MAGENAME})   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
155    
156     # package does not exists
157     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist."
158    
159   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
160   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 168  case ${METHOD} in Line 181  case ${METHOD} in
181   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
182    
183   # source the highest magefile of this pkg   # source the highest magefile of this pkg
184   source $(get_highest_magefile ${PCAT} ${MAGENAME})   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
185    
186     # package does not exists
187     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist."
188    
189   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
190   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 194  case ${METHOD} in Line 210  case ${METHOD} in
210   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
211    
212   # source the highest magefile of this pkg   # source the highest magefile of this pkg
213   source $(get_highest_magefile ${PCAT} ${MAGENAME})   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
214    
215     # package does not exists
216     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist."
217    
218   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
219   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 227  case ${METHOD} in Line 246  case ${METHOD} in
246   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
247    
248   # source the highest magefile of this pkg   # source the highest magefile of this pkg
249   source $(get_highest_magefile ${PCAT} ${MAGENAME})   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
250    
251     # package does not exists
252     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist."
253    
254   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
255   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 238  case ${METHOD} in Line 260  case ${METHOD} in
260   if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}   if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}
261   then   then
262   echo -en "Package "   echo -en "Package "
263   echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"   echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
264   echo -e  " already installed."   echo -e  " already installed."
265   exit 3   exit 3
266   fi   fi
# Line 266  case ${METHOD} in Line 288  case ${METHOD} in
288   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
289    
290   # source the highest magefile of this pkg   # source the highest magefile of this pkg
291   source $(get_highest_magefile ${PCAT} ${MAGENAME})   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
292    
293     # package does not exists
294     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist."
295    
296   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
297   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 277  case ${METHOD} in Line 302  case ${METHOD} in
302   if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}   if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}
303   then   then
304   echo -en "Package "   echo -en "Package "
305   echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"   echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
306   echo -e  " already installed."   echo -e  " already installed."
307   exit 3   exit 3
308   fi   fi
# Line 311  case ${METHOD} in Line 336  case ${METHOD} in
336   --pbuild ${METHOD}   --pbuild ${METHOD}
337   ;;   ;;
338    
339   upgrade|srcupgrade)   upgrade)
340     # get all dependencies of *all* installed packages
341     # fake pcat,pname,pver,pbuild ...
342     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
343     --method ${METHOD} \
344     --pcat ${METHOD} \
345     --pname ${METHOD} \
346     --pver ${METHOD} \
347     --pbuild ${METHOD})"
348    
349     # first fetch all packages
350     fetch_packages ${ALLDEPS} || die "fetching packages"
351     md5sum_packages ${ALLDEPS} || die "md5 sum packages"
352     unpack_packages ${ALLDEPS} || die "unpacking packages"
353     install_packages ${ALLDEPS} || die "installing packages"
354     ;;
355    
356     srcupgrade)
357   # get all dependencies of *all* installed packages   # get all dependencies of *all* installed packages
358   # fake pcat,pname,pver,pbuild ...   # fake pcat,pname,pver,pbuild ...
359   ALLDEPS="$(${MLIBDIR}/depwalker.sh \   ALLDEPS="$(${MLIBDIR}/depwalker.sh \
# Line 321  case ${METHOD} in Line 363  case ${METHOD} in
363   --pver ${METHOD} \   --pver ${METHOD} \
364   --pbuild ${METHOD})"   --pbuild ${METHOD})"
365    
366   echo "DEBUG: ${ALLDEPS}"   install_packages --src-install ${ALLDEPS} || die "src-installing packages"
367   ;;   ;;
368    
369   search)   search)
370   ${MLIBDIR}/pkgsearch.sh ${MAGENAME}   pkgsearch "${MAGENAME}"
371   ;;   ;;
372    
373   unpack)   unpack)
# Line 335  case ${METHOD} in Line 378  case ${METHOD} in
378   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
379    
380   # source the highest magefile of this pkg   # source the highest magefile of this pkg
381   source $(get_highest_magefile ${PCAT} ${MAGENAME})   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
382    
383     # package does not exists
384     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist."
385    
386   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
387   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 364  case ${METHOD} in Line 410  case ${METHOD} in
410   ;;   ;;
411    
412   version)   version)
413   showversion   # showversion
414     exit 0
415   ;;   ;;
416    
417   regen-mage-tree)   regen-mage-tree)

Legend:
Removed from v.233  
changed lines
  Added in v.370