/[smeserver]/cdrom.image/updates/upgrade.py
ViewVC logotype

Contents of /cdrom.image/updates/upgrade.py

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.15 - (show annotations) (download) (as text)
Fri Jun 9 05:03:00 2006 UTC (18 years, 6 months ago) by gordonr
Branch: MAIN
CVS Tags: HEAD
Changes since 1.14: +0 -0 lines
Content type: text/x-python
FILE REMOVED
See bug 1510 - all changes should be in the anaconda CVS repository

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

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed