Magellan Linux

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

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

revision 1080 by niro, Mon Jun 28 17:45:18 2010 UTC revision 2210 by niro, Mon Oct 14 13:13:46 2013 UTC
# Line 1  Line 1 
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.17 2008-06-16 09:29:57 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    
# Line 22  die() Line 22  die()
22   source ${MLIBDIR}/mage4.functions.sh || \   source ${MLIBDIR}/mage4.functions.sh || \
23   die "mage functions missing"   die "mage functions missing"
24    
 ## 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  
   
25  # export default path  # export default path
26  export PATH="${PATH}:${MLIBDIR}"  export PATH="${PATH}:${MLIBDIR}"
27    
# Line 89  print_usage() Line 65  print_usage()
65   echo "    upgrade         - runs a complete system upgrade"   echo "    upgrade         - runs a complete system upgrade"
66   echo "    srcuppretend    - pretend dependencies for a system upgrade from source"   echo "    srcuppretend    - pretend dependencies for a system upgrade from source"
67   echo "    srcupgrade      - runs a complete system upgrade from source"   echo "    srcupgrade      - runs a complete system upgrade from source"
68     echo "    pretend-build-prerequisites"
69     echo "    install-build-prerequisites"
70   echo "    search          - searches mage-tree for a package"   echo "    search          - searches mage-tree for a package"
71   echo "    clean           - removes *all* downloaded packages"   echo "    clean           - removes *all* downloaded packages"
72   echo "    unpack          - unpacks *all* needed package for 'foo'"   echo "    unpack          - unpacks *all* needed package for 'foo'"
73   echo "    download        - downloads *all* needed packages for 'foo'"   echo "    download        - downloads *all* needed packages for 'foo'"
74     echo "    print-features  - prints all enabled mage-features"
75   echo "    version         - prints version info"   echo "    version         - prints version info"
76   echo "    regen-mage-tree - regenerates the whole mage database (for devs only)"   echo "    regen-mage-tree - regenerates the whole mage database (for devs only)"
77   echo   echo
# Line 118  echo Line 97  echo
97  # install method  # install method
98  METHOD="$1"  METHOD="$1"
99    
100  # initial unversionized packagename, gets overridden later  # initial unversionized packagename, gets overridden later on
101  MAGENAME="$2"  MAGENAME="$2"
102    
103  if [[ ${METHOD} != upgrade ]] && \  if [[ ${METHOD} != upgrade ]] &&
104   [[ ${METHOD} != srcupgrade ]] && \   [[ ${METHOD} != srcupgrade ]] &&
105   [[ ${METHOD} != uppretend ]] && \   [[ ${METHOD} != uppretend ]] &&
106   [[ ${METHOD} != srcuppretend ]] && \   [[ ${METHOD} != srcuppretend ]] &&
107   [[ ${METHOD} != update ]] && \   [[ ${METHOD} != update ]] &&
108   [[ ${METHOD} != update-tarball ]] && \   [[ ${METHOD} != update-tarball ]] &&
109   [[ ${METHOD} != clean ]] && \   [[ ${METHOD} != clean ]] &&
110   [[ ${METHOD} != version ]] && \   [[ ${METHOD} != version ]] &&
111   [[ ${METHOD} != search ]] && \   [[ ${METHOD} != search ]] &&
112   [[ ${METHOD} != regen-mage-tree ]]   [[ ${METHOD} != regen-mage-tree ]] &&
113     [[ ${METHOD} != print-features ]]
114  then  then
115   [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1   [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1
116  fi  fi
# Line 145  fi Line 125  fi
125  # before anything run mage_setup  # before anything run mage_setup
126  mage_setup || die "error in mage_setup()"  mage_setup || die "error in mage_setup()"
127    
128    # load supported mage features
129    load_mage_features
130    
131  case ${METHOD} in  case ${METHOD} in
132   download)   download)
133   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
# Line 205  case ${METHOD} in Line 188  case ${METHOD} in
188   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
189   ;;   ;;
190    
191   pretend|srcpretend)   pretend|srcpretend|pretend-build-prerequisites)
192   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
193   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
194    
# Line 241  case ${METHOD} in Line 224  case ${METHOD} in
224   --pbuild ${PBUILD}   --pbuild ${PBUILD}
225   ;;   ;;
226    
227   install)   install|install-build-prerequisites)
228     have_root_privileges || die "You must be root to run this operation."
229    
230   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
231   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
232    
# Line 279  case ${METHOD} in Line 264  case ${METHOD} in
264   # first fetch all packages   # first fetch all packages
265   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
266   md5sum_packages ${ALLDEPS} || die "md5 sum packages"   md5sum_packages ${ALLDEPS} || die "md5 sum packages"
  unpack_packages ${ALLDEPS} || die "unpacking packages"  
267   install_packages ${ALLDEPS} || die "installing packages"   install_packages ${ALLDEPS} || die "installing packages"
268   ;;   ;;
269    
270   srcinstall)   srcinstall)
271     have_root_privileges || die "You must be root to run this operation."
272    
273   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
274   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
275    
# Line 322  case ${METHOD} in Line 308  case ${METHOD} in
308   ;;   ;;
309    
310   uninstall)   uninstall)
311   ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})"   have_root_privileges || die "You must be root to run this operation."
312   if [ -z "${ALLDEPS}" ]  
313   then   ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})"
314   die "No package installed named '${MAGENAME}'."   if [ -z "${ALLDEPS}" ]
315   fi   then
316   uninstall_packages ${ALLDEPS}   die "No package installed named '${MAGENAME}'."
317     fi
318     uninstall_packages ${ALLDEPS}
319   ;;   ;;
320    
321   uppretend|srcuppretend)   uppretend|srcuppretend)
# Line 340  case ${METHOD} in Line 328  case ${METHOD} in
328   ;;   ;;
329    
330   upgrade)   upgrade)
331     have_root_privileges || die "You must be root to run this operation."
332    
333   # get all dependencies of *all* installed packages   # get all dependencies of *all* installed packages
334   # fake pcat,pname,pver,pbuild ...   # fake pcat,pname,pver,pbuild ...
335   ALLDEPS="$(${MLIBDIR}/depwalker.sh \   ALLDEPS="$(${MLIBDIR}/depwalker.sh \
# Line 352  case ${METHOD} in Line 342  case ${METHOD} in
342   # first fetch all packages   # first fetch all packages
343   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
344   md5sum_packages ${ALLDEPS} || die "md5 sum packages"   md5sum_packages ${ALLDEPS} || die "md5 sum packages"
  unpack_packages ${ALLDEPS} || die "unpacking packages"  
345   install_packages ${ALLDEPS} || die "installing packages"   install_packages ${ALLDEPS} || die "installing packages"
346   ;;   ;;
347    
348   srcupgrade)   srcupgrade)
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 \
# Line 374  case ${METHOD} in Line 365  case ${METHOD} in
365   ;;   ;;
366    
367   unpack)   unpack)
368     have_root_privileges || die "You must be root to run this operation."
369    
370   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
371   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
372    
# Line 405  case ${METHOD} in Line 398  case ${METHOD} in
398   ;;   ;;
399    
400   update)   update)
401     have_root_privileges || die "You must be root to run this operation."
402   syncmage   syncmage
403   ;;   ;;
404    
405   update-tarball)   update-tarball)
406     have_root_privileges || die "You must be root to run this operation."
407   syncmage_tarball   syncmage_tarball
408   ;;   ;;
409    
410   clean)   clean)
411     have_root_privileges || die "You must be root to run this operation."
412   cleanpkg   cleanpkg
413   ;;   ;;
414    
# Line 422  case ${METHOD} in Line 418  case ${METHOD} in
418   ;;   ;;
419    
420   regen-mage-tree)   regen-mage-tree)
421     have_root_privileges || die "You must be root to run this operation."
422    
423   if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ]   if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ]
424   then   then
425   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."
# Line 433  case ${METHOD} in Line 431  case ${METHOD} in
431   done   done
432   ;;   ;;
433    
434     print-features)
435     mprintfeatures
436     ;;
437    
438   *)   *)
439   print_usage   print_usage
440   ;;   ;;

Legend:
Removed from v.1080  
changed lines
  Added in v.2210