Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2112 - (show annotations) (download)
Thu May 12 18:51:46 2011 UTC (12 years, 11 months ago) by niro
File size: 4217 byte(s)
-update network settings properly, added helper function read_value()
-only upgrade once, this script is called at every update
-do not exec etc-update, our conf_prot handling should do it automatically
1 #!/bin/bash
2 # $Id$
3
4 read_value()
5 {
6 local file=$1
7 local var=$2
8 local value
9
10 [[ ! -e ${file} ]] && return 1
11
12 value=$(source ${file}; echo $(eval echo \${${var}}))
13 echo "${value}"
14 return 0
15 }
16
17 MAGERC="/etc/mage.rc"
18 MAGEPROFILE="alx-060"
19 NEW_MAGE_DISTRIBUTION="unstable"
20 NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0"
21 NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}"
22 NEW_PACKAGES_SERVER_PATH='packages/${ARCH}'
23 NEW_MAGE_UNINSTALL_TIMEOUT=0
24
25 # fix mage.rc
26 for i in RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT
27 do
28 value="$(eval echo \${NEW_${i}})"
29 if [[ ! -z $(grep "^${i}=" ${MAGERC}) ]]
30 then
31 echo "fixing $i -> ${value}"
32 sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${MAGERC}
33 else
34 echo "adding $i=${value}"
35 echo "${i}=\"${value}\"" >> ${MAGERC}
36 fi
37 done
38
39 # fix profile
40 if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]]
41 then
42 echo "fixing profile link -> /usr/mage/profiles/${MAGEPROFILE}"
43 ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile
44 fi
45
46 # update mage3 -> mage4
47 if [[ -z $(magequery -n mage) ]]
48 then
49 # update mage tree
50 mage update
51
52 # mage3 has problems with md5
53 rm -rf /usr/mage/app-mage/mage/md5
54 if [[ ${NEW_MAGE_DISTRIBUTION} = unstable ]]
55 then
56 USE_UNSTABLE=true MAGE_DISTRIBUTION=unstable mage install mage
57 elif [[ ${NEW_MAGE_DISTRIBUTION} = testing ]]
58 then
59 USE_TESTING=true MAGE_DISTRIBUTION=testing mage install mage
60 else
61 mage install mage
62 fi
63
64 # drop all virtuals
65 :> /var/db/mage/virtuals
66
67 # enable run of orphaned files check
68 touch /.orphaned
69
70 # tell that we're running an dist-upgrade
71 touch /.dist-upgrade
72 fi
73
74 # install new toolchain if not exist
75 TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)"
76 if [[ -z $(magequery -n ${TOOLCHAIN}) ]]
77 then
78 # export bootstrap to not start any services
79 export MAGE_BOOTSTRAP=true
80 mage install ${TOOLCHAIN}
81 unset MAGE_BOOTSTRAP
82
83 # enable run of orphaned files check
84 touch /.orphaned
85
86 # tell that we're running an dist-upgrade
87 touch /.dist-upgrade
88 fi
89
90 # install new basesystem
91 BASESYSTEM="$(< /etc/mage-profile/basesystem.defaults)"
92 if [[ -z $(magequery -n ${BASESYSTEM}) ]]
93 then
94 # first keep some important files
95
96 # export bootstrap to not start any services
97 export MAGE_BOOTSTRAP=true
98 mage install ${BASESYSTEM}
99 unset MAGE_BOOTSTRAP
100
101 # enable run of orphaned files check
102 touch /.orphaned
103
104 # tell that we're running an dist-upgrade
105 touch /.dist-upgrade
106 fi
107
108 # install remserial, if the plugin was enabled
109 if [[ ! -z $(magequery -n remserial-alx) ]]
110 then
111 mage install remserial
112
113 # enable run of orphaned files check
114 touch /.orphaned
115 fi
116
117 # etc-update
118 #etc-update
119
120 # clean mage cache
121 mage clean
122
123 echo "Searching for deprecated packages ..."
124 for i in $(magequery -i | grep -- -alx | sed 's:.*/\(.*\)-.*-.*:\1:')
125 do
126 # excludes
127 case ${i} in
128 kernel-alx) continue ;;
129 kernel26-alx) continue ;;
130 kernel-sources-alx) continue ;;
131 kernel26-sources-alx) continue ;;
132 esac
133
134 echo "Removing deprecated mage-target '${i}'"
135 mage uninstall ${i}
136 done
137
138 if [[ -f /.orphaned ]]
139 then
140 echo "Searching for orphaned files and directories ..."
141 bash /etc/mage-profile/prune-orphaned-files
142 rm -f /.orphaned
143 fi
144
145 if [[ -f /.dist-upgrade ]]
146 then
147 # array of wireless opts
148 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 )
149
150 # fixing current dhcp network settings
151 #for i in $(grep -irl NETWORKING=.*dhcp.* /etc/conf.d/net.*)
152 for i in $(grep -irl DHCP_PROG=.*dhcpcd.* /etc/conf.d/net.*)
153 do
154 case ${i} in
155 */net.sample) continue ;;
156 */net.routes) continue ;;
157 esac
158
159 echo "fixing current dhcp network settings in '${i}'"
160 mv ${i}{,.orig}
161 onboot="$(read_value ${i}.orig ONBOOT)"
162 echo "ONBOOT=\"${onboot}\"" > ${i}
163 echo 'NETWORKING="dhcp"' >> ${i}
164 # check wireless extensions
165 for opt in ${WIRELESS_OPTS[*]}
166 do
167 value="$(read_value ${i}.orig ${opt})"
168 if [[ ! -z ${value} ]]
169 then
170 echo "${opt}=\"${value}\"" >> ${i}
171 fi
172 done
173 rm -f ${i}.orig
174 done
175 fi
176
177 if [[ -f /.dist-upgrade ]]
178 then
179 rm -f /.dist-upgrade
180 # force a reboot at this point here
181 reboot -f
182 fi