Magellan Linux

Diff of /branches/mage-next/src/mage.in

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

trunk/mage/usr/lib/mage/mage4.sh revision 2268 by niro, Fri Oct 25 06:48:57 2013 UTC branches/mage-next/src/mage.in revision 2620 by niro, Tue Mar 4 15:42:54 2014 UTC
# Line 2  Line 2 
2  # Magellan Linux Installer (mage.sh)  # Magellan Linux Installer (mage.sh)
3  # $Id$  # $Id$
4    
5  # default die function  # set default variables
6  die()  : ${MAGERC="@@SYSCONFDIR@@/mage.rc"}
7  {  : ${MLIBDIR="@@MAGELIBDIR@@"}
8   xtitleclean  
9   mqueryfeature "debug" && echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT}  # first of all include common functions
10   echo -e ${COLRED}"$@"${COLDEFAULT}  source ${MLIBDIR}/common.functions.sh
11   exit 1  source @@SYSCONFDIR@@/mage.rc.global
12  }  source ${MAGERC}
13    source ${MLIBDIR}/mage4.functions.sh
 # include all needed files  
 [ -f /etc/mage.rc.global ] &&  \  
  source /etc/mage.rc.global || \  
  die "/etc/mage.rc.global missing"  
   
 [ -f ${MAGERC} ] && source ${MAGERC} || \  
  die "Your ${MAGERC} is missing. Aborting."  
   
 [ -f ${MLIBDIR}/mage4.functions.sh ] && \  
  source ${MLIBDIR}/mage4.functions.sh || \  
  die "mage functions missing"  
14    
15  # export default path  # export default path
16  export PATH="${PATH}:${MLIBDIR}"  export PATH="${PATH}:${MLIBDIR}"
# Line 32  export LC_ALL=C Line 21  export LC_ALL=C
21  # sanity checks  # sanity checks
22  [ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE}  [ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE}
23    
24  if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] && [[ $1 != update-tarball ]]  if [ ! -e ${VIRTUALDB_DEFAULTS} ] &&
25     [[ $1 != update ]] &&
26     [[ $1 != update-rsync ]] &&
27     [[ $1 != update-tarball ]]
28  then  then
29   echo   echo
30   echo "Please choose an profile from the mage tree."   echo "Please choose an profile from the mage tree."
31   echo "ln -snf ${MAGEDIR}/profiles/profilename /etc/mage-profile"   echo "ln -snf ${MAGEDIR}/profiles/profilename @@SYSCONFDIR@@/mage-profile"
32   exit 1   exit 1
33  fi  fi
34    
35  # default messages  # default messages
 showversion()  
 {  
  local MAGEVERSION="$(< ${MLIBDIR}/version)"  
   
  echo -en "Magellan Package Manager v${MAGEVERSION} "  
  echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"  
 }  
   
36  print_usage()  print_usage()
37  {  {
38   #showversion   #showversion
# Line 60  print_usage() Line 44  print_usage()
44   echo "    install         - installs a package"   echo "    install         - installs a package"
45   echo "    srcinstall      - installs a package from source"   echo "    srcinstall      - installs a package from source"
46   echo "    uninstall       - removes a package"   echo "    uninstall       - removes a package"
47   echo "    update          - updates the mage-tree via rsync"   echo "    update          - updates the mage-tree via default sync method"
48     echo "    update-rsync    - updates the mage-tree via rsync"
49   echo "    update-tarball  - updates the mage-tree via a tarball"   echo "    update-tarball  - updates the mage-tree via a tarball"
50   echo "    uppretend       - pretend dependencies for a system upgrade"   echo "    uppretend       - pretend dependencies for a system upgrade"
51   echo "    upgrade         - runs a complete system upgrade"   echo "    upgrade         - runs a complete system upgrade"
52   echo "    srcuppretend    - pretend dependencies for a system upgrade from source"   echo "    srcuppretend    - pretend dependencies for a system upgrade from source"
53   echo "    srcupgrade      - runs a complete system upgrade from source"   echo "    srcupgrade      - runs a complete system upgrade from source"
54   echo "    pretend-build-prerequisites"   echo "    pretend-build-prerequisites - prints build prerequisites"
55   echo "    install-build-prerequisites"   echo "    install-build-prerequisites - install build prerequisites"
56     echo "    run-preinstall  - runs preinstall part of an installed package"
57     echo "    run-postinstall - runs postinstall part of an installed package"
58   echo "    search          - searches mage-tree for a package"   echo "    search          - searches mage-tree for a package"
59   echo "    clean           - removes *all* downloaded packages"   echo "    clean           - removes *all* downloaded packages"
60   echo "    unpack          - unpacks *all* needed package for 'foo'"   echo "    unpack          - unpacks *all* needed package for 'foo'"
# Line 106  if [[ ${METHOD} != upgrade ]] && Line 93  if [[ ${METHOD} != upgrade ]] &&
93   [[ ${METHOD} != uppretend ]] &&   [[ ${METHOD} != uppretend ]] &&
94   [[ ${METHOD} != srcuppretend ]] &&   [[ ${METHOD} != srcuppretend ]] &&
95   [[ ${METHOD} != update ]] &&   [[ ${METHOD} != update ]] &&
96     [[ ${METHOD} != update-rsync ]] &&
97   [[ ${METHOD} != update-tarball ]] &&   [[ ${METHOD} != update-tarball ]] &&
98   [[ ${METHOD} != clean ]] &&   [[ ${METHOD} != clean ]] &&
99   [[ ${METHOD} != version ]] &&   [[ ${METHOD} != version ]] &&
# Line 160  case ${METHOD} in Line 148  case ${METHOD} in
148   PBUILD="$(pkgname2pbuild ${PKGNAME})"   PBUILD="$(pkgname2pbuild ${PKGNAME})"
149    
150   # get all dependencies of this package   # get all dependencies of this package
151   ALLDEPS="$(${MLIBDIR}/depwalker.sh \   ALLDEPS="$(${MLIBDIR}/depwalker \
152   --method install \   --method install \
153   --pcat ${PCAT} \   --pcat ${PCAT} \
154   --pname ${PNAME} \   --pname ${PNAME} \
# Line 193  case ${METHOD} in Line 181  case ${METHOD} in
181   PBUILD="$(pkgname2pbuild ${PKGNAME})"   PBUILD="$(pkgname2pbuild ${PKGNAME})"
182    
183   # get all dependencies of this package   # get all dependencies of this package
184   ALLDEPS="$(${MLIBDIR}/depwalker.sh \   ALLDEPS="$(${MLIBDIR}/depwalker \
185   --method srcinstall \   --method srcinstall \
186   --pcat ${PCAT} \   --pcat ${PCAT} \
187   --pname ${PNAME} \   --pname ${PNAME} \
# Line 231  case ${METHOD} in Line 219  case ${METHOD} in
219   exit 3   exit 3
220   fi   fi
221   # get all dependencies of this package   # get all dependencies of this package
222   ${MLIBDIR}/depwalker.sh \   ${MLIBDIR}/depwalker \
223   --method ${METHOD} \   --method ${METHOD} \
224   --pcat ${PCAT} \   --pcat ${PCAT} \
225   --pname ${PNAME} \   --pname ${PNAME} \
# Line 270  case ${METHOD} in Line 258  case ${METHOD} in
258   fi   fi
259    
260   # get all dependencies of this package   # get all dependencies of this package
261   ALLDEPS="$(${MLIBDIR}/depwalker.sh \   ALLDEPS="$(${MLIBDIR}/depwalker \
262   --method ${METHOD} \   --method ${METHOD} \
263   --pcat ${PCAT} \   --pcat ${PCAT} \
264   --pname ${PNAME} \   --pname ${PNAME} \
# Line 314  case ${METHOD} in Line 302  case ${METHOD} in
302   fi   fi
303    
304   # get all dependencies of this package   # get all dependencies of this package
305   ALLDEPS="$(${MLIBDIR}/depwalker.sh \   ALLDEPS="$(${MLIBDIR}/depwalker \
306   --method ${METHOD} \   --method ${METHOD} \
307   --pcat ${PCAT} \   --pcat ${PCAT} \
308   --pname ${PNAME} \   --pname ${PNAME} \
# Line 336  case ${METHOD} in Line 324  case ${METHOD} in
324   uninstall_packages ${ALLDEPS}   uninstall_packages ${ALLDEPS}
325   ;;   ;;
326    
327     run-preinstall|run-postinstall)
328     have_root_privileges || die "You must be root to run this operation."
329    
330     ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})"
331     if [ -z "${ALLDEPS}" ]
332     then
333     die "No package installed named '${MAGENAME}'."
334     fi
335     rerun_pkgfunctions --method "${METHOD//run-}" ${ALLDEPS}
336     ;;
337    
338   uppretend|srcuppretend)   uppretend|srcuppretend)
339   ${MLIBDIR}/depwalker.sh \   ${MLIBDIR}/depwalker \
340   --method ${METHOD} \   --method ${METHOD} \
341   --pcat ${METHOD} \   --pcat ${METHOD} \
342   --pname ${METHOD} \   --pname ${METHOD} \
# Line 351  case ${METHOD} in Line 350  case ${METHOD} in
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 \
354   --method ${METHOD} \   --method ${METHOD} \
355   --pcat ${METHOD} \   --pcat ${METHOD} \
356   --pname ${METHOD} \   --pname ${METHOD} \
# Line 370  case ${METHOD} in Line 369  case ${METHOD} in
369    
370   # get all dependencies of *all* installed packages   # get all dependencies of *all* installed packages
371   # fake pcat,pname,pver,pbuild ...   # fake pcat,pname,pver,pbuild ...
372   ALLDEPS="$(${MLIBDIR}/depwalker.sh \   ALLDEPS="$(${MLIBDIR}/depwalker \
373   --method ${METHOD} \   --method ${METHOD} \
374   --pcat ${METHOD} \   --pcat ${METHOD} \
375   --pname ${METHOD} \   --pname ${METHOD} \
# Line 407  case ${METHOD} in Line 406  case ${METHOD} in
406   PBUILD="$(pkgname2pbuild ${PKGNAME})"   PBUILD="$(pkgname2pbuild ${PKGNAME})"
407    
408   # get all dependencies of this package   # get all dependencies of this package
409   ALLDEPS="$(${MLIBDIR}/depwalker.sh \   ALLDEPS="$(${MLIBDIR}/depwalker \
410   --method install \   --method install \
411   --pcat ${PCAT} \   --pcat ${PCAT} \
412   --pname ${PNAME} \   --pname ${PNAME} \
# Line 422  case ${METHOD} in Line 421  case ${METHOD} in
421    
422   update)   update)
423   have_root_privileges || die "You must be root to run this operation."   have_root_privileges || die "You must be root to run this operation."
424     # default to tarball
425     [[ -z ${MAGE_UPDATE_METHOD} ]] && MAGE_UPDATE_METHOD="tarball"
426     case ${MAGE_UPDATE_METHOD} in
427     rsync) syncmage ;;
428     tarball) syncmage_tarball ;;
429     *) die "Unknown MAGE_UPDATE_METHOD defined." ;;
430     esac
431     ;;
432    
433     update-rsync)
434     have_root_privileges || die "You must be root to run this operation."
435   syncmage   syncmage
436   ;;   ;;
437    

Legend:
Removed from v.2268  
changed lines
  Added in v.2620