Magellan Linux

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

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

revision 166 by niro, Fri Jul 29 14:18:41 2005 UTC revision 211 by niro, Sun Aug 28 19:19:25 2005 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    
3  # mage upgrade  # mage upgrade
4  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mageupgrade.sh,v 1.9 2005-07-29 14:18:41 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mageupgrade.sh,v 1.11 2005-08-28 19:19:25 niro Exp $
5    
6  # some default vars  # some default vars
7  : ${MLIBDIR=/usr/lib/mage}  : ${MLIBDIR=/usr/lib/mage}
8  : ${DEBUG=false}  : ${DEBUG=false}
9  : ${AUTOANSWER=false}  : ${AUTOANSWER=false}
10  : ${SRCINSTALL=false}  : ${SRCINSTALL=false}
11    : ${AUTOCLEAN=false}
12    : ${NO_CALC=false}
13    
14  source /etc/mage.rc  source /etc/mage.rc
15  source ${MLIBDIR}/mage3.functions.sh  source ${MLIBDIR}/mage3.functions.sh
16  source /etc/init.d/functions  source /etc/init.d/functions
17    
   
18  unset UPGRADE_LIST  unset UPGRADE_LIST
19  unset PLEASE_VALIDATE  unset PLEASE_VALIDATE
20    
21  echo "Fetching list of all installed packages ..."  if [[ ${NOCOLORS} = true ]]
22    then
23     COLRED=""
24     COLGREEN=""
25     COLYELLOW=""
26     COLBLUE=""
27     COLMAGENTA=""
28     COLWHITE=""
29     COLDEFAULT=""
30    fi
31    
32    usage()
33    {
34     echo
35     echo "Usage: $(basename $0) [command] ..."
36     echo
37     echo "   --help          shows this help"
38     echo "   --calc          only calculates the dependencies"
39     echo "   --calc-bash     only calculates the deps but with scriptable output"
40     echo "                   output: categorie,pname,oldpver,newpver"
41     echo "   --no-calc       do not show deps, running straight forward"
42     echo "   --autoclean     clean all downloaded files automatically"
43     echo "   --autoanswer    answer all questions automatically"
44     echo "   --src-install   install from sources rather from binary packages"
45     echo "   --debug         show debug messages"
46     echo
47     exit 1
48    }
49    
50    # get options
51    for opt in $@
52    do
53     case ${opt} in
54     --no-calc)
55     NO_CALC=true
56     ;;
57     --calc)
58     ONLY_CALC_DEPS=true
59     ;;
60     --calc-bash)
61     ONLY_CALC_DEPS_SCRIPTABLE=true
62     ;;
63     --autoclean)
64     AUTOCLEAN=true
65     ;;
66     --autoanswer)
67     AUTOANSWER=true
68     ;;
69     --src-install)
70     SRCINSTALL=true
71     ;;
72     --debug)
73     DEBUG=true
74     ;;
75     --help)
76     usage
77     ;;
78     *)
79     usage
80     ;;
81     esac
82    done
83    
84    # show this only if ONLY_CALC_DEPS_SCRIPTABLE is not set
85    [[ ${ONLY_CALC_DEPS_SCRIPTABLE} != true ]] && \
86     echo "Fetching list of all installed packages ..."
87    
88  # get list  # get list
89  for directory in ${INSTALLDB}/*  for directory in ${INSTALLDB}/*
# Line 52  do Line 118  do
118   then   then
119   UPGRADE_LIST="${UPGRADE_LIST} ${PNAME}"   UPGRADE_LIST="${UPGRADE_LIST} ${PNAME}"
120   SHOW_LIST="${SHOW_LIST}:${PCAT}/${PNAME},[${PVER}-${PBUILD} -> $(basename ${HIGHEST_MAGEFILE#${HIGHEST_MAGEFILE%-*-*}-} .mage)]"   SHOW_LIST="${SHOW_LIST}:${PCAT}/${PNAME},[${PVER}-${PBUILD} -> $(basename ${HIGHEST_MAGEFILE#${HIGHEST_MAGEFILE%-*-*}-} .mage)]"
121     SHOW_LIST_SCRIPTABLE="${SHOW_LIST_SCRIPTABLE}:${PCAT},${PNAME},${PVER}-${PBUILD},$(basename ${HIGHEST_MAGEFILE#${HIGHEST_MAGEFILE%-*-*}-} .mage)"
122   else   else
123   # put them only on PLEASE_VALIDATE if they are not the same package   # put them only on PLEASE_VALIDATE if they are not the same package
124   if [[ $(basename ${HIGHEST_MAGEFILE} .mage) != ${PNAME}-${PVER}-${PBUILD} ]]   if [[ $(basename ${HIGHEST_MAGEFILE} .mage) != ${PNAME}-${PVER}-${PBUILD} ]]
125   then   then
126   echo "Not added: ${PNAME}-${PVER}-${PBUILD} is newer than $(basename ${HIGHEST_MAGEFILE} .mage)."   # show this only if ONLY_CALC_DEPS_SCRIPTABLE is not set
127     [[ ${ONLY_CALC_DEPS_SCRIPTABLE} != true ]] && \
128     echo "Not added: ${PNAME}-${PVER}-${PBUILD} is newer than $(basename ${HIGHEST_MAGEFILE} .mage)."
129   PLEASE_VALIDATE="${PLEASE_VALIDATE} ${PNAME}-${PVER}-${PBUILD}"   PLEASE_VALIDATE="${PLEASE_VALIDATE} ${PNAME}-${PVER}-${PBUILD}"
130   fi   fi
131   fi   fi
# Line 76  done Line 145  done
145    
146  unset package directory  unset package directory
147    
148  # show the list  if [[ ${NO_CALC} = false ]] && [[ ${AUTOANSWER} = false ]]
149  echo  then
150  echo "Packages selected for upgrade:"   # show the list
151  OLDIFS="${IFS}"   if [[ ${ONLY_CALC_DEPS_SCRIPTABLE} = true ]]
152  IFS=:   then
153  for package in ${SHOW_LIST}   OLDIFS="${IFS}"
154  do   IFS=:
155   # nice output :)   for package in ${SHOW_LIST_SCRIPTABLE}
156   echo -en \\033[10G   do
157   echo -en ${COLGREEN}"$(echo ${package} | cut -d',' -f1)"${COLDEFAULT}   # only if not empty # scriptable output
158   echo -en \\033[40G   [ -n "${package}" ] && echo "${package}"
159   echo -e ${COLBLUE}"$(echo ${package} | cut -d',' -f2)"${COLDEFAULT}   done
160  done   IFS="${OLDIFS}"
161  IFS="${OLDIFS}"   else
162     echo
163     echo "Packages selected for upgrade:"
164     OLDIFS="${IFS}"
165     IFS=:
166     for package in ${SHOW_LIST}
167     do
168     # nice output :)
169     echo -en \\033[10G
170     echo -en ${COLGREEN}"$(echo ${package} | cut -d',' -f1)"${COLDEFAULT}
171     echo -en \\033[40G
172     echo -e ${COLBLUE}"$(echo ${package} | cut -d',' -f2)"${COLDEFAULT}
173     done
174     IFS="${OLDIFS}"
175     fi
176     # exit now if only_calc_deps is set
177     [[ ${ONLY_CALC_DEPS} = true ]] || \
178     [[ ${ONLY_CALC_DEPS_SCRIPTABLE} = true ]] && exit 0
179    
180     echo
181     echo "I'm now ready to upgrade your system."
182     echo "Press any key to continue or [CTRL-C] to abort ..."
183     echo
184     read
185    fi
186    
 echo  
 echo "I'm now ready to upgrade your system."  
 echo "Press any key to continue or [CTRL-C] to abort ..."  
 echo  
 read  
187    
188  # now run the update  # now run the update
189  for package in ${UPGRADE_LIST}  for package in ${UPGRADE_LIST}
# Line 122  do Line 209  do
209   MAGE_UNINSTALL_TIMEOUT=0 /sbin/mage uninstall ${package} || exit 1   MAGE_UNINSTALL_TIMEOUT=0 /sbin/mage uninstall ${package} || exit 1
210   fi   fi
211    
212     if [[ ${AUTOCLEAN} = true ]]
213     then
214     /sbin/mage clean || exit 1
215     if [[ ${SRCINSTALL} = true ]] && \
216     [ -d ${SOURCEDIR}/${package} ]
217     then
218     rm -f ${SOURCEDIR}/${package} || exit 1
219     fi
220     fi
221    
222   if [[ ${DEBUG} = true ]]   if [[ ${DEBUG} = true ]]
223   then   then
224   echo "Uninstallation of ${package} completed."   echo "Uninstallation of ${package} completed."
# Line 135  done Line 232  done
232    
233  echo "The system upgrade is now complete."  echo "The system upgrade is now complete."
234    
235  if [ -n "${PLEASE_VALIDATE}" ]  if [ -n "${PLEASE_VALIDATE}" ] && [[ ${AUTOANSWER} = false ]]
236  then  then
237   echo -n "Would you like to see the list of ignored packages ? [ y/n ] "   echo -n "Would you like to see the list of ignored packages ? [ y/n ] "
238   read answer   read answer

Legend:
Removed from v.166  
changed lines
  Added in v.211