Example #1
0
    def testGetArchFlavor(self):
        f = deps.parseFlavor("use: blah is: x86")
        self.failUnlessEqual(installable_iso.getArchFlavor(f).freeze(), flavors.pathSearchOrder[1])

        f = deps.parseFlavor("use: blah is: x86 x86_64")
        self.failUnlessEqual(installable_iso.getArchFlavor(f).freeze(), flavors.pathSearchOrder[0])

        f = deps.parseFlavor("use: foo")
        self.failUnlessEqual(installable_iso.getArchFlavor(f), None)
Example #2
0
 def testMissedFlavor(self):
     flv = deps.parseFlavor('is: trash')
     res = installable_iso.getArchFlavor(flv)
     ref = deps.Flavor()
     self.failIf(res != ref, "expected '%s' but got '%s'" % (ref, res))
Example #3
0
    def write(self):
        topDir = os.path.join(self.workDir, 'unified')
        tbdir = os.path.join(topDir, self.productDir, 'tarballs')
        baseDir = os.path.join(topDir, self.productDir, 'base')
        util.mkdirChain(tbdir)
        util.mkdirChain(baseDir)

        basePath = os.path.join(self.workDir, self.basefilename)
        if os.path.exists(basePath):
            util.rmtree(basePath)
        util.mkdirChain(basePath)
        outputDir = os.path.join(constants.finishedDir, self.UUID)
        util.mkdirChain(outputDir)
        tarball = os.path.join(self.workDir, self.basefilename + '.tar.gz')
        cwd = os.getcwd()
        try:
            self.installFileTree(basePath, no_mbr=True)

            self.status('Preparing to build ISOs')

            os.chdir(basePath)
            util.execute('tar -C %s -cpPsS --to-stdout ./ | gzip > %s' % \
                             (basePath, tarball))
            ts = TarSplit(tarball)
            ts.splitFile(tbdir)
            ts.writeTbList(os.path.join(baseDir, 'tblist'))
            util.rmtree(basePath, ignore_errors = True)
            util.rmtree(tarball, ignore_errors = True)
            try:
                os.chdir(cwd)
            except:
                # block all errors so that real ones can get through
                pass

            self.callback = installable_iso.Callback(self.status)

            print >> sys.stderr, "Building ISOs of size: %d Mb" % \
              (self.maxIsoSize / 1048576)
            sys.stderr.flush()

            # FIXME: hack to ensure we don't trigger overburns.
            # there are probably cleaner ways to do this.
            if self.maxIsoSize > 681574400:
                self.maxIsoSize -= 1024 * 1024

            templateDir, clientVersion = self.retrieveTemplates()
            csdir = self.prepareTemplates(topDir, templateDir)

            util.rmtree(csdir, ignore_errors=True)

            if self.arch == 'x86':
                anacondaArch = 'i386'
            else:
                anacondaArch = self.arch

            # write .discinfo
            discInfoPath = os.path.join(topDir, ".discinfo")
            if os.path.exists(discInfoPath):
                os.unlink(discInfoPath)
            discInfoFile = open(discInfoPath, "w")
            print >> discInfoFile, time.time()
            print >> discInfoFile, self.jobData['name']
            print >> discInfoFile, anacondaArch
            print >> discInfoFile, "1"
            for x in ["base", "tarballs", 'pixmaps']:
                print >> discInfoFile, "%s/%s" % (self.productDir, x)
            discInfoFile.close()

            self.extractMediaTemplate(topDir)
            self.setupKickstart(topDir)
            self.writeProductImage(topDir, installable_iso.getArchFlavor(self.baseFlavor).freeze())

            self.status("Building ISOs")

            # Mostly copied from splitdistro
            current = os.path.join(self.workDir, 'disc1')
            discnum = 1
            if os.path.isdir(current):
                print >> sys.stderr, 'removing stale', current
                util.rmtree(current)
            print >> sys.stderr, 'creating', current
            os.mkdir(current)
            splitdistro.lndir(topDir, current, excludes=('media-template',))
            # lay 'disc1' before 'all' to ensure collisions are handled correctly
            for cDir in ('disc1', 'all'):
                if 'media-template' in os.listdir(topDir) and \
                       cDir in os.listdir(os.path.join(topDir, 'media-template')):
                    splitdistro.lndir(os.path.join(topDir, 'media-template', cDir), current)

            for cDir in ('all', 'disc1'):
                srcDir = os.path.join(topDir, 'media-template2', cDir)
                if os.path.exists(srcDir):
                    for src in os.listdir(srcDir):
                        call('cp', '-R', '--no-dereference',
                                os.path.join(srcDir, src), current)

            outputFileList = self.buildIsos(topDir)

            if self.buildOVF10:
                self.workingDir = os.path.join(self.workDir, self.basefilename)
                util.mkdirChain(self.workingDir)

                diskFileSize = imagegen.getFileSize(outputFileList[0][0])
                self.ovfImage = ovf_image.ISOOvfImage(self.basefilename,
                    self.jobData['description'], None, outputFileList[0][0],
                    diskFileSize, self.maxIsoSize, False,
                    self.getBuildData('vmMemory'), self.workingDir, 
                    self.outputDir)

                self.ovfObj = self.ovfImage.createOvf()
                self.ovfXml = self.ovfImage.writeOvf()
                self.ovfImage.createManifest()
                self.ovaPath = self.ovfImage.createOva()

                outputFileList.append((self.ovaPath, 'Appliance ISO OVF 1.0'))

            # notify client that images are ready
            self.postOutput(outputFileList)
        finally:
            util.rmtree(os.path.normpath(os.path.join(topDir, "..")),
                        ignore_errors = True)
            util.rmtree(constants.cachePath, ignore_errors = True)