Annotation of /mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall
Parent Directory | Revision Log
Revision 2716 -
(hide annotations)
(download)
Mon Aug 8 08:23:09 2011 UTC (13 years, 1 month ago) by niro
File size: 7150 byte(s)
Mon Aug 8 08:23:09 2011 UTC (13 years, 1 month ago) by niro
File size: 7150 byte(s)
-honor new variable ALX_PLUGLINS and install/update the grub bootloader and initrd/initramfs
1 | niro | 2081 | #!/bin/bash |
2 | # $Id$ | ||
3 | |||
4 | niro | 2181 | # 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 | niro | 2179 | 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 | niro | 2572 | NEW_ALX_DHCP_START="-T 10 -t 5 -n -i" |
31 | niro | 2179 | NEW_ALX_DHCP_STOP="" |
32 | niro | 2373 | NEW_MIN_DISK_SPACE="85000" |
33 | niro | 2716 | NEW_ALX_PLUGINS="/etc/alxconfig-ng/plugins" |
34 | niro | 2179 | |
35 | niro | 2112 | read_value() |
36 | { | ||
37 | local file=$1 | ||
38 | local var=$2 | ||
39 | local value | ||
40 | |||
41 | [[ ! -e ${file} ]] && return 1 | ||
42 | |||
43 | value=$(source ${file}; echo $(eval echo \${${var}})) | ||
44 | echo "${value}" | ||
45 | return 0 | ||
46 | } | ||
47 | |||
48 | niro | 2179 | updateconfig() |
49 | { | ||
50 | local variables="$@" | ||
51 | local value | ||
52 | local i | ||
53 | niro | 2081 | |
54 | niro | 2179 | if [[ -z ${CONFIG} ]] |
55 | niro | 2081 | then |
56 | niro | 2179 | echo "You must define \$CONFIG varibale first!" |
57 | return 1 | ||
58 | niro | 2081 | fi |
59 | |||
60 | niro | 2179 | for i in ${variables} |
61 | do | ||
62 | value="$(eval echo \${NEW_${i}})" | ||
63 | if [[ ! -z $(grep "^${i}=" ${CONFIG}) ]] | ||
64 | then | ||
65 | echo "fixing ${i} -> ${value}" | ||
66 | sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${CONFIG} | ||
67 | else | ||
68 | echo "adding ${i}=${value}" | ||
69 | echo "${i}=\"${value}\"" >> ${CONFIG} | ||
70 | fi | ||
71 | done | ||
72 | } | ||
73 | |||
74 | niro | 2716 | updategrub2() |
75 | { | ||
76 | # create a device.map | ||
77 | if [[ ! -f /boot/grub/device.map ]] | ||
78 | then | ||
79 | grub-mkdevicemap | ||
80 | fi | ||
81 | |||
82 | # needed by grub-mkconfig on the first run | ||
83 | if [[ ! -f /boot/grub/video.lst ]] | ||
84 | then | ||
85 | install -m0644 /lib/grub/*/video.lst /boot/grub/video.lst | ||
86 | fi | ||
87 | |||
88 | # update grub.cfg | ||
89 | grub-mkconfig -o /boot/grub/grub.cfg | ||
90 | |||
91 | # install bootloader to disk | ||
92 | local bootdisk | ||
93 | bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')" | ||
94 | |||
95 | # Generate core.img, but don't let it be installed in boot sector | ||
96 | grub-install --no-floppy "${bootdisk}" | ||
97 | } | ||
98 | |||
99 | niro | 2179 | # fix mage.rc |
100 | CONFIG="${MAGERC}" | ||
101 | updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT | ||
102 | |||
103 | # fix config.rc | ||
104 | CONFIG="${CONFIGRC}" | ||
105 | niro | 2716 | updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE ALX_PLUGINS |
106 | niro | 2179 | |
107 | niro | 2081 | # fix profile |
108 | if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]] | ||
109 | then | ||
110 | echo "fixing profile link -> /usr/mage/profiles/${MAGEPROFILE}" | ||
111 | ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile | ||
112 | fi | ||
113 | |||
114 | # update mage3 -> mage4 | ||
115 | if [[ -z $(magequery -n mage) ]] | ||
116 | then | ||
117 | # update mage tree | ||
118 | mage update | ||
119 | |||
120 | # mage3 has problems with md5 | ||
121 | rm -rf /usr/mage/app-mage/mage/md5 | ||
122 | if [[ ${NEW_MAGE_DISTRIBUTION} = unstable ]] | ||
123 | then | ||
124 | USE_UNSTABLE=true MAGE_DISTRIBUTION=unstable mage install mage | ||
125 | elif [[ ${NEW_MAGE_DISTRIBUTION} = testing ]] | ||
126 | then | ||
127 | USE_TESTING=true MAGE_DISTRIBUTION=testing mage install mage | ||
128 | else | ||
129 | mage install mage | ||
130 | fi | ||
131 | |||
132 | # drop all virtuals | ||
133 | :> /var/db/mage/virtuals | ||
134 | |||
135 | # enable run of orphaned files check | ||
136 | touch /.orphaned | ||
137 | niro | 2112 | |
138 | # tell that we're running an dist-upgrade | ||
139 | touch /.dist-upgrade | ||
140 | niro | 2081 | fi |
141 | |||
142 | niro | 2616 | # only run this if X11R6 is a directory and not a symlink |
143 | if [[ -d /usr/X11R6 ]] && [[ ! -L /usr/X11R6 ]] | ||
144 | niro | 2373 | then |
145 | niro | 2616 | # check for -f option |
146 | if [[ -n $(magequery -h | grep -- -f) ]] | ||
147 | then | ||
148 | # uninstall all /usr/X11R6 packages first | ||
149 | for i in $(magequery -f /usr/X11R6 | sed 's:.*/\(.*\)-.*-r.*:\1:') | ||
150 | do | ||
151 | mage uninstall ${i} | ||
152 | done | ||
153 | fi | ||
154 | |||
155 | # if there are any files after uninstall, simply delete them | ||
156 | [ -d /usr/X11R6 ] && rm -rf /usr/X11R6 | ||
157 | niro | 2373 | fi |
158 | |||
159 | niro | 2081 | # install new toolchain if not exist |
160 | TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)" | ||
161 | if [[ -z $(magequery -n ${TOOLCHAIN}) ]] | ||
162 | then | ||
163 | # export bootstrap to not start any services | ||
164 | export MAGE_BOOTSTRAP=true | ||
165 | mage install ${TOOLCHAIN} | ||
166 | unset MAGE_BOOTSTRAP | ||
167 | |||
168 | # enable run of orphaned files check | ||
169 | touch /.orphaned | ||
170 | niro | 2112 | |
171 | # tell that we're running an dist-upgrade | ||
172 | touch /.dist-upgrade | ||
173 | niro | 2081 | fi |
174 | |||
175 | # install new basesystem | ||
176 | BASESYSTEM="$(< /etc/mage-profile/basesystem.defaults)" | ||
177 | if [[ -z $(magequery -n ${BASESYSTEM}) ]] | ||
178 | then | ||
179 | # first keep some important files | ||
180 | |||
181 | # export bootstrap to not start any services | ||
182 | export MAGE_BOOTSTRAP=true | ||
183 | mage install ${BASESYSTEM} | ||
184 | unset MAGE_BOOTSTRAP | ||
185 | |||
186 | niro | 2716 | # fix locale |
187 | echo "LANG=\"de_DE\"" > /etc/conf.d/locale | ||
188 | |||
189 | niro | 2081 | # enable run of orphaned files check |
190 | touch /.orphaned | ||
191 | niro | 2112 | |
192 | # tell that we're running an dist-upgrade | ||
193 | touch /.dist-upgrade | ||
194 | niro | 2081 | fi |
195 | |||
196 | # install remserial, if the plugin was enabled | ||
197 | if [[ ! -z $(magequery -n remserial-alx) ]] | ||
198 | then | ||
199 | mage install remserial | ||
200 | |||
201 | # enable run of orphaned files check | ||
202 | touch /.orphaned | ||
203 | fi | ||
204 | |||
205 | niro | 2112 | # etc-update |
206 | #etc-update | ||
207 | |||
208 | niro | 2081 | # clean mage cache |
209 | mage clean | ||
210 | |||
211 | echo "Searching for deprecated packages ..." | ||
212 | for i in $(magequery -i | grep -- -alx | sed 's:.*/\(.*\)-.*-.*:\1:') | ||
213 | do | ||
214 | # excludes | ||
215 | case ${i} in | ||
216 | niro | 2181 | alxconfig-ng) continue ;; |
217 | alxinstall-ng) continue ;; | ||
218 | niro | 2081 | kernel-alx) continue ;; |
219 | kernel26-alx) continue ;; | ||
220 | kernel-sources-alx) continue ;; | ||
221 | kernel26-sources-alx) continue ;; | ||
222 | esac | ||
223 | |||
224 | echo "Removing deprecated mage-target '${i}'" | ||
225 | mage uninstall ${i} | ||
226 | done | ||
227 | |||
228 | niro | 2112 | if [[ -f /.dist-upgrade ]] |
229 | then | ||
230 | # array of wireless opts | ||
231 | 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 ) | ||
232 | |||
233 | # fixing current dhcp network settings | ||
234 | #for i in $(grep -irl NETWORKING=.*dhcp.* /etc/conf.d/net.*) | ||
235 | for i in $(grep -irl DHCP_PROG=.*dhcpcd.* /etc/conf.d/net.*) | ||
236 | do | ||
237 | case ${i} in | ||
238 | */net.sample) continue ;; | ||
239 | */net.routes) continue ;; | ||
240 | esac | ||
241 | |||
242 | echo "fixing current dhcp network settings in '${i}'" | ||
243 | mv ${i}{,.orig} | ||
244 | onboot="$(read_value ${i}.orig ONBOOT)" | ||
245 | echo "ONBOOT=\"${onboot}\"" > ${i} | ||
246 | echo 'NETWORKING="dhcp"' >> ${i} | ||
247 | # check wireless extensions | ||
248 | for opt in ${WIRELESS_OPTS[*]} | ||
249 | do | ||
250 | value="$(read_value ${i}.orig ${opt})" | ||
251 | if [[ ! -z ${value} ]] | ||
252 | then | ||
253 | echo "${opt}=\"${value}\"" >> ${i} | ||
254 | fi | ||
255 | done | ||
256 | rm -f ${i}.orig | ||
257 | done | ||
258 | niro | 2117 | # search modules files |
259 | for i in $(find /etc/modules.d -name net.\*) | ||
260 | do | ||
261 | install -d /etc/modprobe.d | ||
262 | mv ${i} /etc/modprobe.d/${i%.conf}.conf | ||
263 | done | ||
264 | niro | 2716 | |
265 | mount /boot &> /dev/null | ||
266 | # install an appropriate uvesafb.conf | ||
267 | install -d /etc/modprobe.d || die | ||
268 | echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > /etc/modprobe.d/uvesafb.conf || die | ||
269 | # create an updated initrd | ||
270 | local DISKMODS="sd_mod" | ||
271 | local OLDPATAMODS="amd74xx piix sis5513 via82cxxx" | ||
272 | local PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via" | ||
273 | local SATAMODS="sata_via sata_sis sata_nv" | ||
274 | local DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via" | ||
275 | local FBMODS="uvesafb" | ||
276 | echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd | ||
277 | local kernelver=$(readlink /boot/vmlinuz | sed 's:kernel-::') | ||
278 | mkinitrd -f /boot/initrd-${kernelver}.img ${kernelver} | ||
279 | # update grub bootloader | ||
280 | updategrub2 | ||
281 | niro | 2112 | fi |
282 | |||
283 | niro | 2117 | if [[ -f /.orphaned ]] |
284 | then | ||
285 | echo "Searching for orphaned files and directories ..." | ||
286 | bash /etc/mage-profile/prune-orphaned-files | ||
287 | rm -f /.orphaned | ||
288 | fi | ||
289 | |||
290 | niro | 2181 | #if [[ -f /.dist-upgrade ]] |
291 | #then | ||
292 | # rm -f /.dist-upgrade | ||
293 | # # force a reboot at this point here | ||
294 | # ( reboot -f & ); exit 0 | ||
295 | #fi |