Example #1
0
def package(version=None, config=None, env=None):
    'Creates deployable packages'
    cleanitup = False
    if not env:
        env = builder.BuildEnv()
    if not version:
        version = prompt("What version did you want packaged there, hotshot?")
    if not env.rootdir:
        env.rootdir = tempfile.mkdtemp(prefix='builder-root-')
        cleanitup = True
        build(version, config, env)
    elif not env.exists('rootdir'):
        build(version, config, rootdir)

    for pkgtype in 'deb', 'rpm':
        if config.has_section(pkgtype):
            pkg = packager.Package(config, env, pkgtype)
            pkg.build(version)

    if cleanitup:
        _local('rm -rf %s' % env.rootdir)
Example #2
0
File: git.py Project: kafana/ubik
        version = ''
    if not isinstance(config, ConfigParser.SafeConfigParser):
        if config:
            config = _get_config(config)
        else:
            config = _get_config()

    # These are the variables that can be percent expanded in the ini
    config_vars = {
        'root': os.path.abspath(env.rootdir),
        'version': version.split('-', 1)[0],
    }
    repo = config.get(NAME, 'repo', vars=config_vars)

    # Clone if doesn't exist, but don't touch repo otherwise
    if not os.path.exists(os.path.join(env.srcdir, '.git')):
        _local("git clone %s %s" % (repo, env.srcdir))

    if config.has_option(NAME, 'tag'):
        _local("git checkout %s" % config.get(NAME, 'tag', vars=config_vars),
               cwd=env.srcdir)
    elif config.has_option(NAME, 'branch'):
        _local("git checkout %s" %
               config.get(NAME, 'branch', vars=config_vars),
               cwd=env.srcdir)


if __name__ == '__main__':
    clone("0.9.13", "doc/example-%s.ini" % NAME,
          builder.BuildEnv(builddir='test/out'))
Example #3
0
import shutil as sh
import sys

from fabric.api import abort, local, prompt, warn
# Fabric 1.0 changed changed the scope of cd() to only affect remote calls.
# This bit of kludgery maintains compatibility of this file with fabric 0.9,
# but it is only possible because no remote calls are made in this file
try:
    from fabric.api import lcd as cd
except ImportError:
    from fabric.api import cd

from ubik import builder, packager

# filemap copies files directly from source to root, there is no build step
defenv = builder.BuildEnv('_root', '_root', '.')

file_map, file_map_table = None, None


def _install_file_map(fmap, installdir):
    for src, dst in fmap:
        _install(src, os.path.join(installdir, dst))


def _install(src, dst):
    if src and os.path.isdir(src):
        sh.copytree(src, dst)
    else:
        if not os.path.exists(os.path.dirname(dst)):
            os.makedirs(os.path.dirname(dst))
Example #4
0
File: pip.py Project: kafana/ubik
    'Creates deployable packages'
    cleanitup = False
    if not env:
        env = builder.BuildEnv()
    if not version:
        version = prompt("What version did you want packaged there, hotshot?")
    if not env.rootdir:
        env.rootdir = tempfile.mkdtemp(prefix='builder-root-')
        cleanitup = True
        build(version, config, env)
    elif not env.exists('rootdir'):
        build(version, config, env)

    for pkgtype in 'deb', 'rpm':
        if config.has_section(pkgtype):
            pkg = packager.Package(config, env, pkgtype)
            pkg.build(version)

    if cleanitup:
        local('rm -rf %s' % env.rootdir)


def rpm(version=None):
    'Build a Red Hat package'
    package(version, 'rpm')


if __name__ == '__main__':
    build('1.0', ('doc/example-%s.ini' % NAME),
          builder.BuildEnv(rootdir="tests/out/pip"))
Example #5
0
File: fab.py Project: kafana/ubik
# Fabric 1.0 changed changed the scope of cd() to only affect remote calls.
# This bit of kludgery maintains compatibility of this file with fabric 0.9,
# but it is only possible because no remote calls are made in this file
try:
    from fabric.api import lcd as cd
except ImportError:
    from fabric.api import cd

from ubik import builder, packager

# Ok, so this part gets a little complicated.
# This is a rug module that uses the fabric library to call the
# "fab" unix command.  In this instance, think of "fab" like "make"

NAME = 'fab'
defenv = builder.BuildEnv('_root', '_root', '.')
log = logging.getLogger(NAME)


def _get_config(configfile='package.ini'):
    config = ConfigParser.SafeConfigParser()
    config.read(configfile)
    return config


def build(version, config, env=defenv):
    'Builds this package into a directory tree'
    if not version:
        version = prompt("What version did you want packaged there, hotshot?")
    if not isinstance(config, ConfigParser.SafeConfigParser):
        if config:
Example #6
0
                        section,
                        config_vars,
                        section_type=_get_section_type(section))


if __name__ == '__main__':
    basedir = os.path.dirname(os.path.abspath(__file__))
    test_section = """[program:cat]
command=/bin/cat
process_name=%(program_name)s
numprocs=1
directory=/tmp
umask=022
priority=999
autostart=true
autorestart=true
startsecs=10
startretries=3
exitcodes=0,2
stopsignal=TERM
socket=tcp://127.0.0.1:9001
"""
    target = os.path.abspath(
        os.path.join(basedir, '../../../tests/out/opt/prod'))
    if not os.path.exists(target):
        os.makedirs(target)
    with open(os.path.join(target, "service.conf"), 'w') as f:
        f.write(test_section)
    write_supervisor_config('1.0', '../doc/ini/example-%s.ini' % NAME,
                            builder.BuildEnv(rootdir='../tests/out'))