def setUp(self):
   self._ce = command_executer.GetCommandExecuter()
   self._program_dir = tempfile.mkdtemp()
   self._writeProgram()
   self._writeMakefile()
   with misc.WorkingDirectory(self._program_dir):
     self._ce.RunCommand('make')
   num_profile_dirs = 2
   self._profile_dirs = []
   for i in range(num_profile_dirs):
     profile_dir = tempfile.mkdtemp()
     command = ('GCOV_PREFIX_STRIP=%s GCOV_PREFIX=$(/bin/pwd) '
                ' %s/program' % (profile_dir.count('/'), self._program_dir))
     with misc.WorkingDirectory(profile_dir):
       self._ce.RunCommand(command)
     self._profile_dirs.append(profile_dir)
   self._merge_program = '/home/build/static/projects/crosstool/profile-merge/v14.5/profile_merge.par'
Beispiel #2
0
 def CommitLocally(self, commit_message=None, message_file=None):
     with misc.WorkingDirectory(self._root_dir):
         command = 'pwd'
         for ignore in self.ignores:
             command += '&& echo \'%s\' >> .git/info/exclude' % ignore
         command += '&& git add -Av .'
         if message_file:
             message_arg = '-F %s' % message_file
         elif commit_message:
             message_arg = '-m \'%s\'' % commit_message
         else:
             raise RuntimeError('No commit message given!')
         command += '&& git commit -v %s' % message_arg
         return self._ce.RunCommand(command)
Beispiel #3
0
 def MapSources(self, root_dir):
     if not self.mappings:
         self._RsyncExcludingRepoDirs(self._root_dir, root_dir)
         return
     with misc.WorkingDirectory(self._root_dir):
         for mapping in self.mappings:
             remote_path, local_path = SplitMapping(mapping)
             remote_path.rstrip('...')
             local_path.rstrip('...')
             full_local_path = os.path.join(root_dir, local_path)
             ret = self._RsyncExcludingRepoDirs(remote_path,
                                                full_local_path)
             if ret:
                 return ret
     return 0
Beispiel #4
0
    def PullSources(self):
        with misc.WorkingDirectory(self._root_dir):
            ret = self._CloneSources()
            if ret:
                return ret

            command = 'git checkout %s' % self.branch
            ret = self._ce.RunCommand(command)
            if ret:
                return ret

            command = 'git describe --always'
            ret, o, _ = self._ce.RunCommandWOutput(command)
            self.revision = o.strip()
            return ret
Beispiel #5
0
    def PullSources(self):
        with misc.WorkingDirectory(self._root_dir):
            for mapping in self.mappings:
                remote_path, local_path = SplitMapping(mapping)
                command = 'svn co %s/%s %s' % (self.address, remote_path,
                                               local_path)
            ret = self._ce.RunCommand(command)
            if ret:
                return ret

            self.revision = ''
            for mapping in self.mappings:
                remote_path, local_path = SplitMapping(mapping)
                command = 'cd %s && svnversion -c .' % (local_path)
                ret, o, _ = self._ce.RunCommandWOutput(command)
                self.revision += o.strip().split(':')[-1]
                if ret:
                    return ret
        return 0
Beispiel #6
0
 def PushSources(self,
                 commit_message=None,
                 dry_run=False,
                 message_file=None):
     ret = self.CommitLocally(commit_message, message_file)
     if ret:
         return ret
     push_args = ''
     if dry_run:
         push_args += ' -n '
     with misc.WorkingDirectory(self._root_dir):
         if self.gerrit:
             label = 'somelabel'
             command = 'git remote add %s %s' % (label, self.address)
             command += ('&& git push %s %s HEAD:refs/for/master' %
                         (push_args, label))
         else:
             command = 'git push -v %s origin %s:%s' % (
                 push_args, self.branch, self.branch)
         ret = self._ce.RunCommand(command)
     return ret
Beispiel #7
0
    def SetupForPush(self):
        with misc.WorkingDirectory(self._root_dir):
            ret = self._CloneSources()
            logger.GetLogger().LogFatalIf(
                ret, 'Could not clone git repo %s.' % self.address)

            command = 'git branch -a | grep -wq %s' % self.branch
            ret = self._ce.RunCommand(command)

            if ret == 0:
                if self.branch != 'master':
                    command = ('git branch --track %s remotes/origin/%s' %
                               (self.branch, self.branch))
                else:
                    command = 'pwd'
                command += '&& git checkout %s' % self.branch
            else:
                command = 'git symbolic-ref HEAD refs/heads/%s' % self.branch
            command += '&& rm -rf *'
            ret = self._ce.RunCommand(command)
            return ret
Beispiel #8
0
 def _CloneSources(self):
     with misc.WorkingDirectory(self._root_dir):
         command = 'git clone %s .' % (self.address)
         return self._ce.RunCommand(command)