1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
|
#
# Copyright (c) 2005 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# general public license.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
from flags import flags
import sys
import os
import shutil
import timer
import rpm
import rpmUtils
import urlgrabber.progress
import urlgrabber.grabber
import yum
import yum.repos
import yum.packages
import yum.groups
from yum.constants import *
from yum.Errors import RepoError, YumBaseError
from yum.packages import returnBestPackages
from repomd.mdErrors import PackageSackError
from backend import AnacondaBackend
from sortedtransaction import *
from genheader import *
from constants import *
from rhpl.translate import _
import logging
log = logging.getLogger("anaconda")
import urlparse
urlparse.uses_fragment.append('media')
import iutil
import isys
from whiteout import whiteout
#XXX: this needs to be somewhere better - probably method
def getcd(po):
try:
uri = po.returnSimple('basepath')
(scheme, netloc, path, query, fragid) = urlparse.urlsplit(uri)
if scheme != "media" or not fragid:
return 0
else:
return int(fragid)
except KeyError:
return 0
class simpleCallback:
def __init__(self, messageWindow, progress, pkgTimer, method,
progressWindowClass, instLog, modeText, ts):
self.messageWindow = messageWindow
self.progress = progress
self.pkgTimer = pkgTimer
self.method = method
self.progressWindowClass = progressWindowClass
self.progressWindow = None
self.lastprogress = 0
self.incr = 20
self.instLog = instLog
self.modeText = modeText
self.beenCalled = 0
self.initWindow = None
self.ts = ts
self.fdnos = {}
def callback(self, what, amount, total, h, user):
# first time here means we should pop the window telling
# user to wait until we get here
if not self.beenCalled:
self.beenCalled = 1
self.initWindow.pop()
if what == rpm.RPMCALLBACK_TRANS_START:
# step 6 is the bulk of the ts processing time
if amount == 6:
self.progressWindow = \
self.progressWindowClass (_("Processing"),
_("Preparing to install..."),
total)
try:
self.incr = total / 10
except:
pass
if what == rpm.RPMCALLBACK_TRANS_PROGRESS:
if self.progressWindow and amount > self.lastprogress + self.incr:
self.progressWindow.set(amount)
self.lastprogress = amount
if what == rpm.RPMCALLBACK_TRANS_STOP and self.progressWindow:
self.progressWindow.pop()
if what == rpm.RPMCALLBACK_INST_OPEN_FILE:
self.pkgTimer.start()
po = h
hdr = po.returnLocalHeader()
path = po.returnSimple('relativepath')
self.progress.setPackage(hdr)
self.progress.setPackageScale(0, 1)
self.instLog.write(self.modeText % (po.returnSimple('name'),
po.returnSimple('version'),
po.returnSimple('release'),
po.returnSimple('arch')))
self.instLog.flush()
self.size = po.returnSimple('installedsize')
fn = self.method.getRPMFilename(os.path.basename(path), getcd(po), None)
fd = os.open(fn, os.O_RDONLY)
nvra = po.returnNevraPrintable()
self.fdnos[nvra] = fd
return fd
elif what == rpm.RPMCALLBACK_INST_PROGRESS:
if amount > total:
amount = total
if not total or total == 0 or total == "0":
total = amount
self.progress.setPackageScale(amount, total)
elif what == rpm.RPMCALLBACK_INST_CLOSE_FILE:
po = h
hdr = po.returnLocalHeader()
path = po.returnSimple('relativepath')
fn = self.method.getRPMFilename(os.path.basename(path), getcd(po), None)
nvra = po.returnNevraPrintable()
os.close(self.fdnos[nvra])
self.method.unlinkFilename(fn)
self.progress.completePackage(hdr, self.pkgTimer)
self.progress.processEvents()
else:
pass
self.progress.processEvents()
class AnacondaYumConf:
"""Dynamic yum configuration"""
def __init__( self, methodstr, configfile = "/tmp/yum.conf", root = '/'):
self.methodstr = methodstr
self.configfile = configfile
self.root = root
self.yumconfstr = """
[main]
cachedir=/var/cache/yum
reposdir=/tmp/repos.d
debuglevel=2
logfile=/tmp/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
retries=5
obsoletes=1
gpgcheck=0
installroot=%s
exclude=*debuginfo*
[anaconda]
baseurl=%s
enabled=1
gpgcheck=0
gpgkey=%s/RPM-GPG-KEY-fedora
""" % (self.root, self.methodstr, self.methodstr)
def write(self):
f = open(self.configfile, 'w')
f.write(self.yumconfstr)
f.close()
class AnacondaYum(yum.YumBase):
def __init__(self, fn="/etc/yum.conf", root="/"):
yum.YumBase.__init__(self)
self.doConfigSetup(fn, root)
self.macros = {}
if flags.selinux:
for dir in ("/tmp/updates", "/mnt/source/RHupdates",
"/etc/selinux/targeted/contexts/files",
"/etc/security/selinux/src/policy/file_contexts",
"/etc/security/selinux"):
fn = "%s/file_contexts" %(dir,)
if os.access(fn, os.R_OK):
break
self.macros["__file_context_path"] = fn
else:
self.macros["__file_context_path"] = "%{nil}"
self.macros["_dependency_whiteout"] = whiteout
self.updates = []
self.localPackages = []
def errorlog(self, value, msg):
log.error(msg)
def filelog(self, value, msg):
pass
def log(self, value, msg):
if value >= 2:
log.debug(msg)
elif value == 1:
log.info(msg)
else:
log.warning(msg)
def getDownloadPkgs(self):
downloadpkgs = []
totalSize = 0
totalFiles = 0
for txmbr in self.tsInfo.getMembers():
if txmbr.ts_state in ['i', 'u']:
po = txmbr.po
if po:
totalSize += int(po.returnSimple("installedsize")) / 1024
for filetype in po.returnFileTypes():
totalFiles += len(po.returnFileEntries(ftype=filetype))
downloadpkgs.append(po)
return (downloadpkgs, totalSize, totalFiles)
def setColor(self):
if (rpmUtils.arch.canonArch.startswith("ppc64") or
rpmUtils.arch.canonArch in ("s390x", "sparc64", "x86_64", "ia64")):
self.ts.ts.setColor(3)
def run(self, instLog, cb, intf):
self.initActionTs()
self.setColor()
self.populateTs(keepold=0)
self.ts.check()
self.ts.order()
self._run(instLog, cb, intf)
def _run(self, instLog, cb, intf):
# set log fd. FIXME: this is ugly. see changelog entry from 2005-09-13
self.ts.ts.scriptFd = instLog.fileno()
rpm.setLogFile(instLog)
try:
self.runTransaction(cb=cb)
except YumBaseError, probs:
# FIXME: we need to actually look at these problems...
log.error("error running transaction: %s" %(probs,))
intf.messageWindow(_("Error running transaction"),
("There was an error running your transaction, "
"probably a disk space problem. For now, "
"exiting on this although we should diagnose "
"and then let you go back."))
sys.exit(1)
def doCacheSetup(self):
for repo in self.repos.repos.values():
repo.set('cachedir', '/tmp/cache/')
repo.set('pkgdir', '/mnt/sysimage/')
repo.set('hdrdir', '/tmp/cache/headers')
def doMacros(self):
for (key, val) in self.macros.items():
rpm.addMacro(key, val)
def getBestPackages(self, pkgname, pkgarch = None):
"""Return a list of the packages which should be installed.
Note that it's a list because of multilib!"""
if pkgarch:
pkgs = self.pkgSack.returnNewestByName(pkgname, pkgarch)
else:
pkgs = self.pkgSack.returnNewestByName(pkgname)
if len(pkgs) <= 1: # 0 or 1, just return it
return pkgs
t = {}
for pkg in pkgs:
if not t.has_key(pkg.name): t[pkg.name] = []
t[pkg.name].append(pkg.pkgtup)
pkgs = returnBestPackages(t)
return map(lambda x: self.getPackageObject(x), pkgs)
#From yum depsolve.py
def populateTs(self, test=0, keepold=1):
"""take transactionData class and populate transaction set"""
if self.dsCallback: self.dsCallback.transactionPopulation()
ts_elem = {}
if keepold:
for te in self.ts:
epoch = te.E()
if epoch is None:
epoch = '0'
pkginfo = (te.N(), te.A(), epoch, te.V(), te.R())
if te.Type() == 1:
mode = 'i'
elif te.Type() == 2:
mode = 'e'
ts_elem[(pkginfo, mode)] = 1
for txmbr in self.tsInfo.getMembers():
self.log(6, 'Member: %s' % txmbr)
if txmbr.ts_state in ['u', 'i']:
if ts_elem.has_key((txmbr.pkgtup, 'i')):
continue
self.downloadHeader(txmbr.po)
hdr = txmbr.po.returnLocalHeader()
rpmfile = txmbr.po.localPkg()
if txmbr.ts_state == 'u':
if txmbr.po.name.startswith("kernel-module-"):
self.handleKernelModule(txmbr)
if self.allowedMultipleInstalls(txmbr.po):
self.log(5, '%s converted to install' % (txmbr.po))
txmbr.ts_state = 'i'
txmbr.output_state = TS_INSTALL
#XXX: Changed callback api to take a package object
self.ts.addInstall(hdr, txmbr.po, txmbr.ts_state)
self.log(4, 'Adding Package %s in mode %s' % (txmbr.po, txmbr.ts_state))
if self.dsCallback:
self.dsCallback.pkgAdded(txmbr.pkgtup, txmbr.ts_state)
elif txmbr.ts_state in ['e']:
if ts_elem.has_key((txmbr.pkgtup, txmbr.ts_state)):
continue
indexes = self.rpmdb.returnIndexByTuple(txmbr.pkgtup)
for idx in indexes:
self.ts.addErase(idx)
if self.dsCallback: self.dsCallback.pkgAdded(txmbr.pkgtup, 'e')
self.log(4, 'Removing Package %s' % txmbr.po)
class AnacondaYumMedia(AnacondaYum):
def __init__(self, fn="/etc/yum.conf", root="/", method=None):
AnacondaYum.__init__(self, fn, root)
self.method = method
self.deps = {}
self.path = []
self.loops = []
self.whiteout = whiteout.split()
def run(self, instLog, cb, intf):
self.initActionTs()
self.setColor()
if len(self.tsInfo.reqmedia.keys()) == 0:
self.populateTs(keepold=0)
self.ts.check()
self.ts.order()
self._run(instLog, cb, intf)
else:
for i in self.tsInfo.reqmedia.keys():
self.tsInfo.curmedia = i
self.method.switchMedia(i)
self.populateTs(keepold=0)
self.ts.check()
self.ts.order()
self._run(instLog, cb, intf)
def _provideToPkg(self, req):
best = None
(r, f, v) = req
satisfiers = []
for po in self.whatProvides(r, f, v):
if po.name not in satisfiers:
satisfiers.append(po)
if satisfiers:
best = self.bestPackageFromList(satisfiers)
self.deps[req] = best
# raise resolution error
def resolveDeps(self):
CheckDeps = 1
if self.dsCallback: self.dsCallback.start()
while CheckDeps > 0:
if self.dsCallback: self.dsCallback.tscheck()
unresolved = self.tsCheck()
CheckDeps = len(unresolved)
return (2, ['Success - deps resolved'])
def tsCheck(self):
unresolved = []
for txmbr in self.tsInfo.getMembers():
reqs = txmbr.po.returnPrco('requires')
provs = txmbr.po.returnPrco('provides')
reqs.sort()
for req in reqs:
if req[0].startswith('rpmlib(') or req[0].startswith('config('):
continue
#XXX: handle unresolvable dep
if req in provs:
continue
if req not in self.deps.keys():
self._provideToPkg(req)
try:
dep = self.deps[req]
except KeyError, e:
raise yum.Errors.DepError, "Unresolvable dependancy %s in %s" % (req[0], txmbr.name)
# Skip filebased requires on self, etc
if txmbr.name == dep.name:
continue
if "%s>%s" % (txmbr.name, dep.name) in self.whiteout:
continue
#XXX: handle in rpmdb too for upgrades
#if pkgs:
# member = self.bestPackageFromList(pkgs)
#else:
if self.tsInfo.exists(dep.pkgtup):
pkgs = self.tsInfo.getMembers(pkgtup=dep.pkgtup)
member = self.bestPackageFromList(pkgs)
else:
member = self.tsInfo.addInstall(dep)
unresolved.append(dep)
#Add relationship
firstelts = map(lambda tup: tup[0], txmbr.relatedto)
if member.po.pkgtup not in firstelts:
txmbr.setAsDep(member.po.pkgtup)
return unresolved
def doTsSetup(self):
if hasattr(self, 'read_ts'):
return
if not self.conf.installroot:
raise yum.Errors.YumBaseError, 'Setting up TransactionSets before config class is up'
installroot = self.conf.installroot
self.read_ts = rpmUtils.transaction.initReadOnlyTransaction(root=installroot)
self.tsInfo = SplitMediaTransactionData()
self.rpmdb = rpmUtils.RpmDBHolder()
self.initActionTs()
class YumBackend(AnacondaBackend):
def __init__(self, method, instPath):
AnacondaBackend.__init__(self, method, instPath)
self.ac = AnacondaYumConf(self.method.getMethodUri(),
configfile="/tmp/yum.conf", root=instPath)
self.ac.write()
self.ayum = AnacondaYumMedia(fn="/tmp/yum.conf", root=instPath,
method=method)
# FIXME: this is a bad hack until we can get something better into yum
self.anaconda_grouplist = []
def doRepoSetup(self, intf, instPath):
if not os.path.exists("/tmp/cache"):
iutil.mkdirChain("/tmp/cache/headers")
tasks = (self.ayum.doMacros,
self.ayum.doTsSetup,
self.ayum.doRpmDBSetup,
self.ayum.doRepoSetup,
self.ayum.doCacheSetup,
self.ayum.doGroupSetup,
self.ayum.doSackSetup )
waitwin = YumProgress(intf, _("Retrieving installation information"),
len(tasks))
self.ayum.repos.callback = waitwin
try:
for task in tasks:
task()
waitwin.next_task()
waitwin.pop()
except RepoError, e:
log.error("reading package metadata: %s" %(e,))
waitwin.pop()
intf.messageWindow(_("Error"),
_("Unable to read package metadata. This may be "
"due to a missing repodata directory. Please "
"ensure that your install tree has been "
"correctly generated. %s" % e),
type="custom", custom_icon="error",
custom_buttons=[_("_Exit")])
sys.exit(0)
def selectBestKernel(self):
"""Find the best kernel package which is available and select it."""
def getBestKernelByArch(pkgname, ayum):
"""Convenience func to find the best arch of a kernel by name"""
pkgs = ayum.pkgSack.returnNewestByName(pkgname)
if len(pkgs) == 0:
return None
archs = {}
for pkg in pkgs:
(n, a, e, v, r) = pkg.pkgtup
archs[a] = pkg
a = rpmUtils.arch.getBestArchFromList(archs.keys())
return archs[a]
foundkernel = False
kpkg = getBestKernelByArch("kernel", self.ayum)
if not foundkernel and os.path.exists("/proc/xen"):
try:
kxen = getBestKernelByArch("kernel-xen-guest", self.ayum)
log.info("selecting kernel-xen-guest package for kernel")
foundkernel = True
except PackageSackError:
kxen = None
log.debug("no kernel-xen-guest package")
else:
self.ayum.tsInfo.addInstall(kxen)
if len(self.ayum.tsInfo.matchNaevr(name="gcc")) > 0:
log.debug("selecting kernel-xen-guest-devel")
self.selectPackage("kernel-xen-guest-devel")
if not foundkernel and \
(open("/proc/cmdline").read().find("xen0") != -1):
try:
kxen = getBestKernelByArch("kernel-xen-hypervisor", self.ayum)
log.info("selecting kernel-xen-hypervisor package for kernel")
foundkernel = True
except PackageSackError:
kxen = None
log.debug("no kernel-xen-hypervisor package")
else:
self.ayum.tsInfo.addInstall(kxen)
if len(self.ayum.tsInfo.matchNaevr(name="gcc")) > 0:
log.debug("selecting kernel-xen-hypervisor-devel")
self.selectPackage("kernel-xen-hypervisor-devel")
if not foundkernel and (isys.smpAvailable() or isys.htavailable()
or iutil.hasNX()):
try:
ksmp = getBestKernelByArch("kernel-smp", self.ayum)
log.info("selected kernel-smp package for kernel")
foundkernel = True
except PackageSackError:
ksmp = None
log.debug("no kernel-smp package")
if ksmp and ksmp.returnSimple("arch") == kpkg.returnSimple("arch"):
self.ayum.tsInfo.addInstall(ksmp)
if len(self.ayum.tsInfo.matchNaevr(name="gcc")) > 0:
log.debug("selecting kernel-smp-devel")
self.selectPackage("kernel-smp-devel")
if not foundkernel:
log.info("selected kernel package for kernel")
self.ayum.tsInfo.addInstall(kpkg)
if len(self.ayum.tsInfo.matchNaevr(name="gcc")) > 0:
log.debug("selecting kernel-devel")
self.selectPackage("kernel-devel")
def selectBootloader(self):
if iutil.getArch() in ("i386", "x86_64"):
self.selectPackage("grub")
elif iutil.getArch() == "s390":
self.selectPackage("s390utils")
elif iutil.getArch() == "ppc":
self.selectPackage("yaboot")
elif iutil.getArch() == "ia64":
self.selectPackage("elilo")
def doPostSelection(self, intf, id, instPath):
# do some sanity checks for kernel and bootloader
self.selectBestKernel()
self.selectBootloader()
dscb = YumDepSolveProgress(intf)
self.ayum.dsCallback = dscb
try:
(code, msgs) = self.ayum.buildTransaction()
(self.dlpkgs, self.totalSize, self.totalFiles) = self.ayum.getDownloadPkgs()
finally:
dscb.pop()
def doPreInstall(self, intf, id, instPath, dir):
if dir == DISPATCH_BACK:
for d in ("/selinux", "/dev"):
try:
isys.umount(instPath + d, removeDir = 0)
except Exception, e:
log.error("unable to unmount %s: %s" %(d, e))
return
if flags.test:
return
# shorthand
upgrade = id.getUpgrade()
if upgrade:
# An old mtab can cause confusion (esp if loop devices are
# in it)
f = open(instPath + "/etc/mtab", "w+")
f.close()
# we really started writing modprobe.conf out before things were
# all completely ready. so now we need to nuke old modprobe.conf's
# if you're upgrading from a 2.4 dist so that we can get the
# transition right
if (os.path.exists(instPath + "/etc/modules.conf") and
os.path.exists(instPath + "/etc/modprobe.conf") and
not os.path.exists(instPath + "/etc/modprobe.conf.anacbak")):
log.info("renaming old modprobe.conf -> modprobe.conf.anacbak")
os.rename(instPath + "/etc/modprobe.conf",
instPath + "/etc/modprobe.conf.anacbak")
if self.method.systemMounted (id.fsset, instPath):
id.fsset.umountFilesystems(instPath)
return DISPATCH_BACK
for i in ( '/var', '/var/lib', '/var/lib/rpm', '/tmp', '/dev', '/etc',
'/etc/sysconfig', '/etc/sysconfig/network-scripts',
'/etc/X11', '/root', '/var/tmp', '/etc/rpm', '/var/cache', '/var/cache/yum' ):
try:
os.mkdir(instPath + i)
except os.error, (errno, msg):
pass
# log.error("Error making directory %s: %s" % (i, msg))
self.initLog(id, instPath)
if flags.setupFilesystems:
# setup /etc/rpm/platform for the post-install environment
iutil.writeRpmPlatform(instPath)
try:
# FIXME: making the /var/lib/rpm symlink here is a hack to
# workaround db->close() errors from rpm
iutil.mkdirChain("/var/lib")
for path in ("/var/tmp", "/var/lib/rpm"):
if os.path.exists(path) and not os.path.islink(path):
iutil.rmrf(path)
if not os.path.islink(path):
os.symlink("/mnt/sysimage/%s" %(path,), "%s" %(path,))
else:
log.warning("%s already exists as a symlink to %s" %(path, os.readlink(path),))
except Exception, e:
# how this could happen isn't entirely clear; log it in case
# it does and causes problems later
log.error("error creating symlink, continuing anyway: %s" %(e,))
# SELinux hackery (#121369)
if flags.selinux:
try:
os.mkdir(instPath + "/selinux")
except Exception, e:
pass
try:
isys.mount("/selinux", instPath + "/selinux", "selinuxfs")
except Exception, e:
log.error("error mounting selinuxfs: %s" %(e,))
# we need to have a /dev during install and now that udev is
# handling /dev, it gets to be more fun. so just bind mount the
# installer /dev
if 1:
log.warning("no dev package, going to bind mount /dev")
isys.mount("/dev", "/mnt/sysimage/dev", bindMount = 1)
# write out the fstab
if not upgrade:
id.fsset.write(instPath)
# rootpath mode doesn't have this file around
if os.access("/tmp/modprobe.conf", os.R_OK):
iutil.copyFile("/tmp/modprobe.conf",
instPath + "/etc/modprobe.conf")
if os.access("/tmp/zfcp.conf", os.R_OK):
iutil.copyFile("/tmp/zfcp.conf",
instPath + "/etc/zfcp.conf")
# make a /etc/mtab so mkinitrd can handle certain hw (usb) correctly
f = open(instPath + "/etc/mtab", "w+")
f.write(id.fsset.mtab())
f.close()
def doInstall(self, intf, id, instPath):
log.info("Preparing to install packages")
if flags.test:
log.info("Test mode - not performing install")
return
if not id.upgrade:
rpm.addMacro("__dbi_htconfig",
"hash nofsync %{__dbi_other} %{__dbi_perms}")
pkgTimer = timer.Timer(start = 0)
id.instProgress.setSizes(len(self.dlpkgs), self.totalSize, self.totalFiles)
id.instProgress.processEvents()
cb = simpleCallback(intf.messageWindow, id.instProgress, pkgTimer, self.method, intf.progressWindow, self.instLog, self.modeText, self.ayum.ts)
cb.initWindow = intf.waitWindow(_("Install Starting"),
_("Starting install process. This may take several minutes..."))
self.ayum.run(self.instLog, cb, intf)
if not cb.beenCalled:
cb.initWindow.pop()
self.method.filesDone()
self.instLog.close ()
id.instProgress = None
def doPostInstall(self, intf, id, instPath):
if flags.test:
return
w = intf.progressWindow(_("Post Install"),
_("Performing post install configuration..."), 6)
id.network.write(instPath)
for tsmbr in self.ayum.tsInfo.matchNaevr(name='rhgb'):
id.bootloader.args.append("rhgb quiet")
break
for tsmbr in self.ayum.tsInfo.matchNaevr(name='gdm'):
id.desktop.setDefaultRunLevel(5)
break
# XXX: write proper lvm config
w.pop()
AnacondaBackend.doPostInstall(self, intf, id, instPath)
def kernelVersionList(self):
kernelVersions = []
# nick is used to generate the lilo name
for (ktag, nick) in [ ('kernel-smp', 'smp'),
('kernel-xen-hypervisor', 'hypervisor'),
('kernel-xen-guest', 'guest') ]:
tag = ktag.rsplit('-', 1)[1]
for tsmbr in self.ayum.tsInfo.matchNaevr(name=ktag):
version = ( tsmbr.version + '-' + tsmbr.release + tag)
kernelVersions.append((version, nick))
for tsmbr in self.ayum.tsInfo.matchNaevr(name='kernel'):
version = ( tsmbr.version + '-' + tsmbr.release)
kernelVersions.append((version, 'up'))
return kernelVersions
def groupExists(self, group):
return self.ayum.groupInfo.groupExists(group)
def selectGroup(self, group, *args):
if not self.groupExists(group):
log.debug("no such group %s" %(group,))
return
pkgs = self.ayum.groupInfo.pkgTree(group)
for pkg in pkgs:
try:
map(lambda x: self.ayum.tsInfo.addInstall(x),
self.ayum.getBestPackages(pkg))
except PackageSackError:
log.debug("no such package %s" %(pkg,))
for grp in self.ayum.groupInfo.groupTree(group):
if grp not in self.anaconda_grouplist:
self.anaconda_grouplist.append(grp)
def deselectGroup(self, group, *args):
if not self.groupExists(group):
log.debug("no such group %s" %(group,))
return
gid = self.ayum.groupInfo.matchGroup(group)
for pkg in self.ayum.groupInfo.default_pkgs[gid] + \
self.ayum.groupInfo.mandatory_pkgs[gid]:
try:
map(lambda x: self.ayum.tsInfo.remove(x.pkgtup),
self.ayum.getBestPackages(pkg))
except PackageSackError:
log.debug("no such package %s" %(pkg,))
for grp in self.ayum.groupInfo.groupTree(group):
if grp in self.anaconda_grouplist:
self.anaconda_grouplist.remove(grp)
def selectPackage(self, pkg, *args):
sp = pkg.rsplit(".", 2)
p = None
if len(sp) == 2:
try:
map(lambda x: self.ayum.tsInfo.addInstall(x),
self.ayum.getBestPackages(sp[0], sp[1]))
return
except PackageSackError:
# maybe the package has a . in the name
pass
if p is None:
try:
map(lambda x: self.ayum.tsInfo.addInstall(x),
self.ayum.getBestPackages(pkg))
except PackageSackError:
log.debug("no such package %s" %(pkg,))
return
def deselectPackage(self, pkg, *args):
sp = pkg.rsplit(".", 2)
p = None
if len(sp) == 2:
try:
map(lambda x: self.ayum.tsInfo.remove(x),
self.ayum.getBestPackages(sp[0], sp[1]))
return
except PackageSackError:
# maybe the package has a . in the name
pass
if p is None:
try:
map(lambda x: self.ayum.tsInfo.remove(x),
self.ayum.getBestPackages(pkg))
except PackageSackError:
log.debug("no such package %s" %(pkg,))
return
class YumProgress:
def __init__(self, intf, text, total):
window = intf.progressWindow(_("Installation Progress"), text ,total)
self.window = window
self.total = float(total)
self.num = 0
self.popped = False
def progressbar(self, current, total, name=None):
if not self.popped:
self.window.set(current)
def pop(self):
self.window.pop()
self.popped = True
def next_task(self):
self.num += 1
if not self.popped:
self.window.set(self.num/self.total)
def errorlog(self, value, msg):
log.error(msg)
def filelog(self, value, msg):
pass
def log(self, value, msg):
log.info(msg)
class YumDepSolveProgress:
def __init__(self, intf):
window = intf.progressWindow(_("Dependency Check"),
_("Checking dependencies in packages selected for installation..."), 1.0)
self.window = window
self.total = 1.0
self.pkgAdded = self.procReq = self.transactionPopulation = self.downloadHeader = self.tscheck = self.unresolved = self.procConflict = self.refresh
def refresh(self, *args):
self.window.refresh()
def set(self, value):
self.current = value
self.window.set(self.current)
def start(self):
self.set(0.1)
self.refresh()
def restartLoop(self):
new = ((1.0 - self.current) / 2) + self.current
self.set(new)
self.refresh()
def end(self):
self.window.set(1.0)
self.window.refresh()
def pop(self):
self.window.pop()
def errorlog(self, value, msg):
log.error(msg)
def filelog(self, value, msg):
pass
def log(self, value, msg):
log.info(msg)
|