1 |
gordonr |
1.1 |
# |
2 |
|
|
# upgrade.py - Existing install probe and upgrade procedure |
3 |
|
|
# |
4 |
|
|
# Matt Wilson <msw@redhat.com> |
5 |
|
|
# |
6 |
|
|
# Copyright 2001-2003 Red Hat, Inc. |
7 |
|
|
# |
8 |
|
|
# This software may be freely redistributed under the terms of the GNU |
9 |
|
|
# library public license. |
10 |
|
|
# |
11 |
|
|
# You should have received a copy of the GNU Library Public License |
12 |
|
|
# along with this program; if not, write to the Free Software |
13 |
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
14 |
|
|
# |
15 |
|
|
|
16 |
|
|
import isys |
17 |
|
|
import os |
18 |
|
|
import iutil |
19 |
|
|
import time |
20 |
|
|
import rpm |
21 |
|
|
import sys |
22 |
|
|
import os.path |
23 |
|
|
import partedUtils |
24 |
|
|
import string |
25 |
|
|
import shutil |
26 |
|
|
import lvm |
27 |
|
|
import hdrlist |
28 |
|
|
from flags import flags |
29 |
|
|
from fsset import * |
30 |
|
|
from partitioning import * |
31 |
|
|
from constants import * |
32 |
|
|
from installmethod import FileCopyException |
33 |
|
|
from product import productName |
34 |
|
|
|
35 |
|
|
from rhpl.log import log |
36 |
|
|
from rhpl.translate import _ |
37 |
|
|
|
38 |
|
|
upgrade_remove_blacklist = () |
39 |
|
|
|
40 |
|
|
def findRootParts(intf, id, dispatch, dir, chroot): |
41 |
gordonr |
1.11 |
|
42 |
gordonr |
1.12 |
# w = intf.waitWindow(_("Converting to RAID"), |
43 |
|
|
# _("Converting to RAID, this may take several minutes...")) |
44 |
|
|
# |
45 |
|
|
# # XXX - FIXME - HACK RAID upgrade |
46 |
|
|
# |
47 |
|
|
# rc = iutil.execWithRedirect("/tmp/updates/raidconvert", |
48 |
|
|
# ["raidconvert"], |
49 |
|
|
# stdin = None, |
50 |
|
|
# stdout = "/dev/tty5", |
51 |
|
|
# stderr = "/dev/tty5") |
52 |
|
|
# w.pop() |
53 |
|
|
# |
54 |
|
|
# if rc: |
55 |
|
|
# raise SystemError |
56 |
gordonr |
1.11 |
|
57 |
gordonr |
1.1 |
if dir == DISPATCH_BACK: |
58 |
|
|
return |
59 |
|
|
if id.rootParts is None: |
60 |
|
|
id.rootParts = findExistingRoots(intf, id, chroot) |
61 |
|
|
|
62 |
|
|
id.upgradeRoot = [] |
63 |
|
|
for (dev, fs, meta) in id.rootParts: |
64 |
|
|
id.upgradeRoot.append( (dev, fs) ) |
65 |
|
|
|
66 |
|
|
if id.rootParts is not None and len(id.rootParts) > 0: |
67 |
|
|
dispatch.skipStep("findinstall", skip = 0) |
68 |
slords |
1.3 |
if productName.find("SME Server") == -1: |
69 |
|
|
dispatch.skipStep("installtype", skip = 1) |
70 |
gordonr |
1.1 |
else: |
71 |
|
|
dispatch.skipStep("findinstall", skip = 1) |
72 |
slords |
1.3 |
dispatch.skipStep("installtype", skip = 0) |
73 |
gordonr |
1.1 |
|
74 |
|
|
def findExistingRoots(intf, id, chroot, upgradeany = 0): |
75 |
|
|
if not flags.setupFilesystems: |
76 |
|
|
relstr = partedUtils.getCentOSReleaseString (chroot) |
77 |
|
|
if ((cmdline.find("upgradeany") != -1) or |
78 |
|
|
(upgradeany == 1) or |
79 |
|
|
(partedUtils.productMatches(relstr, productName))): |
80 |
|
|
return [(chroot, 'ext2', "")] |
81 |
|
|
return [] |
82 |
|
|
|
83 |
|
|
diskset = partedUtils.DiskSet() |
84 |
|
|
diskset.openDevices() |
85 |
|
|
|
86 |
|
|
win = intf.progressWindow(_("Searching"), |
87 |
|
|
_("Searching for %s installations...") % |
88 |
|
|
(productName,), 5) |
89 |
|
|
|
90 |
|
|
rootparts = diskset.findExistingRootPartitions(intf, chroot, |
91 |
|
|
upgradeany = upgradeany) |
92 |
|
|
for i in range(1, 6): |
93 |
|
|
time.sleep(0.25) |
94 |
|
|
win.set(i) |
95 |
|
|
|
96 |
|
|
win.pop() |
97 |
|
|
|
98 |
|
|
# close the devices to make sure we don't leave things sitting open |
99 |
|
|
diskset.closeDevices() |
100 |
|
|
|
101 |
|
|
# this is a hack... need to clear the skipped disk list after this |
102 |
|
|
partedUtils.DiskSet.skippedDisks = [] |
103 |
|
|
|
104 |
|
|
return rootparts |
105 |
|
|
|
106 |
|
|
def getDirtyDevString(dirtyDevs): |
107 |
|
|
ret = "" |
108 |
|
|
for dev in dirtyDevs: |
109 |
|
|
if dev != "loop": |
110 |
|
|
ret = "/dev/%s\n" % (dev,) |
111 |
|
|
else: |
112 |
|
|
ret = "%s\n" % (dev,) |
113 |
|
|
return ret |
114 |
|
|
|
115 |
|
|
def mountRootPartition(intf, rootInfo, oldfsset, instPath, allowDirty = 0, |
116 |
|
|
raiseErrors = 0, warnDirty = 0, readOnly = 0): |
117 |
|
|
(root, rootFs) = rootInfo |
118 |
|
|
|
119 |
|
|
diskset = partedUtils.DiskSet() |
120 |
|
|
diskset.openDevices() |
121 |
|
|
diskset.startAllRaid() |
122 |
|
|
lvm.vgscan() |
123 |
|
|
lvm.vgactivate() |
124 |
|
|
|
125 |
|
|
log("going to mount %s on %s as %s" %(root, instPath, rootFs)) |
126 |
|
|
isys.mount(root, instPath, rootFs) |
127 |
|
|
|
128 |
|
|
oldfsset.reset() |
129 |
|
|
newfsset = fsset.readFstab(instPath + '/etc/fstab', intf) |
130 |
|
|
for entry in newfsset.entries: |
131 |
|
|
oldfsset.add(entry) |
132 |
|
|
|
133 |
|
|
isys.umount(instPath) |
134 |
|
|
|
135 |
|
|
dirtyDevs = oldfsset.hasDirtyFilesystems(instPath) |
136 |
|
|
if not allowDirty and dirtyDevs != []: |
137 |
|
|
diskset.stopAllRaid() |
138 |
|
|
lvm.vgdeactivate() |
139 |
|
|
intf.messageWindow(_("Dirty File Systems"), |
140 |
|
|
_("The following file systems for your Linux system " |
141 |
|
|
"were not unmounted cleanly. Please boot your " |
142 |
|
|
"Linux installation, let the file systems be " |
143 |
|
|
"checked and shut down cleanly to upgrade.\n" |
144 |
|
|
"%s" %(getDirtyDevString(dirtyDevs),))) |
145 |
|
|
sys.exit(0) |
146 |
|
|
elif warnDirty and dirtyDevs != []: |
147 |
|
|
rc = intf.messageWindow(_("Dirty File Systems"), |
148 |
|
|
_("The following file systems for your Linux " |
149 |
|
|
"system were not unmounted cleanly. Would " |
150 |
|
|
"you like to mount them anyway?\n" |
151 |
|
|
"%s" % (getDirtyDevString(dirtyDevs,))), |
152 |
|
|
type = "yesno") |
153 |
|
|
if rc == 0: |
154 |
|
|
return -1 |
155 |
|
|
|
156 |
|
|
if flags.setupFilesystems: |
157 |
|
|
oldfsset.mountFilesystems(instPath, readOnly = readOnly) |
158 |
|
|
|
159 |
|
|
# XXX we should properly support 'auto' at some point |
160 |
|
|
if (not oldfsset.getEntryByMountPoint("/") or |
161 |
|
|
not oldfsset.getEntryByMountPoint("/").fsystem or |
162 |
|
|
not oldfsset.getEntryByMountPoint("/").fsystem.isMountable()): |
163 |
|
|
raise RuntimeError, "/etc/fstab did not list a fstype for the root partition which we support" |
164 |
|
|
|
165 |
|
|
# returns None if no filesystem exist to migrate |
166 |
|
|
def upgradeMigrateFind(dispatch, thefsset): |
167 |
|
|
migents = thefsset.getMigratableEntries() |
168 |
|
|
if not migents or len(migents) < 1: |
169 |
|
|
dispatch.skipStep("upgrademigratefs") |
170 |
|
|
else: |
171 |
|
|
dispatch.skipStep("upgrademigratefs", skip = 0) |
172 |
|
|
|
173 |
|
|
|
174 |
|
|
# returns None if no more swap is needed |
175 |
|
|
def upgradeSwapSuggestion(dispatch, id, instPath): |
176 |
|
|
# mem is in kb -- round it up to the nearest 4Mb |
177 |
|
|
mem = iutil.memInstalled() |
178 |
|
|
rem = mem % 16384 |
179 |
|
|
if rem: |
180 |
|
|
mem = mem + (16384 - rem) |
181 |
|
|
mem = mem / 1024 |
182 |
|
|
|
183 |
|
|
dispatch.skipStep("addswap", 0) |
184 |
|
|
|
185 |
|
|
# don't do this if we have more then 250 MB |
186 |
|
|
if mem > 250: |
187 |
|
|
dispatch.skipStep("addswap", 1) |
188 |
|
|
return |
189 |
|
|
|
190 |
|
|
swap = iutil.swapAmount() / 1024 |
191 |
|
|
|
192 |
|
|
# if we have twice as much swap as ram and at least 192 megs |
193 |
|
|
# total, we're safe |
194 |
|
|
if (swap >= (mem * 1.5)) and (swap + mem >= 192): |
195 |
|
|
dispatch.skipStep("addswap", 1) |
196 |
|
|
return |
197 |
|
|
|
198 |
|
|
# if our total is 512 megs or more, we should be safe |
199 |
|
|
if (swap + mem >= 512): |
200 |
|
|
dispatch.skipStep("addswap", 1) |
201 |
|
|
return |
202 |
|
|
|
203 |
|
|
fsList = [] |
204 |
|
|
|
205 |
|
|
for entry in id.fsset.entries: |
206 |
|
|
if entry.fsystem.getName() in fsset.getUsableLinuxFs(): |
207 |
|
|
if flags.setupFilesystems and not entry.isMounted(): |
208 |
|
|
continue |
209 |
|
|
space = isys.pathSpaceAvailable(instPath + entry.mountpoint) |
210 |
|
|
if space > 16: |
211 |
|
|
info = (entry.mountpoint, entry.device.getDevice(), space) |
212 |
|
|
fsList.append(info) |
213 |
|
|
|
214 |
|
|
suggestion = mem * 2 - swap |
215 |
|
|
if (swap + mem + suggestion) < 192: |
216 |
|
|
suggestion = 192 - (swap + mem) |
217 |
|
|
if suggestion < 32: |
218 |
|
|
suggestion = 32 |
219 |
|
|
suggSize = 0 |
220 |
|
|
suggMnt = None |
221 |
|
|
for (mnt, part, size) in fsList: |
222 |
|
|
if (size > suggSize) and (size > (suggestion + 100)): |
223 |
|
|
suggMnt = mnt |
224 |
|
|
|
225 |
|
|
id.upgradeSwapInfo = (fsList, suggestion, suggMnt) |
226 |
|
|
|
227 |
|
|
def swapfileExists(swapname): |
228 |
|
|
try: |
229 |
|
|
os.lstat(swapname) |
230 |
|
|
return 1 |
231 |
|
|
except: |
232 |
|
|
return 0 |
233 |
|
|
|
234 |
|
|
def createSwapFile(instPath, theFsset, mntPoint, size): |
235 |
|
|
fstabPath = instPath + "/etc/fstab" |
236 |
|
|
prefix = "" |
237 |
|
|
|
238 |
|
|
if mntPoint != "/": |
239 |
|
|
file = mntPoint + "/SWAP" |
240 |
|
|
else: |
241 |
|
|
file = "/SWAP" |
242 |
|
|
|
243 |
|
|
swapFileDict = {} |
244 |
|
|
for entry in theFsset.entries: |
245 |
|
|
if entry.fsystem.getName() == "swap": |
246 |
|
|
swapFileDict[entry.device.getName()] = 1 |
247 |
|
|
|
248 |
|
|
count = 0 |
249 |
|
|
while (swapfileExists(instPath + file) or |
250 |
|
|
swapFileDict.has_key(file)): |
251 |
|
|
count = count + 1 |
252 |
|
|
tmpFile = "/SWAP-%d" % (count) |
253 |
|
|
if mntPoint != "/": |
254 |
|
|
file = mntPoint + tmpFile |
255 |
|
|
else: |
256 |
|
|
file = tmpFile |
257 |
|
|
|
258 |
|
|
device = SwapFileDevice(file) |
259 |
|
|
device.setSize(size) |
260 |
|
|
fsystem = fileSystemTypeGet("swap") |
261 |
|
|
entry = FileSystemSetEntry(device, "swap", fsystem) |
262 |
|
|
entry.setFormat(1) |
263 |
|
|
theFsset.add(entry) |
264 |
|
|
theFsset.formatEntry(entry, instPath) |
265 |
|
|
theFsset.turnOnSwap(instPath) |
266 |
|
|
|
267 |
|
|
# XXX generalize fstab modification |
268 |
|
|
f = open(fstabPath, "a") |
269 |
|
|
format = "%-23s %-23s %-7s %-15s %d %d\n"; |
270 |
|
|
f.write(format % (prefix + file, "swap", "swap", "defaults", 0, 0)) |
271 |
|
|
f.close() |
272 |
|
|
|
273 |
|
|
# XXX handle going backwards |
274 |
|
|
def upgradeMountFilesystems(intf, rootInfo, oldfsset, instPath): |
275 |
|
|
# mount everything and turn on swap |
276 |
|
|
|
277 |
|
|
if flags.setupFilesystems: |
278 |
|
|
try: |
279 |
|
|
mountRootPartition(intf, rootInfo[0], oldfsset, instPath, |
280 |
|
|
allowDirty = 0) |
281 |
|
|
except SystemError, msg: |
282 |
|
|
intf.messageWindow(_("Mount failed"), |
283 |
|
|
_("One or more of the file systems listed in the " |
284 |
|
|
"/etc/fstab on your Linux system cannot be mounted. " |
285 |
|
|
"Please fix this problem and try to upgrade again.")) |
286 |
|
|
sys.exit(0) |
287 |
|
|
except RuntimeError, msg: |
288 |
|
|
intf.messageWindow(_("Mount failed"), |
289 |
|
|
_("One or more of the file systems listed in the " |
290 |
|
|
"/etc/fstab of your Linux system are inconsistent and " |
291 |
|
|
"cannot be mounted. Please fix this problem and try to " |
292 |
|
|
"upgrade again.")) |
293 |
|
|
sys.exit(0) |
294 |
|
|
|
295 |
|
|
checkLinks = ( '/etc', '/var', '/var/lib', '/var/lib/rpm', |
296 |
|
|
'/boot', '/tmp', '/var/tmp', '/root', |
297 |
|
|
'/bin/sh', '/usr/tmp') |
298 |
|
|
badLinks = [] |
299 |
|
|
for n in checkLinks: |
300 |
|
|
if not os.path.islink(instPath + n): continue |
301 |
|
|
l = os.readlink(instPath + n) |
302 |
|
|
if l[0] == '/': |
303 |
|
|
badLinks.append(n) |
304 |
|
|
|
305 |
|
|
if badLinks: |
306 |
|
|
message = _("The following files are absolute symbolic " |
307 |
|
|
"links, which we do not support during an " |
308 |
|
|
"upgrade. Please change them to relative " |
309 |
|
|
"symbolic links and restart the upgrade.\n\n") |
310 |
|
|
for n in badLinks: |
311 |
|
|
message = message + '\t' + n + '\n' |
312 |
|
|
intf.messageWindow(_("Absolute Symlinks"), message) |
313 |
|
|
sys.exit(0) |
314 |
|
|
|
315 |
|
|
# fix for 80446 |
316 |
|
|
badLinks = [] |
317 |
|
|
mustBeLinks = ( '/usr/tmp', ) |
318 |
|
|
for n in mustBeLinks: |
319 |
|
|
if not os.path.islink(instPath + n): |
320 |
|
|
badLinks.append(n) |
321 |
|
|
|
322 |
|
|
if badLinks: |
323 |
|
|
message = _("The following are directories which should instead " |
324 |
|
|
"be symbolic links, which will cause problems with the " |
325 |
|
|
"upgrade. Please return them to their original state " |
326 |
|
|
"as symbolic links and restart the upgrade.\n\n") |
327 |
|
|
for n in badLinks: |
328 |
|
|
message = message + '\t' + n + '\n' |
329 |
|
|
intf.messageWindow(_("Invalid Directories"), message) |
330 |
|
|
sys.exit(0) |
331 |
|
|
|
332 |
|
|
else: |
333 |
|
|
if not os.access (instPath + "/etc/fstab", os.R_OK): |
334 |
|
|
rc = intf.messageWindow(_("Warning"), |
335 |
|
|
_("%s not found") |
336 |
|
|
% (instPath + "/etc/fstab",), |
337 |
|
|
type="ok") |
338 |
|
|
return DISPATCH_BACK |
339 |
|
|
|
340 |
|
|
newfsset = fsset.readFstab(instPath + '/etc/fstab', intf) |
341 |
|
|
for entry in newfsset.entries: |
342 |
|
|
oldfsset.add(entry) |
343 |
|
|
|
344 |
|
|
if flags.setupFilesystems: |
345 |
|
|
oldfsset.turnOnSwap(instPath) |
346 |
|
|
|
347 |
|
|
# move the old pre-convert db back in case of problems |
348 |
|
|
def resetRpmdb(olddb, instPath): |
349 |
|
|
if olddb is not None: |
350 |
|
|
iutil.rmrf(instPath + "/var/lib/rpm") |
351 |
|
|
os.rename (olddb, instPath + "/var/lib/rpm") |
352 |
|
|
|
353 |
|
|
rebuildTime = None |
354 |
|
|
|
355 |
|
|
def upgradeFindPackages(intf, method, id, instPath, dir): |
356 |
|
|
if dir == DISPATCH_BACK: |
357 |
|
|
return |
358 |
|
|
global rebuildTime |
359 |
|
|
if not rebuildTime: |
360 |
|
|
rebuildTime = str(int(time.time())) |
361 |
|
|
try: |
362 |
|
|
method.mergeFullHeaders(id.grpset.hdrlist) |
363 |
|
|
except FileCopyException: |
364 |
|
|
method.unmountCD() |
365 |
|
|
intf.messageWindow(_("Error"), |
366 |
|
|
_("Unable to merge header list. This may be " |
367 |
|
|
"due to a missing file or bad media. " |
368 |
|
|
"Press <return> to try again.")) |
369 |
|
|
|
370 |
|
|
# if we've been through here once for this root, then short-circuit |
371 |
|
|
if ((id.upgradeInfoFound is not None) and |
372 |
|
|
(id.upgradeInfoFound == id.upgradeRoot)): |
373 |
|
|
log("already found packages to upgrade for %s" %(id.upgradeRoot,)) |
374 |
|
|
return |
375 |
|
|
else: |
376 |
|
|
id.upgradeInfoFound = id.upgradeRoot |
377 |
|
|
|
378 |
|
|
win = intf.waitWindow(_("Finding"), |
379 |
|
|
_("Finding packages to upgrade...")) |
380 |
|
|
|
381 |
|
|
# now, set the system clock so the timestamps will be right: |
382 |
|
|
if flags.setupFilesystems: |
383 |
|
|
iutil.setClock(instPath) |
384 |
|
|
|
385 |
|
|
# we should only have to rebuild for upgrades of pre rpm 4.0.x systems |
386 |
|
|
# according to jbj |
387 |
|
|
if (os.access(instPath + "/var/lib/rpm/packages.rpm", os.R_OK) and |
388 |
|
|
not os.access(instPath + "/var/lib/rpm/Packages", os.R_OK)): |
389 |
|
|
win.pop() |
390 |
|
|
intf.messageWindow(_("Error"), |
391 |
|
|
_("The installation program is unable to upgrade " |
392 |
|
|
"systems with a pre-rpm 4.x database. " |
393 |
|
|
"Please install the errata rpm packages " |
394 |
|
|
"for your release as described in the release " |
395 |
|
|
"notes and then run the upgrade procedure.")) |
396 |
|
|
sys.exit(0) |
397 |
|
|
|
398 |
|
|
else: |
399 |
|
|
id.dbpath = None |
400 |
|
|
|
401 |
|
|
try: |
402 |
|
|
import findpackageset |
403 |
|
|
|
404 |
|
|
# FIXME: make sure that the rpmdb doesn't have stale locks :/ |
405 |
|
|
for file in ["__db.001", "__db.002", "__db.003"]: |
406 |
|
|
try: |
407 |
|
|
os.unlink("%s/var/lib/rpm/%s" %(instPath, file)) |
408 |
|
|
except: |
409 |
slords |
1.6 |
log("failed to unlink /var/lib/rpm/%s" %(file,)) |
410 |
gordonr |
1.1 |
|
411 |
|
|
packages = findpackageset.findpackageset(id.grpset.hdrlist.hdlist, |
412 |
|
|
instPath) |
413 |
|
|
except rpm.error: |
414 |
|
|
if id.dbpath is not None: |
415 |
|
|
resetRpmdb(id.dbpath, instPath) |
416 |
|
|
win.pop() |
417 |
|
|
intf.messageWindow(_("Error"), |
418 |
|
|
_("An error occurred when finding the packages to " |
419 |
|
|
"upgrade.")) |
420 |
|
|
sys.exit(0) |
421 |
|
|
|
422 |
|
|
# Turn off all comps |
423 |
|
|
id.grpset.unselectAll() |
424 |
|
|
|
425 |
|
|
# unselect all packages |
426 |
|
|
for package in id.grpset.hdrlist.pkgs.values(): |
427 |
|
|
package.usecount = 0 |
428 |
|
|
package.manual_state = 0 |
429 |
|
|
|
430 |
|
|
# turn on the packages in the upgrade set |
431 |
|
|
for package in packages: |
432 |
|
|
id.grpset.hdrlist[hdrlist.nevra(package)].select() |
433 |
|
|
|
434 |
|
|
# open up the database to check dependencies and currently |
435 |
|
|
# installed packages |
436 |
|
|
ts = rpm.TransactionSet(instPath) |
437 |
|
|
ts.setVSFlags(~(rpm.RPMVSF_NORSA|rpm.RPMVSF_NODSA)) |
438 |
|
|
|
439 |
|
|
# make sure we have an arch match. (#87655) |
440 |
|
|
# FIXME: bash wasn't good enough (#129677). let's try initscripts |
441 |
|
|
mi = ts.dbMatch('name', 'initscripts') |
442 |
|
|
myarch = id.grpset.hdrlist["initscripts"][rpm.RPMTAG_ARCH] |
443 |
|
|
for h in mi: |
444 |
|
|
if h[rpm.RPMTAG_ARCH] != myarch: |
445 |
|
|
rc = intf.messageWindow(_("Warning"), |
446 |
|
|
_("The arch of the release of %s you " |
447 |
|
|
"are upgrading to appears to be %s " |
448 |
|
|
"which does not match your previously " |
449 |
|
|
"installed arch of %s. This is likely " |
450 |
|
|
"to not succeed. Are you sure you " |
451 |
|
|
"wish to continue the upgrade process?") |
452 |
slords |
1.13 |
%(productName, myarch, |
453 |
|
|
h[rpm.RPMTAG_ARCH]), |
454 |
gordonr |
1.1 |
type="yesno") |
455 |
|
|
if rc == 0: |
456 |
|
|
try: |
457 |
|
|
resetRpmdb(id.dbpath, instPath) |
458 |
|
|
except Exception, e: |
459 |
|
|
log("error returning rpmdb to old state: %s" %(e,)) |
460 |
|
|
pass |
461 |
|
|
sys.exit(0) |
462 |
|
|
else: |
463 |
|
|
log("WARNING: upgrade between possibly incompatible " |
464 |
|
|
"arches %s -> %s" %(h[rpm.RPMTAG_ARCH], myarch)) |
465 |
|
|
|
466 |
|
|
mi = ts.dbMatch() |
467 |
|
|
found = 0 |
468 |
|
|
hasX = 0 |
469 |
|
|
hasFileManager = 0 |
470 |
|
|
|
471 |
|
|
for h in mi: |
472 |
|
|
release = h[rpm.RPMTAG_RELEASE] |
473 |
|
|
# I'm going to try to keep this message as politically correct |
474 |
|
|
# as possible. I think the Ximian GNOME is a very pretty desktop |
475 |
|
|
# and the hackers there do an extraordinary amount of work on |
476 |
|
|
# them. But it throws a huge wrench in our upgrade process. We |
477 |
|
|
# just want to warn our users that there are packages on the system |
478 |
|
|
# that might get messed up during the upgrade process. Nothing |
479 |
|
|
# personal, guys. - msw |
480 |
|
|
if (string.find(release, "helix") > -1 |
481 |
|
|
or string.find(release, "ximian") > -1 |
482 |
|
|
or string.find(release, "eazel") > -1): |
483 |
|
|
log("Third party package %s-%s-%s could cause problems." % |
484 |
|
|
(h[rpm.RPMTAG_NAME], |
485 |
|
|
h[rpm.RPMTAG_VERSION], |
486 |
|
|
h[rpm.RPMTAG_RELEASE])) |
487 |
|
|
found = 1 |
488 |
|
|
if h[rpm.RPMTAG_NAME] == "XFree86" or h[rpm.RPMTAG_NAME] == "xorg-x11": |
489 |
|
|
hasX = 1 |
490 |
|
|
if h[rpm.RPMTAG_NAME] == "nautilus": |
491 |
|
|
hasFileManager = 1 |
492 |
|
|
if h[rpm.RPMTAG_NAME] == "kdebase": |
493 |
|
|
hasFileManager = 1 |
494 |
|
|
if h[rpm.RPMTAG_NAME] == "gmc": |
495 |
|
|
hasFileManager = 1 |
496 |
|
|
|
497 |
|
|
if found: |
498 |
|
|
rc = intf.messageWindow(_("Warning"), |
499 |
|
|
_("This system appears to have third " |
500 |
|
|
"party packages installed that " |
501 |
|
|
"overlap with packages included in " |
502 |
|
|
"%s. Because these packages " |
503 |
|
|
"overlap, continuing the upgrade " |
504 |
|
|
"process may cause them to stop " |
505 |
|
|
"functioning properly or may cause " |
506 |
|
|
"other system instability. Please see " |
507 |
|
|
"the release notes for more information." |
508 |
|
|
"\n\n" |
509 |
|
|
"Do you wish to continue the upgrade " |
510 |
|
|
"process?") % (productName,), |
511 |
|
|
type="yesno") |
512 |
|
|
if rc == 0: |
513 |
|
|
try: |
514 |
|
|
resetRpmdb(id.dbpath, instPath) |
515 |
|
|
except Exception, e: |
516 |
|
|
log("error returning rpmdb to old state: %s" %(e,)) |
517 |
|
|
pass |
518 |
|
|
sys.exit(0) |
519 |
|
|
|
520 |
|
|
if not os.access(instPath + "/etc/e-smith-release", os.R_OK): |
521 |
|
|
rc = intf.messageWindow(_("Warning"), |
522 |
|
|
_("This system does not have an " |
523 |
|
|
"/etc/e-smith-release file. It is possible " |
524 |
|
|
"that this is not a %s system. " |
525 |
|
|
"Continuing with the upgrade process may " |
526 |
|
|
"leave the system in an unusable state. Do " |
527 |
|
|
"you wish to continue the upgrade process?") % (productName,), |
528 |
|
|
type="yesno") |
529 |
|
|
if rc == 0: |
530 |
|
|
try: |
531 |
|
|
resetRpmdb(id.dbpath, instPath) |
532 |
|
|
except Exception, e: |
533 |
|
|
log("error returning rpmdb to old state: %s" %(e,)) |
534 |
|
|
pass |
535 |
|
|
sys.exit(0) |
536 |
|
|
|
537 |
slords |
1.3 |
# Figure out current version for upgrade nag and for determining weird |
538 |
|
|
# upgrade cases |
539 |
|
|
supportedUpgradeVersion = -1 |
540 |
|
|
mi = ts.dbMatch('provides', 'e-smith-release') |
541 |
|
|
for h in mi: |
542 |
|
|
if h[rpm.RPMTAG_EPOCH] is None: |
543 |
|
|
epoch = None |
544 |
|
|
else: |
545 |
|
|
epoch = str(h[rpm.RPMTAG_EPOCH]) |
546 |
|
|
|
547 |
|
|
if supportedUpgradeVersion <= 0: |
548 |
|
|
val = rpm.labelCompare(('21', '6.0', '11'), |
549 |
|
|
(epoch, h[rpm.RPMTAG_VERSION], |
550 |
|
|
h[rpm.RPMTAG_RELEASE])) |
551 |
|
|
if val > 0: |
552 |
|
|
supportedUpgradeVersion = 0 |
553 |
|
|
else: |
554 |
|
|
supportedUpgradeVersion = 1 |
555 |
|
|
break |
556 |
|
|
|
557 |
|
|
if supportedUpgradeVersion == 0: |
558 |
|
|
rc = intf.messageWindow(_("Warning"), |
559 |
|
|
_("You appear to be upgrading from a system " |
560 |
|
|
"which is too old to upgrade to this " |
561 |
|
|
"version of %s. Are you sure you wish to " |
562 |
|
|
"continue the upgrade " |
563 |
|
|
"process?") %(productName,), |
564 |
|
|
type = "yesno") |
565 |
|
|
if rc == 0: |
566 |
|
|
try: |
567 |
|
|
resetRpmdb(id.dbpath, instPath) |
568 |
|
|
except Exception, e: |
569 |
|
|
log("error returning rpmdb to old state: %s" %(e,)) |
570 |
|
|
pass |
571 |
|
|
sys.exit(0) |
572 |
|
|
|
573 |
gordonr |
1.1 |
|
574 |
|
|
# during upgrade, make sure that we only install %lang colored files |
575 |
|
|
# for the languages selected to be supported. |
576 |
|
|
langs = '' |
577 |
|
|
if os.access(instPath + "/etc/sysconfig/i18n", os.R_OK): |
578 |
|
|
f = open(instPath + "/etc/sysconfig/i18n", 'r') |
579 |
|
|
for line in f.readlines(): |
580 |
|
|
line = string.strip(line) |
581 |
|
|
parts = string.split(line, '=') |
582 |
|
|
if len(parts) < 2: |
583 |
|
|
continue |
584 |
|
|
if string.strip(parts[0]) == 'SUPPORTED': |
585 |
|
|
langs = parts[1] |
586 |
|
|
if len(langs) > 0: |
587 |
|
|
if langs[0] == '"' and langs[-1:] == '"': |
588 |
|
|
langs = langs[1:-1] |
589 |
|
|
break |
590 |
|
|
del f |
591 |
|
|
## if langs: |
592 |
|
|
## rpm.addMacro("_install_langs", langs) |
593 |
|
|
|
594 |
|
|
# check the installed system to see if the packages just |
595 |
|
|
# are not newer in this release. |
596 |
|
|
if hasX and not hasFileManager: |
597 |
|
|
for name in ("nautilus", "kdebase", "gmc"): |
598 |
|
|
try: |
599 |
|
|
h = ts.dbMatch('name', name).next() |
600 |
|
|
except StopIteration: |
601 |
|
|
continue |
602 |
|
|
if h is not None: |
603 |
|
|
hasFileManager = 1 |
604 |
|
|
break |
605 |
|
|
|
606 |
|
|
# make sure the boot loader being used is being installed. |
607 |
|
|
# FIXME: generalize so that specific bits aren't needed |
608 |
|
|
if iutil.getArch() == "i386" and id.bootloader.useGrub(): |
609 |
|
|
log("Upgrade: User selected to use GRUB for bootloader") |
610 |
|
|
if id.grpset.hdrlist.has_key("grub") and not id.grpset.hdrlist["grub"].isSelected(): |
611 |
|
|
log("Upgrade: grub is not currently selected to be upgraded") |
612 |
|
|
h = None |
613 |
|
|
try: |
614 |
|
|
h = ts.dbMatch('name', 'grub').next() |
615 |
|
|
except StopIteration: |
616 |
|
|
pass |
617 |
|
|
if h is None: |
618 |
|
|
text = ("Upgrade: GRUB is not already installed on the " |
619 |
|
|
"system, selecting GRUB") |
620 |
|
|
id.upgradeDeps ="%s%s\n" % (id.upgradeDeps, text) |
621 |
|
|
log(text) |
622 |
|
|
id.grpset.hdrlist["grub"].select() |
623 |
|
|
if iutil.getArch() == "i386" and not id.bootloader.useGrub(): |
624 |
|
|
log("Upgrade: User selected to use LILO for bootloader") |
625 |
|
|
if id.grpset.hdrlist.has_key("lilo") and not id.grpset.hdrlist["lilo"].isSelected(): |
626 |
|
|
log("Upgrade: lilo is not currently selected to be upgraded") |
627 |
|
|
h = None |
628 |
|
|
try: |
629 |
|
|
h = ts.dbMatch('name', 'lilo').next() |
630 |
|
|
except StopIteration: |
631 |
|
|
pass |
632 |
|
|
if h is None: |
633 |
|
|
text = ("Upgrade: LILO is not already installed on the " |
634 |
|
|
"system, selecting LILO") |
635 |
|
|
id.upgradeDeps ="%s%s\n" % (id.upgradeDeps, text) |
636 |
|
|
log(text) |
637 |
|
|
id.grpset.hdrlist["lilo"].select() |
638 |
|
|
|
639 |
|
|
|
640 |
|
|
h = None |
641 |
|
|
try: |
642 |
|
|
h = ts.dbMatch('name', 'gnome-core').next() |
643 |
|
|
except StopIteration: |
644 |
|
|
pass |
645 |
|
|
if h is not None: |
646 |
|
|
log("Upgrade: gnome-core was on the system. Upgrading to GNOME 2") |
647 |
|
|
upgraded = [] |
648 |
|
|
for pkg in ("gnome-terminal", "gnome-desktop", "gnome-session", |
649 |
|
|
"gnome-panel", "metacity", "file-roller", "yelp", |
650 |
|
|
"nautilus"): |
651 |
|
|
if id.grpset.hdrlist.has_key(pkg) and not id.grpset.hdrlist[pkg].isSelected(): |
652 |
|
|
id.grpset.hdrlist[pkg].select() |
653 |
|
|
upgraded.append(pkg) |
654 |
|
|
|
655 |
|
|
text = ("Upgrade: gnome-core is on the system. Selecting packages " |
656 |
|
|
"to upgrade to GNOME2: %s" %(str(upgraded),)) |
657 |
|
|
id.upgradeDeps = "%s%s\n" %(id.upgradeDeps, text) |
658 |
|
|
|
659 |
|
|
# if they have up2date-gnome, they probably want the applet now too |
660 |
|
|
# since it works in both gnome and kde |
661 |
|
|
if (id.grpset.hdrlist.has_key("rhn-applet") |
662 |
|
|
and not id.grpset.hdrlist["rhn-applet"].isSelected()): |
663 |
|
|
log("Upgrade: rhn-applet is not currently selected to be upgraded") |
664 |
|
|
h = None |
665 |
|
|
try: |
666 |
|
|
h = ts.dbMatch('name', 'up2date-gnome').next() |
667 |
|
|
except StopIteration: |
668 |
|
|
pass |
669 |
|
|
|
670 |
|
|
if h is not None: |
671 |
|
|
hdr = None |
672 |
|
|
try: |
673 |
|
|
hdr = ts.dbMatch('name', 'rhn-applet').next() |
674 |
|
|
except StopIteration: |
675 |
|
|
pass |
676 |
|
|
if hdr is None: |
677 |
|
|
text = ("Upgrade: up2date-gnome is on the " |
678 |
|
|
"system, but rhn-applet isn't. Selecting " |
679 |
|
|
"rhn-applet to be installed") |
680 |
|
|
id.upgradeDeps = "%s%s\n" % (id.upgradeDeps, text) |
681 |
|
|
log(text) |
682 |
|
|
id.grpset.hdrlist["rhn-applet"].select() |
683 |
|
|
|
684 |
|
|
# and since xterm is now split out from XFree86 (#98254) |
685 |
|
|
if (id.grpset.hdrlist.has_key("xterm") and |
686 |
|
|
not id.grpset.hdrlist["xterm"].isSelected()): |
687 |
|
|
h = None |
688 |
|
|
try: |
689 |
|
|
h = ts.dbMatch('name', 'XFree86').next() |
690 |
|
|
except StopIteration: |
691 |
|
|
pass |
692 |
|
|
if h is not None: |
693 |
|
|
text = ("Upgrade: XFree86 was on the system. Pulling in xterm " |
694 |
|
|
"for upgrade.") |
695 |
|
|
id.upgradeDeps = "%s%s\n" %(id.upgradeDeps, text) |
696 |
|
|
log(text) |
697 |
|
|
id.grpset.hdrlist["xterm"].select() |
698 |
|
|
|
699 |
|
|
# input methods all changed. hooray! |
700 |
|
|
imupg = ( ("ami", "iiimf-le-hangul"), |
701 |
|
|
("kinput2-canna-wnn6", "iiimf-le-canna"), |
702 |
|
|
("miniChinput", "iiimf-le-chinput"), |
703 |
|
|
("xcin", "iiimf-le-xcin") ) |
704 |
|
|
iiimf = 0 |
705 |
|
|
for (old, new) in imupg: |
706 |
|
|
mi = ts.dbMatch("name", old) |
707 |
|
|
if (mi.count() > 0 and id.grpset.hdrlist.has_key(new) and |
708 |
|
|
not id.grpset.hdrlist[new].isSelected()): |
709 |
|
|
text = "Upgrade: %s was on the system. Pulling in %s" %(old, new) |
710 |
|
|
id.upgradeDeps = "%s%s\n" %(id.upgradeDeps, text) |
711 |
|
|
log(text) |
712 |
|
|
id.grpset.hdrlist[new].select() |
713 |
|
|
iiimf = 1 |
714 |
|
|
if iiimf: |
715 |
|
|
imupg = ( ("iiimf-gnome-im-switcher", "control-center"), |
716 |
|
|
("iiimf-gnome-im-switcher", "gnome-panel"), |
717 |
|
|
("iiimf-gtk", "gtk2"), |
718 |
|
|
("system-switch-im", "gtk2"), |
719 |
|
|
("iiimf-x", "xorg-x11"), |
720 |
|
|
("iiimf-x", "XFree86")) |
721 |
|
|
for (new, old) in imupg: |
722 |
|
|
mi = ts.dbMatch("name", old) |
723 |
|
|
if (not id.grpset.hdrlist.has_key(new) or |
724 |
|
|
id.grpset.hdrlist[new].isSelected()): |
725 |
|
|
continue |
726 |
|
|
if (mi.count() > 0 or |
727 |
|
|
id.grpset.hdrlist.has_key(old) and |
728 |
|
|
id.grpset.hdrlist[old].isSelected()): |
729 |
|
|
text = "Upgrade: Need iiimf base package %s" %(new,) |
730 |
|
|
id.upgradeDeps = "%s%s\n" %(id.upgradeDeps, text) |
731 |
|
|
log(text) |
732 |
|
|
id.grpset.hdrlist[new].select() |
733 |
|
|
|
734 |
|
|
# firefox replaces mozilla/netscape (#137244) |
735 |
|
|
if (id.grpset.hdrlist.has_key("firefox") and |
736 |
|
|
not id.grpset.hdrlist["firefox"].isSelected()): |
737 |
|
|
found = 0 |
738 |
|
|
for p in ("mozilla", "netscape-navigator", "netscape-communicator"): |
739 |
|
|
mi = ts.dbMatch("name", p) |
740 |
|
|
found += mi.count() |
741 |
|
|
if found > 0: |
742 |
|
|
text = "Upgrade: Found a graphical browser. Pulling in firefox" |
743 |
|
|
id.upgradeDeps = "%s%s\n" %(id.upgradeDeps, text) |
744 |
|
|
log(text) |
745 |
|
|
id.grpset.hdrlist["firefox"].select() |
746 |
|
|
|
747 |
|
|
# now some upgrade removal black list checking... there are things that |
748 |
|
|
# if they were installed in the past, we want to remove them because |
749 |
|
|
# they'll screw up the upgrade otherwise |
750 |
|
|
for pkg in upgrade_remove_blacklist: |
751 |
|
|
h = None |
752 |
|
|
try: |
753 |
|
|
h = ts.dbMatch('name', pkg).next() |
754 |
|
|
except StopIteration: |
755 |
|
|
pass |
756 |
|
|
if h is not None: |
757 |
|
|
text = ("Upgrade: %s is on the system but will cause problems " |
758 |
|
|
"with the upgrade transaction. Removing." %(pkg,)) |
759 |
|
|
log(text) |
760 |
|
|
id.upgradeDeps = "%s%s\n" %(id.upgradeDeps, text) |
761 |
|
|
id.upgradeRemove.append(pkg) |
762 |
|
|
|
763 |
|
|
# new package dependency fixup |
764 |
|
|
depcheck = hdrlist.DependencyChecker(id.grpset, how = "u") |
765 |
|
|
for p in id.grpset.hdrlist.pkgs.values(): |
766 |
|
|
if p.isSelected(): |
767 |
|
|
ts.addInstall(p.hdr, p.hdr, "u") |
768 |
|
|
deps = ts.check(depcheck.callback) |
769 |
|
|
for pkgnevra in deps: |
770 |
|
|
text = ("Upgrade Dependency: Needs %s, " |
771 |
|
|
"automatically added." % (pkgnevra,)) |
772 |
|
|
# log(text) |
773 |
|
|
id.upgradeDeps = "%s%s\n" % (id.upgradeDeps, text) |
774 |
|
|
|
775 |
|
|
win.pop() |
776 |
|
|
|
777 |
|
|
|