Magellan Linux

Annotation of /mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall

Parent Directory Parent Directory | Revision Log Revision Log


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