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

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

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


Revision 1.8 - (hide annotations) (download) (as text)
Mon Oct 10 04:14:41 2005 UTC (18 years, 8 months ago) by gordonr
Branch: MAIN
Changes since 1.7: +2 -2 lines
Content type: text/x-python
Put back post-install/post-upgrade message boxes

1 slords 1.1 #
2     # packages.py: package management - mainly package installation
3     #
4     # Erik Troan <ewt@redhat.com>
5     # Matt Wilson <msw@redhat.com>
6     # Michael Fulbright <msf@redhat.com>
7     # Jeremy Katz <katzj@redhat.com>
8     #
9     # Copyright 2001-2003 Red Hat, Inc.
10     #
11     # This software may be freely redistributed under the terms of the GNU
12     # library public license.
13     #
14     # You should have received a copy of the GNU Library Public License
15     # along with this program; if not, write to the Free Software
16     # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17     #
18    
19     import iutil
20     import isys
21     import rpm
22     import hdrlist
23     import os
24     import timer
25     import time
26     import sys
27     import string
28     import pcmcia
29     import language
30     import fsset
31     import kudzu
32     from flags import flags
33     from product import *
34     from constants import *
35     from syslogd import syslog
36     from hdrlist import PKGTYPE_MANDATORY, PKGTYPE_DEFAULT, DependencyChecker
37     from installmethod import FileCopyException
38    
39     from rhpl.log import log
40     from rhpl.translate import _
41     import rhpl.arch
42    
43     def queryUpgradeContinue(intf, dir):
44     if dir == DISPATCH_FORWARD:
45     return
46    
47     rc = intf.messageWindow(_("Proceed with upgrade?"),
48     _("The file systems of the Linux installation "
49     "you have chosen to upgrade have already been "
50     "mounted. You cannot go back past this point. "
51     "\n\n") +
52     _( "Would you like to continue with the upgrade?"),
53     type = "yesno")
54     if rc == 0:
55     sys.exit(0)
56     return DISPATCH_FORWARD
57    
58 gordonr 1.8 def doPostAction(id, instPath, intf):
59     id.instClass.postAction(instPath, flags.serial, intf)
60 slords 1.1
61     def firstbootConfiguration(id, instPath):
62     if id.firstboot == FIRSTBOOT_RECONFIG:
63     f = open(instPath + '/etc/reconfigSys', 'w+')
64     f.close()
65     elif id.firstboot == FIRSTBOOT_SKIP:
66     f = open(instPath + '/etc/sysconfig/firstboot', 'w+')
67     f.write('RUN_FIRSTBOOT=NO')
68     f.close()
69    
70     return
71    
72    
73     def writeConfiguration(id, instPath):
74     log("Writing main configuration")
75     if not flags.test:
76     id.write(instPath)
77    
78     def writeKSConfiguration(id, instPath):
79     log("Writing autokickstart file")
80     if not flags.test:
81     fn = instPath + "/root/anaconda-ks.cfg"
82     else:
83     fn = "/tmp/anaconda-ks.cfg"
84    
85     id.writeKS(fn)
86    
87     def copyAnacondaLogs(instPath):
88     log("Copying anaconda logs")
89     for (fn, dest) in (("/tmp/anaconda.log", "anaconda.log"),
90     ("/tmp/syslog", "anaconda.syslog"),
91     ("/tmp/ramfs/X.log", "anaconda.xlog")):
92     if os.access(fn, os.R_OK):
93     try:
94     iutil.copyFile(fn, "%s/var/log/%s" %(instPath, dest))
95     os.chmod("%s/var/log/%s" %(instPath, dest), 0600)
96     except:
97     pass
98    
99     def writeXConfiguration(id, instPath):
100     testmode = flags.test
101    
102     # comment out to test
103     if testmode:
104     return
105     # end code to comment to test
106     # uncomment to test writing X config in test mode
107     # try:
108     # os.mkdir("/tmp/etc")
109     # except:
110     # pass
111     # try:
112     # os.mkdir("/tmp/etc/X11")
113     # except:
114     # pass
115     # instPath = '/'
116     # end code for test writing
117    
118     if id.xsetup.skipx:
119     return
120    
121     xserver = id.videocard.primaryCard().getXServer()
122     if not xserver:
123     return
124    
125     log("Writing X configuration")
126     if not testmode:
127     fn = instPath
128    
129     if os.access (instPath + "/etc/X11/X", os.R_OK):
130     os.rename (instPath + "/etc/X11/X",
131     instPath + "/etc/X11/X.rpmsave")
132    
133     try:
134     os.unlink (instPath + "/etc/X11/X")
135     except OSError:
136     pass
137    
138     os.symlink ("../../usr/X11R6/bin/" + xserver,
139     instPath + "/etc/X11/X")
140     else:
141     fn = "/tmp/"
142    
143     id.xsetup.write(fn+"/etc/X11", id.mouse, id.keyboard)
144     id.desktop.write(instPath)
145    
146     def readPackages(intf, method, id):
147     if id.grpset:
148     grpset = id.grpset
149     hdrlist = id.grpset.hdrlist
150     doselect = 0
151     else:
152     grpset = None
153     hdrlist = None
154     doselect = 1
155    
156     while hdrlist is None:
157     w = intf.waitWindow(_("Reading"), _("Reading package information..."))
158     try:
159     hdrlist = method.readHeaders()
160     except FileCopyException:
161     w.pop()
162     method.unmountCD()
163     intf.messageWindow(_("Error"),
164     _("Unable to read header list. This may be "
165     "due to a missing file or bad media. "
166     "Press <return> to try again."))
167     continue
168    
169     w.pop()
170    
171     while grpset is None:
172     try:
173     grpset = method.readComps(hdrlist)
174     except FileCopyException:
175     method.unmountCD()
176     intf.messageWindow(_("Error"),
177     _("Unable to read comps file. This may be "
178     "due to a missing file or bad media. "
179     "Press <return> to try again."))
180     continue
181    
182     # people make bad tree copies all the time. let's just mandate that
183     # the Core group has to exist in the comps file else we complain
184     if not grpset.groups.has_key("core"):
185     intf.messageWindow(_("Error"),
186     _("The comps file in your installation tree is "
187     "missing critical groups. Please ensure that "
188     "your install tree has been correctly "
189     "generated."),
190     type="custom", custom_icon="error",
191     custom_buttons=[_("_Exit")])
192     sys.exit(0)
193    
194     while iutil.getArch() == "ia64":
195     try:
196     method.mergeFullHeaders(hdrlist)
197     break
198     except FileCopyException:
199     method.unmountCD()
200     intf.messageWindow(_("Error"),
201     _("Unable to merge header list. This may be "
202     "due to a missing file or bad media. "
203     "Press <return> to try again."))
204    
205     # this is a crappy hack, but I don't want bug reports from these people
206     if (iutil.getArch() == "i386") and (not grpset.hdrlist.has_key("kernel")):
207     intf.messageWindow(_("Error"),
208     _("You are trying to install on a machine "
209     "which isn't supported by this release of "
210     "%s.") %(productName,),
211     type="custom", custom_icon="error",
212     custom_buttons=[_("_Exit")])
213     sys.exit(0)
214    
215     id.grpset = grpset
216    
217     if doselect:
218     id.instClass.setGroupSelection(grpset, intf)
219     id.instClass.setPackageSelection(hdrlist, intf)
220    
221     def handleX11Packages(dir, intf, disp, id, instPath):
222    
223     if dir == DISPATCH_BACK:
224     return
225    
226     # skip X setup if it is not being installed
227     #
228     # uncomment this block if you want X configuration to be presented
229     #
230     # START BLOCK
231     # if (not id.grpset.hdrlist.has_key('XFree86') or
232     # not id.grpset.hdrlist['XFree86'].isSelected()):
233     # disp.skipStep("videocard")
234     # disp.skipStep("monitor")
235     # disp.skipStep("xcustom")
236     # disp.skipStep("writexconfig")
237     # id.xsetup.skipx = 1
238     # elif disp.stepInSkipList("videocard"):
239     # # if X is being installed, but videocard step skipped
240     # # need to turn it back on
241     # disp.skipStep("videocard", skip=0)
242     # disp.skipStep("monitor", skip=0)
243     # disp.skipStep("xcustom", skip=0)
244     # disp.skipStep("writexconfig", skip=0)
245     # id.xsetup.skipx = 0
246     # END BLOCK
247    
248     # set default runlevel based on packages
249     gnomeSelected = (id.grpset.hdrlist.has_key('gnome-session')
250     and id.grpset.hdrlist['gnome-session'].isSelected())
251     gdmSelected = (id.grpset.hdrlist.has_key('gdm')
252     and id.grpset.hdrlist['gdm'].isSelected())
253     kdeSelected = (id.grpset.hdrlist.has_key('kdebase')
254     and id.grpset.hdrlist['kdebase'].isSelected())
255     xinstalled = ((id.grpset.hdrlist.has_key('xorg-x11')
256     and id.grpset.hdrlist['xorg-x11'].isSelected()) or
257     (id.grpset.hdrlist.has_key('XFree86')
258     and id.grpset.hdrlist['XFree86'].isSelected()))
259    
260     if gnomeSelected:
261     id.desktop.setDefaultDesktop("GNOME")
262     elif kdeSelected:
263     id.desktop.setDefaultDesktop("KDE")
264    
265     if (gdmSelected or kdeSelected) and (xinstalled) and (not flags.serial) and (not flags.virtpconsole):
266     id.desktop.setDefaultRunLevel(5)
267     else:
268     id.desktop.setDefaultRunLevel(3)
269    
270     # verifies that monitor is not Unprobed, and if so we can skip monitor question
271     def checkMonitorOK(monitor, dispatch):
272     rc = 0
273     if monitor is not None:
274     if monitor.getMonitorID() != "Unprobed Monitor":
275     rc = 1
276    
277     dispatch.skipStep("monitor", skip=rc)
278    
279     # sets a reasonable default for X settings.
280     def setSaneXSettings(xsetup):
281     if xsetup is not None and xsetup.xhwstate is not None:
282     if not xsetup.imposed_sane_default:
283     # XXX HACK see if we have a user specified LCD display
284     import re
285    
286     regx = re.compile("LCD Panel .*x.*")
287     monid = xsetup.xhwstate.monitor.getMonitorID()
288     lcdres = None
289     if regx.match(monid):
290     for testres in ["640x480", "800x600", "1024x480", "1024x768",
291     "1280x960", "1280x1024", "1400x1050",
292     "1600x1200"]:
293     if string.find(monid, testres) != -1:
294     lcdres = testres
295     break
296    
297     if lcdres is not None:
298     xsetup.xhwstate.set_resolution(lcdres)
299     else:
300     xsetup.xhwstate.choose_sane_default()
301     xsetup.imposed_sane_default = 1
302    
303     def getAnacondaTS(instPath = None):
304     if instPath:
305     ts = rpm.TransactionSet(instPath)
306     else:
307     ts = rpm.TransactionSet()
308     ts.setVSFlags(~(rpm.RPMVSF_NORSA|rpm.RPMVSF_NODSA))
309     ts.setFlags(rpm.RPMTRANS_FLAG_ANACONDA)
310    
311     # set color if needed. FIXME: why isn't this the default :/
312     if (rhpl.arch.canonArch.startswith("ppc64") or
313     rhpl.arch.canonArch in ("s390x", "sparc64", "x86_64", "ia64")):
314     ts.setColor(3)
315    
316     return ts
317    
318     def checkDependencies(dir, intf, disp, id, instPath):
319     if dir == DISPATCH_BACK:
320     return
321    
322     win = intf.waitWindow(_("Dependency Check"),
323     _("Checking dependencies in packages selected for installation..."))
324    
325     # FIXME: we really don't need to build up a ts more than once
326     # granted, this is better than before still
327     if id.upgrade.get():
328     ts = getAnacondaTS(instPath)
329     how = "u"
330     else:
331     ts = getAnacondaTS()
332     how = "i"
333    
334     # set the rpm log file to /dev/null so that we don't segfault
335     f = open("/dev/null", "w+")
336     rpm.setLogFile(f)
337     ts.scriptFd = f.fileno()
338    
339     for p in id.grpset.hdrlist.pkgs.values():
340     if p.isSelected():
341     ts.addInstall(p.hdr, p.hdr, how)
342     depcheck = DependencyChecker(id.grpset, how)
343     id.dependencies = ts.check(depcheck.callback)
344    
345     win.pop()
346    
347     if depcheck.added and id.handleDeps == CHECK_DEPS:
348     disp.skipStep("dependencies", skip = 0)
349     log("had unresolved dependencies, resolved.")
350     disp.skipStep("dependencies")
351     else:
352     disp.skipStep("dependencies")
353    
354     return
355     # FIXME: I BROKE IT
356     # this is kind of hackish, but makes kickstart happy
357     if id.handleDeps == CHECK_DEPS:
358     pass
359     elif id.handleDeps == IGNORE_DEPS:
360     id.comps.selectDepCause(id.dependencies)
361     id.comps.unselectDeps(id.dependencies)
362     elif id.handleDeps == RESOLVE_DEPS:
363     id.comps.selectDepCause(id.dependencies)
364     id.comps.selectDeps(id.dependencies)
365    
366     class InstallCallback:
367     def packageDownloadCB(self, state, amount):
368     self.progress.setPackageStatus(state, amount)
369    
370     def cb(self, what, amount, total, h, (param)):
371     # first time here means we should pop the window telling
372     # user to wait until we get here
373     if not self.beenCalled:
374     self.beenCalled = 1
375     self.initWindow.pop()
376    
377     if (what == rpm.RPMCALLBACK_TRANS_START):
378     # step 6 is the bulk of the transaction set
379     # processing time
380     if amount == 6:
381     self.progressWindow = \
382     self.progressWindowClass (_("Processing"),
383     _("Preparing to install..."),
384     total)
385     try:
386     self.incr = total / 10
387     except:
388     pass
389     if (what == rpm.RPMCALLBACK_TRANS_PROGRESS):
390     if self.progressWindow and amount > self.lastprogress + self.incr:
391     self.progressWindow.set (amount)
392     self.lastprogress = amount
393    
394     if (what == rpm.RPMCALLBACK_TRANS_STOP and self.progressWindow):
395     self.progressWindow.pop ()
396    
397     if (what == rpm.RPMCALLBACK_INST_OPEN_FILE):
398     # We don't want to start the timer until we get to the first
399     # file.
400     self.pkgTimer.start()
401    
402     self.progress.setPackage(h)
403     self.progress.setPackageScale(0, 1)
404     self.instLog.write (self.modeText % (hdrlist.nevra(h)))
405     self.instLog.flush ()
406    
407     self.rpmFD = -1
408     self.size = h[rpm.RPMTAG_SIZE]
409    
410     while self.rpmFD < 0:
411     try:
412     fn = self.method.getRPMFilename(h, self.pkgTimer,
413     callback=self.packageDownloadCB)
414     self.rpmFD = os.open(fn, os.O_RDONLY)
415    
416     # Make sure this package seems valid
417     try:
418     hdr = self.ts.hdrFromFdno(self.rpmFD)
419     os.lseek(self.rpmFD, 0, 0)
420    
421     # if we don't have a valid package, throw an error
422     if not hdr:
423     raise SystemError
424    
425     except:
426     try:
427     os.close(self.rpmFD)
428     except:
429     pass
430     self.rpmFD = -1
431     raise FileCopyException
432     except Exception, e:
433     log("exception was %s for %s-%s-%s" %(e, h['name'],
434     h['version'],
435     h['release']))
436    
437     self.method.unmountCD()
438     self.messageWindow(_("Error"),
439     _("The package %s-%s-%s cannot be opened. This is due "
440     "to a missing file or perhaps a corrupt package. "
441     "If you are installing from CD media this usually "
442     "means the CD media is corrupt, or the CD drive is "
443     "unable to read the media.\n\n"
444     "Press <return> to try again.") % (h['name'],
445     h['version'],
446     h['release']))
447     self.progress.setPackageStatus(_("Installing..."), None)
448     fn = self.method.unlinkFilename(fn)
449     return self.rpmFD
450     elif (what == rpm.RPMCALLBACK_INST_PROGRESS):
451     # RPM returns strange values sometimes
452     if amount > total:
453     amount = total
454     if not total or total == 0 or total == "0":
455     total = amount
456     self.progress.setPackageScale(amount, total)
457     elif (what == rpm.RPMCALLBACK_INST_CLOSE_FILE):
458     os.close (self.rpmFD)
459     self.progress.completePackage(h, self.pkgTimer)
460     self.progress.processEvents()
461     elif ((what == rpm.RPMCALLBACK_UNPACK_ERROR) or
462     (what == rpm.RPMCALLBACK_CPIO_ERROR)):
463     # we may want to make this error more fine-grained at some
464     # point
465     pkg = "%s-%s-%s" % (h[rpm.RPMTAG_NAME],
466     h[rpm.RPMTAG_VERSION],
467     h[rpm.RPMTAG_RELEASE])
468     self.messageWindow(_("Error Installing Package"),
469     _("There was an error installing %s. This "
470     "can indicate media failure, lack of disk "
471     "space, and/or hardware problems. This is "
472     "a fatal error and your install will be "
473     "aborted. Please verify your media and try "
474     "your install again.\n\n"
475     "Press the OK button to reboot "
476     "your system.") % (pkg,))
477     sys.exit(0)
478     else:
479     pass
480    
481     self.progress.processEvents()
482    
483     def __init__(self, messageWindow, progress, pkgTimer, method,
484     progressWindowClass, instLog, modeText, ts):
485     self.messageWindow = messageWindow
486     self.progress = progress
487     self.pkgTimer = pkgTimer
488     self.method = method
489     self.progressWindowClass = progressWindowClass
490     self.progressWindow = None
491     self.lastprogress = 0
492     self.incr = 20
493     self.instLog = instLog
494     self.modeText = modeText
495     self.beenCalled = 0
496     self.initWindow = None
497     self.ts = ts
498    
499     def sortPackages(first, second):
500     # install packages in cd order (cd tag is 1000002)
501     one = None
502     two = None
503    
504     if first[1000003] != None:
505     one = first[1000003]
506    
507     if second[1000003] != None:
508     two = second[1000003]
509    
510     if one == None or two == None:
511     one = 0
512     two = 0
513     if first[1000002] != None:
514     one = first[1000002]
515    
516     if second[1000002] != None:
517     two = second[1000002]
518    
519     if one < two:
520     return -1
521     elif one > two:
522     return 1
523     elif (string.lower(first[rpm.RPMTAG_NAME])
524     < string.lower(second[rpm.RPMTAG_NAME])):
525     return -1
526     elif (string.lower(first[rpm.RPMTAG_NAME])
527     > string.lower(second[rpm.RPMTAG_NAME])):
528     return 1
529    
530     return 0
531    
532     class rpmErrorClass:
533    
534     def cb(self):
535     self.f.write (rpm.errorString () + "\n")
536    
537     def __init__(self, f):
538     self.f = f
539    
540     def doMigrateFilesystems(dir, thefsset, diskset, upgrade, instPath):
541     if dir == DISPATCH_BACK:
542     return DISPATCH_NOOP
543    
544     if thefsset.haveMigratedFilesystems():
545     return DISPATCH_NOOP
546    
547     thefsset.migrateFilesystems (instPath)
548    
549     # if we're upgrading, we may need to do lvm device node hackery
550     if upgrade.get():
551     thefsset.makeLVMNodes(instPath, trylvm1 = 1)
552    
553    
554     def turnOnFilesystems(dir, thefsset, diskset, partitions, upgrade, instPath):
555     if dir == DISPATCH_BACK:
556     log("unmounting filesystems")
557     thefsset.umountFilesystems(instPath)
558     return
559    
560     if flags.setupFilesystems:
561     if not upgrade.get():
562     partitions.doMetaDeletes(diskset)
563     thefsset.setActive(diskset)
564     if not thefsset.isActive():
565     diskset.savePartitions ()
566     thefsset.checkBadblocks(instPath)
567     if not thefsset.volumesCreated:
568     thefsset.createLogicalVolumes(instPath)
569     thefsset.formatSwap(instPath)
570     thefsset.turnOnSwap(instPath)
571     thefsset.makeFilesystems (instPath)
572     thefsset.mountFilesystems (instPath)
573    
574     def setupTimezone(timezone, upgrade, instPath, dir):
575     # we don't need this on an upgrade or going backwards
576     if upgrade.get() or (dir == DISPATCH_BACK):
577     return
578    
579     # dont do this in test mode!
580     if flags.test:
581     return
582    
583     os.environ["TZ"] = timezone.tz
584     tzfile = "/usr/share/zoneinfo/" + timezone.tz
585     if not os.access(tzfile, os.R_OK):
586     log("unable to set timezone")
587     else:
588     try:
589     iutil.copyFile(tzfile, "/etc/localtime")
590     except OSError, (errno, msg):
591     log("Error copying timezone (from %s): %s" %(tzfile, msg))
592    
593     if iutil.getArch() == "s390":
594     return
595     args = [ "/usr/sbin/hwclock", "--hctosys" ]
596     if timezone.utc:
597     args.append("-u")
598     elif timezone.arc:
599     args.append("-a")
600    
601     try:
602     iutil.execWithRedirect(args[0], args, stdin = None,
603     stdout = "/dev/tty5", stderr = "/dev/tty5")
604     except RuntimeError:
605     log("Failed to set clock")
606    
607    
608    
609     def doPreInstall(method, id, intf, instPath, dir):
610     if dir == DISPATCH_BACK:
611     for d in ("/selinux", "/dev"):
612     try:
613     isys.umount(instPath + d, removeDir = 0)
614     except Exception, e:
615     log("unable to unmount %s: %s" %(d, e))
616     return
617    
618     arch = iutil.getArch ()
619    
620     # this is a crappy hack, but I don't want bug reports from these people
621     if (arch == "i386") and (not id.grpset.hdrlist.has_key("kernel")):
622     intf.messageWindow(_("Error"),
623     _("You are trying to install on a machine "
624     "which isn't supported by this release of "
625     "%s.") %(productName,),
626     type="custom", custom_icon="error",
627     custom_buttons=[_("_Exit")])
628     sys.exit(0)
629    
630     # shorthand
631     upgrade = id.upgrade.get()
632    
633     def select(hdrlist, name):
634     if hdrlist.has_key(name):
635     hdrlist[name].select(isManual = 1)
636     return 1
637     return 0
638    
639     def selected(hdrlist, name):
640     if hdrlist.has_key(name) and hdrlist[name].isSelected():
641     return 1
642     return 0
643    
644     if not upgrade:
645     foundkernel = 0
646     if isys.smpAvailable() or isys.htavailable():
647     if select(id.grpset.hdrlist, 'kernel-smp'):
648     foundkernel = 1
649     if selected(id.grpset.hdrlist, "gcc"):
650     select(id.grpset.hdrlist, "kernel-smp-devel")
651    
652     if iutil.needsEnterpriseKernel():
653     if select(id.grpset.hdrlist, "kernel-bigmem"):
654     foundkernel = 1
655    
656     if isys.summitavailable():
657     if select(id.grpset.hdrlist, "kernel-summit"):
658     foundkernel = 1
659    
660     if foundkernel == 0:
661     # we *always* need to have some sort of kernel installed
662     select(id.grpset.hdrlist, 'kernel')
663     if selected(id.grpset.hdrlist, "gcc"):
664     select(id.grpset.hdrlist, "kernel-devel")
665    
666     # if NIS is configured, install ypbind and dependencies:
667     if id.auth.useNIS:
668     select(id.grpset.hdrlist, 'ypbind')
669     select(id.grpset.hdrlist, 'yp-tools')
670     select(id.grpset.hdrlist, 'portmap')
671    
672     if id.auth.useLdap:
673     select(id.grpset.hdrlist, 'nss_ldap')
674     select(id.grpset.hdrlist, 'openldap')
675     select(id.grpset.hdrlist, 'perl')
676    
677     if id.auth.useKrb5:
678     select(id.grpset.hdrlist, 'pam_krb5')
679     select(id.grpset.hdrlist, 'krb5-workstation')
680     select(id.grpset.hdrlist, 'krbafs')
681     select(id.grpset.hdrlist, 'krb5-libs')
682    
683     if id.auth.useSamba:
684     select(id.grpset.hdrlist, 'pam_smb')
685    
686     if iutil.getArch() == "i386" and id.bootloader.useGrubVal == 0:
687     select(id.grpset.hdrlist, 'lilo')
688     elif iutil.getArch() == "i386" and id.bootloader.useGrubVal == 1:
689     select(id.grpset.hdrlist, 'grub')
690     elif iutil.getArch() == "s390":
691     select(id.grpset.hdrlist, 's390utils')
692     elif iutil.getArch() == "ppc":
693     select(id.grpset.hdrlist, 'yaboot')
694     elif iutil.getArch() == "ia64":
695     select(id.grpset.hdrlist, 'elilo')
696    
697     if pcmcia.pcicType():
698     select(id.grpset.hdrlist, 'pcmcia-cs')
699    
700     for entry in id.fsset.entries:
701     for pkg in entry.fsystem.getNeededPackages():
702     if select(id.grpset.hdrlist, pkg):
703     log("Needed %s for %s" %(pkg, entry.getMountPoint()))
704    
705     if flags.test:
706     return
707    
708     # make sure that all comps that include other comps are
709     # selected (i.e. - recurse down the selected comps and turn
710     # on the children
711     while 1:
712     try:
713     method.mergeFullHeaders(id.grpset.hdrlist)
714     except FileCopyException:
715     method.unmountCD()
716     intf.messageWindow(_("Error"),
717     _("Unable to merge header list. This may be "
718     "due to a missing file or bad media. "
719     "Press <return> to try again."))
720     else:
721     break
722    
723     if upgrade:
724     # An old mtab can cause confusion (esp if loop devices are
725     # in it)
726     f = open(instPath + "/etc/mtab", "w+")
727     f.close()
728    
729     # we really started writing modprobe.conf out before things were
730     # all completely ready. so now we need to nuke old modprobe.conf's
731     # if you're upgrading from a 2.4 dist so that we can get the
732     # transition right
733     if (os.path.exists(instPath + "/etc/modules.conf") and
734     os.path.exists(instPath + "/etc/modprobe.conf") and
735     not os.path.exists(instPath + "/etc/modprobe.conf.anacbak")):
736     log("renaming old modprobe.conf -> modprobe.conf.anacbak")
737     os.rename(instPath + "/etc/modprobe.conf",
738     instPath + "/etc/modprobe.conf.anacbak")
739    
740    
741     if method.systemMounted (id.fsset, instPath):
742     id.fsset.umountFilesystems(instPath)
743     return DISPATCH_BACK
744    
745     for i in ( '/var', '/var/lib', '/var/lib/rpm', '/tmp', '/dev', '/etc',
746     '/etc/sysconfig', '/etc/sysconfig/network-scripts',
747     '/etc/X11', '/root', '/var/tmp', '/etc/rpm' ):
748     try:
749     os.mkdir(instPath + i)
750     except os.error, (errno, msg):
751     pass
752     # log("Error making directory %s: %s" % (i, msg))
753    
754    
755     if flags.setupFilesystems:
756     # setup /etc/rpm/platform for the post-install environment
757     iutil.writeRpmPlatform(instPath)
758    
759     try:
760     # FIXME: making the /var/lib/rpm symlink here is a hack to
761     # workaround db->close() errors from rpm
762     iutil.mkdirChain("/var/lib")
763     for path in ("/var/tmp", "/var/lib/rpm"):
764     if os.path.exists(path) and not os.path.islink(path):
765     iutil.rmrf(path)
766     if not os.path.islink(path):
767     os.symlink("/mnt/sysimage/%s" %(path,), "%s" %(path,))
768     else:
769     log("%s already exists as a symlink to %s" %(path, os.readlink(path),))
770     except Exception, e:
771     # how this could happen isn't entirely clear; log it in case
772     # it does and causes problems later
773     log("error creating symlink, continuing anyway: %s" %(e,))
774    
775     # SELinux hackery (#121369)
776     if flags.selinux:
777     try:
778     os.mkdir(instPath + "/selinux")
779     except Exception, e:
780     pass
781     try:
782     isys.mount("/selinux", instPath + "/selinux", "selinuxfs")
783     except Exception, e:
784     log("error mounting selinuxfs: %s" %(e,))
785    
786     # we need to have a /dev during install and now that udev is
787     # handling /dev, it gets to be more fun. so just bind mount the
788     # installer /dev
789     if not id.grpset.hdrlist.has_key("dev"):
790     log("no dev package, going to bind mount /dev")
791     isys.mount("/dev", "/mnt/sysimage/dev", bindMount = 1)
792    
793     # try to copy the comps package. if it doesn't work, don't worry about it
794     try:
795     id.compspkg = method.copyFileToTemp("%s/base/comps.rpm" % (productPath,))
796     except:
797     log("Unable to copy comps package")
798     id.compspkg = None
799    
800     # write out the fstab
801     if not upgrade:
802     id.fsset.write(instPath)
803     # rootpath mode doesn't have this file around
804     if os.access("/tmp/modprobe.conf", os.R_OK):
805     iutil.copyFile("/tmp/modprobe.conf",
806     instPath + "/etc/modprobe.conf")
807     if os.access("/tmp/zfcp.conf", os.R_OK):
808     iutil.copyFile("/tmp/zfcp.conf",
809     instPath + "/etc/zfcp.conf")
810    
811     # make a /etc/mtab so mkinitrd can handle certain hw (usb) correctly
812     f = open(instPath + "/etc/mtab", "w+")
813     f.write(id.fsset.mtab())
814     f.close()
815    
816     # delay writing migrate adjusted fstab till later, in case
817     # rpm transaction set determines they don't have enough space to upgrade
818     # else:
819     # id.fsset.migratewrite(instPath)
820    
821     def doInstall(method, id, intf, instPath):
822     if flags.test:
823     return
824    
825     # set up dependency white outs
826     import whiteout
827    
828     upgrade = id.upgrade.get()
829     ts = getAnacondaTS(instPath)
830    
831     total = 0
832     totalSize = 0
833     totalFiles = 0
834    
835     if upgrade:
836     how = "u"
837     else:
838     how = "i"
839     rpm.addMacro("__dbi_htconfig", "hash nofsync %{__dbi_other} %{__dbi_perms}")
840    
841     if id.excludeDocs:
842     rpm.addMacro("_excludedocs", "1")
843    
844     l = []
845    
846     for p in id.grpset.hdrlist.values():
847     if p.isSelected():
848     l.append(p)
849     l.sort(sortPackages)
850    
851     progress = intf.progressWindow(_("Processing"),
852     _("Preparing RPM transaction..."),
853     len(l))
854    
855    
856     # this is kind of a hack, but has to be done so we can have a chance
857     # with broken triggers
858     if upgrade and len(id.upgradeRemove) > 0:
859     # simple rpm callback since erasure doesn't need anything
860     def install_callback(what, bytes, total, h, user):
861     pass
862    
863     for pkg in id.upgradeRemove:
864     ts.addErase(pkg)
865    
866     # if we hit problems, it's not like there's anything we can
867     # do about it
868     ts.run(install_callback, 0)
869    
870     # new transaction set
871     ts.closeDB()
872     del ts
873     ts = getAnacondaTS(instPath)
874    
875     # we don't want to try to remove things more than once (#84221)
876     id.upgradeRemove = []
877    
878     i = 0
879     updcount = 0
880     updintv = len(l) / 25
881     for p in l:
882     ts.addInstall(p.hdr, p.hdr, how)
883     total = total + 1
884     totalSize = totalSize + (p[rpm.RPMTAG_SIZE] / 1024)
885     totalFiles = totalFiles + len(p[rpm.RPMTAG_BASENAMES])
886     i = i + 1
887    
888     # HACK - dont overload progress bar with useless requests
889     updcount = updcount + 1
890     if updcount > updintv:
891     progress.set(i)
892     updcount = 0
893    
894     progress.pop()
895    
896     depcheck = DependencyChecker(id.grpset)
897     if not id.grpset.hdrlist.preordered():
898     log ("WARNING: not all packages in hdlist had order tag")
899     # have to call ts.check before ts.order() to set up the alIndex
900     ts.check(depcheck.callback)
901     ts.order()
902     else:
903     ts.check(depcheck.callback)
904    
905     if upgrade:
906     logname = '/root/upgrade.log'
907     else:
908     logname = '/root/install.log'
909    
910     instLogName = instPath + logname
911     try:
912     iutil.rmrf (instLogName)
913     except OSError:
914     pass
915    
916     instLog = open(instLogName, "w+")
917    
918     # dont start syslogd if we arent creating filesystems
919     if flags.setupFilesystems:
920     syslogname = "%s%s.syslog" % (instPath, logname)
921     try:
922     iutil.rmrf (syslogname)
923     except OSError:
924     pass
925     syslog.start (instPath, syslogname)
926     else:
927     syslogname = None
928    
929     if id.compspkg is not None:
930     num = i + 1
931     else:
932     num = i
933    
934     if upgrade:
935     instLog.write(_("Upgrading %s packages\n\n") % (num,))
936     else:
937     instLog.write(_("Installing %s packages\n\n") % (num,))
938    
939     ts.scriptFd = instLog.fileno ()
940     rpm.setLogFile(instLog)
941     # the transaction set dup()s the file descriptor and will close the
942     # dup'd when we go out of scope
943    
944     if upgrade:
945     modeText = _("Upgrading %s\n")
946     else:
947     modeText = _("Installing %s\n")
948    
949     errors = rpmErrorClass(instLog)
950     pkgTimer = timer.Timer(start = 0)
951    
952     id.instProgress.setSizes(total, totalSize, totalFiles)
953     id.instProgress.processEvents()
954    
955     cb = InstallCallback(intf.messageWindow, id.instProgress, pkgTimer,
956     method, intf.progressWindow, instLog, modeText,
957     ts)
958    
959     # write out migrate adjusted fstab so kernel RPM can get initrd right
960     if upgrade:
961     id.fsset.migratewrite(instPath)
962     if id.upgradeDeps:
963     instLog.write(_("\n\nThe following packages were automatically\n"
964     "selected to be installed:"
965     "\n"
966     "%s"
967     "\n\n") % (id.upgradeDeps,))
968    
969     cb.initWindow = intf.waitWindow(_("Install Starting"),
970     _("Starting install process, this may take several minutes..."))
971    
972     ts.setProbFilter(~rpm.RPMPROB_FILTER_DISKSPACE)
973     problems = ts.run(cb.cb, 0)
974    
975     if problems:
976     # restore old fstab if we did anything for migrating
977     if upgrade:
978     id.fsset.restoreMigratedFstab(instPath)
979    
980     spaceneeded = {}
981     nodeneeded = {}
982     size = 12
983    
984     for (descr, (type, mount, need)) in problems:
985     log("(%s, (%s, %s, %s))" %(descr, type, mount, need))
986     if mount and mount.startswith(instPath):
987     mount = mount[len(instPath):]
988     if not mount:
989     mount = '/'
990    
991     if type == rpm.RPMPROB_DISKSPACE:
992     if spaceneeded.has_key (mount) and spaceneeded[mount] < need:
993     spaceneeded[mount] = need
994     else:
995     spaceneeded[mount] = need
996     elif type == nodeprob:
997     if nodeneeded.has_key (mount) and nodeneeded[mount] < need:
998     nodeneeded[mount] = need
999     else:
1000     nodeneeded[mount] = need
1001     else:
1002     if descr is None:
1003     descr = "no description"
1004     log ("WARNING: unhandled problem returned from "
1005     "transaction set type %d (%s)",
1006     type, descr)
1007    
1008     probs = ""
1009     if spaceneeded:
1010     probs = probs + _("You don't appear to have enough disk space "
1011     "to install the packages you've selected. "
1012     "You need more space on the following "
1013     "file systems:\n\n")
1014     probs = probs + ("%-15s %s\n") % (_("Mount Point"),
1015     _("Space Needed"))
1016    
1017     for (mount, need) in spaceneeded.items ():
1018     log("(%s, %s)" %(mount, need))
1019     if need > (1024*1024):
1020     need = (need + 1024 * 1024 - 1) / (1024 * 1024)
1021     suffix = "M"
1022     else:
1023     need = (need + 1023) / 1024
1024     suffix = "k"
1025    
1026     prob = "%-15s %d %c\n" % (mount, need, suffix)
1027     probs = probs + prob
1028     if nodeneeded:
1029     if probs:
1030     probs = probs + '\n'
1031     probs = probs + _("You don't appear to have enough file nodes "
1032     "to install the packages you've selected. "
1033     "You need more file nodes on the following "
1034     "file systems:\n\n")
1035     probs = probs + ("%-15s %s\n") % (_("Mount Point"),
1036     _("Nodes Needed"))
1037    
1038     for (mount, need) in nodeneeded.items ():
1039     prob = "%-15s %d\n" % (mount, need)
1040     probs = probs + prob
1041    
1042     if len(probs) == 0:
1043     probs = ("ERROR: NO! An unexpected problem has occurred with "
1044     "your transaction set. Please see tty3 for more "
1045     "information")
1046    
1047     intf.messageWindow (_("Disk Space"), probs)
1048    
1049     ts.closeDB()
1050     del ts
1051     instLog.close()
1052    
1053     if syslogname:
1054     syslog.stop()
1055    
1056     method.systemUnmounted ()
1057    
1058     return DISPATCH_BACK
1059    
1060     # This should close the RPM database so that you can
1061     # do RPM ops in the chroot in a %post ks script
1062     ts.closeDB()
1063     del ts
1064    
1065     # make sure the window gets popped (#82862)
1066     if not cb.beenCalled:
1067     cb.initWindow.pop()
1068    
1069     method.filesDone ()
1070    
1071     # rpm environment files go bye-bye
1072     for file in ["__db.001", "__db.002", "__db.003"]:
1073     try:
1074     os.unlink("%s/var/lib/rpm/%s" %(instPath, file))
1075     except Exception, e:
1076     log("failed to unlink /var/lib/rpm/%s: %s" %(file,e))
1077     # FIXME: remove the /var/lib/rpm symlink that keeps us from having
1078     # db->close error messages shown. I don't really like this though :(
1079     try:
1080     os.unlink("/var/lib/rpm")
1081     except Exception, e:
1082     log("failed to unlink /var/lib/rpm: %s" %(e,))
1083    
1084     instLog.close ()
1085    
1086     id.instProgress = None
1087    
1088     def doPostInstall(method, id, intf, instPath):
1089     if flags.test:
1090     return
1091    
1092     upgrade = id.upgrade.get()
1093     arch = iutil.getArch ()
1094    
1095     if upgrade:
1096 gordonr 1.7 w = intf.progressWindow(_("Post Upgrade"),
1097     _("Performing post upgrade configuration..."), 6)
1098 slords 1.1 logname = '/root/upgrade.log'
1099     else:
1100 gordonr 1.7 w = intf.progressWindow(_("Post Install"),
1101     _("Performing post install configuration..."), 6)
1102 slords 1.1 logname = '/root/install.log'
1103    
1104     instLogName = instPath + logname
1105     instLog = open(instLogName, "a")
1106    
1107     try:
1108     if not upgrade:
1109     w.set(1)
1110    
1111     copyExtraModules(instPath, id.grpset, id.extraModules)
1112    
1113     w.set(2)
1114    
1115     # pcmcia is supported only on i386 at the moment
1116     if arch == "i386":
1117     pcmcia.createPcmciaConfig(
1118     instPath + "/etc/sysconfig/pcmcia")
1119    
1120     # we need to write out the network bits before kudzu runs
1121     # to avoid getting devices in the wrong order (#102276)
1122     id.network.write(instPath)
1123    
1124     w.set(3)
1125    
1126     # blah. If we're on a serial mouse, and we have X, we need to
1127     # close the mouse device, then run kudzu, then open it again.
1128    
1129     # turn it off
1130     mousedev = None
1131    
1132     # XXX currently Bad Things (X async reply) happen when doing
1133     # Mouse Magic on Sparc (Mach64, specificly)
1134     # The s390 doesn't even have a mouse!
1135     if os.environ.get('DISPLAY') == ':1' and arch != 'sparc':
1136     try:
1137     import xmouse
1138     mousedev = xmouse.get()[0]
1139     except RuntimeError:
1140     pass
1141    
1142     if mousedev:
1143     try:
1144     os.rename (mousedev, "/dev/disablemouse")
1145     except OSError:
1146     pass
1147     try:
1148     xmouse.reopen()
1149     except RuntimeError:
1150     pass
1151    
1152     if arch != "s390" and flags.setupFilesystems:
1153     # we need to unmount usbdevfs before mounting it
1154     usbWasMounted = iutil.isUSBDevFSMounted()
1155     if usbWasMounted:
1156     isys.umount('/proc/bus/usb', removeDir = 0)
1157    
1158     # see if unmount suceeded, if not pretent it isnt mounted
1159     # because we're screwed anywyas if system is going to
1160     # lock up
1161     if iutil.isUSBDevFSMounted():
1162     usbWasMounted = 0
1163    
1164     unmountUSB = 0
1165     try:
1166     isys.mount('/usbfs', instPath+'/proc/bus/usb', 'usbfs')
1167     unmountUSB = 1
1168     except:
1169     log("Mount of /proc/bus/usb in chroot failed")
1170     pass
1171    
1172     argv = [ "/usr/sbin/kudzu", "-q" ]
1173     if id.grpset.hdrlist.has_key("kernel"):
1174     ver = "%s-%s" %(id.grpset.hdrlist["kernel"][rpm.RPMTAG_VERSION],
1175     id.grpset.hdrlist["kernel"][rpm.RPMTAG_RELEASE])
1176     argv.extend(["-k", ver])
1177    
1178     devnull = os.open("/dev/null", os.O_RDWR)
1179     iutil.execWithRedirect(argv[0], argv, root = instPath,
1180     stdout = devnull)
1181     # turn it back on
1182     if mousedev:
1183     try:
1184     os.rename ("/dev/disablemouse", mousedev)
1185     except OSError:
1186     pass
1187     try:
1188     xmouse.reopen()
1189     except RuntimeError:
1190     pass
1191    
1192     if unmountUSB:
1193     try:
1194     isys.umount(instPath + '/proc/bus/usb', removeDir = 0)
1195     except SystemError:
1196     # if we fail to unmount, then we should just not
1197     # try to remount it. this protects us from random
1198     # suckage
1199     usbWasMounted = 0
1200    
1201     if usbWasMounted:
1202     isys.mount('/usbfs', '/proc/bus/usb', 'usbfs')
1203    
1204     w.set(4)
1205    
1206     if upgrade and id.dbpath is not None:
1207     # remove the old rpmdb
1208     try:
1209     iutil.rmrf (id.dbpath)
1210     except OSError:
1211     pass
1212    
1213     if upgrade:
1214     # needed for prior systems which were not xinetd based
1215     migrateXinetd(instPath, instLogName)
1216    
1217     # needed for prior to 2.6 so that mice have some chance
1218     # of working afterwards. FIXME: this is a hack
1219     migrateMouseConfig(instPath, instLogName)
1220    
1221     if id.grpset.hdrlist.has_key("rhgb") and id.grpset.hdrlist["rhgb"].isSelected():
1222     log("rhgb installed, adding to boot loader config")
1223     id.bootloader.args.append("rhgb quiet")
1224    
1225     w.set(5)
1226    
1227     # FIXME: hack to install the comps package
1228     if (id.compspkg is not None and
1229     os.access(id.compspkg, os.R_OK)):
1230     log("found the comps package")
1231     try:
1232     # ugly hack
1233     path = id.compspkg.split("/mnt/sysimage")[1]
1234     args = ["/bin/rpm", "-Uvh", path]
1235     rc = iutil.execWithRedirect(args[0], args,
1236     stdout = "/dev/tty5",
1237     stderr = "/dev/tty5",
1238     root = instPath)
1239     ts = rpm.TransactionSet()
1240     ts.setVSFlags(~(rpm.RPMVSF_NORSA|rpm.RPMVSF_NODSA))
1241     ts.closeDB()
1242     fd = os.open(id.compspkg, os.O_RDONLY)
1243     h = ts.hdrFromFdno(fd)
1244     os.close(fd)
1245     if upgrade:
1246     text = _("Upgrading %s\n")
1247     else:
1248     text = _("Installing %s\n")
1249     instLog.write (text % (hdrlist.nevra(h)))
1250     os.unlink(id.compspkg)
1251     del ts
1252    
1253     except Exception, e:
1254     log("comps.rpm failed to install: %s" %(e,))
1255     try:
1256     os.unlink(id.compspkg)
1257     except:
1258     pass
1259     else:
1260     log("no comps package found")
1261    
1262     w.set(6)
1263    
1264    
1265     finally:
1266     pass
1267    
1268     if upgrade:
1269     instLog.write(_("\n\nThe following packages were available in "
1270     "this version but NOT upgraded:\n"))
1271     else:
1272     instLog.write(_("\n\nThe following packages were available in "
1273     "this version but NOT installed:\n"))
1274    
1275     ts = rpm.TransactionSet(instPath)
1276     ts.setVSFlags(~(rpm.RPMVSF_NORSA|rpm.RPMVSF_NODSA))
1277    
1278     lines = []
1279     for p in id.grpset.hdrlist.values():
1280     if not p.isSelected():
1281 slords 1.2 text = "%s" % hdrlist.nevra(p)
1282     for f in ts.dbMatch('name', p.hdr[rpm.RPMTAG_NAME]):
1283     if hdrlist.nevra(p) == hdrlist.nevra(f):
1284     text = "%s (already installed)" % text
1285     else:
1286     text = "%s (%s installed)" % (text, hdrlist.nevra(f))
1287     lines.append("%s\n" % text)
1288 slords 1.1 lines.sort()
1289     for line in lines:
1290     instLog.write(line)
1291    
1292     # XXX hack - we should really write a proper lvm "config". but for now
1293     # just vgscan if they have /sbin/lvm and some appearance of volumes
1294     if (os.access(instPath + "/sbin/lvm", os.X_OK) and
1295     os.access(instPath + "/dev/mapper", os.X_OK) and
1296     len(os.listdir("/dev/mapper")) > 1):
1297     rc = iutil.execWithRedirect("/sbin/lvm",
1298     ["lvm", "vgscan", "-v"],
1299     stdout = "/dev/tty5",
1300     stderr = "/dev/tty5",
1301     root = instPath,
1302     searchPath = 1)
1303    
1304     # write out info on install method used
1305     try:
1306     if id.methodstr is not None:
1307     if os.access (instPath + "/etc/sysconfig/installinfo", os.R_OK):
1308     os.rename (instPath + "/etc/sysconfig/installinfo",
1309     instPath + "/etc/sysconfig/installinfo.rpmsave")
1310    
1311     f = open(instPath + "/etc/sysconfig/installinfo", "w+")
1312     f.write("INSTALLMETHOD=%s\n" % (string.split(id.methodstr, ':')[0],))
1313    
1314     try:
1315     ii = open("/tmp/isoinfo", "r")
1316     il = ii.readlines()
1317     ii.close()
1318     for line in il:
1319     f.write(line)
1320     except:
1321     pass
1322     f.close()
1323     else:
1324     log("methodstr not set for some reason")
1325     except:
1326     log("Failed to write out installinfo")
1327    
1328     w.pop ()
1329    
1330     sys.stdout.flush()
1331    
1332     if flags.setupFilesystems:
1333     syslog.stop()
1334    
1335     # FIXME: this is a huge gross hack. hard coded list of files
1336     # created by anaconda so that we can not be killed by selinux
1337     def setFileCons(instPath, partitions):
1338     import partRequests
1339    
1340     if flags.selinux:
1341     log("setting SELinux contexts for anaconda created files")
1342    
1343     files = ["/etc/rpm/platform", "/etc/rpm/macros",
1344     "/etc/lilo.conf", "/etc/lilo.conf.anaconda",
1345     "/etc/mtab", "/etc/fstab", "/etc/resolv.conf",
1346     "/etc/modprobe.conf", "/etc/modprobe.conf~",
1347     "/var/log/wtmp", "/var/run/utmp",
1348     "/dev/log", "/var/lib/rpm", "/", "/etc/raidtab",
1349     "/etc/mdadm.conf"]
1350    
1351     vgs = []
1352     for entry in partitions.requests:
1353     if isinstance(entry, partRequests.VolumeGroupRequestSpec):
1354     vgs.append("/dev/%s" %(entry.volumeGroupName,))
1355    
1356     # ugh, this is ugly
1357     for dir in ["/var/lib/rpm", "/etc/lvm", "/dev/mapper"] + vgs:
1358     def addpath(x): return dir + "/" + x
1359    
1360     if not os.path.isdir(instPath + dir):
1361     continue
1362     dirfiles = os.listdir(instPath + dir)
1363     files.extend(map(addpath, dirfiles))
1364     files.append(dir)
1365    
1366     # blah, to work in a chroot, we need to actually be inside so the
1367     # regexes will work
1368     child = os.fork()
1369     if (not child):
1370     os.chroot(instPath)
1371     for f in files:
1372     if not os.access("%s" %(f,), os.R_OK):
1373     log("%s doesn't exist" %(f,))
1374     continue
1375     ret = isys.resetFileContext(f)
1376     log("set fc of %s to %s" %(f, ret))
1377     os._exit(0)
1378    
1379     try:
1380     os.waitpid(child, 0)
1381     except OSError, (num, msg):
1382     pass
1383    
1384    
1385     return
1386    
1387     # XXX: large hack lies here
1388     def migrateMouseConfig(instPath, instLog):
1389     if not os.access (instPath + "/usr/sbin/fix-mouse-psaux", os.X_OK):
1390     return
1391    
1392     argv = [ "/usr/sbin/fix-mouse-psaux" ]
1393    
1394     logfile = os.open (instLog, os.O_APPEND)
1395     iutil.execWithRedirect(argv[0], argv, root = instPath,
1396     stdout = logfile, stderr = logfile)
1397     os.close(logfile)
1398    
1399    
1400     def migrateXinetd(instPath, instLog):
1401     if not os.access (instPath + "/usr/sbin/inetdconvert", os.X_OK):
1402     return
1403    
1404     if not os.access (instPath + "/etc/inetd.conf.rpmsave", os.R_OK):
1405     return
1406    
1407     argv = [ "/usr/sbin/inetdconvert", "--convertremaining",
1408     "--inetdfile", "/etc/inetd.conf.rpmsave" ]
1409    
1410     logfile = os.open (instLog, os.O_APPEND)
1411     iutil.execWithRedirect(argv[0], argv, root = instPath,
1412     stdout = logfile, stderr = logfile)
1413     os.close(logfile)
1414    
1415     def copyExtraModules(instPath, grpset, extraModules):
1416     kernelVersions = grpset.kernelVersionList()
1417     foundModule = 0
1418    
1419     try:
1420     f = open("/etc/arch")
1421     arch = f.readline().strip()
1422     del f
1423     except IOError:
1424     arch = os.uname()[2]
1425    
1426     for (path, name) in extraModules:
1427     if not path:
1428     path = "/modules.cgz"
1429     pattern = ""
1430     names = ""
1431     for (n, tag) in kernelVersions:
1432     if tag == "up":
1433     pkg = "kernel"
1434     else:
1435     pkg = "kernel-%s" %(tag,)
1436     arch = grpset.hdrlist[pkg][rpm.RPMTAG_ARCH]
1437     # version 1 path
1438     pattern = pattern + " %s/%s/%s.ko " % (n, arch, name)
1439     # version 0 path
1440     pattern = pattern + " %s/%s.ko " % (n, name)
1441     names = names + " %s.ko" % (name,)
1442     command = ("cd %s/lib/modules; gunzip < %s | "
1443     "%s/bin/cpio --quiet -iumd %s" %
1444     (instPath, path, instPath, pattern))
1445     log("running: '%s'" % (command, ))
1446     os.system(command)
1447    
1448     for (n, tag) in kernelVersions:
1449     if tag == "up":
1450     pkg = "kernel"
1451     else:
1452     pkg = "kernel-%s" %(tag,)
1453    
1454     toDir = "%s/lib/modules/%s/updates" % \
1455     (instPath, n)
1456     to = "%s/%s.ko" % (toDir, name)
1457    
1458     if (os.path.isdir("%s/lib/modules/%s" %(instPath, n)) and not
1459     os.path.isdir("%s/lib/modules/%s/updates" %(instPath, n))):
1460     os.mkdir("%s/lib/modules/%s/updates" %(instPath, n))
1461     if not os.path.isdir(toDir):
1462     continue
1463    
1464     arch = grpset.hdrlist[pkg][rpm.RPMTAG_ARCH]
1465     for p in ("%s/%s.ko" %(arch, name), "%s.ko" %(name,)):
1466     fromFile = "%s/lib/modules/%s/%s" % (instPath, n, p)
1467    
1468     if (os.access(fromFile, os.R_OK)):
1469     log("moving %s to %s" % (fromFile, to))
1470     os.rename(fromFile, to)
1471     # the file might not have been owned by root in the cgz
1472     os.chown(to, 0, 0)
1473     foundModule = 1
1474     else:
1475     log("missing DD module %s (this may be okay)" %
1476     fromFile)
1477    
1478     if foundModule == 1:
1479     for (n, tag) in kernelVersions:
1480     recreateInitrd(n, instPath)
1481    
1482    
1483     #Recreate initrd for use when driver disks add modules
1484     def recreateInitrd (kernelTag, instRoot):
1485     log("recreating initrd for %s" % (kernelTag,))
1486     iutil.execWithRedirect("/sbin/new-kernel-pkg",
1487     [ "/sbin/new-kernel-pkg", "--mkinitrd",
1488     "--depmod", "--install", kernelTag ],
1489     stdout = None, stderr = None,
1490     searchPath = 1, root = instRoot)
1491    
1492     # XXX Deprecated. Is this ever called anymore?
1493     def depmodModules(comps, instPath):
1494     kernelVersions = comps.kernelVersionList()
1495    
1496     for (version, tag) in kernelVersions:
1497     iutil.execWithRedirect ("/sbin/depmod",
1498     [ "/sbin/depmod", "-a", version,
1499     "-F", "/boot/System.map-" + version ],
1500     root = instPath, stderr = '/dev/null')
1501    
1502    
1503     def betaNagScreen(intf, dir):
1504     publicBetas = { "Red Hat Linux": "Red Hat Linux Public Beta",
1505     "Red Hat Enterprise Linux": "Red Hat Enterprise Linux Public Beta",
1506     "Fedora Core": "Fedora Core" }
1507    
1508    
1509     if dir == DISPATCH_BACK:
1510     return DISPATCH_NOOP
1511    
1512     fileagainst = None
1513     for (key, val) in publicBetas.items():
1514     if productName.startswith(key):
1515     fileagainst = val
1516     if fileagainst is None:
1517     fileagainst = "%s Beta" %(productName,)
1518    
1519     while 1:
1520     rc = intf.messageWindow( _("Warning! This is pre-release software!"),
1521     _("Thank you for downloading this "
1522     "pre-release of %s.\n\n"
1523     "This is not a final "
1524     "release and is not intended for use "
1525     "on production systems. The purpose of "
1526     "this release is to collect feedback "
1527     "from testers, and it is not suitable "
1528     "for day to day usage.\n\n"
1529     "To report feedback, please visit:\n\n"
1530     " http://www.centos.orrg/bugs\n\n"
1531     "and file a report against '%s'.\n"
1532     %(productName, fileagainst)),
1533     type="custom", custom_icon="warning",
1534     custom_buttons=[_("_Exit"), _("_Install anyway")])
1535    
1536     if not rc:
1537     if flags.rootpath:
1538     msg = _("The installer will now exit...")
1539     buttons = [_("_Back"), _("_Exit")]
1540     else:
1541     msg = _("Your system will now be rebooted...")
1542     buttons = [_("_Back"), _("_Reboot")]
1543     rc = intf.messageWindow( _("Rebooting System"),
1544     msg,
1545     type="custom", custom_icon="warning",
1546     custom_buttons=buttons)
1547     if rc:
1548     sys.exit(0)
1549     else:
1550     break
1551    
1552     # FIXME: this is a kind of poor way to do this, but it will work for now
1553     def selectLanguageSupportGroups(grpset, langSupport):
1554     sup = langSupport.supported
1555     if len(sup) == 0:
1556     sup = langSupport.getAllSupported()
1557    
1558     for group in grpset.groups.values():
1559     xmlgrp = grpset.compsxml.groups[group.basename]
1560     langs = []
1561     for name in sup:
1562     try:
1563     lang = langSupport.langInfoByName[name][0]
1564     langs.extend(language.expandLangs(lang))
1565     except:
1566     continue
1567    
1568     if group.langonly is not None and group.langonly in langs:
1569     group.select()
1570     for package in xmlgrp.pkgConditionals.keys():
1571     req = xmlgrp.pkgConditionals[package]
1572     if not grpset.hdrlist.has_key(package):
1573     log("Missing %s which is in a langsupport conditional" %(package,))
1574     continue
1575     # add to the deps in the dependencies structure for the
1576     # package. this should take care of whenever we're
1577     # selected
1578     grpset.hdrlist[req].addDeps([package], main = 0)
1579     if grpset.hdrlist[req].isSelected():
1580     grpset.hdrlist[package].select()
1581     sys.stdout.flush()
1582     grpset.hdrlist[package].usecount += grpset.hdrlist[req].usecount - 1
1583     group.selectDeps([package], uses = grpset.hdrlist[req].usecount)
1584    

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