def remote_transaction_sqlite(conn_info):
            remote_db_local_path = join(self.db_path, 'remote_config.db3')

            log.info('Fetching db to %r', remote_db_local_path)
            utils.rsync(self.config, '{remote_server}:' + self.config.remote_db_path,
                utils.to_cygwin_path(remote_db_local_path))

            remote_conn_info = self.db_backend.conn_info.copy()
            remote_conn_info['path'] = remote_db_local_path

            yield remote_conn_info
示例#2
0
def run(env, args):
    config = env.config
    if not config.prefix:
        raise Exception('Prefix is required.')

    svn_info = utils.SVNInfo(env.source_path)
    revision_path = 'r{0}'.format(svn_info.version)

    package_relative_dir = os.sep.join([
        env.platform, env.mode, svn_info.branch, revision_path])

    package_dir = join(config.packages_save_path, package_relative_dir)
    if os.path.isdir(package_dir):
        if config.no_package_overwrite:
            log.info('Package directory already exists (%r) not building.',
                package_dir)
            return

    try:
        if not os.path.isdir(package_dir):
            os.makedirs(package_dir)
    except:
        raise Exception('Failed to create the '
            'directory in %r, cannot continue' % package_dir)

    log.info('Cleaning prefix %r', config.prefix)
    utils.RemoveDirectory(config.prefix)

    log.info('Installing Synthese to %r', config.prefix)
    builder = synthesepy.build.get_builder(env)
    builder.install()

    env_dir = os.path.join(config.prefix, 'share', 'synthese', 'env')
    if not os.path.isdir(env_dir):
        log.info('CMake install didn\'t create the environment '
            'directory in %r, we do not seal it' % env_dir)
    else:
        with open(join(env_dir, 'sealed.txt'), 'wb') as f:
            f.write('Environment sealed\n')

    # Archive
    ARCHIVE_NAME = 'synthese.tar.bz2'
    if config.prefix_with_svnrelease:
        ARCHIVE_NAME = 'synthese-relative-' +  revision_path + '.tar.bz2'
    archive_path = join(package_dir, ARCHIVE_NAME)

    log.info('Creating archive %r', archive_path)
    prefix_parent = os.path.dirname(config.prefix)
    prefix_tail = os.path.basename(config.prefix)
    utils.call([
        'tar', '-C',  utils.to_cygwin_path(prefix_parent),
        '-jcf', utils.to_cygwin_path(archive_path),
        '--owner=0', '--group=0',
        '--numeric-owner', '--mode=go-w', prefix_tail])

    log.info('Remove the build directory in %r' % config.prefix)
    utils.RemoveDirectory(config.prefix)

    # Deploy script

    deploy_script_path = join(package_dir, 'install_synthese.py')
    source_deploy_script = join(
        env.source_path, 'tools', 'synthesepy', 'install_synthese.py.in')
    deploy_script_content = open(source_deploy_script).read()

    archive_url = (config.packages_access_url + package_relative_dir +
        '/' + ARCHIVE_NAME)
    deploy_script_content = deploy_script_content.replace(
        '@@ARCHIVE_URL@@', archive_url).replace(
        '@@PREFIX@@', config.prefix)
    with open(deploy_script_path, 'wb') as f:
        f.write(deploy_script_content)
    log.debug('Deploy script written to %r', deploy_script_path)

    # TODO: remove old packages to avoid filling up the disk.

    # latest symlink
    if env.platform != 'win':
        link_name = join(package_dir, os.pardir, 'latest')
        if os.path.exists(link_name):
            os.unlink(link_name)
        os.symlink(revision_path, link_name)
示例#3
0
文件: package.py 项目: yvc74/synthese
def run(env, args):
    config = env.config
    if not config.prefix:
        raise Exception('Prefix is required.')

    # Pass the branch from the command line, useful in Jenkins
    # where we get HEAD instead of the branch
    git_info = utils.GITInfo(env.source_path, config.branch)
    revision_path = datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
    revision_path += '-{0}'.format(git_info.version)

    # On Linux, lets pick a more precise name for the platform
    # through lsb_release (this package must be installed)
    distro_name = env.platform
    if env.platform == 'lin':
        try:
            # TODO: use subprocess.check_output once we require Python 2.7
            distro_name = subprocess.Popen(
                ["lsb_release", "-cs"],
                stdout=subprocess.PIPE).communicate()[0]
            distro_name = distro_name.rstrip()
        except:
            raise Exception('Failed to run lsb_release. '
                            'Please install it (apt-get install lsb-release)')

    package_relative_dir = os.sep.join(
        [env.platform, env.mode, git_info.branch, revision_path])

    package_dir = join(config.packages_save_path, package_relative_dir)
    if os.path.isdir(package_dir):
        if config.no_package_overwrite:
            log.info('Package directory already exists (%r) not building.',
                     package_dir)
            return

    try:
        if not os.path.isdir(package_dir):
            os.makedirs(package_dir)
    except:
        raise Exception('Failed to create the '
                        'directory in %r, cannot continue' % package_dir)

    log.info('Cleaning prefix %r', config.prefix)
    utils.RemoveDirectory(config.prefix)

    log.info('Installing Synthese to %r', config.prefix)
    builder = synthesepy.build.get_builder(env)
    builder.install()

    env_dir = os.path.join(config.prefix, 'share', 'synthese', 'env')
    if not os.path.isdir(env_dir):
        log.info('CMake install didn\'t create the environment '
                 'directory in %r, we do not seal it' % env_dir)
    else:
        with open(join(env_dir, 'sealed.txt'), 'wb') as f:
            f.write('Environment sealed\n')

    # Archive
    ARCHIVE_NAME = 'synthese.tar.bz2'
    if config.prefix_with_svnrelease:
        ARCHIVE_NAME = 'synthese-relative-' + revision_path + '.tar.bz2'
    archive_path = join(package_dir, ARCHIVE_NAME)

    log.info('Creating archive %r', archive_path)
    prefix_parent = os.path.dirname(config.prefix)
    prefix_tail = os.path.basename(config.prefix)
    utils.call([
        'tar', '-C',
        utils.to_cygwin_path(prefix_parent), '-jcf',
        utils.to_cygwin_path(archive_path), '--owner=0', '--group=0',
        '--numeric-owner', '--mode=go-w', prefix_tail
    ])

    log.info('Remove the build directory in %r' % config.prefix)
    utils.RemoveDirectory(config.prefix)

    # Deploy script

    deploy_script_path = join(package_dir, 'install_synthese.py')
    source_deploy_script = join(env.source_path, 'tools', 'synthesepy',
                                'install_synthese.py.in')
    deploy_script_content = open(source_deploy_script).read()

    archive_url = (config.packages_access_url + package_relative_dir + '/' +
                   ARCHIVE_NAME)
    deploy_script_content = deploy_script_content.replace(
        '@@ARCHIVE_URL@@', archive_url).replace('@@PREFIX@@', config.prefix)
    with open(deploy_script_path, 'wb') as f:
        f.write(deploy_script_content)
    log.debug('Deploy script written to %r', deploy_script_path)

    # TODO: remove old packages to avoid filling up the disk.

    # latest symlink
    if env.platform != 'win':
        link_name = join(package_dir, os.pardir, 'latest')
        if os.path.exists(link_name):
            os.unlink(link_name)
        os.symlink(revision_path, link_name)
示例#4
0
def run(env, args):
    config = env.config
    if not config.prefix:
        raise Exception('Prefix is required.')

    # Pass the branch from the command line, useful in Jenkins
    # where we get HEAD instead of the branch
    git_info = utils.GITInfo(env.source_path, config.branch)
    revision_path = datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
    revision_path += '-{0}'.format(git_info.version)

    # On Linux, lets pick a more precise name for the platform
    # through lsb_release (this package must be installed)
    distro_name = env.platform
    if env.platform == 'lin':
        try:
            # TODO: use subprocess.check_output once we require Python 2.7
            distro_name = subprocess.Popen(
                ["lsb_release", "-cs"], stdout=subprocess.PIPE).communicate()[0]
            distro_name = distro_name.rstrip()
        except:
            raise Exception('Failed to run lsb_release. '
                            'Please install it (apt-get install lsb-release)')


    package_relative_dir = os.sep.join([
        env.platform, env.mode, git_info.branch, revision_path])

    package_dir = join(config.packages_save_path, package_relative_dir)
    if os.path.isdir(package_dir):
        if config.no_package_overwrite:
            log.info('Package directory already exists (%r) not building.',
                package_dir)
            return

    try:
        if not os.path.isdir(package_dir):
            os.makedirs(package_dir)
    except:
        raise Exception('Failed to create the '
            'directory in %r, cannot continue' % package_dir)

    log.info('Cleaning prefix %r', config.prefix)
    utils.RemoveDirectory(config.prefix)

    log.info('Installing Synthese to %r', config.prefix)
    builder = synthesepy.build.get_builder(env)
    builder.install()

    env_dir = os.path.join(config.prefix, 'share', 'synthese', 'env')
    if not os.path.isdir(env_dir):
        log.info('CMake install didn\'t create the environment '
            'directory in %r, we do not seal it' % env_dir)
    else:
        with open(join(env_dir, 'sealed.txt'), 'wb') as f:
            f.write('Environment sealed\n')

    # Archive
    ARCHIVE_NAME = 'synthese.tar.bz2'
    if config.prefix_with_svnrelease:
        ARCHIVE_NAME = 'synthese-relative-' +  revision_path + '.tar.bz2'
    archive_path = join(package_dir, ARCHIVE_NAME)

    log.info('Creating archive %r', archive_path)
    prefix_parent = os.path.dirname(config.prefix)
    prefix_tail = os.path.basename(config.prefix)
    utils.call([
        'tar', '-C',  utils.to_cygwin_path(prefix_parent),
        '-jcf', utils.to_cygwin_path(archive_path),
        '--owner=0', '--group=0',
        '--numeric-owner', '--mode=go-w', prefix_tail])

    log.info('Remove the build directory in %r' % config.prefix)
    utils.RemoveDirectory(config.prefix)

    # Deploy script

    deploy_script_path = join(package_dir, 'install_synthese.py')
    source_deploy_script = join(
        env.source_path, 'tools', 'synthesepy', 'install_synthese.py.in')
    deploy_script_content = open(source_deploy_script).read()

    archive_url = (config.packages_access_url + package_relative_dir +
        '/' + ARCHIVE_NAME)
    deploy_script_content = deploy_script_content.replace(
        '@@ARCHIVE_URL@@', archive_url).replace(
        '@@PREFIX@@', config.prefix)
    with open(deploy_script_path, 'wb') as f:
        f.write(deploy_script_content)
    log.debug('Deploy script written to %r', deploy_script_path)

    # TODO: remove old packages to avoid filling up the disk.

    # latest symlink
    if env.platform != 'win':
        link_name = join(package_dir, os.pardir, 'latest')
        if os.path.exists(link_name):
            os.unlink(link_name)
        os.symlink(revision_path, link_name)