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