Contents of /mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall
Parent Directory | Revision Log
Revision 2616 -
(show annotations)
(download)
Wed Jul 6 22:02:19 2011 UTC (12 years, 10 months ago) by niro
File size: 5671 byte(s)
Wed Jul 6 22:02:19 2011 UTC (12 years, 10 months ago) by niro
File size: 5671 byte(s)
-only remove /usr/X11R6 packages if this is a directory and not a symlink
1 | #!/bin/bash |
2 | # $Id$ |
3 | |
4 | # setup exit trap for reboot |
5 | trap_exit() |
6 | { |
7 | if [[ -f /.dist-upgrade ]] |
8 | then |
9 | rm -f /.dist-upgrade |
10 | # force a reboot at this point here |
11 | ( sleep 3 && reboot -f & ); exit 0 |
12 | fi |
13 | } |
14 | trap "trap_exit" EXIT |
15 | |
16 | # get a suitable environment |
17 | source /etc/profile |
18 | |
19 | MAGERC="/etc/mage.rc" |
20 | MAGEPROFILE="alx-060" |
21 | NEW_MAGE_DISTRIBUTION="unstable" |
22 | NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0" |
23 | NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}" |
24 | NEW_PACKAGES_SERVER_PATH='packages/${ARCH}' |
25 | NEW_MAGE_UNINSTALL_TIMEOUT=0 |
26 | |
27 | CONFIGRC="/etc/alxconfig-ng/config.rc" |
28 | NEW_ALX_NETWORKING="dhcp" |
29 | NEW_ALX_DHCP_PROG="/sbin/udhcpc" |
30 | NEW_ALX_DHCP_START="-T 10 -t 5 -n -i" |
31 | NEW_ALX_DHCP_STOP="" |
32 | NEW_MIN_DISK_SPACE="85000" |
33 | |
34 | read_value() |
35 | { |
36 | local file=$1 |
37 | local var=$2 |
38 | local value |
39 | |
40 | [[ ! -e ${file} ]] && return 1 |
41 | |
42 | value=$(source ${file}; echo $(eval echo \${${var}})) |
43 | echo "${value}" |
44 | return 0 |
45 | } |
46 | |
47 | updateconfig() |
48 | { |
49 | local variables="$@" |
50 | local value |
51 | local i |
52 | |
53 | if [[ -z ${CONFIG} ]] |
54 | then |
55 | echo "You must define \$CONFIG varibale first!" |
56 | return 1 |
57 | fi |
58 | |
59 | for i in ${variables} |
60 | do |
61 | value="$(eval echo \${NEW_${i}})" |
62 | if [[ ! -z $(grep "^${i}=" ${CONFIG}) ]] |
63 | then |
64 | echo "fixing ${i} -> ${value}" |
65 | sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${CONFIG} |
66 | else |
67 | echo "adding ${i}=${value}" |
68 | echo "${i}=\"${value}\"" >> ${CONFIG} |
69 | fi |
70 | done |
71 | } |
72 | |
73 | # fix mage.rc |
74 | CONFIG="${MAGERC}" |
75 | updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT |
76 | |
77 | # fix config.rc |
78 | CONFIG="${CONFIGRC}" |
79 | updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE |
80 | |
81 | # fix profile |
82 | if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]] |
83 | then |
84 | echo "fixing profile link -> /usr/mage/profiles/${MAGEPROFILE}" |
85 | ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile |
86 | fi |
87 | |
88 | # update mage3 -> mage4 |
89 | if [[ -z $(magequery -n mage) ]] |
90 | then |
91 | # update mage tree |
92 | mage update |
93 | |
94 | # mage3 has problems with md5 |
95 | rm -rf /usr/mage/app-mage/mage/md5 |
96 | if [[ ${NEW_MAGE_DISTRIBUTION} = unstable ]] |
97 | then |
98 | USE_UNSTABLE=true MAGE_DISTRIBUTION=unstable mage install mage |
99 | elif [[ ${NEW_MAGE_DISTRIBUTION} = testing ]] |
100 | then |
101 | USE_TESTING=true MAGE_DISTRIBUTION=testing mage install mage |
102 | else |
103 | mage install mage |
104 | fi |
105 | |
106 | # drop all virtuals |
107 | :> /var/db/mage/virtuals |
108 | |
109 | # enable run of orphaned files check |
110 | touch /.orphaned |
111 | |
112 | # tell that we're running an dist-upgrade |
113 | touch /.dist-upgrade |
114 | fi |
115 | |
116 | # only run this if X11R6 is a directory and not a symlink |
117 | if [[ -d /usr/X11R6 ]] && [[ ! -L /usr/X11R6 ]] |
118 | then |
119 | # check for -f option |
120 | if [[ -n $(magequery -h | grep -- -f) ]] |
121 | then |
122 | # uninstall all /usr/X11R6 packages first |
123 | for i in $(magequery -f /usr/X11R6 | sed 's:.*/\(.*\)-.*-r.*:\1:') |
124 | do |
125 | mage uninstall ${i} |
126 | done |
127 | fi |
128 | |
129 | # if there are any files after uninstall, simply delete them |
130 | [ -d /usr/X11R6 ] && rm -rf /usr/X11R6 |
131 | fi |
132 | |
133 | # install new toolchain if not exist |
134 | TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)" |
135 | if [[ -z $(magequery -n ${TOOLCHAIN}) ]] |
136 | then |
137 | # export bootstrap to not start any services |
138 | export MAGE_BOOTSTRAP=true |
139 | mage install ${TOOLCHAIN} |
140 | unset MAGE_BOOTSTRAP |
141 | |
142 | # enable run of orphaned files check |
143 | touch /.orphaned |
144 | |
145 | # tell that we're running an dist-upgrade |
146 | touch /.dist-upgrade |
147 | fi |
148 | |
149 | # install new basesystem |
150 | BASESYSTEM="$(< /etc/mage-profile/basesystem.defaults)" |
151 | if [[ -z $(magequery -n ${BASESYSTEM}) ]] |
152 | then |
153 | # first keep some important files |
154 | |
155 | # export bootstrap to not start any services |
156 | export MAGE_BOOTSTRAP=true |
157 | mage install ${BASESYSTEM} |
158 | unset MAGE_BOOTSTRAP |
159 | |
160 | # enable run of orphaned files check |
161 | touch /.orphaned |
162 | |
163 | # tell that we're running an dist-upgrade |
164 | touch /.dist-upgrade |
165 | fi |
166 | |
167 | # install remserial, if the plugin was enabled |
168 | if [[ ! -z $(magequery -n remserial-alx) ]] |
169 | then |
170 | mage install remserial |
171 | |
172 | # enable run of orphaned files check |
173 | touch /.orphaned |
174 | fi |
175 | |
176 | # etc-update |
177 | #etc-update |
178 | |
179 | # clean mage cache |
180 | mage clean |
181 | |
182 | echo "Searching for deprecated packages ..." |
183 | for i in $(magequery -i | grep -- -alx | sed 's:.*/\(.*\)-.*-.*:\1:') |
184 | do |
185 | # excludes |
186 | case ${i} in |
187 | alxconfig-ng) continue ;; |
188 | alxinstall-ng) continue ;; |
189 | kernel-alx) continue ;; |
190 | kernel26-alx) continue ;; |
191 | kernel-sources-alx) continue ;; |
192 | kernel26-sources-alx) continue ;; |
193 | esac |
194 | |
195 | echo "Removing deprecated mage-target '${i}'" |
196 | mage uninstall ${i} |
197 | done |
198 | |
199 | if [[ -f /.dist-upgrade ]] |
200 | then |
201 | # array of wireless opts |
202 | WIRELESS_OPTS=( WIRELESS_BITRATE WIRELESS_CHANNEL WIRELESS_ESSID WIRELESS_FREQUENCY WIRELESS_MODE WIRELESS_NICK WIRELESS_AUTH_MODE WIRELESS_KEY_LENGTH WIRELESS_KEY WIRELESS_KEY_ASCII WIRELESS_WPA_DRIVER ) |
203 | |
204 | # fixing current dhcp network settings |
205 | #for i in $(grep -irl NETWORKING=.*dhcp.* /etc/conf.d/net.*) |
206 | for i in $(grep -irl DHCP_PROG=.*dhcpcd.* /etc/conf.d/net.*) |
207 | do |
208 | case ${i} in |
209 | */net.sample) continue ;; |
210 | */net.routes) continue ;; |
211 | esac |
212 | |
213 | echo "fixing current dhcp network settings in '${i}'" |
214 | mv ${i}{,.orig} |
215 | onboot="$(read_value ${i}.orig ONBOOT)" |
216 | echo "ONBOOT=\"${onboot}\"" > ${i} |
217 | echo 'NETWORKING="dhcp"' >> ${i} |
218 | # check wireless extensions |
219 | for opt in ${WIRELESS_OPTS[*]} |
220 | do |
221 | value="$(read_value ${i}.orig ${opt})" |
222 | if [[ ! -z ${value} ]] |
223 | then |
224 | echo "${opt}=\"${value}\"" >> ${i} |
225 | fi |
226 | done |
227 | rm -f ${i}.orig |
228 | done |
229 | # search modules files |
230 | for i in $(find /etc/modules.d -name net.\*) |
231 | do |
232 | install -d /etc/modprobe.d |
233 | mv ${i} /etc/modprobe.d/${i%.conf}.conf |
234 | done |
235 | fi |
236 | |
237 | if [[ -f /.orphaned ]] |
238 | then |
239 | echo "Searching for orphaned files and directories ..." |
240 | bash /etc/mage-profile/prune-orphaned-files |
241 | rm -f /.orphaned |
242 | fi |
243 | |
244 | #if [[ -f /.dist-upgrade ]] |
245 | #then |
246 | # rm -f /.dist-upgrade |
247 | # # force a reboot at this point here |
248 | # ( reboot -f & ); exit 0 |
249 | #fi |