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

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

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


Revision 1.1 - (hide annotations) (download) (as text)
Sat Jul 2 06:33:16 2005 UTC (19 years, 5 months ago) by gordonr
Branch: MAIN
Branch point for: V7_0_alpha23
Content type: text/x-python
Initial revision

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

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