Esempio n. 1
0
    def testUnknownSig(self):
        # the repository shouldn't blow up on this commit unless it's bene
        # run w/ requireSigs = True
        self.stopRepository(0)
        sigRepos = self.openRepository(0, requireSigs=True)

        fingerprint = 'F7440D78FE813C882212C2BF8AC2828190B1E477'
        keyCache = openpgpkey.getKeyCache()
        keyCache.getPrivateKey(fingerprint, '111111')
        os.chdir(self.workDir)
        self.newpkg('testcase')
        os.chdir('testcase')
        self.writeFile('testcase.recipe', testRecipe)
        self.addfile('testcase.recipe')

        repos = self.openRepository()

        self.cfg.signatureKey = fingerprint

        try:
            checkin.commit(repos, self.cfg, 'testcase', None)
            self.fail("Repository should have required a signature")
        except DigitalSignatureVerificationError:
            pass

        self.stopRepository(0)
        repos = self.openRepository(0)
        checkin.commit(repos, self.cfg, 'testcase', None)

        self.cfg.signatureKey = None
Esempio n. 2
0
 def commit(self, targetDir, message):
     cfg = self.getConaryConfig()
     self._initializeFlavors()
     use.setBuildFlagsFromFlavor(None, cfg.buildFlavor, False)
     cwd = os.getcwd()
     try:
         os.chdir(targetDir)
         checkin.commit(self._getRepositoryClient(), cfg, message=message)
     except conaryerrors.CvcError, e:
         tb = sys.exc_info()[2]
         raise errors.RbuildError, str(e), tb
Esempio n. 3
0
 def commit(self, targetDir, message):
     cfg = self.getConaryConfig()
     self._initializeFlavors()
     use.setBuildFlagsFromFlavor(None, cfg.buildFlavor, False)
     cwd = os.getcwd()
     try:
         os.chdir(targetDir)
         checkin.commit(self._getRepositoryClient(), cfg, message=message)
     except conaryerrors.CvcError, e:
         tb = sys.exc_info()[2]
         raise errors.RbuildError, str(e), tb
Esempio n. 4
0
def _doCommit(recipePath, repos, cfg, message):
    try:
        kw = {}
        if compat.ConaryVersion().supportsForceCommit():
            kw.update(force=True)
        rv = checkin.commit(repos, cfg, message, **kw)
    except (conaryerrors.CvcError, conaryerrors.ConaryError), msg:
        raise errors.RmakeError("Could not commit changes to build"
                                " recipe %s: %s" % (recipePath, msg))
Esempio n. 5
0
class CommitCommand(CvcCommand):

    commands = ['commit', 'ci']
    help = 'Commit changes to a source component'
    commandGroup = 'Repository Access'
    docs = {
        'message':
        'Use MESSAGE to describe why the commit was performed',
        'test': ('Runs through all the steps of committing but does not '
                 'modify the repository'),
        'log-file':
        'Read the commit message from file LOGFILE (use - for '
        'standard input)',
    }
    # allow "cvc commit -m'foo bar'" to work
    hobbleShortOpts = False

    def addParameters(self, argDef):
        CvcCommand.addParameters(self, argDef)
        argDef["message"] = '-m', ONE_PARAM
        argDef["test"] = NO_PARAM
        argDef["log-file"] = '-l', ONE_PARAM

    def runCommand(self,
                   cfg,
                   argSet,
                   args,
                   profile=False,
                   callback=None,
                   repos=None):
        args = args[1:]
        level = log.getVerbosity()
        message = argSet.pop("message", None)
        test = argSet.pop("test", False)
        logfile = argSet.pop("log-file", None)

        if argSet or len(args) != 1: return self.usage()

        if message and logfile:
            raise errors.ConaryError("options --message and --log-file are "
                                     "mutually exclusive")
        if logfile:
            # Read the checkin message from the file
            if logfile == '-':
                message = sys.stdin.read()
            else:
                try:
                    message = open(logfile).read()
                except IOError, e:
                    raise errors.ConaryError("While opening %s: %s" %
                                             (e.filename, e.strerror))
            # Get rid of trailing white spaces, they're probably not
            # intended to be there anyway
            message = message.rstrip()

        checkin.commit(repos, cfg, message, callback=callback, test=test)
        log.setVerbosity(level)
Esempio n. 6
0
def _doCommit(recipePath, repos, cfg, message):
    try:
        kw = {}
        if compat.ConaryVersion().supportsForceCommit():
            kw.update(force=True)
        rv = checkin.commit(repos, cfg, message, **kw)
    except (conaryerrors.CvcError, conaryerrors.ConaryError), msg:
        raise errors.RmakeError("Could not commit changes to build"
                                " recipe %s: %s" % (recipePath, msg))
Esempio n. 7
0
    def testReposRequireSigs(self):
        fingerprint = '95B457D16843B21EA3FC73BBC7C32FC1F94E405E'
        # supply the pass phrase for our private key
        keyCache = openpgpkey.getKeyCache()
        keyCache.getPrivateKey(fingerprint, '111111')

        callback = checkin.CheckinCallback()
        # make sure there's not a cached repo index 1
        self.stopRepository(1)
        sigRepos = self.openRepository(1, requireSigs=True)
        ascKey = open(resources.get_path('conary_test', 'archive',
                                         'key.asc')).read()
        buildLabel = self.cfg.buildLabel
        signatureKey = self.cfg.signatureKey
        signatureKeyMap = self.cfg.signatureKeyMap
        # try block protects test suite from the alteration of self.cfg
        # or most especially, the effects of leaving a requireSigs repo around
        try:
            self.cfg.signatureKey = None
            self.cfg.signatureKeyMap = None
            self.cfg.buildLabel = versions.Label('localhost1@rpl:linux')
            sigRepos.addNewAsciiPGPKey(self.cfg.buildLabel, 'test', ascKey)
            try:
                self.addQuickTestComponent("test:doc",
                                           "/localhost1@rpl:devel/1.0-1-1")
                self.fail("Repository should have required a signature")
            except DigitalSignatureVerificationError:
                pass

            name = 'testcase'
            fullName = name + '=/localhost1@rpl:linux'
            # test commit codepath.
            origDir = os.getcwd()
            try:
                os.chdir(self.workDir)
                self.newpkg(name)
                os.chdir(name)
                self.writeFile(name + '.recipe', testRecipe)
                self.addfile(name + '.recipe')
                try:
                    checkin.commit(sigRepos, self.cfg, 'foobar', callback)
                    self.fail("Repository should have rejected  commit")
                except DigitalSignatureVerificationError:
                    pass
                # but we really need a source trove for the rest of the paths
                self.cfg.signatureKey = fingerprint
                checkin.commit(sigRepos, self.cfg, fullName, None)
                self.cfg.signatureKey = None
            finally:
                os.chdir(origDir)

        # test cook codepath
            try:
                self.cookItem(sigRepos,
                              self.cfg,
                              fullName,
                              callback=callback,
                              ignoreDeps=True)
                self.fail("Repository should have rejected cook")
            except DigitalSignatureVerificationError:
                pass
            self.cfg.signatureKey = fingerprint
            self.cookItem(sigRepos,
                          self.cfg,
                          fullName,
                          callback=callback,
                          ignoreDeps=True)
            self.cfg.signatureKey = None

            # test clone codepath
            try:
                self.clone('/localhost1@rpl:shadow',
                           'testcase:source=/localhost1@rpl:linux')
                self.fail("Repository should have rejected clone")
            except DigitalSignatureVerificationError:
                pass

            # test branch codepath
            try:
                self.mkbranch("1.0-1",
                              "localhost1@rpl:shadow",
                              "testcase:source",
                              shadow=False)
                self.fail("Repository should have rejected branch")
            except DigitalSignatureVerificationError:
                pass

            # test shadow codepath
            try:
                self.mkbranch("1.0-1",
                              "localhost1@rpl:shadow",
                              "testcase:source",
                              shadow=True)
                self.fail("Repository should have rejected shadow")
            except DigitalSignatureVerificationError:
                pass

        finally:
            self.cfg.buildLabel = buildLabel
            self.cfg.signatureKey = signatureKey
            self.cfg.signatureKeyMap = signatureKeyMap
            # this repo MUST be destroyed, other tests will fail against it.
            self.stopRepository(1)
            sigRepos = self.openRepository(1)
        self.addQuickTestComponent("test:doc", "/localhost1@rpl:devel/1.0-1-1")
Esempio n. 8
0
def _doCommit(recipePath, repos, cfg, message):
    try:
        rv = checkin.commit(repos, cfg, message, force=True)
    except (conaryerrors.CvcError, conaryerrors.ConaryError), msg:
        raise errors.RmakeError("Could not commit changes to build"
                                " recipe %s: %s" % (recipePath, msg))