Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 166 - (show annotations) (download) (as text)
Fri Jul 29 14:18:41 2005 UTC (18 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 3524 byte(s)
fixed missing fake directory when updating

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