Example #1
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()
Example #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)
Example #3
0
 def gen_spec(self, name):
     cabal_file = name + '.cabal'
     with self.logged('cabal2spec') as c2s_log:
         with self.pkg_src.in_dir():
             cmd = ['cabal2spec', cabal_file]
             p = Popen(cmd, stdout=c2s_log, stderr=c2s_log)
             log.info('Generating spec file for %s' % cabal_file)
             p.communicate()
Example #4
0
 def gen_spec(self, name):
     spec_file = name + '.spec'
     with self.logged('rpmdevtools') as rdt_log:
         with self.pkg_src.in_dir():
             cmd = ['rpmdev-newspec', spec_file]
             p = Popen(cmd, stdout=rdt_log, stderr=rdt_log)
             log.info('Generating spec file for %s' % spec_file)
             p.communicate()
Example #5
0
 def _check_sources(self):
     '''necessary to make sure self.sources is a list
     '''
     if 'sources' not in self.cfg:
         self.cfg['sources'] = list()
     elif type(self.sources) is not list:
         log.warn('sources for this package is not a list, overwriting!')
         log.info('sources was, fyi, ' + str(self.sources))
         self.cfg['sources'] = list()
Example #6
0
 def compile_setup(self, *args):
     '''compiles the setup script for faster execution
     '''
     with self.logged('ghc') as ghc_out:
         with self.pkg_src.in_src_dir():
             setup_f = self.find_setup()
             p = Popen([self.compiler, '--make', setup_f] + list(args),
                       stdout=ghc_out, stderr=ghc_out)
             log.info('Building %s, please wait...' % setup_f)
             p.communicate()
Example #7
0
 def verify_patches(self, *args):
     test_file = join(self.pkg_src_dir, "test.patch.")
     with self.patches_applied(*args):
         with self.do_diff(self.branch("orig"), ".") as diff:
             with pwd(self.dir):
                 with file(test_file, "w") as patch_file:
                     diff(patch_file)
     clean = False if len(file(test_file).read()) else True
     log.info("Verified clean patches: " + str(clean))
     return clean
Example #8
0
 def prepare(self, install=False, force=False, *args):
     with self.logged() as autotools_out:
         with self.pkg_src.in_src_dir():
             print 'preparing'
             cmd = ['autoreconf'] \
                 + ['--install'] if install else [] \
                 + ['--force'] if force else [] \
                 + list(args)
             p = Popen(cmd, stdout=autotools_out, stderr=autotools_out)
             log.info('Preparing %s, please wait...' % self.name)
             p.communicate()
Example #9
0
    def install(self, *args):
        '''runs the install stage of autotools

        This is not safe to run on an unconfigured source dir, because
        this module does not track the state of autotools systems. The user
        must do this on their own.
        '''
        with self.logged() as autotools_out:
            with self.pkg_src.in_src_dir():
                cmd = ['make', 'install'] + list(args)
                p = Popen(cmd, stdout=autotools_out, stderr=autotools_out)
                log.info('Installing %s, please wait...' % self.name)
                p.communicate()
Example #10
0
    def install(self, *args):
        '''runs the install stage of cabal

        This is not safe to run on an unconfigured source dir, because
        this module does not track the state of cabal systems. The user
        must do this on their own.
        '''
        self.compile_setup()
        with self.logged() as cabal_out:
            with self.pkg_src.in_src_dir():
                cmd = [abspath('Setup'), 'install'] + list(args)
                p = Popen(cmd, stdout=cabal_out, stderr=cabal_out)
                log.info('Building %s, please wait...' % self.name)
                p.communicate()
Example #11
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()
Example #12
0
    def configure(self, target='home', *args):
        '''runs the configure stage of autotools
        
        target is either 'home' or 'root' and will configure the package to
        install either to the user's home directory, or to the system
        wide haskell.

        Some help is needed making this more flexible
        '''
        user = True if target == 'home' else False
        with self.logged() as autotools_out:
            with self.pkg_src.in_src_dir():
                cmd = [abspath('configure'),
                       '--prefix=' + expanduser('~') if user else target] \
                       + list(args)
                p = Popen(cmd, stdout=autotools_out, stderr=autotools_out)
                log.info('Configuring %s, please wait...' % self.name)
                p.communicate()
Example #13
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
Example #14
0
 def command(fd):
     p = Popen(cmd, stdout=fd, stderr=diff_out)
     log.info("generating patch %s, please wait..." % fd.name)
     p.communicate()