Пример #1
0
def quick(domain, stack_version, project_name, ref="origin/master", url=None, path_to_missile=None, debs_path=None, meta_path=None):
    """
    One-command to build and add to stack a specific branch.
    Depends heavily on pre-configuration via config file.
    Package version are set from Git commit.

    <domain> domain where the stack will be registered to (some kind of type for stack).
    <stack_version> version of the stack to attach the package to.
    <project_name> name of the project.
    <branch> is the branch to actually checkout.
    <url> is the url of the repo in github.
    <path_to_missile> is the path to the missile file in the project that will be used by trebuchet to build packages.
    <debs_path> path to where the DEB package should be created into.
    <meta_path> path to the stacks and other meta information related to package
    """
    # Get value for the project, complain otherwise
    meta_path = meta_path if 'meta_path' not in env else env.meta_path
    debs_path = debs_path if 'debs_path' not in env else env.debs_path
    url = url if "projects" not in env or project_name not in env.projects or 'url' not in env.projects[project_name] else env.projects[project_name]['url']
    path_to_missile = path_to_missile if "projects" not in env or project_name not in env.projects or 'path_to_missile' not in env.projects[project_name] else env.projects[project_name]['path_to_missile']
    
    if not meta_path or not debs_path:
        abort("Please specify a meta_path/debs_path or add it approprietly in a config file")

    if not url:
        abort("Please specify a url or add it approprietly in a config file: projects.%s.url" % project_name)

    name = project_name if ref is None else project_name+"_"+ref.replace("/", "-")

    # use existing stack only (create one manually)
    new_stack = Stack(domain, stack_version, meta_path=meta_path)
    if not new_stack.is_persisted():
        abort("""Please create a new stack first, using: `gachette stack_create`""")

    # Checkout specific branch and build
    wc = WorkingCopy(name)
    wc.prepare_environment()
    wc.checkout_working_copy(url, ref)

    # set version based on the git commit
    suffix = "" if ref is None else ref.replace("/", "-")
    version = wc.get_version_from_git(suffix=suffix)
    wc.set_version(app=version, env=version, service=version)

    results = wc.build(debs_path, path_to_missile, trebuchet_bin=trebuchet_bin)
    print "results: ", results
    # TODO extract package build results properly
    for item in results:
        new_stack.add_package(item['name'], item['version'], item['file_name'])
Пример #2
0
def stack_create(domain, name, meta_path=None, from_stack=None):
    """
    Create a new stack. From old one if specified.
    """
    # get the meta_path from .gachetterc
    meta_path = meta_path if 'meta_path' not in env else env.meta_path
    if not meta_path:
        abort("Please specify a `meta_path` or use a config file to define it")
    
    new_stack = Stack(domain, name, meta_path=meta_path)

    if not new_stack.is_persisted():
        if from_stack:
            old_stack = Stack(domain, from_stack, meta_path=meta_path)
            new_stack.clone_from(old_stack)
        else:
            new_stack.persist()
Пример #3
0
def stack_create(domain, name, meta_path=None, from_stack=None):
    """
    Create a new stack. From old one if specified.
    """
    # get the meta_path from .gachetterc
    meta_path = meta_path if 'meta_path' not in env else env.meta_path
    if not meta_path:
        abort("Please specify a `meta_path` or use a config file to define it")

    new_stack = Stack(domain, name, meta_path=meta_path)

    if not new_stack.is_persisted():
        if from_stack:
            old_stack = Stack(domain, from_stack, meta_path=meta_path)
            new_stack.clone_from(old_stack)
        else:
            new_stack.persist()
Пример #4
0
def quick(domain,
          stack_version,
          project_name,
          ref="origin/master",
          url=None,
          path_to_missile=None,
          debs_path=None,
          meta_path=None):
    """
    One-command to build and add to stack a specific branch.
    Depends heavily on pre-configuration via config file.
    Package version are set from Git commit.

    <domain> domain where the stack will be registered to (some kind of type for stack).
    <stack_version> version of the stack to attach the package to.
    <project_name> name of the project.
    <branch> is the branch to actually checkout.
    <url> is the url of the repo in github.
    <path_to_missile> is the path to the missile file in the project that will be used by trebuchet to build packages.
    <debs_path> path to where the DEB package should be created into.
    <meta_path> path to the stacks and other meta information related to package
    """
    # Get value for the project, complain otherwise
    meta_path = meta_path if 'meta_path' not in env else env.meta_path
    debs_path = debs_path if 'debs_path' not in env else env.debs_path
    url = url if "projects" not in env or project_name not in env.projects or 'url' not in env.projects[
        project_name] else env.projects[project_name]['url']
    path_to_missile = path_to_missile if "projects" not in env or project_name not in env.projects or 'path_to_missile' not in env.projects[
        project_name] else env.projects[project_name]['path_to_missile']

    if not meta_path or not debs_path:
        abort(
            "Please specify a meta_path/debs_path or add it approprietly in a config file"
        )

    if not url:
        abort(
            "Please specify a url or add it approprietly in a config file: projects.%s.url"
            % project_name)

    name = project_name if ref is None else project_name + "_" + ref.replace(
        "/", "-")

    # use existing stack only (create one manually)
    new_stack = Stack(domain, stack_version, meta_path=meta_path)
    if not new_stack.is_persisted():
        abort(
            """Please create a new stack first, using: `gachette stack_create`"""
        )

    # Checkout specific branch and build
    wc = WorkingCopy(name)
    wc.prepare_environment()
    wc.checkout_working_copy(url, ref)

    # set version based on the git commit
    suffix = "" if ref is None else ref.replace("/", "-")
    version = wc.get_version_from_git(suffix=suffix)
    wc.set_version(app=version, env=version, service=version)

    results = wc.build(debs_path, path_to_missile, trebuchet_bin=trebuchet_bin)
    print "results: ", results
    # TODO extract package build results properly
    for item in results:
        new_stack.add_package(item['name'], item['version'], item['file_name'])