Beispiel #1
0
    def testGetTrovesToBuildWithRecipeAndRPM(self):
        recipePath = self.workDir + '/local.recipe'
        self.writeFile(recipePath, localSourceRecipe)
        self.writeFile(self.workDir + '/foo', 'Contents\n')
        shutil.copyfile(resources.get_archive('/tmpwatch-2.9.0-2.src.rpm'),
                        self.workDir + '/tmpwatch-2.9.0-2.src.rpm')

        self.openRepository()
        self.openRmakeRepository()
        helper = self.getRmakeHelper()

        self.logFilter.add()
        v = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                      [recipePath])[0][1]
        assert (v.trailingLabel().getHost() == self.rmakeCfg.reposName)

        self.writeFile(recipePath, localSourceRecipe + '\n')

        v2 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                       [recipePath])[0][1]
        assert (v2.trailingLabel().getHost() == self.rmakeCfg.reposName)
        assert (v2 != v)

        self.writeFile(recipePath, localSourceRecipe + '\n')
        v3 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                       [recipePath])[0][1]
        assert (v3.trailingLabel().getHost() == self.rmakeCfg.reposName)
        assert (v3 == v2)
Beispiel #2
0
    def testGetTrovesToBuildWithRecipeAndRPM(self):
        recipePath = self.workDir + '/local.recipe'
        self.writeFile(recipePath, localSourceRecipe)
        self.writeFile(self.workDir + '/foo', 'Contents\n')
        shutil.copyfile(resources.get_archive('/tmpwatch-2.9.0-2.src.rpm'),
                        self.workDir + '/tmpwatch-2.9.0-2.src.rpm')

        self.openRepository()
        self.openRmakeRepository()
        helper = self.getRmakeHelper()

        self.logFilter.add()
        v = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(), 
                                      [recipePath])[0][1]
        assert(v.trailingLabel().getHost() == self.rmakeCfg.reposName)

        self.writeFile(recipePath, localSourceRecipe + '\n')

        v2 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                       [recipePath])[0][1]
        assert(v2.trailingLabel().getHost() == self.rmakeCfg.reposName)
        assert(v2 != v)

        self.writeFile(recipePath, localSourceRecipe + '\n')
        v3 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                       [recipePath])[0][1]
        assert(v3.trailingLabel().getHost() == self.rmakeCfg.reposName)
        assert(v3 == v2)
Beispiel #3
0
    def testGetTrovesToBuild(self):
        repos = self.openRmakeRepository()
        helper = self.getRmakeHelper()

        self.addComponent('simple:source', '1', '',
                          [('simple.recipe', recipes.simpleRecipe),
                           ('foo', 'content\n')])

        os.chdir(self.workDir)
        self.checkout('simple')
        os.chdir('simple')
        self.writeFile('simple.recipe',
                       recipes.simpleRecipe + '\tr.AddSource("bar")\n')
        self.remove('foo')
        self.writeFile('bar', 'content\n')
        self.addfile('bar', text=True)
        os.mkdir('baz')  # just make a random dir - rmake should
        # ignore this.
        (n, v, f) = buildcmd.getTrovesToBuild(self.buildCfg,
                                              helper.getConaryClient(),
                                              ['simple.recipe[bam]'],
                                              message='foo')[0]
        assert (f == deps.parseFlavor('bam'))
        f = deps.parseFlavor('')
        assert (v.trailingLabel().getHost() == self.rmakeCfg.reposName)
        # make sure we can commit this uphill
        assert (len(list(v.iterLabels())) == 2)
        trove = repos.getTrove(n, v, f, withFiles=True)
        assert (set(x[1] for x in list(trove.iterFileList())) == set(
            ['simple.recipe', 'bar']))
        # okay now let's do it again, no change this time
        v2 = buildcmd.getTrovesToBuild(self.buildCfg,
                                       helper.getConaryClient(),
                                       ['simple.recipe'],
                                       message='foo')[0][1]
        assert (v == v2)
        # this time, change the config setting for foo
        self.setSourceFlag('bar', binary=True)
        v3 = buildcmd.getTrovesToBuild(self.buildCfg,
                                       helper.getConaryClient(),
                                       ['simple.recipe'],
                                       message='foo')[0][1]
        assert (v3 != v2)

        # one more time, revert back to original.
        self.writeFile('simple.recipe', recipes.simpleRecipe)
        v4 = buildcmd.getTrovesToBuild(self.buildCfg,
                                       helper.getConaryClient(),
                                       ['simple.recipe'],
                                       message='foo')[0][1]
        assert (v4.trailingLabel().getHost() == self.rmakeCfg.reposName)
        assert (v4 != v3)
        assert (helper.buildConfig.buildTroveSpecs == [
            (self.workDir + '/simple/simple.recipe', None,
             deps.parseFlavor(''))
        ])
Beispiel #4
0
    def testGetTrovesWithOtherDirectory(self):
        simpleRecipe = recipes.simpleRecipe
        self.addComponent('simple:source', '1-1', 
                            [('simple.recipe', simpleRecipe)])
        os.chdir(self.workDir)
        self.checkout('simple')
        self.addComponent('simple:source', '1-2',
                            [('simple.recipe', simpleRecipe)])
        # file with the name of the package we're trying to build.
        # If this working correctly, "rmake build simple" should build the 
        # file in the repository (1-2), not the local .recipe (which is 1-1)
        self.writeFile('simple/simple', 'foo\n')
        self.writeFile('simple/simple.recipe', simpleRecipe + '#change\n')

        self.openRepository()
        self.openRmakeRepository()
        helper = self.getRmakeHelper()
        _gifp = cook.getRecipeInfoFromPath
        try:
            def checkCWD(*args, **kwargs):
                self.failUnlessEqual(os.getcwd(),
                    os.path.join(self.workDir, 'simple'))
                return _gifp(*args, **kwargs)
            cook.getRecipeInfoFromPath = checkCWD

            v = buildcmd.getTrovesToBuild(self.buildCfg,
                helper.getConaryClient(), ['simple/simple.recipe'])[0][1]
        finally:
            cook.getRecipeInfoFromPath = _gifp
        self.assertEquals(v.getHost(), 'rmakehost')
Beispiel #5
0
 def testGetTrovesToBuildNoPackageWithTemplate(self):
     repos = self.openRepository()
     self.openRmakeRepository()
     helper = self.getRmakeHelper()
     templateDir = resources.get_archive('recipeTemplates')
     oldRTD = self.cfg.recipeTemplateDirs
     oldTemplate = self.cfg.recipeTemplate
     self.buildCfg.recipeTemplateDirs = [templateDir]
     self.buildCfg.recipeTemplate = 'test'
     os.chdir(self.workDir)
     self.writeFile('simple.recipe',
                    recipes.simpleRecipe + '\tr.Create("/bar")\n')
     v = buildcmd.getTrovesToBuild(self.buildCfg,
                                   helper.getConaryClient(),
                                   ['simple.recipe'],
                                   message='foo')[0][1]
     assert (v.trailingLabel().getHost() == self.rmakeCfg.reposName)
     assert (len(list(v.iterLabels())) == 2)
     assert (str(v.branch().parentBranch()) == '/localhost@rpl:linux')
     fileList = repos.iterFilesInTrove('simple:source',
                                       v,
                                       deps.parseFlavor(''),
                                       withFiles=True)
     for item in fileList:
         assert (item[4].flags.isConfig())
Beispiel #6
0
    def testGetTrovesWithOtherDirectory(self):
        simpleRecipe = recipes.simpleRecipe
        self.addComponent('simple:source', '1-1',
                          [('simple.recipe', simpleRecipe)])
        os.chdir(self.workDir)
        self.checkout('simple')
        self.addComponent('simple:source', '1-2',
                          [('simple.recipe', simpleRecipe)])
        # file with the name of the package we're trying to build.
        # If this working correctly, "rmake build simple" should build the
        # file in the repository (1-2), not the local .recipe (which is 1-1)
        self.writeFile('simple/simple', 'foo\n')
        self.writeFile('simple/simple.recipe', simpleRecipe + '#change\n')

        self.openRepository()
        self.openRmakeRepository()
        helper = self.getRmakeHelper()
        _gifp = cook.getRecipeInfoFromPath
        try:

            def checkCWD(*args, **kwargs):
                self.failUnlessEqual(os.getcwd(),
                                     os.path.join(self.workDir, 'simple'))
                return _gifp(*args, **kwargs)

            cook.getRecipeInfoFromPath = checkCWD

            v = buildcmd.getTrovesToBuild(self.buildCfg,
                                          helper.getConaryClient(),
                                          ['simple/simple.recipe'])[0][1]
        finally:
            cook.getRecipeInfoFromPath = _gifp
        self.assertEquals(v.getHost(), 'rmakehost')
Beispiel #7
0
    def testGetTrovesToBuild(self):
        repos = self.openRmakeRepository()
        helper = self.getRmakeHelper()

        self.addComponent('simple:source', '1', '',
                            [ ('simple.recipe', recipes.simpleRecipe),
                              ('foo',           'content\n')])

        os.chdir(self.workDir)
        self.checkout('simple')
        os.chdir('simple')
        self.writeFile('simple.recipe', 
                        recipes.simpleRecipe + '\tr.AddSource("bar")\n')
        self.remove('foo')
        self.writeFile('bar', 'content\n')
        self.addfile('bar', text=True)
        os.mkdir('baz') # just make a random dir - rmake should
                        # ignore this.
        (n,v,f) = buildcmd.getTrovesToBuild(self.buildCfg,
                                    helper.getConaryClient(),
                                   ['simple.recipe[bam]'], message='foo')[0]
        assert(f == deps.parseFlavor('bam'))
        f = deps.parseFlavor('')
        assert(v.trailingLabel().getHost() == self.rmakeCfg.reposName)
        # make sure we can commit this uphill
        assert(len(list(v.iterLabels())) == 2)
        trove = repos.getTrove(n,v,f, withFiles=True)
        assert(set(x[1] for x in list(trove.iterFileList())) == set(['simple.recipe', 'bar']))
        # okay now let's do it again, no change this time
        v2 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                    ['simple.recipe'], message='foo')[0][1]
        assert(v == v2)
        # this time, change the config setting for foo
        self.setSourceFlag('bar', binary=True)
        v3 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                    ['simple.recipe'], message='foo')[0][1]
        assert(v3 != v2)


        # one more time, revert back to original.
        self.writeFile('simple.recipe', recipes.simpleRecipe)
        v4 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                    ['simple.recipe'], message='foo')[0][1]
        assert(v4.trailingLabel().getHost() == self.rmakeCfg.reposName)
        assert(v4 != v3)
        assert(helper.buildConfig.buildTroveSpecs == 
                                        [(self.workDir + '/simple/simple.recipe', None, deps.parseFlavor(''))])
Beispiel #8
0
    def testGetInfoRecipe(self):
        recipePath = self.workDir + '/info-foo.recipe'
        self.writeFile(recipePath, infoRecipe)
        self.openRepository()
        self.openRmakeRepository()
        helper = self.getRmakeHelper()

        self.logFilter.add()
        v = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                      [recipePath])[0][1]
        assert (v.trailingLabel().getHost() == self.rmakeCfg.reposName)
Beispiel #9
0
    def testGetInfoRecipe(self):
        recipePath = self.workDir + '/info-foo.recipe'
        self.writeFile(recipePath, infoRecipe)
        self.openRepository()
        self.openRmakeRepository()
        helper = self.getRmakeHelper()

        self.logFilter.add()
        v = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(), 
                                      [recipePath])[0][1]
        assert(v.trailingLabel().getHost() == self.rmakeCfg.reposName)
Beispiel #10
0
    def testChangeFactory(self):
        repos = self.openRmakeRepository()
        helper = self.getRmakeHelper()

        # Commit factory to use
        # Warning: can't use this factory unless set it's factory to "factory"
        self.addComponent('factory-test:source',
                          '0',
                          '', [('factory-test.recipe', localFactory)],
                          factory='factory')

        # Commit recipe which won't cook successfully
        self.addComponent('simple:source', '1', '',
                          [('simple.recipe', recipes.simpleRecipe)])

        os.chdir(self.workDir)
        self.checkout('simple')
        os.chdir('simple')

        # Hack around conary's bug not notice only factory change during checkin
        self.writeFile('simple.recipe',
                       recipes.simpleRecipe + '\tr.Create("bar")\n')

        # Load CONARY state file
        stateFile = "CONARY"
        conaryState = ConaryStateFromFile(stateFile)
        sourceState = conaryState.getSourceState()

        # Verify no factory
        assert (sourceState.getFactory() == '')

        # Set factory
        sourceState.setFactory('test')
        conaryState.write(stateFile)

        # Verify build is successful
        (name, version,
         flavor) = buildcmd.getTrovesToBuild(self.buildCfg,
                                             helper.getConaryClient(),
                                             ['simple.recipe'],
                                             message='foo')[0]

        # checkout newly shadowed package
        self.checkout(name, versionStr=version.asString())

        # get state file object of newly shadowed package
        os.chdir('simple')
        conaryState = ConaryStateFromFile(stateFile)
        sourceState = conaryState.getSourceState()

        # check factory matches
        assert (sourceState.getFactory() == 'test')
Beispiel #11
0
    def testChangeFactory(self):
        repos = self.openRmakeRepository()
        helper = self.getRmakeHelper()

        # Commit factory to use
        # Warning: can't use this factory unless set it's factory to "factory"
        self.addComponent('factory-test:source', '0', '',
                          [('factory-test.recipe', localFactory)],
                          factory='factory')

        # Commit recipe which won't cook successfully
        self.addComponent('simple:source', '1', '',
                          [ ('simple.recipe', recipes.simpleRecipe)])

        os.chdir(self.workDir)
        self.checkout('simple')
        os.chdir('simple')

        # Hack around conary's bug not notice only factory change during checkin
        self.writeFile('simple.recipe',
                        recipes.simpleRecipe + '\tr.Create("bar")\n')

        # Load CONARY state file
        stateFile = "CONARY"
        conaryState = ConaryStateFromFile(stateFile)
        sourceState = conaryState.getSourceState()

        # Verify no factory
        assert(sourceState.getFactory() == '')

        # Set factory
        sourceState.setFactory('test')
        conaryState.write(stateFile)

        # Verify build is successful
        (name,version,flavor) = buildcmd.getTrovesToBuild(self.buildCfg,
                                    helper.getConaryClient(),
                                   ['simple.recipe'], message='foo')[0]

        # checkout newly shadowed package
        self.checkout(name,versionStr=version.asString())

        # get state file object of newly shadowed package
        os.chdir('simple')
        conaryState = ConaryStateFromFile(stateFile)
        sourceState = conaryState.getSourceState()

        # check factory matches
        assert(sourceState.getFactory() == 'test')
Beispiel #12
0
    def testGetTrovesToBuildFailedPackage(self):
        self.openRmakeRepository()
        helper = self.getRmakeHelper()

        os.chdir(self.workDir)
        self.newpkg('simple')
        os.chdir('simple')
        self.writeFile('simple.recipe', 
                        recipes.simpleRecipe + '\ta = b # NameError\n')
        try:
            v = buildcmd.getTrovesToBuild(self.buildCfg, 
                                       helper.getConaryClient(),
                                       ['simple.recipe'], message='foo')[0][1]
        except errors.RmakeError, msg:
            assert(str(msg) == "could not initialize recipe: %s/simple/simple.recipe:8:\n NameError: global name 'b' is not defined" % self.workDir)
Beispiel #13
0
    def testCookBinaryGroup(self):
        repos = self.openRmakeRepository()
        self.startRmakeServer()
        helper = self.getRmakeHelper()
        bamTrv = self.addComponent('group-bam:source', '1')
        self.addComponent('group-bam:source', '2')
        binTrv = self.addCollection('simple',
                                    '1', [':runtime'],
                                    createComps=True,
                                    defaultFlavor='readline')
        self.addCollection('group-foo',
                           '1', ['simple'],
                           defaultFlavor='readline',
                           sourceName='group-bam:source')
        sourceTrv = self.addComponent(
            'simple:source', '2', [('simple.recipe', recipes.simpleRecipe)])

        trvs = buildcmd.getTrovesToBuild(self.buildCfg,
                                         helper.getConaryClient(),
                                         ['group-foo[ssl]'],
                                         matchSpecs=['-group-foo'],
                                         recurseGroups=True)
        assert (len(trvs) == 2)
        assert (set(trvs) == set([
            ('simple:source', sourceTrv.getVersion(), binTrv.getFlavor()),
            ('group-bam:source', bamTrv.getVersion(), deps.parseFlavor('ssl'))
        ]))
        jobId, txt = self.captureOutput(helper.buildTroves, ['group-foo'],
                                        matchSpecs=['-group-bam'],
                                        recurseGroups=True)
        helper.waitForJob(jobId)
        assert (helper.client.getJob(jobId).isBuilt())
        self.addComponent('foo:source=2')
        binTrv = self.addCollection('foo',
                                    '2', [':runtime'],
                                    createComps=True,
                                    defaultFlavor='~readline,~ssl')
        self.addCollection('group-foo',
                           '2', ['foo=2'],
                           defaultFlavor='~readline,~ssl',
                           sourceName='group-bam:source')
        job = helper.createRestartJob(jobId, updateSpecs=['-group-*'])
        assert (sorted(x.getName()
                       for x in job.iterTroves()) == ['simple:source'])
        job = helper.createRestartJob(jobId)
        assert (sorted(x.getName()
                       for x in job.iterTroves()) == ['foo:source'])
Beispiel #14
0
    def testGetTrovesToBuildNewPackage(self):
        self.openRmakeRepository()
        # create another version in that repository on another label.
        # this triggers RMK-685
        self.addComponent( 
            'simple:source=/localhost@foo:branch//rmakehost@local:branch/1:1-1')
        helper = self.getRmakeHelper()

        os.chdir(self.workDir)
        self.newpkg('simple=localhost@rpl:branch')
        os.chdir('simple')
        self.writeFile('simple.recipe', 
                        recipes.simpleRecipe + '\tr.Create("/bar")\n\tr.addAction("echo 1")\n')
        v = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                   ['simple.recipe'], message='foo')[0][1]
        assert(v.trailingLabel().getHost() == self.rmakeCfg.reposName)
        assert(str(v.branch().parentBranch()) == '/localhost@rpl:branch')
Beispiel #15
0
 def testGetTrovesToBuildNoPackage(self):
     repos = self.openRepository()
     self.openRmakeRepository()
     helper = self.getRmakeHelper()
     templateDir = resources.get_archive('recipeTemplates')
     os.chdir(self.workDir)
     self.writeFile('simple.recipe', 
                     recipes.simpleRecipe + '\tr.Create("/bar")\n')
     v = buildcmd.getTrovesToBuild(self.buildCfg,
                                 helper.getConaryClient(),
                                ['simple.recipe'], message='foo')[0][1]
     assert(v.trailingLabel().getHost() == self.rmakeCfg.reposName)
     assert(len(list(v.iterLabels())) == 2)
     assert(str(v.branch().parentBranch()) == '/localhost@rpl:linux')
     fileList = repos.iterFilesInTrove('simple:source', v, 
                          deps.parseFlavor(''), withFiles=True)
     for item  in fileList:
         assert(item[4].flags.isConfig())
Beispiel #16
0
    def testGetTrovesToBuildFailedPackage(self):
        self.openRmakeRepository()
        helper = self.getRmakeHelper()

        os.chdir(self.workDir)
        self.newpkg('simple')
        os.chdir('simple')
        self.writeFile('simple.recipe',
                       recipes.simpleRecipe + '\ta = b # NameError\n')
        try:
            v = buildcmd.getTrovesToBuild(self.buildCfg,
                                          helper.getConaryClient(),
                                          ['simple.recipe'],
                                          message='foo')[0][1]
        except errors.RmakeError, msg:
            assert (
                str(msg) ==
                "could not initialize recipe: %s/simple/simple.recipe:8:\n NameError: global name 'b' is not defined"
                % self.workDir)
Beispiel #17
0
    def testCookBinaryGroup(self):
        repos = self.openRmakeRepository()
        self.startRmakeServer()
        helper = self.getRmakeHelper()
        bamTrv = self.addComponent('group-bam:source', '1')
        self.addComponent('group-bam:source', '2')
        binTrv = self.addCollection('simple', '1', [':runtime'], 
                                    createComps=True,
                                    defaultFlavor='readline')
        self.addCollection('group-foo', '1', ['simple'], 
                           defaultFlavor='readline', 
                           sourceName='group-bam:source')
        sourceTrv = self.addComponent('simple:source', '2', 
                                      [('simple.recipe', recipes.simpleRecipe)])

        trvs = buildcmd.getTrovesToBuild(self.buildCfg, 
                                         helper.getConaryClient(),
                                         ['group-foo[ssl]'],
                                         matchSpecs=['-group-foo'],
                                         recurseGroups=True)
        assert(len(trvs) == 2)
        assert(set(trvs) == set([('simple:source', sourceTrv.getVersion(),
                                 binTrv.getFlavor()),
                                 ('group-bam:source', bamTrv.getVersion(), 
                                  deps.parseFlavor('ssl'))]))
        jobId, txt = self.captureOutput(helper.buildTroves,
                                       ['group-foo'], 
                                       matchSpecs=['-group-bam'],
                                       recurseGroups=True)
        helper.waitForJob(jobId)
        assert(helper.client.getJob(jobId).isBuilt())
        self.addComponent('foo:source=2')
        binTrv = self.addCollection('foo', '2', [':runtime'], 
                                    createComps=True,
                                    defaultFlavor='~readline,~ssl')
        self.addCollection('group-foo', '2', ['foo=2'],
                           defaultFlavor='~readline,~ssl',
                           sourceName='group-bam:source')
        job = helper.createRestartJob(jobId, updateSpecs=['-group-*'])
        assert(sorted(x.getName() for x in job.iterTroves()) == ['simple:source'])
        job = helper.createRestartJob(jobId)
        assert(sorted(x.getName() for x in job.iterTroves()) == ['foo:source'])
Beispiel #18
0
    def testGetTrovesToBuildNewPackage(self):
        self.openRmakeRepository()
        # create another version in that repository on another label.
        # this triggers RMK-685
        self.addComponent(
            'simple:source=/localhost@foo:branch//rmakehost@local:branch/1:1-1'
        )
        helper = self.getRmakeHelper()

        os.chdir(self.workDir)
        self.newpkg('simple=localhost@rpl:branch')
        os.chdir('simple')
        self.writeFile(
            'simple.recipe', recipes.simpleRecipe +
            '\tr.Create("/bar")\n\tr.addAction("echo 1")\n')
        v = buildcmd.getTrovesToBuild(self.buildCfg,
                                      helper.getConaryClient(),
                                      ['simple.recipe'],
                                      message='foo')[0][1]
        assert (v.trailingLabel().getHost() == self.rmakeCfg.reposName)
        assert (str(v.branch().parentBranch()) == '/localhost@rpl:branch')
Beispiel #19
0
    def testGetTrovesWithFileWithPackageNameInSameDirectory(self):
        simpleRecipe = recipes.simpleRecipe
        self.addComponent('simple:source', '1-1', 
                            [('simple.recipe', simpleRecipe)])
        os.chdir(self.workDir)
        self.checkout('simple')
        os.chdir('simple')
        self.addComponent('simple:source', '1-2',
                            [('simple.recipe', simpleRecipe)])
        # file with the name of the package we're trying to build.
        # If this working correctly, "rmake build simple" should build the 
        # file in the repository (1-2), not the local .recipe (which is 1-1)
        self.writeFile('simple', 'foo\n')
        self.writeFile('simple.recipe', simpleRecipe + '#change\n')

        self.openRepository()
        self.openRmakeRepository()
        helper = self.getRmakeHelper()
        v = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(), 
                                      ['simple'])[0][1]
        self.assertEquals(v.getHost(), 'localhost')
Beispiel #20
0
    def testGetTrovesWithFileWithPackageNameInSameDirectory(self):
        simpleRecipe = recipes.simpleRecipe
        self.addComponent('simple:source', '1-1',
                          [('simple.recipe', simpleRecipe)])
        os.chdir(self.workDir)
        self.checkout('simple')
        os.chdir('simple')
        self.addComponent('simple:source', '1-2',
                          [('simple.recipe', simpleRecipe)])
        # file with the name of the package we're trying to build.
        # If this working correctly, "rmake build simple" should build the
        # file in the repository (1-2), not the local .recipe (which is 1-1)
        self.writeFile('simple', 'foo\n')
        self.writeFile('simple.recipe', simpleRecipe + '#change\n')

        self.openRepository()
        self.openRmakeRepository()
        helper = self.getRmakeHelper()
        v = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                      ['simple'])[0][1]
        self.assertEquals(v.getHost(), 'localhost')
Beispiel #21
0
 def _getTroves(*matchSpecs):
     return buildcmd.getTrovesToBuild(self.buildCfg, 
                                      helper.getConaryClient(),
                                      ['group-foo'], recurseGroups=True,
                                      matchSpecs=matchSpecs)
Beispiel #22
0
 def testCookSourceGroup(self):
     self.openRepository()
     repos = self.openRepository(1)
     trv0 = self.addComponent('test0:source', '1').getNameVersionFlavor()
     trv1 = self.addComponent('test:source', '1').getNameVersionFlavor()
     trv2 = self.addComponent('test2:source', '1').getNameVersionFlavor()
     trv5 = self.addComponent('test5:source', '1').getNameVersionFlavor()
     self.addComponent('test4:source',
                       '/localhost1@rpl:linux/1-1').getNameVersionFlavor()
     self.addComponent('group-foo:source', '1',
                       [('group-foo.recipe', groupRecipe),
                        ('preupdate.sh', '#!/bin/sh\necho "hello"\n')])
     self.openRmakeRepository()
     helper = self.getRmakeHelper()
     self.buildCfg.limitToHosts('localhost')
     self.buildCfg.addMatchRule('-group-foo')
     job = buildcmd.getBuildJob(
         self.buildCfg,
         helper.getConaryClient(), ['group-foo[ssl]', 'group-foo[!ssl]'],
         recurseGroups=buildcmd.BUILD_RECURSE_GROUPS_SOURCE)
     trvs = set(job.iterTroveList())
     assert (trvs == set([(trv0[0], trv0[1], deps.parseFlavor('')),
                          (trv1[0], trv1[1], deps.parseFlavor('ssl')),
                          (trv2[0], trv2[1], deps.parseFlavor('readline')),
                          (trv5[0], trv5[1], deps.parseFlavor(''))]))
     helper = self.getRmakeHelper()
     db = self.openRmakeDatabase()
     db.addJob(job)
     jobId = job.jobId
     job = helper.createRestartJob(jobId)
     os.chdir(self.workDir)
     self.checkout('group-foo')
     os.chdir('group-foo')
     self.writeFile('group-foo.recipe', groupRecipe + '#\n')  # change
     self.buildCfg.matchTroveRule = []
     self.buildCfg.limitToLabels('localhost@rpl:linux')
     self.buildCfg.addMatchRule('-group-foo')
     self.buildCfg.addMatchRule('-[readline]')
     trvs = buildcmd.getTrovesToBuild(
         self.buildCfg,
         helper.getConaryClient(),
         ['group-foo.recipe[ssl]', 'group-foo.recipe[!ssl]'],
         recurseGroups=buildcmd.BUILD_RECURSE_GROUPS_SOURCE,
         matchSpecs=self.buildCfg.matchTroveRule)
     trvs = set(trvs)
     assert (trvs == set([(trv0[0], trv0[1], deps.parseFlavor('')),
                          (trv1[0], trv1[1], deps.parseFlavor('ssl')),
                          (trv5[0], trv5[1], deps.parseFlavor(''))]))
     # Build the actual group, and this time let's do a fresh commit
     # instead of a shadow + commit.
     os.remove('CONARY')
     self.buildCfg.matchTroveRule = []
     trvs = buildcmd.getTrovesToBuild(
         self.buildCfg,
         helper.getConaryClient(),
         ['group-foo.recipe[ssl]', 'group-foo.recipe[!ssl]'],
         recurseGroups=buildcmd.BUILD_RECURSE_GROUPS_NONE,
         matchSpecs=self.buildCfg.matchTroveRule)
     trvs = set(trvs)
     assert (len(trvs) == 2)
     assert ([x[0]
              for x in trvs] == ['group-foo:source', 'group-foo:source'])
Beispiel #23
0
 def testCookSourceGroup(self):
     self.openRepository()
     repos = self.openRepository(1)
     trv0 = self.addComponent('test0:source', '1').getNameVersionFlavor()
     trv1 = self.addComponent('test:source', '1').getNameVersionFlavor()
     trv2 = self.addComponent('test2:source', '1').getNameVersionFlavor()
     trv5 = self.addComponent('test5:source', '1').getNameVersionFlavor()
     self.addComponent('test4:source', 
                        '/localhost1@rpl:linux/1-1').getNameVersionFlavor()
     self.addComponent('group-foo:source', '1',
                       [('group-foo.recipe', groupRecipe),
                         ('preupdate.sh', '#!/bin/sh\necho "hello"\n')])
     self.openRmakeRepository()
     helper = self.getRmakeHelper()
     self.buildCfg.limitToHosts('localhost')
     self.buildCfg.addMatchRule('-group-foo')
     job = buildcmd.getBuildJob(self.buildCfg,
                       helper.getConaryClient(),
                       ['group-foo[ssl]',
                        'group-foo[!ssl]'],
                       recurseGroups=buildcmd.BUILD_RECURSE_GROUPS_SOURCE)
     trvs = set(job.iterTroveList())
     assert(trvs == set([(trv0[0], trv0[1], deps.parseFlavor('')),
                         (trv1[0], trv1[1], deps.parseFlavor('ssl')),
                         (trv2[0], trv2[1], deps.parseFlavor('readline')),
                         (trv5[0], trv5[1], deps.parseFlavor(''))]))
     helper = self.getRmakeHelper()
     db = self.openRmakeDatabase()
     db.addJob(job)
     jobId = job.jobId
     job = helper.createRestartJob(jobId)
     os.chdir(self.workDir)
     self.checkout('group-foo')
     os.chdir('group-foo')
     self.writeFile('group-foo.recipe', groupRecipe + '#\n') # change
     self.buildCfg.matchTroveRule = []
     self.buildCfg.limitToLabels('localhost@rpl:linux')
     self.buildCfg.addMatchRule('-group-foo')
     self.buildCfg.addMatchRule('-[readline]')
     trvs = buildcmd.getTrovesToBuild(
                       self.buildCfg, helper.getConaryClient(),
                       ['group-foo.recipe[ssl]',
                        'group-foo.recipe[!ssl]'],
                       recurseGroups=buildcmd.BUILD_RECURSE_GROUPS_SOURCE,
                       matchSpecs=self.buildCfg.matchTroveRule)
     trvs = set(trvs)
     assert(trvs == set([(trv0[0], trv0[1], deps.parseFlavor('')),
                         (trv1[0], trv1[1], deps.parseFlavor('ssl')),
                         (trv5[0], trv5[1], deps.parseFlavor(''))]))
     # Build the actual group, and this time let's do a fresh commit
     # instead of a shadow + commit.
     os.remove('CONARY')
     self.buildCfg.matchTroveRule = []
     trvs = buildcmd.getTrovesToBuild(
                       self.buildCfg, helper.getConaryClient(),
                       ['group-foo.recipe[ssl]',
                        'group-foo.recipe[!ssl]'],
                       recurseGroups=buildcmd.BUILD_RECURSE_GROUPS_NONE,
                       matchSpecs=self.buildCfg.matchTroveRule)
     trvs = set(trvs)
     assert(len(trvs) == 2)
     assert([x[0] for x in trvs] == ['group-foo:source', 'group-foo:source'])
Beispiel #24
0
 def _getTroves(*matchSpecs):
     return buildcmd.getTrovesToBuild(self.buildCfg,
                                      helper.getConaryClient(),
                                      ['group-foo'],
                                      recurseGroups=True,
                                      matchSpecs=matchSpecs)
Beispiel #25
0
                                          helper.getConaryClient(),
                                          ['simple.recipe'],
                                          message='foo')[0][1]
        except errors.RmakeError, msg:
            assert (
                str(msg) ==
                "could not initialize recipe: %s/simple/simple.recipe:8:\n NameError: global name 'b' is not defined"
                % self.workDir)
        else:
            assert 0, "expected RmakeError"

        self.writeFile('simple.recipe',
                       recipes.simpleRecipe + '\tr.addArchive("blammo")\n')
        try:
            v = buildcmd.getTrovesToBuild(self.buildCfg,
                                          helper.getConaryClient(),
                                          ['simple.recipe'],
                                          message='foo')[0][1]
        except errors.RmakeError, msg:
            assert (
                str(msg) ==
                'Could not commit changes to build recipe %s/simple/simple.recipe: Source file blammo does not exist'
                % self.workDir)
        else:
            assert 0, "expected RmakeError"

    def testCookBinaryGroup(self):
        repos = self.openRmakeRepository()
        self.startRmakeServer()
        helper = self.getRmakeHelper()
        bamTrv = self.addComponent('group-bam:source', '1')
        self.addComponent('group-bam:source', '2')
Beispiel #26
0
        self.writeFile('simple.recipe', 
                        recipes.simpleRecipe + '\ta = b # NameError\n')
        try:
            v = buildcmd.getTrovesToBuild(self.buildCfg, 
                                       helper.getConaryClient(),
                                       ['simple.recipe'], message='foo')[0][1]
        except errors.RmakeError, msg:
            assert(str(msg) == "could not initialize recipe: %s/simple/simple.recipe:8:\n NameError: global name 'b' is not defined" % self.workDir)
        else:
            assert 0, "expected RmakeError"

        self.writeFile('simple.recipe', 
                        recipes.simpleRecipe + '\tr.addArchive("blammo")\n')
        try:
            v = buildcmd.getTrovesToBuild(self.buildCfg, 
                                          helper.getConaryClient(),
                                       ['simple.recipe'], message='foo')[0][1]
        except errors.RmakeError, msg:
            assert(str(msg) == 'Could not commit changes to build recipe %s/simple/simple.recipe: Source file blammo does not exist' % self.workDir)
        else:
            assert 0, "expected RmakeError"


    def testCookBinaryGroup(self):
        repos = self.openRmakeRepository()
        self.startRmakeServer()
        helper = self.getRmakeHelper()
        bamTrv = self.addComponent('group-bam:source', '1')
        self.addComponent('group-bam:source', '2')
        binTrv = self.addCollection('simple', '1', [':runtime'], 
                                    createComps=True,