Magellan Linux

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

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

revision 370 by niro, Thu Apr 27 11:52:59 2006 UTC revision 2222 by niro, Wed Oct 16 07:41:04 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.13 2006-04-27 11:52:59 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     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} ] && [[ $1 != update ]] && [[ $1 != update-tarball ]]
36  then  then
37   echo   echo
38   echo "Please choose an profile from the mage tree."   echo "Please choose an profile from the mage tree."
# Line 82  print_usage() Line 60  print_usage()
60   echo "    install         - installs a package"   echo "    install         - installs a package"
61   echo "    srcinstall      - installs a package from source"   echo "    srcinstall      - installs a package from source"
62   echo "    uninstall       - removes a package"   echo "    uninstall       - removes a package"
63   echo "    update          - updates mage-tree"   echo "    update          - updates the mage-tree via rsync"
64     echo "    update-tarball  - updates the mage-tree via a tarball"
65   echo "    uppretend       - pretend dependencies for a system upgrade"   echo "    uppretend       - pretend dependencies for a system upgrade"
66   echo "    upgrade         - runs a complete system upgrade"   echo "    upgrade         - runs a complete system upgrade"
67   echo "    srcuppretend    - pretend dependencies for a system upgrade from source"   echo "    srcuppretend    - pretend dependencies for a system upgrade from source"
68   echo "    srcupgrade      - runs a complete system upgrade from source"   echo "    srcupgrade      - runs a complete system upgrade from source"
69     echo "    pretend-build-prerequisites"
70     echo "    install-build-prerequisites"
71   echo "    search          - searches mage-tree for a package"   echo "    search          - searches mage-tree for a package"
72   echo "    clean           - removes *all* downloaded packages"   echo "    clean           - removes *all* downloaded packages"
73   echo "    unpack          - unpacks *all* needed package for 'foo'"   echo "    unpack          - unpacks *all* needed package for 'foo'"
74   echo "    download        - downloads *all* needed packages for 'foo'"   echo "    download        - downloads *all* needed packages for 'foo'"
75     echo "    print-features  - prints all enabled mage-features"
76   echo "    version         - prints version info"   echo "    version         - prints version info"
77   echo "    regen-mage-tree - regenerates the whole mage database (for devs only)"   echo "    regen-mage-tree - regenerates the whole mage database (for devs only)"
78   echo   echo
# Line 116  echo Line 98  echo
98  # install method  # install method
99  METHOD="$1"  METHOD="$1"
100    
101  # initial unversionized packagename, gets overridden later  # initial unversionized packagename, gets overridden later on
102  MAGENAME="$2"  MAGENAME="$2"
103    
104  if [[ ${METHOD} != upgrade ]] && \  if [[ ${METHOD} != upgrade ]] &&
105   [[ ${METHOD} != srcupgrade ]] && \   [[ ${METHOD} != srcupgrade ]] &&
106   [[ ${METHOD} != uppretend ]] && \   [[ ${METHOD} != uppretend ]] &&
107   [[ ${METHOD} != srcuppretend ]] && \   [[ ${METHOD} != srcuppretend ]] &&
108   [[ ${METHOD} != update ]] && \   [[ ${METHOD} != update ]] &&
109   [[ ${METHOD} != clean ]] && \   [[ ${METHOD} != update-tarball ]] &&
110   [[ ${METHOD} != version ]] && \   [[ ${METHOD} != clean ]] &&
111   [[ ${METHOD} != search ]] && \   [[ ${METHOD} != version ]] &&
112   [[ ${METHOD} != regen-mage-tree ]]   [[ ${METHOD} != search ]] &&
113     [[ ${METHOD} != regen-mage-tree ]] &&
114     [[ ${METHOD} != print-features ]]
115  then  then
116   [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1   [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1
117  fi  fi
# Line 142  fi Line 126  fi
126  # before anything run mage_setup  # before anything run mage_setup
127  mage_setup || die "error in mage_setup()"  mage_setup || die "error in mage_setup()"
128    
129    # load supported mage features
130    load_mage_features
131    
132    # query debug mode
133    if mqueryfeature "debug"
134    then
135     depwalker_debug="--debug"
136    else
137     depwalker_debug=""
138    fi
139    
140  case ${METHOD} in  case ${METHOD} in
141   download)   download)
142   # 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 148  case ${METHOD} in
148   # source the highest magefile of this pkg   # source the highest magefile of this pkg
149   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
150    
151   # package does not exists   # package is masked
152   [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
153    
154   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
155   # 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 163  case ${METHOD} in
163   --pcat ${PCAT} \   --pcat ${PCAT} \
164   --pname ${PNAME} \   --pname ${PNAME} \
165   --pver ${PVER} \   --pver ${PVER} \
166   --pbuild ${PBUILD})"   --pbuild ${PBUILD} \
167     ${depwalker_debug})"
168   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
169   md5sum_packages ${ALLDEPS} || die "md5 sum packages"   md5sum_packages ${ALLDEPS} || die "md5 sum packages"
170   ;;   ;;
# Line 183  case ${METHOD} in Line 179  case ${METHOD} in
179   # source the highest magefile of this pkg   # source the highest magefile of this pkg
180   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
181    
182   # package does not exists   # package is masked
183   [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
184    
185   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
186   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 198  case ${METHOD} in Line 194  case ${METHOD} in
194   --pcat ${PCAT} \   --pcat ${PCAT} \
195   --pname ${PNAME} \   --pname ${PNAME} \
196   --pver ${PVER} \   --pver ${PVER} \
197   --pbuild ${PBUILD})"   --pbuild ${PBUILD} \
198     ${depwalker_debug})"
199   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
200   ;;   ;;
201    
202   pretend|srcpretend)   pretend|srcpretend|pretend-build-prerequisites)
203   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
204   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
205    
# Line 212  case ${METHOD} in Line 209  case ${METHOD} in
209   # source the highest magefile of this pkg   # source the highest magefile of this pkg
210   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
211    
212   # package does not exists   # package is masked
213   [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
214    
215   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
216   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 235  case ${METHOD} in Line 232  case ${METHOD} in
232   --pcat ${PCAT} \   --pcat ${PCAT} \
233   --pname ${PNAME} \   --pname ${PNAME} \
234   --pver ${PVER} \   --pver ${PVER} \
235   --pbuild ${PBUILD}   --pbuild ${PBUILD} \
236     ${depwalker_debug}
237   ;;   ;;
238    
239   install)   install|install-build-prerequisites)
240     have_root_privileges || die "You must be root to run this operation."
241    
242   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
243   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
244    
# Line 248  case ${METHOD} in Line 248  case ${METHOD} in
248   # source the highest magefile of this pkg   # source the highest magefile of this pkg
249   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
250    
251   # package does not exists   # package is masked
252   [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
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 271  case ${METHOD} in Line 271  case ${METHOD} in
271   --pcat ${PCAT} \   --pcat ${PCAT} \
272   --pname ${PNAME} \   --pname ${PNAME} \
273   --pver ${PVER} \   --pver ${PVER} \
274   --pbuild ${PBUILD})"   --pbuild ${PBUILD} \
275     ${depwalker_debug})"
276    
277   # first fetch all packages   # first fetch all packages
278   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
279   md5sum_packages ${ALLDEPS} || die "md5 sum packages"   md5sum_packages ${ALLDEPS} || die "md5 sum packages"
  unpack_packages ${ALLDEPS} || die "unpacking packages"  
280   install_packages ${ALLDEPS} || die "installing packages"   install_packages ${ALLDEPS} || die "installing packages"
281   ;;   ;;
282    
283   srcinstall)   srcinstall)
284     have_root_privileges || die "You must be root to run this operation."
285    
286   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
287   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
288    
# Line 290  case ${METHOD} in Line 292  case ${METHOD} in
292   # source the highest magefile of this pkg   # source the highest magefile of this pkg
293   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
294    
295   # package does not exists   # package is masked
296   [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
297    
298   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
299   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 313  case ${METHOD} in Line 315  case ${METHOD} in
315   --pcat ${PCAT} \   --pcat ${PCAT} \
316   --pname ${PNAME} \   --pname ${PNAME} \
317   --pver ${PVER} \   --pver ${PVER} \
318   --pbuild ${PBUILD})"   --pbuild ${PBUILD} \
319     ${depwalker_debug})"
320    
321   install_packages --src-install ${ALLDEPS} || die "src-installing packages"   install_packages --src-install ${ALLDEPS} || die "src-installing packages"
322   ;;   ;;
323    
324   uninstall)   uninstall)
325   ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})"   have_root_privileges || die "You must be root to run this operation."
326   if [ -z "${ALLDEPS}" ]  
327   then   ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})"
328   die "No package installed named '${MAGENAME}'."   if [ -z "${ALLDEPS}" ]
329   fi   then
330   uninstall_packages ${ALLDEPS}   die "No package installed named '${MAGENAME}'."
331     fi
332     uninstall_packages ${ALLDEPS}
333   ;;   ;;
334    
335   uppretend|srcuppretend)   uppretend|srcuppretend)
# Line 333  case ${METHOD} in Line 338  case ${METHOD} in
338   --pcat ${METHOD} \   --pcat ${METHOD} \
339   --pname ${METHOD} \   --pname ${METHOD} \
340   --pver ${METHOD} \   --pver ${METHOD} \
341   --pbuild ${METHOD}   --pbuild ${METHOD} \
342     ${depwalker_debug}
343   ;;   ;;
344    
345   upgrade)   upgrade)
346     have_root_privileges || die "You must be root to run this operation."
347    
348   # get all dependencies of *all* installed packages   # get all dependencies of *all* installed packages
349   # fake pcat,pname,pver,pbuild ...   # fake pcat,pname,pver,pbuild ...
350   ALLDEPS="$(${MLIBDIR}/depwalker.sh \   ALLDEPS="$(${MLIBDIR}/depwalker.sh \
# Line 344  case ${METHOD} in Line 352  case ${METHOD} in
352   --pcat ${METHOD} \   --pcat ${METHOD} \
353   --pname ${METHOD} \   --pname ${METHOD} \
354   --pver ${METHOD} \   --pver ${METHOD} \
355   --pbuild ${METHOD})"   --pbuild ${METHOD} \
356     ${depwalker_debug})"
357    
358   # first fetch all packages   # first fetch all packages
359   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
360   md5sum_packages ${ALLDEPS} || die "md5 sum packages"   md5sum_packages ${ALLDEPS} || die "md5 sum packages"
  unpack_packages ${ALLDEPS} || die "unpacking packages"  
361   install_packages ${ALLDEPS} || die "installing packages"   install_packages ${ALLDEPS} || die "installing packages"
362   ;;   ;;
363    
364   srcupgrade)   srcupgrade)
365     have_root_privileges || die "You must be root to run this operation."
366    
367   # get all dependencies of *all* installed packages   # get all dependencies of *all* installed packages
368   # fake pcat,pname,pver,pbuild ...   # fake pcat,pname,pver,pbuild ...
369   ALLDEPS="$(${MLIBDIR}/depwalker.sh \   ALLDEPS="$(${MLIBDIR}/depwalker.sh \
# Line 361  case ${METHOD} in Line 371  case ${METHOD} in
371   --pcat ${METHOD} \   --pcat ${METHOD} \
372   --pname ${METHOD} \   --pname ${METHOD} \
373   --pver ${METHOD} \   --pver ${METHOD} \
374   --pbuild ${METHOD})"   --pbuild ${METHOD} \
375     ${depwalker_debug})"
376    
377   install_packages --src-install ${ALLDEPS} || die "src-installing packages"   install_packages --src-install ${ALLDEPS} || die "src-installing packages"
378   ;;   ;;
# Line 371  case ${METHOD} in Line 382  case ${METHOD} in
382   ;;   ;;
383    
384   unpack)   unpack)
385     have_root_privileges || die "You must be root to run this operation."
386    
387   # first of all get the right pkg which going to be installed   # first of all get the right pkg which going to be installed
388   PCAT="$(pname2pcat ${MAGENAME})"   PCAT="$(pname2pcat ${MAGENAME})"
389    
# Line 380  case ${METHOD} in Line 393  case ${METHOD} in
393   # source the highest magefile of this pkg   # source the highest magefile of this pkg
394   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
395    
396   # package does not exists   # package is masked
397   [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
398    
399   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
400   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 395  case ${METHOD} in Line 408  case ${METHOD} in
408   --pcat ${PCAT} \   --pcat ${PCAT} \
409   --pname ${PNAME} \   --pname ${PNAME} \
410   --pver ${PVER} \   --pver ${PVER} \
411   --pbuild ${PBUILD})"   --pbuild ${PBUILD} \
412     ${depwalker_debug})"
413    
414   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
415   md5sum_packages ${ALLDEPS} || die "md5 sum packages"   md5sum_packages ${ALLDEPS} || die "md5 sum packages"
416   unpack_packages ${ALLDEPS} || die "unpacking packages"   unpack_packages ${ALLDEPS} || die "unpacking packages"
417   ;;   ;;
418    
419   update)   update)
420     have_root_privileges || die "You must be root to run this operation."
421   syncmage   syncmage
422   ;;   ;;
423    
424     update-tarball)
425     have_root_privileges || die "You must be root to run this operation."
426     syncmage_tarball
427     ;;
428    
429   clean)   clean)
430     have_root_privileges || die "You must be root to run this operation."
431   cleanpkg   cleanpkg
432   ;;   ;;
433    
# Line 415  case ${METHOD} in Line 437  case ${METHOD} in
437   ;;   ;;
438    
439   regen-mage-tree)   regen-mage-tree)
440     have_root_privileges || die "You must be root to run this operation."
441    
442   if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ]   if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ]
443   then   then
444   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 426  case ${METHOD} in Line 450  case ${METHOD} in
450   done   done
451   ;;   ;;
452    
453     print-features)
454     mprintfeatures
455     ;;
456    
457   *)   *)
458   print_usage   print_usage
459   ;;   ;;

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