Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 80 - (hide annotations) (download) (as text)
Wed Jun 1 15:50:56 2005 UTC (18 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 3543 byte(s)
heavily changed:
- added preview which pkgs are going to be installed
- added src-compile support
- some minor logic fixes

1 niro 32 #!/bin/bash
2    
3     # mage upgrade
4 niro 80 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mageupgrade.sh,v 1.8 2005-06-01 15:50:56 niro Exp $
5 niro 32
6     # some default vars
7     : ${MLIBDIR=/usr/lib/mage}
8     : ${DEBUG=false}
9     : ${AUTOANSWER=false}
10 niro 80 : ${SRCINSTALL=false}
11 niro 32
12     source /etc/mage.rc
13     source ${MLIBDIR}/mage3.functions.sh
14 niro 80 source /etc/init.d/functions
15 niro 32
16 niro 80
17 niro 32 unset UPGRADE_LIST
18     unset PLEASE_VALIDATE
19    
20 niro 80 echo "Fetching list of all installed packages ..."
21    
22 niro 32 # get list
23     for directory in ${INSTALLDB}/*
24     do
25     # supress virtuals and fake packages or files
26     x=$(basename ${directory})
27     if [ ${x} = fake ] ||
28     [ ${x} = virtual ] ||
29     [ ${x} = virtuals ] ||
30     [ ${x} = virtuals.old ] ||
31     [ ! -d ${directory} ]
32     then
33     continue
34     fi
35    
36     for package in ${directory}/*
37     do
38     x=$(basename ${package})
39     PNAME=${x%-*-*}
40     PVER=$(echo ${x#${PNAME}-}| cut -d- -f1)
41     PBUILD=$(echo ${x#${PNAME}-}| cut -d- -f2)
42     PCAT=$(basename $(dirname ${package}))
43    
44     # check if there is any higher version in mage db
45    
46     #needed packages may have ben renamed ??
47     if [ -d ${MAGEDIR}/${PCAT}/${PNAME} ]
48     then
49 niro 37 CATEGORIE=${PCAT} MAGENAME=${PNAME} get_highest_magefile &> /dev/null
50 niro 32
51     #compare them
52     if [[ $(basename ${HIGHEST_MAGEFILE} .mage) > ${PNAME}-${PVER}-${PBUILD} ]]
53     then
54     UPGRADE_LIST="${UPGRADE_LIST} ${PNAME}"
55 niro 80 SHOW_LIST="${SHOW_LIST}:${PCAT}/${PNAME},[${PVER}-${PBUILD} -> $(basename ${HIGHEST_MAGEFILE#${HIGHEST_MAGEFILE%-*-*}-} .mage)]"
56 niro 32 else
57     # put them only on PLEASE_VALIDATE if they are not the same package
58     if [[ $(basename ${HIGHEST_MAGEFILE} .mage) != ${PNAME}-${PVER}-${PBUILD} ]]
59     then
60     echo "Not added: ${PNAME}-${PVER}-${PBUILD} is newer than $(basename ${HIGHEST_MAGEFILE} .mage)."
61     PLEASE_VALIDATE="${PLEASE_VALIDATE} ${PNAME}-${PVER}-${PBUILD}"
62     fi
63     fi
64     fi
65    
66     #unset some vars for shure
67     unset x
68     unset PNAME
69     unset PVER
70     unset PBUILD
71     unset PCAT
72     unset CATEGORIE
73     unset MAGENAME
74     unset HIGHEST_MAGEFILE
75     done
76     done
77    
78     unset package directory
79    
80 niro 80 # show the list
81 niro 32 echo
82 niro 80 echo "Packages selected for upgrade:"
83     OLDIFS="${IFS}"
84     IFS=:
85     for package in ${SHOW_LIST}
86     do
87     # nice output :)
88     echo -en \\033[10G
89     echo -en ${COLGREEN}"$(echo ${package} | cut -d',' -f1)"${COLDEFAULT}
90     echo -en \\033[40G
91     echo -e ${COLBLUE}"$(echo ${package} | cut -d',' -f2)"${COLDEFAULT}
92     done
93     IFS="${OLDIFS}"
94    
95    
96     echo
97 niro 32 echo "I'm now ready to upgrade your system."
98     echo "Press any key to continue or [CTRL-C] to abort ..."
99     echo
100     read
101    
102     #now run the update
103     for package in ${UPGRADE_LIST}
104     do
105 niro 80 if [[ ${SRCINSTALL} = false ]]
106     then
107     /sbin/mage install ${package} || exit 1
108     else
109     /sbin/mage srcinstall ${package} || exit 1
110     fi
111    
112 niro 32 if [[ ${DEBUG} = true ]]
113     then
114     echo "Installation of ${package} completed."
115     echo "Press any key to continue ..."
116     read
117     fi
118    
119     if [[ ${AUTOANSWER} = true ]]
120     then
121     yes | MAGE_UNINSTALL_TIMEOUT=0 /sbin/mage uninstall ${package} || exit 1
122     else
123     MAGE_UNINSTALL_TIMEOUT=0 /sbin/mage uninstall ${package} || exit 1
124     fi
125    
126     if [[ ${DEBUG} = true ]]
127     then
128     echo "Uninstallation of ${package} completed."
129     echo "Press any key to continue ..."
130     read
131     fi
132    
133     #resource /etc/profile
134     source /etc/profile
135     done
136    
137     echo "The system upgrade is now complete."
138 niro 80
139     if [ -n "${PLEASE_VALIDATE}" ]
140 niro 32 then
141 niro 80 echo -n "Would you like to see the list of ignored packages ? [ y/n ] "
142     read answer
143     if [[ ${answer} = y ]]
144     then
145     echo
146     for i in ${PLEASE_VALIDATE}
147     do
148     echo "avoided: ${i}"
149     done
150     fi
151 niro 32 fi
152    
153     echo
154     echo "Please remember to run etc-update to update your config files."
155     echo "You should also source /etc/profile or re-login to your shell."
156     echo