Esempio n. 1
0
    def __init__(self, name=None, fedora_name=None):
        if fedora_name:
            if not name:
                name = fedora_name
            tmp_dir = mkdtemp()
            with pwd(tmp_dir):
                env = copy(environ)
                env['CVSROOT'] = CVSROOT
                cmd = ['cvs', 'co', fedora_name]
                with log_file('cvs.log') as cvs_log:
                    p = Popen(cmd, stdout=cvs_log, stderr=cvs_log,
                              env=env)
                    log.info('Fetching full source from CVS... please wait...')
                    p.communicate()

                with pwd(join(fedora_name, 'common')):
                    with file('branches', 'r') as branches:
                        branches = (branch for branch in branches if ':' in branch)
                        branches = (branch.split(':')[0] for branch in branches)
                        branches = list(branches)
                with pwd(fedora_name):
                    p_branches = os.listdir('.')
                    v_branches = (branch for branch in branches if branch in p_branches)
                    v_branches = list(v_branches)
                for branch in v_branches:
                    dir_name = fedora_name + '.' + branch
                    cvs_branch = join(fedora_name, branch)
                    cmd = ['git', 'cvsimport', '-o', branch, '-C', dir_name, cvs_branch]
                    with log_file('cvs.log') as cvs_log:
                        p = Popen(cmd, stdout=cvs_log, stderr=cvs_log,
                                  env=env)
                        log.info('Fetching partial source from CVS for %s... please wait...' % branch)
                        p.communicate()
                non_devel_v_branches = (branch for branch in v_branches if branch is not 'devel')
                for branch in non_devel_v_branches:
                    dir_name = fedora_name + '.' + branch
                    cvs_branch = join(fedora_name, branch)
                    refspec = branch + ':' + branch
                    cmd = ['git', 'fetch', join(tmp_dir, dir_name), refspec]
                    with log_file('cvs.log') as cvs_log:
                        with pwd(fedora_name + '.devel'):
                            p = Popen(cmd, stdout=cvs_log, stderr=cvs_log,
                                      env=env)
                            log.info('Combining CVS sources for %s ... please wait...' % branch)
                            p.communicate()

            move(join(tmp_dir, fedora_name + '.devel'), name)
            move(join(tmp_dir, fedora_name), join(name, '.fedora_cvs'))
            move(join(tmp_dir, 'cvs.log'), join(name, 'cvs.log'))
        super(RpmCvsPackage, self).__init__(name)
        if fedora_name:
            self.cfg['branches'] = v_branches
            self.cfg['pkg_name'] = fedora_name
Esempio n. 2
0
    def rpmbuild(self, param, package, profile=None):
        '''The work horse of building rpms

        Given a directive param for rpmbuild, the package, and a possible
        profile, it runs rpmbuild appropriatly.

        package is a directory name to a Package (Directory).
        profile is a Profile object, this parameter should only be used internally
 
        returns nothing
        '''
        pkg = DirFactory(package)
        log.debug(package)
        log.debug(pkg)
        if profile:
            defines = join_defines(profile.dist_defines,
                                   dir_defines(self.dir))
        else:
            defines = dir_defines(self.dir)
        log.debug('defines are ' + str(defines))
        log.debug('spec file is ' + pkg.spec_file)
        cmd = ['rpmbuild'] + defines + ['-v', param, pkg.spec_file]
        log.debug('cmd is ' + str(cmd))
        with pwd(pkg.dir):
            with log_file('rpmbuild.log') as rpm_out:
                with pwd(join(self.dir, 'SPECS')):
                    p = Popen(cmd, stdout=rpm_out, stderr=rpm_out)
                    log.info('building %s... please wait'
                             % pkg.spec_file)
                    p.wait()
                    log.debug(p.returncode)
Esempio n. 3
0
 def do_patch(self, patch, cmd):
     with log_file(join(self.pkg_src_dir, "patch.log")) as patch_log:
         patch_log.write("using patch %s...\n" % basename(patch))
         with file(patch, "r") as pfile:
             p = Popen(cmd, stdin=pfile, stdout=patch_log, stderr=patch_log)
             log.info("patching %s, please wait...." % basename(patch))
             p.communicate()
Esempio n. 4
0
 def checkout(self, *args):
     with pwd(self.source_dir):
         with log_file('git.log') as git_out:
             # NB: args is a tuple, must be converted
             p = Popen(['git', 'checkout'] + list(args),
                       stdout=git_out, stderr=git_out)
             log.info('git checkout %s, please wait....' % str(args))
             p.communicate()
Esempio n. 5
0
    def do_diff(self, src, tgt):
        cmd = ["diff", "-r", "-u", "-X", DIFF_EXCLUDES_FILE, src, tgt]
        with pwd(self.pkg_src_dir):
            with log_file("diff.log") as diff_out:

                def command(fd):
                    p = Popen(cmd, stdout=fd, stderr=diff_out)
                    log.info("generating patch %s, please wait..." % fd.name)
                    p.communicate()

                yield command
Esempio n. 6
0
    def get(self, src, tgt, *args):
        '''sets up a branch given arguments, taken from a source with a target

        the idioms of branching in different VCSes vary, and a common
        api for this in devshell has not yet been realized

        currently, this creates a new temporary local branch in darcs
        and sets the source to it
        '''
        with log_file('darcs.log') as darcs_out:
            # NB: args is a tuple, must be converted
            p = Popen(['darcs', 'get'] + list(args) + [src, tgt],
                      stdout = darcs_out, stderr = darcs_out)
            log.info('darcs get %s %s, please wait....' % (src, tgt))
            p.communicate()
Esempio n. 7
0
    def build(self, package):
        pkg = DirFactory(package)

        srpm_name = pkg.get_srpm_name(self.profile)
        mock_cfg = self.profile.mock_cfg
        result_dir = self.profile.result_dir
        config_dir = self.profile.mock_cfg_dir
        log.debug("mock_cfg is " + mock_cfg)
        log.debug("result_dir is " + result_dir)
        log.debug("config_dir is " + config_dir)
        cmd = ["mock", "-r", mock_cfg, "--configdir=%s" % config_dir, "--resultdir=%s" % result_dir, srpm_name]
        log.debug("cmd is " + str(cmd))
        with pwd(result_dir):
            with log_file("mock.log") as mock_out:
                p = Popen(cmd, stdout=mock_out, stderr=mock_out)
                log.info("mock compiling %s... please wait" % srpm_name)
                p.communicate()
Esempio n. 8
0
 def setup_sourceball(self, ver, delete_old=False):
     '''gets darcs to spit out a sourceball to be used in rpm making by other modules'''
     log.debug('someone set us up the bomb')
     if delete_old:
         with pwd(self.pkg_src_dir):
             rm(self.sourceball)
     name = self.upstream_name
     date = self.date
     full_name = '%s-%s.%sdarcs' % (name, ver, date)
     log.debug('full name is ' + full_name)
     sourceball = full_name + '.tar.gz'
     with pwd(self.source_dir):
         with log_file('darcs.log') as darcs_out:
             log.debug('we get signal')
             p = Popen(['darcs', 'dist', '-d', full_name],
                       stdout=darcs_out, stderr=darcs_out)
             log.info('generating tarball %s.tar.gz, please wait...'
                      % full_name)
             p.communicate()
     with pwd(self.pkg_src_dir):
         move(join(self.source_dir, sourceball), sourceball)
         self.cfg['sourceball'] = sourceball
Esempio n. 9
0
 def setup_sourceball(self, ver, delete_old=False):
     '''gets darcs to spit out a sourceball to be used in rpm making by other modules'''
     log.debug('someone set us up the bomb')
     if delete_old:
         with pwd(self.pkg_src_dir):
             rm(self.sourceball)
     name = self.upstream_name
     date = self.date
     full_name = '%s-%s.%s' % (name, ver, self.alphatag)
     log.debug('full name is ' + full_name)
     sourceball = full_name + '.tar.gz'
     with pwd(self.source_dir):
         with log_file('git.log') as git_out:
             p1 = Popen(['git', 'archive', '--format=tar', "--prefix=%s/" % full_name, "HEAD"],
                       stdout=PIPE, stderr=git_out)
             log.info('generating tarball %s.tar.gz, please wait...'
                      % full_name)
             with pwd(self.pkg_src_dir):
                 with file(sourceball, "wb") as sourceball_file:
                     p2 = Popen(['gzip'], stdin=p1.stdout,
                                stdout=sourceball_file, stderr=git_out)
                     p2.communicate()
     self.cfg['sourceball'] = sourceball
     self.cfg['full_name'] = full_name
Esempio n. 10
0
 def logged(self, name=""):
     with log_file(join(self.pkg_src.pkg_src_dir, 
                        (name if name else self._type) + '.log')) \
             as log_out:
         yield log_out