示例#1
0
文件: tasks.py 项目: jjardon/builder
def build_iso(self, iso, branch):
    logger.info('Fetching ISO configuration...')
    iso.source.checkout(branch=branch)

    config = iso.config

    if not config:
        logger.error('ISO configuration not found: ' + iso.name)
        return

    logger.info('Setting up the build directory...')
    rsync('/usr/share/archiso/configs/releng', config.workdir)

    logger.info('Preparing ISO configuration...')

    # Add any additional repos
    replace_in_file(config.path('pacman.conf'), r'\#\[testing\]',
                    '\n\n'.join(config.custom_repos) + '\n\n#[testing]')

    # Add the requested packages
    append_to_file(config.path('packages.both'), config.packages)
    append_to_file(config.path('packages.i686'), config.packages_i686)
    append_to_file(config.path('packages.x86_64'), config.packages_x86_64)

    # Add customizations
    append_to_file(config.path('airootfs/root/customize_airootfs.sh'), config.customizations)

    if config.graphical_target:
        replace_in_file(config.path('airootfs/root/customize_airootfs.sh'),
                        r'multi-user.target', 'graphical.target')

    logger.info('Building ISO...')
    cmd = [config.path('build.sh'), '-v']

    if config.name:
        cmd += ['-N ' + config.name]
    if config.version:
        cmd += ['-V ' + config.version]
    if config.label:
        cmd += ['-L ' + config.label]

    run(cmd, capture_stdout=False, sudo=True, workdir=config.workdir)
示例#2
0
文件: tasks.py 项目: jjardon/builder
def build_repository(self, repo, branch):
    logger.info('Fetching repository configuration and PKGBUILDs...')
    repo.source.pull(branch=branch)

    config = repo.config

    if not config:
        logger.error('Repository configuration not found: ' + repo.name)
        return

    logger.info('Loading configuration...')
    config.load()

    logger.info('Downloading package sources...')
    config.download()

    logger.info('Loading package information...')
    config.refresh()

    logger.info('Building packages...')
    if os.path.exists(config.repo_dir):
        rmtree(config.repo_dir)
    for package in config.packages:
        package.build()

    logger.info('Saving build information...')
    for package in config.packages:
        config.buildinfo.get('packages')[package.name] = package.gitrev
    config.buildinfo['build_number'] = config.build_number
    save_yaml(os.path.join(config.workdir, 'buildinfo.yml'), config.buildinfo)

    logger.info('Committing build information...')
    repo.source.repo.index.add(['buildinfo.yml'] + ['packages/{}/PKGBUILD'.format(pkg.name)
                                                    for pkg in config.packages])
    repo.source.repo.index.commit('Build {} at {:%c}\n\n{}'.format(config.build_number,
                                                                   datetime.now(),
                                                                   config.changelog),
                                  author=Actor("Builder", "*****@*****.**"))
    repo.source.repo.remotes.origin.push()

    logger.info('Exporting built packages...')
    rsync(config.repo_dir, config.export_dir, sudo=True)
示例#3
0
文件: tasks.py 项目: jjardon/builder
def build_continuous(self, repo, sha=None, branch=None, patch_url=None):
    chroot = Chroot(repo.name)
    chroot.bind_rw = [repo.workdir + ':/source', '/var/cache/npm:/npm_cache']

    logger.info('Building repo: ' + repo.name)
    logger.info('Fetching sources...')
    repo.source.checkout(sha=sha, branch=branch, patch_url=patch_url)

    config = repo.config

    if not config:
        logger.warn('Repository has no build config: ' + repo.name)
        return

    logger.info('Creating chroot...')
    chroot.create()

    logger.info('Installing dependencies...')
    chroot.install(config.get('dependencies', []))

    if 'npm-dependencies' in config:
        logger.info('Installing NPM dependencies globally...')
        chroot.install(['npm'])
        chroot.run(['npm', 'install', '-g'] + config['npm-dependencies'])

    logger.info("Copying source directory...")
    chroot.run(['cp', '-r', '/source', '/build'])

    logger.info('Running build steps...')
    for cmd in config.get('build', []):
        logger.info('--> ' + cmd)
        try:
            chroot.run(cmd.format(srcdir='/build'), workdir='/build')
        except Exception as ex:
            logger.error("Continous integration failed: " + cmd)
            raise ex

    logger.info('Repository passed continuous integration: ' + repo.name)