Annotation of /trunk/mage/usr/lib/mage/mageupgrade.sh
Parent Directory | Revision Log
Revision 32 -
(hide annotations)
(download)
(as text)
Thu Jan 6 02:54:09 2005 UTC (19 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 2696 byte(s)
Thu Jan 6 02:54:09 2005 UTC (19 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 2696 byte(s)
initial release
1 | niro | 32 | #!/bin/bash |
2 | |||
3 | # mage upgrade | ||
4 | |||
5 | # some default vars | ||
6 | : ${MLIBDIR=/usr/lib/mage} | ||
7 | : ${DEBUG=false} | ||
8 | : ${AUTOANSWER=false} | ||
9 | |||
10 | source /etc/mage.rc | ||
11 | source ${MLIBDIR}/mage3.functions.sh | ||
12 | |||
13 | unset UPGRADE_LIST | ||
14 | unset PLEASE_VALIDATE | ||
15 | |||
16 | # get list | ||
17 | for directory in ${INSTALLDB}/* | ||
18 | do | ||
19 | # supress virtuals and fake packages or files | ||
20 | x=$(basename ${directory}) | ||
21 | if [ ${x} = fake ] || | ||
22 | [ ${x} = virtual ] || | ||
23 | [ ${x} = virtuals ] || | ||
24 | [ ${x} = virtuals.old ] || | ||
25 | [ ! -d ${directory} ] | ||
26 | then | ||
27 | continue | ||
28 | fi | ||
29 | |||
30 | for package in ${directory}/* | ||
31 | do | ||
32 | x=$(basename ${package}) | ||
33 | PNAME=${x%-*-*} | ||
34 | PVER=$(echo ${x#${PNAME}-}| cut -d- -f1) | ||
35 | PBUILD=$(echo ${x#${PNAME}-}| cut -d- -f2) | ||
36 | PCAT=$(basename $(dirname ${package})) | ||
37 | |||
38 | # check if there is any higher version in mage db | ||
39 | |||
40 | #needed packages may have ben renamed ?? | ||
41 | if [ -d ${MAGEDIR}/${PCAT}/${PNAME} ] | ||
42 | then | ||
43 | CATEGORIE=${PCAT} MAGENAME=${PNAME} get_highest_magefile | ||
44 | |||
45 | #compare them | ||
46 | if [[ $(basename ${HIGHEST_MAGEFILE} .mage) > ${PNAME}-${PVER}-${PBUILD} ]] | ||
47 | then | ||
48 | UPGRADE_LIST="${UPGRADE_LIST} ${PNAME}" | ||
49 | else | ||
50 | # put them only on PLEASE_VALIDATE if they are not the same package | ||
51 | if [[ $(basename ${HIGHEST_MAGEFILE} .mage) != ${PNAME}-${PVER}-${PBUILD} ]] | ||
52 | then | ||
53 | echo "Not added: ${PNAME}-${PVER}-${PBUILD} is newer than $(basename ${HIGHEST_MAGEFILE} .mage)." | ||
54 | PLEASE_VALIDATE="${PLEASE_VALIDATE} ${PNAME}-${PVER}-${PBUILD}" | ||
55 | fi | ||
56 | fi | ||
57 | fi | ||
58 | |||
59 | #unset some vars for shure | ||
60 | unset x | ||
61 | unset PNAME | ||
62 | unset PVER | ||
63 | unset PBUILD | ||
64 | unset PCAT | ||
65 | unset CATEGORIE | ||
66 | unset MAGENAME | ||
67 | unset HIGHEST_MAGEFILE | ||
68 | done | ||
69 | done | ||
70 | |||
71 | unset package directory | ||
72 | |||
73 | echo | ||
74 | echo "I'm now ready to upgrade your system." | ||
75 | echo "Press any key to continue or [CTRL-C] to abort ..." | ||
76 | echo | ||
77 | read | ||
78 | |||
79 | #now run the update | ||
80 | for package in ${UPGRADE_LIST} | ||
81 | do | ||
82 | /sbin/mage install ${package} || exit 1 | ||
83 | if [[ ${DEBUG} = true ]] | ||
84 | then | ||
85 | echo "Installation of ${package} completed." | ||
86 | echo "Press any key to continue ..." | ||
87 | read | ||
88 | fi | ||
89 | |||
90 | if [[ ${AUTOANSWER} = true ]] | ||
91 | then | ||
92 | yes | MAGE_UNINSTALL_TIMEOUT=0 /sbin/mage uninstall ${package} || exit 1 | ||
93 | else | ||
94 | MAGE_UNINSTALL_TIMEOUT=0 /sbin/mage uninstall ${package} || exit 1 | ||
95 | fi | ||
96 | |||
97 | if [[ ${DEBUG} = true ]] | ||
98 | then | ||
99 | echo "Uninstallation of ${package} completed." | ||
100 | echo "Press any key to continue ..." | ||
101 | read | ||
102 | fi | ||
103 | |||
104 | #resource /etc/profile | ||
105 | source /etc/profile | ||
106 | done | ||
107 | |||
108 | echo "The system upgrade is now complete." | ||
109 | echo -n "Would you like to see the list of ignored packages ? [ y/n ] " | ||
110 | read answer | ||
111 | if [[ ${answer} = y ]] | ||
112 | then | ||
113 | echo | ||
114 | for i in ${PLEASE_VALIDATE} | ||
115 | do | ||
116 | echo "avoided: ${i}" | ||
117 | done | ||
118 | fi | ||
119 | |||
120 | echo | ||
121 | echo "Please remember to run etc-update to update your config files." | ||
122 | echo "You should also source /etc/profile or re-login to your shell." | ||
123 | echo |