Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 166 - (hide 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 niro 32 #!/bin/bash
2    
3     # mage upgrade
4 niro 166 # $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 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 niro 166 if [ ${x} = virtual ] ||
28 niro 32 [ ${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 niro 166 # needed packages may have been renamed ??
46 niro 32 if [ -d ${MAGEDIR}/${PCAT}/${PNAME} ]
47     then
48 niro 37 CATEGORIE=${PCAT} MAGENAME=${PNAME} get_highest_magefile &> /dev/null
49 niro 32
50 niro 166 # compare them
51 niro 32 if [[ $(basename ${HIGHEST_MAGEFILE} .mage) > ${PNAME}-${PVER}-${PBUILD} ]]
52     then
53     UPGRADE_LIST="${UPGRADE_LIST} ${PNAME}"
54 niro 80 SHOW_LIST="${SHOW_LIST}:${PCAT}/${PNAME},[${PVER}-${PBUILD} -> $(basename ${HIGHEST_MAGEFILE#${HIGHEST_MAGEFILE%-*-*}-} .mage)]"
55 niro 32 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 niro 166 # unset some vars for sure
66 niro 32 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 niro 80 # show the list
80 niro 32 echo
81 niro 80 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 niro 32 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 niro 166 # now run the update
102 niro 32 for package in ${UPGRADE_LIST}
103     do
104 niro 80 if [[ ${SRCINSTALL} = false ]]
105     then
106     /sbin/mage install ${package} || exit 1
107     else
108     /sbin/mage srcinstall ${package} || exit 1
109     fi
110 niro 166
111 niro 32 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 niro 166
125 niro 32 if [[ ${DEBUG} = true ]]
126     then
127     echo "Uninstallation of ${package} completed."
128     echo "Press any key to continue ..."
129     read
130     fi
131 niro 166
132     # resource /etc/profile
133 niro 32 source /etc/profile
134     done
135    
136     echo "The system upgrade is now complete."
137 niro 80
138     if [ -n "${PLEASE_VALIDATE}" ]
139 niro 32 then
140 niro 80 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 niro 32 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