Magellan Linux

Diff of /branches/mage-next/usr/lib/mage/mage4.sh

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

revision 305 by niro, Mon Dec 26 23:13:42 2005 UTC revision 2358 by niro, Mon Jan 6 12:31:51 2014 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.12 2005-12-26 23:13:42 niro Exp $  # $Id$
4    
5  # default die function  # default die function
6  die()  die()
7  {  {
8     xtitleclean
9     mqueryfeature "debug" && echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT}
10   echo -e ${COLRED}"$@"${COLDEFAULT}   echo -e ${COLRED}"$@"${COLDEFAULT}
11   exit 1   exit 1
12  }  }
# Line 14  die() Line 16  die()
16   source /etc/mage.rc.global || \   source /etc/mage.rc.global || \
17   die "/etc/mage.rc.global missing"   die "/etc/mage.rc.global missing"
18    
19  [ -f /etc/mage.rc ] && source /etc/mage.rc || \  [ -f ${MAGERC} ] && source ${MAGERC} || \
20   die "Your /etc/mage.rc is missing. Aborting."   die "Your ${MAGERC} is missing. Aborting."
21    
22  [ -f ${MLIBDIR}/mage4.functions.sh ] && \  [ -f ${MLIBDIR}/mage4.functions.sh ] && \
23   source ${MLIBDIR}/mage4.functions.sh || \   source ${MLIBDIR}/mage4.functions.sh || \
24   die "mage functions missing"   die "mage functions missing"
25    
 ## 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  
   
26  # export default path  # export default path
27  export PATH="${PATH}:${MLIBDIR}"  export PATH="${PATH}:${MLIBDIR}"
28    
# Line 54  export LC_ALL=C Line 32  export LC_ALL=C
32  # sanity checks  # sanity checks
33  [ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE}  [ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE}
34    
35  if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]]  if [ ! -e ${VIRTUALDB_DEFAULTS} ] &&
36     [[ $1 != update ]] &&
37     [[ $1 != update-rsync ]] &&
38     [[ $1 != update-tarball ]]
39  then  then
40   echo   echo
41   echo "Please choose an profile from the mage tree."   echo "Please choose an profile from the mage tree."
# Line 82  print_usage() Line 63  print_usage()
63   echo "    install         - installs a package"   echo "    install         - installs a package"
64   echo "    srcinstall      - installs a package from source"   echo "    srcinstall      - installs a package from source"
65   echo "    uninstall       - removes a package"   echo "    uninstall       - removes a package"
66   echo "    update          - updates mage-tree"   echo "    update          - updates the mage-tree via default sync method"
67     echo "    update-rsync    - updates the mage-tree via rsync"
68     echo "    update-tarball  - updates the mage-tree via a tarball"
69   echo "    uppretend       - pretend dependencies for a system upgrade"   echo "    uppretend       - pretend dependencies for a system upgrade"
70   echo "    upgrade         - runs a complete system upgrade"   echo "    upgrade         - runs a complete system upgrade"
71   echo "    srcuppretend    - pretend dependencies for a system upgrade from source"   echo "    srcuppretend    - pretend dependencies for a system upgrade from source"
72   echo "    srcupgrade      - runs a complete system upgrade from source"   echo "    srcupgrade      - runs a complete system upgrade from source"
73     echo "    pretend-build-prerequisites - prints build prerequisites"
74     echo "    install-build-prerequisites - install build prerequisites"
75   echo "    search          - searches mage-tree for a package"   echo "    search          - searches mage-tree for a package"
76   echo "    clean           - removes *all* downloaded packages"   echo "    clean           - removes *all* downloaded packages"
77   echo "    unpack          - unpacks *all* needed package for 'foo'"   echo "    unpack          - unpacks *all* needed package for 'foo'"
78   echo "    download        - downloads *all* needed packages for 'foo'"   echo "    download        - downloads *all* needed packages for 'foo'"
79     echo "    print-features  - prints all enabled mage-features"
80   echo "    version         - prints version info"   echo "    version         - prints version info"
81   echo "    regen-mage-tree - regenerates the whole mage database (for devs only)"   echo "    regen-mage-tree - regenerates the whole mage database (for devs only)"
82   echo   echo
# Line 116  echo Line 102  echo
102  # install method  # install method
103  METHOD="$1"  METHOD="$1"
104    
105  # initial unversionized packagename, gets overridden later  # initial unversionized packagename, gets overridden later on
106  MAGENAME="$2"  MAGENAME="$2"
107    
108  if [[ ${METHOD} != upgrade ]] && \  if [[ ${METHOD} != upgrade ]] &&
109   [[ ${METHOD} != srcupgrade ]] && \   [[ ${METHOD} != srcupgrade ]] &&
110   [[ ${METHOD} != uppretend ]] && \   [[ ${METHOD} != uppretend ]] &&
111   [[ ${METHOD} != srcuppretend ]] && \   [[ ${METHOD} != srcuppretend ]] &&
112   [[ ${METHOD} != update ]] && \   [[ ${METHOD} != update ]] &&
113   [[ ${METHOD} != clean ]] && \   [[ ${METHOD} != update-rsync ]] &&
114   [[ ${METHOD} != version ]] && \   [[ ${METHOD} != update-tarball ]] &&
115   [[ ${METHOD} != search ]] && \   [[ ${METHOD} != clean ]] &&
116   [[ ${METHOD} != regen-mage-tree ]]   [[ ${METHOD} != version ]] &&
117     [[ ${METHOD} != search ]] &&
118     [[ ${METHOD} != regen-mage-tree ]] &&
119     [[ ${METHOD} != print-features ]]
120  then  then
121   [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1   [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1
122  fi  fi
# Line 142  fi Line 131  fi
131  # before anything run mage_setup  # before anything run mage_setup
132  mage_setup || die "error in mage_setup()"  mage_setup || die "error in mage_setup()"
133    
134    # load supported mage features
135    load_mage_features
136    
137    # query debug mode
138    if mqueryfeature "debug"
139    then
140     depwalker_debug="--debug"
141    else
142     depwalker_debug=""
143    fi
144    
145  case ${METHOD} in  case ${METHOD} in
146   download)   download)
147     have_root_privileges || die "You must be root to run this operation."
148    
149   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
150   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
151    
# Line 153  case ${METHOD} in Line 155  case ${METHOD} in
155   # source the highest magefile of this pkg   # source the highest magefile of this pkg
156   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
157    
158     # package is masked
159     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
160    
161   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
162   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
163   PNAME="$(pkgname2pname ${PKGNAME})"   PNAME="$(pkgname2pname ${PKGNAME})"
# Line 165  case ${METHOD} in Line 170  case ${METHOD} in
170   --pcat ${PCAT} \   --pcat ${PCAT} \
171   --pname ${PNAME} \   --pname ${PNAME} \
172   --pver ${PVER} \   --pver ${PVER} \
173   --pbuild ${PBUILD})"   --pbuild ${PBUILD} \
174     ${depwalker_debug})"
175   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
176   md5sum_packages ${ALLDEPS} || die "md5 sum packages"   md5sum_packages ${ALLDEPS} || die "md5 sum packages"
177   ;;   ;;
178    
179   srcdownload)   srcdownload)
180     have_root_privileges || die "You must be root to run this operation."
181    
182   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
183   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
184    
# Line 180  case ${METHOD} in Line 188  case ${METHOD} in
188   # source the highest magefile of this pkg   # source the highest magefile of this pkg
189   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
190    
191     # package is masked
192     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
193    
194   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
195   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
196   PNAME="$(pkgname2pname ${PKGNAME})"   PNAME="$(pkgname2pname ${PKGNAME})"
# Line 192  case ${METHOD} in Line 203  case ${METHOD} in
203   --pcat ${PCAT} \   --pcat ${PCAT} \
204   --pname ${PNAME} \   --pname ${PNAME} \
205   --pver ${PVER} \   --pver ${PVER} \
206   --pbuild ${PBUILD})"   --pbuild ${PBUILD} \
207     ${depwalker_debug})"
208   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
209   ;;   ;;
210    
211   pretend|srcpretend)   pretend|srcpretend|pretend-build-prerequisites)
212   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
213   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
214    
# Line 206  case ${METHOD} in Line 218  case ${METHOD} in
218   # source the highest magefile of this pkg   # source the highest magefile of this pkg
219   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
220    
221     # package is masked
222     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
223    
224   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
225   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
226   PNAME="$(pkgname2pname ${PKGNAME})"   PNAME="$(pkgname2pname ${PKGNAME})"
# Line 226  case ${METHOD} in Line 241  case ${METHOD} in
241   --pcat ${PCAT} \   --pcat ${PCAT} \
242   --pname ${PNAME} \   --pname ${PNAME} \
243   --pver ${PVER} \   --pver ${PVER} \
244   --pbuild ${PBUILD}   --pbuild ${PBUILD} \
245     ${depwalker_debug}
246   ;;   ;;
247    
248   install)   install|install-build-prerequisites)
249     have_root_privileges || die "You must be root to run this operation."
250    
251   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
252   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
253    
# Line 239  case ${METHOD} in Line 257  case ${METHOD} in
257   # source the highest magefile of this pkg   # source the highest magefile of this pkg
258   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
259    
260     # package is masked
261     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
262    
263   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
264   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
265   PNAME="$(pkgname2pname ${PKGNAME})"   PNAME="$(pkgname2pname ${PKGNAME})"
# Line 259  case ${METHOD} in Line 280  case ${METHOD} in
280   --pcat ${PCAT} \   --pcat ${PCAT} \
281   --pname ${PNAME} \   --pname ${PNAME} \
282   --pver ${PVER} \   --pver ${PVER} \
283   --pbuild ${PBUILD})"   --pbuild ${PBUILD} \
284     ${depwalker_debug})"
285    
286   # first fetch all packages   # first fetch all packages
287   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
288   md5sum_packages ${ALLDEPS} || die "md5 sum packages"   md5sum_packages ${ALLDEPS} || die "md5 sum packages"
  unpack_packages ${ALLDEPS} || die "unpacking packages"  
289   install_packages ${ALLDEPS} || die "installing packages"   install_packages ${ALLDEPS} || die "installing packages"
290   ;;   ;;
291    
292   srcinstall)   srcinstall)
293     have_root_privileges || die "You must be root to run this operation."
294    
295   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
296   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
297    
# Line 278  case ${METHOD} in Line 301  case ${METHOD} in
301   # source the highest magefile of this pkg   # source the highest magefile of this pkg
302   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
303    
304     # package is masked
305     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
306    
307   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
308   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
309   PNAME="$(pkgname2pname ${PKGNAME})"   PNAME="$(pkgname2pname ${PKGNAME})"
# Line 298  case ${METHOD} in Line 324  case ${METHOD} in
324   --pcat ${PCAT} \   --pcat ${PCAT} \
325   --pname ${PNAME} \   --pname ${PNAME} \
326   --pver ${PVER} \   --pver ${PVER} \
327   --pbuild ${PBUILD})"   --pbuild ${PBUILD} \
328     ${depwalker_debug})"
329    
330   install_packages --src-install ${ALLDEPS} || die "src-installing packages"   install_packages --src-install ${ALLDEPS} || die "src-installing packages"
331   ;;   ;;
332    
333   uninstall)   uninstall)
334   ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})"   have_root_privileges || die "You must be root to run this operation."
335   if [ -z "${ALLDEPS}" ]  
336   then   ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})"
337   die "No package installed named '${MAGENAME}'."   if [ -z "${ALLDEPS}" ]
338   fi   then
339   uninstall_packages ${ALLDEPS}   die "No package installed named '${MAGENAME}'."
340     fi
341     uninstall_packages ${ALLDEPS}
342   ;;   ;;
343    
344   uppretend|srcuppretend)   uppretend|srcuppretend)
# Line 318  case ${METHOD} in Line 347  case ${METHOD} in
347   --pcat ${METHOD} \   --pcat ${METHOD} \
348   --pname ${METHOD} \   --pname ${METHOD} \
349   --pver ${METHOD} \   --pver ${METHOD} \
350   --pbuild ${METHOD}   --pbuild ${METHOD} \
351     ${depwalker_debug}
352   ;;   ;;
353    
354   upgrade)   upgrade)
355     have_root_privileges || die "You must be root to run this operation."
356    
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 329  case ${METHOD} in Line 361  case ${METHOD} in
361   --pcat ${METHOD} \   --pcat ${METHOD} \
362   --pname ${METHOD} \   --pname ${METHOD} \
363   --pver ${METHOD} \   --pver ${METHOD} \
364   --pbuild ${METHOD})"   --pbuild ${METHOD} \
365     ${depwalker_debug})"
366    
367   # first fetch all packages   # first fetch all packages
368   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
369   md5sum_packages ${ALLDEPS} || die "md5 sum packages"   md5sum_packages ${ALLDEPS} || die "md5 sum packages"
  unpack_packages ${ALLDEPS} || die "unpacking packages"  
370   install_packages ${ALLDEPS} || die "installing packages"   install_packages ${ALLDEPS} || die "installing packages"
371   ;;   ;;
372    
373   srcupgrade)   srcupgrade)
374     have_root_privileges || die "You must be root to run this operation."
375    
376   # get all dependencies of *all* installed packages   # get all dependencies of *all* installed packages
377   # fake pcat,pname,pver,pbuild ...   # fake pcat,pname,pver,pbuild ...
378   ALLDEPS="$(${MLIBDIR}/depwalker.sh \   ALLDEPS="$(${MLIBDIR}/depwalker.sh \
# Line 346  case ${METHOD} in Line 380  case ${METHOD} in
380   --pcat ${METHOD} \   --pcat ${METHOD} \
381   --pname ${METHOD} \   --pname ${METHOD} \
382   --pver ${METHOD} \   --pver ${METHOD} \
383   --pbuild ${METHOD})"   --pbuild ${METHOD} \
384     ${depwalker_debug})"
385    
386   install_packages --src-install ${ALLDEPS} || die "src-installing packages"   install_packages --src-install ${ALLDEPS} || die "src-installing packages"
387   ;;   ;;
# Line 356  case ${METHOD} in Line 391  case ${METHOD} in
391   ;;   ;;
392    
393   unpack)   unpack)
394     have_root_privileges || die "You must be root to run this operation."
395    
396   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
397   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
398    
# Line 365  case ${METHOD} in Line 402  case ${METHOD} in
402   # source the highest magefile of this pkg   # source the highest magefile of this pkg
403   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
404    
405     # package is masked
406     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
407    
408   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
409   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
410   PNAME="$(pkgname2pname ${PKGNAME})"   PNAME="$(pkgname2pname ${PKGNAME})"
# Line 377  case ${METHOD} in Line 417  case ${METHOD} in
417   --pcat ${PCAT} \   --pcat ${PCAT} \
418   --pname ${PNAME} \   --pname ${PNAME} \
419   --pver ${PVER} \   --pver ${PVER} \
420   --pbuild ${PBUILD})"   --pbuild ${PBUILD} \
421     ${depwalker_debug})"
422    
423   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
424   md5sum_packages ${ALLDEPS} || die "md5 sum packages"   md5sum_packages ${ALLDEPS} || die "md5 sum packages"
425   unpack_packages ${ALLDEPS} || die "unpacking packages"   unpack_packages ${ALLDEPS} || die "unpacking packages"
426   ;;   ;;
427    
428   update)   update)
429     have_root_privileges || die "You must be root to run this operation."
430     # default to tarball
431     [[ -z ${MAGE_UPDATE_METHOD} ]] && MAGE_UPDATE_METHOD="tarball"
432     case ${MAGE_UPDATE_METHOD} in
433     rsync) syncmage ;;
434     tarball) syncmage_tarball ;;
435     *) die "Unknown MAGE_UPDATE_METHOD defined." ;;
436     esac
437     ;;
438    
439     update-rsync)
440     have_root_privileges || die "You must be root to run this operation."
441   syncmage   syncmage
442   ;;   ;;
443    
444     update-tarball)
445     have_root_privileges || die "You must be root to run this operation."
446     syncmage_tarball
447     ;;
448    
449   clean)   clean)
450     have_root_privileges || die "You must be root to run this operation."
451   cleanpkg   cleanpkg
452   ;;   ;;
453    
# Line 397  case ${METHOD} in Line 457  case ${METHOD} in
457   ;;   ;;
458    
459   regen-mage-tree)   regen-mage-tree)
460     have_root_privileges || die "You must be root to run this operation."
461    
462   if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ]   if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ]
463   then   then
464   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 408  case ${METHOD} in Line 470  case ${METHOD} in
470   done   done
471   ;;   ;;
472    
473     print-features)
474     mprintfeatures
475     ;;
476    
477   *)   *)
478   print_usage   print_usage
479   ;;   ;;

Legend:
Removed from v.305  
changed lines
  Added in v.2358