Magellan Linux

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

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

revision 299 by niro, Sun Dec 4 17:12:07 2005 UTC revision 1551 by niro, Tue Dec 27 10:46:36 2011 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.11 2005-12-04 17:12:07 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    
5  # default die function  # default die function
6  die()  die()
7  {  {
8     echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT}
9   echo -e ${COLRED}"$@"${COLDEFAULT}   echo -e ${COLRED}"$@"${COLDEFAULT}
10   exit 1   exit 1
11  }  }
# Line 14  die() Line 15  die()
15   source /etc/mage.rc.global || \   source /etc/mage.rc.global || \
16   die "/etc/mage.rc.global missing"   die "/etc/mage.rc.global missing"
17    
18  [ -f /etc/mage.rc ] && source /etc/mage.rc || \  [ -f ${MAGERC} ] && source ${MAGERC} || \
19   die "Your /etc/mage.rc is missing. Aborting."   die "Your ${MAGERC} is missing. Aborting."
20    
21  [ -f ${MLIBDIR}/mage4.functions.sh ] && \  [ -f ${MLIBDIR}/mage4.functions.sh ] && \
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 54  export LC_ALL=C Line 31  export LC_ALL=C
31  # sanity checks  # sanity checks
32  [ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE}  [ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE}
33    
34  if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]]  if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] && [[ $1 != update-tarball ]]
35  then  then
36   echo   echo
37   echo "Please choose an profile from the mage tree."   echo "Please choose an profile from the mage tree."
# Line 82  print_usage() Line 59  print_usage()
59   echo "    install         - installs a package"   echo "    install         - installs a package"
60   echo "    srcinstall      - installs a package from source"   echo "    srcinstall      - installs a package from source"
61   echo "    uninstall       - removes a package"   echo "    uninstall       - removes a package"
62   echo "    update          - updates mage-tree"   echo "    update          - updates the mage-tree via rsync"
63     echo "    update-tarball  - updates the mage-tree via a tarball"
64   echo "    uppretend       - pretend dependencies for a system upgrade"   echo "    uppretend       - pretend dependencies for a system upgrade"
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"
# Line 113  print_usage() Line 91  print_usage()
91  showversion  showversion
92  echo  echo
93    
 # before anything run mage_setup  
 mage_setup || die "error in mage_setup()"  
   
94  # install method  # install method
95  METHOD="$1"  METHOD="$1"
96    
97  # initial unversionized packagename, gets overridden later  # initial unversionized packagename, gets overridden later on
98  MAGENAME="$2"  MAGENAME="$2"
99    
100  if [[ ${METHOD} != upgrade ]] && \  if [[ ${METHOD} != upgrade ]] && \
# Line 127  if [[ ${METHOD} != upgrade ]] && \ Line 102  if [[ ${METHOD} != upgrade ]] && \
102   [[ ${METHOD} != uppretend ]] && \   [[ ${METHOD} != uppretend ]] && \
103   [[ ${METHOD} != srcuppretend ]] && \   [[ ${METHOD} != srcuppretend ]] && \
104   [[ ${METHOD} != update ]] && \   [[ ${METHOD} != update ]] && \
105     [[ ${METHOD} != update-tarball ]] && \
106   [[ ${METHOD} != clean ]] && \   [[ ${METHOD} != clean ]] && \
107   [[ ${METHOD} != version ]] && \   [[ ${METHOD} != version ]] && \
108   [[ ${METHOD} != search ]] && \   [[ ${METHOD} != search ]] && \
# Line 142  then Line 118  then
118   BUILDDIR=${MROOT}/${BUILDDIR}   BUILDDIR=${MROOT}/${BUILDDIR}
119  fi  fi
120    
121    # before anything run mage_setup
122    mage_setup || die "error in mage_setup()"
123    
124  case ${METHOD} in  case ${METHOD} in
125   download)   download)
126   # 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 153  case ${METHOD} in Line 132  case ${METHOD} in
132   # source the highest magefile of this pkg   # source the highest magefile of this pkg
133   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
134    
135     # package is masked
136     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
137    
138   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
139   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
140   PNAME="$(pkgname2pname ${PKGNAME})"   PNAME="$(pkgname2pname ${PKGNAME})"
# Line 180  case ${METHOD} in Line 162  case ${METHOD} in
162   # source the highest magefile of this pkg   # source the highest magefile of this pkg
163   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
164    
165     # package is masked
166     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
167    
168   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
169   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
170   PNAME="$(pkgname2pname ${PKGNAME})"   PNAME="$(pkgname2pname ${PKGNAME})"
# Line 206  case ${METHOD} in Line 191  case ${METHOD} in
191   # source the highest magefile of this pkg   # source the highest magefile of this pkg
192   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
193    
194     # package is masked
195     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
196    
197   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
198   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
199   PNAME="$(pkgname2pname ${PKGNAME})"   PNAME="$(pkgname2pname ${PKGNAME})"
# Line 230  case ${METHOD} in Line 218  case ${METHOD} in
218   ;;   ;;
219    
220   install)   install)
221     have_root_privileges || die "You must be root to run this operation."
222    
223   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
224   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
225    
# Line 239  case ${METHOD} in Line 229  case ${METHOD} in
229   # source the highest magefile of this pkg   # source the highest magefile of this pkg
230   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
231    
232     # package is masked
233     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
234    
235   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
236   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
237   PNAME="$(pkgname2pname ${PKGNAME})"   PNAME="$(pkgname2pname ${PKGNAME})"
# Line 269  case ${METHOD} in Line 262  case ${METHOD} in
262   ;;   ;;
263    
264   srcinstall)   srcinstall)
265     have_root_privileges || die "You must be root to run this operation."
266    
267   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
268   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
269    
# Line 278  case ${METHOD} in Line 273  case ${METHOD} in
273   # source the highest magefile of this pkg   # source the highest magefile of this pkg
274   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
275    
276     # package is masked
277     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
278    
279   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
280   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
281   PNAME="$(pkgname2pname ${PKGNAME})"   PNAME="$(pkgname2pname ${PKGNAME})"
# Line 304  case ${METHOD} in Line 302  case ${METHOD} in
302   ;;   ;;
303    
304   uninstall)   uninstall)
305   ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})"   have_root_privileges || die "You must be root to run this operation."
306   if [ -z "${ALLDEPS}" ]  
307   then   ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})"
308   die "No package installed named '${MAGENAME}'."   if [ -z "${ALLDEPS}" ]
309   fi   then
310   uninstall_packages ${ALLDEPS}   die "No package installed named '${MAGENAME}'."
311     fi
312     uninstall_packages ${ALLDEPS}
313   ;;   ;;
314    
315   uppretend|srcuppretend)   uppretend|srcuppretend)
# Line 322  case ${METHOD} in Line 322  case ${METHOD} in
322   ;;   ;;
323    
324   upgrade)   upgrade)
325     have_root_privileges || die "You must be root to run this operation."
326    
327   # get all dependencies of *all* installed packages   # get all dependencies of *all* installed packages
328   # fake pcat,pname,pver,pbuild ...   # fake pcat,pname,pver,pbuild ...
329   ALLDEPS="$(${MLIBDIR}/depwalker.sh \   ALLDEPS="$(${MLIBDIR}/depwalker.sh \
# Line 339  case ${METHOD} in Line 341  case ${METHOD} in
341   ;;   ;;
342    
343   srcupgrade)   srcupgrade)
344     have_root_privileges || die "You must be root to run this operation."
345    
346   # get all dependencies of *all* installed packages   # get all dependencies of *all* installed packages
347   # fake pcat,pname,pver,pbuild ...   # fake pcat,pname,pver,pbuild ...
348   ALLDEPS="$(${MLIBDIR}/depwalker.sh \   ALLDEPS="$(${MLIBDIR}/depwalker.sh \
# Line 356  case ${METHOD} in Line 360  case ${METHOD} in
360   ;;   ;;
361    
362   unpack)   unpack)
363     have_root_privileges || die "You must be root to run this operation."
364    
365   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
366   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
367    
# Line 365  case ${METHOD} in Line 371  case ${METHOD} in
371   # source the highest magefile of this pkg   # source the highest magefile of this pkg
372   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
373    
374     # package is masked
375     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
376    
377   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
378   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
379   PNAME="$(pkgname2pname ${PKGNAME})"   PNAME="$(pkgname2pname ${PKGNAME})"
# Line 384  case ${METHOD} in Line 393  case ${METHOD} in
393   ;;   ;;
394    
395   update)   update)
396     have_root_privileges || die "You must be root to run this operation."
397   syncmage   syncmage
398   ;;   ;;
399    
400     update-tarball)
401     have_root_privileges || die "You must be root to run this operation."
402     syncmage_tarball
403     ;;
404    
405   clean)   clean)
406     have_root_privileges || die "You must be root to run this operation."
407   cleanpkg   cleanpkg
408   ;;   ;;
409    
# Line 397  case ${METHOD} in Line 413  case ${METHOD} in
413   ;;   ;;
414    
415   regen-mage-tree)   regen-mage-tree)
416     have_root_privileges || die "You must be root to run this operation."
417    
418   if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ]   if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ]
419   then   then
420   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."

Legend:
Removed from v.299  
changed lines
  Added in v.1551