Contents of /mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall
Parent Directory | Revision Log
Revision 2117 -
(show annotations)
(download)
Thu May 12 20:43:28 2011 UTC (13 years ago) by niro
File size: 4368 byte(s)
Thu May 12 20:43:28 2011 UTC (13 years ago) by niro
File size: 4368 byte(s)
-clean orphaned files at last -copy old modules.d/net.* to modprobe.d
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 /.dist-upgrade ]] |
139 | then |
140 | # array of wireless opts |
141 | 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 ) |
142 | |
143 | # fixing current dhcp network settings |
144 | #for i in $(grep -irl NETWORKING=.*dhcp.* /etc/conf.d/net.*) |
145 | for i in $(grep -irl DHCP_PROG=.*dhcpcd.* /etc/conf.d/net.*) |
146 | do |
147 | case ${i} in |
148 | */net.sample) continue ;; |
149 | */net.routes) continue ;; |
150 | esac |
151 | |
152 | echo "fixing current dhcp network settings in '${i}'" |
153 | mv ${i}{,.orig} |
154 | onboot="$(read_value ${i}.orig ONBOOT)" |
155 | echo "ONBOOT=\"${onboot}\"" > ${i} |
156 | echo 'NETWORKING="dhcp"' >> ${i} |
157 | # check wireless extensions |
158 | for opt in ${WIRELESS_OPTS[*]} |
159 | do |
160 | value="$(read_value ${i}.orig ${opt})" |
161 | if [[ ! -z ${value} ]] |
162 | then |
163 | echo "${opt}=\"${value}\"" >> ${i} |
164 | fi |
165 | done |
166 | rm -f ${i}.orig |
167 | done |
168 | # search modules files |
169 | for i in $(find /etc/modules.d -name net.\*) |
170 | do |
171 | install -d /etc/modprobe.d |
172 | mv ${i} /etc/modprobe.d/${i%.conf}.conf |
173 | done |
174 | fi |
175 | |
176 | if [[ -f /.orphaned ]] |
177 | then |
178 | echo "Searching for orphaned files and directories ..." |
179 | bash /etc/mage-profile/prune-orphaned-files |
180 | rm -f /.orphaned |
181 | fi |
182 | |
183 | if [[ -f /.dist-upgrade ]] |
184 | then |
185 | rm -f /.dist-upgrade |
186 | # force a reboot at this point here |
187 | reboot -f |
188 | fi |