/[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.5 - (hide annotations) (download) (as text)
Mon Aug 1 05:02:21 2005 UTC (19 years, 3 months ago) by slords
Branch: MAIN
Changes since 1.4: +1 -0 lines
Content type: text/x-python
Add entry to check all filesystems and call before mount on upgrade.
Now we just need to convert/migrate to raid.

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

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