Magellan Linux

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

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

revision 226 by niro, Fri Sep 9 16:35:46 2005 UTC revision 739 by niro, Mon Jun 16 09:29:57 2008 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
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.1 2005-09-09 16:35:41 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  }  }
12    
13  # include all needed files  # include all needed files
14  # [ -f ${MLIBDIR}/conf/mage.rc.global ] &&  \  [ -f /etc/mage.rc.global ] &&  \
15  # source ${MLIBDIR}/conf/mage.rc.global || \   source /etc/mage.rc.global || \
16  # die "${MLIBDIR}/conf/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}/mage.functions.sh ] && \  [ -f ${MLIBDIR}/mage4.functions.sh ] && \
22  # source ${MLIBDIR}/mage.functions.sh || \   source ${MLIBDIR}/mage4.functions.sh || \
23  # die "mage functions missing"   die "mage functions missing"
   
 # for tests only  
 source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage.rc.global  
 source /etc/mage.rc  
 source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh  
 MLIBDIR=/home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage  
24    
25  ## only for tests -> normally in /etc/rc.d/init.d/functions  ## only for tests -> normally in /etc/rc.d/init.d/functions
26  COLRED="\033[1;6m\033[31m"  COLRED="\033[1;6m\033[31m"
27  COLGREEN="\033[1;6m\033[32m"  COLGREEN="\033[1;6m\033[32m"
28    COLYELLOW="\033[1;6m\033[33m"
29  COLBLUE="\033[1;6m\033[34m"  COLBLUE="\033[1;6m\033[34m"
30    COLMAGENTA="\033[1;6m\033[35m"
31    COLWHITE="\033[1;6m\033[37m"
32    COLGRAY="\033[0;6m\033[37m"
33    COLBOLD="\033[1m"
34  COLDEFAULT="\033[0m"  COLDEFAULT="\033[0m"
35    
36  if [[ ${NOCOLORS} = true ]]  if [[ ${NOCOLORS} = true ]]
# Line 41  then Line 41  then
41   COLBLUE=""   COLBLUE=""
42   COLMAGENTA=""   COLMAGENTA=""
43   COLWHITE=""   COLWHITE=""
44     COLGRAY=""
45     COLBOLD=""
46   COLDEFAULT=""   COLDEFAULT=""
47  fi  fi
48    
# Line 62  then Line 64  then
64  fi  fi
65    
66  # default messages  # default messages
67  showversion() {  showversion()
68    {
69   local MAGEVERSION="$(< ${MLIBDIR}/version)"   local MAGEVERSION="$(< ${MLIBDIR}/version)"
70    
71   echo -en "Magellan Package Manager v${MAGEVERSION} "   echo -en "Magellan Package Manager v${MAGEVERSION} "
72   echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"   echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"
73  }  }
74    
75  print_usage(){  print_usage()
76   showversion  {
77   echo   #showversion
78     #echo
79   echo "Usage: $(basename $0) [option] pkgname ..."   echo "Usage: $(basename $0) [option] pkgname ..."
80   echo "Options:"   echo "Options:"
81   echo "     pretend        - pretends dependencies of a package"   echo "    pretend         - pretends dependencies of a package"
82   echo "     srcpretend     - pretends dependencies of a package (build from source)"   echo "    srcpretend      - pretends dependencies of a package (build from source)"
83   echo "     install        - installs a package"   echo "    install         - installs a package"
84   echo "     srcinstall     - installs a package from source"   echo "    srcinstall      - installs a package from source"
85   echo "     uninstall      - removes a package"   echo "    uninstall       - removes a package"
86   echo "     update         - updates mage-tree"   echo "    update          - updates the mage-tree via rsync"
87   echo "     search         - searches mage-tree for a package"   echo "    update-tarball  - updates the mage-tree via a tarball"
88   echo "     clean          - removes *all* downloaded packages"   echo "    uppretend       - pretend dependencies for a system upgrade"
89  # echo "     unpack         - unpacks a package"   echo "    upgrade         - runs a complete system upgrade"
90   echo "     download       - downloads a package"   echo "    srcuppretend    - pretend dependencies for a system upgrade from source"
91   echo "     version        - prints version info"   echo "    srcupgrade      - runs a complete system upgrade from source"
92     echo "    search          - searches mage-tree for a package"
93     echo "    clean           - removes *all* downloaded packages"
94     echo "    unpack          - unpacks *all* needed package for 'foo'"
95     echo "    download        - downloads *all* needed packages for 'foo'"
96     echo "    version         - prints version info"
97     echo "    regen-mage-tree - regenerates the whole mage database (for devs only)"
98   echo   echo
99   echo "Other options:"   echo "Other options:"
100  # echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE"  # echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE"
101  # echo "Builds a Package with its dependencies, but won't install anything."  # echo "Builds a Package with its dependencies, but won't install anything."
102  # echo  # echo
103   echo "USE_UNSTABLE=true $(basename $0) [src]install PACKAGE"   echo "MAGE_DISTRIBUTION=unstable $(basename $0) [src]install PACKAGE"
104   echo "Overrides stable packages; you can install packages that are marked unstable."   echo "Overrides stable packages; you can install packages that are marked unstable."
105   echo   echo
106   echo "USE_TESTING=true $(basename $0) [src]install PACKAGE"   echo "MAGE_DISTRIBUTION=testing $(basename $0) [src]install PACKAGE"
107   echo "Overrides stable packages; you can install packages that are marked testing."   echo "Overrides stable packages; you can install packages that are marked testing."
108   echo   echo
109   echo "NOCOLORS=true $(basename $0) [src]install PACKAGE"   echo "NOCOLORS=true $(basename $0) [src]install PACKAGE"
# Line 105  print_usage(){ Line 115  print_usage(){
115  showversion  showversion
116  echo  echo
117    
 # before anything run mage_setup  
 mage_setup || die "error in mage_setup()"  
   
118  # install method  # install method
119  METHOD="$1"  METHOD="$1"
120    
121  # initial unversionized packagename, gets overridden later  # initial unversionized packagename, gets overridden later
122  MAGENAME="$2"  MAGENAME="$2"
123    
124  [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1  if [[ ${METHOD} != upgrade ]] && \
125     [[ ${METHOD} != srcupgrade ]] && \
126     [[ ${METHOD} != uppretend ]] && \
127     [[ ${METHOD} != srcuppretend ]] && \
128     [[ ${METHOD} != update ]] && \
129     [[ ${METHOD} != update-tarball ]] && \
130     [[ ${METHOD} != clean ]] && \
131     [[ ${METHOD} != version ]] && \
132     [[ ${METHOD} != search ]] && \
133     [[ ${METHOD} != regen-mage-tree ]]
134    then
135     [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1
136    fi
137    
138    # set PKGDIR and BUILDDIR to MROOT
139    if [[ -n ${MROOT} ]]
140    then
141     PKGDIR=${MROOT}/${PKGDIR}
142     BUILDDIR=${MROOT}/${BUILDDIR}
143    fi
144    
145    # before anything run mage_setup
146    mage_setup || die "error in mage_setup()"
147    
148  case ${METHOD} in  case ${METHOD} in
149   download)   download)
# Line 126  case ${METHOD} in Line 154  case ${METHOD} in
154   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
155    
156   # source the highest magefile of this pkg   # source the highest magefile of this pkg
157   source $(get_highest_magefile ${PCAT} ${MAGENAME})   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
158    
159     # package is masked
160     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
161    
162   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
163   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 142  case ${METHOD} in Line 173  case ${METHOD} in
173   --pver ${PVER} \   --pver ${PVER} \
174   --pbuild ${PBUILD})"   --pbuild ${PBUILD})"
175   fetch_packages ${ALLDEPS} || die "fetching packages"   fetch_packages ${ALLDEPS} || die "fetching packages"
176     md5sum_packages ${ALLDEPS} || die "md5 sum packages"
177   ;;   ;;
178    
179   srcdownload)   srcdownload)
# Line 152  case ${METHOD} in Line 184  case ${METHOD} in
184   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
185    
186   # source the highest magefile of this pkg   # source the highest magefile of this pkg
187   source $(get_highest_magefile ${PCAT} ${MAGENAME})   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
188    
189     # package is masked
190     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
191    
192   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
193   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 178  case ${METHOD} in Line 213  case ${METHOD} in
213   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
214    
215   # source the highest magefile of this pkg   # source the highest magefile of this pkg
216   source $(get_highest_magefile ${PCAT} ${MAGENAME})   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
217    
218     # package is masked
219     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
220    
221   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
222   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 211  case ${METHOD} in Line 249  case ${METHOD} in
249   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
250    
251   # source the highest magefile of this pkg   # source the highest magefile of this pkg
252   source $(get_highest_magefile ${PCAT} ${MAGENAME})   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
253    
254     # package is masked
255     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
256    
257   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
258   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 222  case ${METHOD} in Line 263  case ${METHOD} in
263   if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}   if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}
264   then   then
265   echo -en "Package "   echo -en "Package "
266   echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"   echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
267   echo -e  " already installed."   echo -e  " already installed."
268   exit 3   exit 3
269   fi   fi
# Line 250  case ${METHOD} in Line 291  case ${METHOD} in
291   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."   [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
292    
293   # source the highest magefile of this pkg   # source the highest magefile of this pkg
294   source $(get_highest_magefile ${PCAT} ${MAGENAME})   PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
295    
296     # package is masked
297     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
298    
299   # convert PKGNAME to PNAME/PVER/PBUILD   # convert PKGNAME to PNAME/PVER/PBUILD
300   # we're working *only* with these three vars from here on   # we're working *only* with these three vars from here on
# Line 261  case ${METHOD} in Line 305  case ${METHOD} in
305   if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}   if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}
306   then   then
307   echo -en "Package "   echo -en "Package "
308   echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"   echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
309   echo -e  " already installed."   echo -e  " already installed."
310   exit 3   exit 3
311   fi   fi
# Line 286  case ${METHOD} in Line 330  case ${METHOD} in
330   uninstall_packages ${ALLDEPS}   uninstall_packages ${ALLDEPS}
331   ;;   ;;
332    
333     uppretend|srcuppretend)
334     ${MLIBDIR}/depwalker.sh \
335     --method ${METHOD} \
336     --pcat ${METHOD} \
337     --pname ${METHOD} \
338     --pver ${METHOD} \
339     --pbuild ${METHOD}
340     ;;
341    
342     upgrade)
343     # get all dependencies of *all* installed packages
344     # fake pcat,pname,pver,pbuild ...
345     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
346     --method ${METHOD} \
347     --pcat ${METHOD} \
348     --pname ${METHOD} \
349     --pver ${METHOD} \
350     --pbuild ${METHOD})"
351    
352     # first fetch all packages
353     fetch_packages ${ALLDEPS} || die "fetching packages"
354     md5sum_packages ${ALLDEPS} || die "md5 sum packages"
355     unpack_packages ${ALLDEPS} || die "unpacking packages"
356     install_packages ${ALLDEPS} || die "installing packages"
357     ;;
358    
359     srcupgrade)
360     # get all dependencies of *all* installed packages
361     # fake pcat,pname,pver,pbuild ...
362     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
363     --method ${METHOD} \
364     --pcat ${METHOD} \
365     --pname ${METHOD} \
366     --pver ${METHOD} \
367     --pbuild ${METHOD})"
368    
369     install_packages --src-install ${ALLDEPS} || die "src-installing packages"
370     ;;
371    
372   search)   search)
373   ${MLIBDIR}/pkgsearch.sh ${MAGENAME}   pkgsearch "${MAGENAME}"
374   ;;   ;;
375    
376  # unpack)   unpack)
377  # build_unpackpkg   # first of all get the right pkg which going to be installed
378  # ;;   PCAT="$(pname2pcat ${MAGENAME})"
379    
380     # package does not exists
381     [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
382    
383     # source the highest magefile of this pkg
384     PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
385    
386     # package is masked
387     [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation."
388    
389     # convert PKGNAME to PNAME/PVER/PBUILD
390     # we're working *only* with these three vars from here on
391     PNAME="$(pkgname2pname ${PKGNAME})"
392     PVER="$(pkgname2pver ${PKGNAME})"
393     PBUILD="$(pkgname2pbuild ${PKGNAME})"
394    
395     # get all dependencies of this package
396     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
397     --method install \
398     --pcat ${PCAT} \
399     --pname ${PNAME} \
400     --pver ${PVER} \
401     --pbuild ${PBUILD})"
402     fetch_packages ${ALLDEPS} || die "fetching packages"
403     md5sum_packages ${ALLDEPS} || die "md5 sum packages"
404     unpack_packages ${ALLDEPS} || die "unpacking packages"
405     ;;
406    
407   update)   update)
408   syncmage   syncmage
409   ;;   ;;
410    
411     update-tarball)
412     syncmage_tarball
413     ;;
414    
415   clean)   clean)
416   cleanpkg   cleanpkg
417   ;;   ;;
418    
419   version)   version)
420   showversion   # showversion
421     exit 0
422   ;;   ;;
423    
424   regen-mage-tree)   regen-mage-tree)

Legend:
Removed from v.226  
changed lines
  Added in v.739