Пример #1
0
def source_init(args, l, st, rc):
    from ..source.repository import new_repository

    dir_ = args.dir

    if not dir_:
        dir_ = os.getcwd()

    repo = new_repository(rc.sourcerepo(args.name))
    repo.bundle_dir = dir_

    repo.delete_remote()
    import time
    time.sleep(3)
    repo.init_descriptor()
    repo.init_remote()

    repo.push()

    st.sync_bundle(dir_)
Пример #2
0
def source_init(args, l, st, rc):
    from ..source.repository import new_repository

    dir_ = args.dir

    if not dir_:
        dir_ = os.getcwd()

    repo = new_repository(rc.sourcerepo(args.name))
    repo.bundle_dir = dir_

    repo.delete_remote()
    import time
    time.sleep(3)
    repo.init_descriptor()
    repo.init_remote()

    repo.push()

    st.sync_bundle(dir_)
Пример #3
0
def source_build(args, l, st, rc):
    """Build a single bundle, or a set of bundles in a directory.

    The build process will build all dependencies for each bundle before
    buildng the bundle.

    """

    from ambry.identity import Identity
    from ..source.repository import new_repository

    repo = new_repository(rc.sourcerepo(args.name))

    dir_ = None
    name = None

    if args.dir:
        if os.path.exists(args.dir):
            dir_ = args.dir
            name = None
        else:
            name = args.dir
            try:
                Identity.parse_name(name)
            except:
                fatal(
                    "Argument '{}' must be either a bundle name or a directory".format(name))
                return

    if not dir_:
        dir_ = rc.sourcerepo.dir

    def build(bundle_dir):
        from ambry.library import new_library

        # Import the bundle file from the directory

        bundle_class = load_bundle(bundle_dir)
        bundle = bundle_class(bundle_dir)

        l = new_library(rc.library(args.library_name))

        if l.get(bundle.identity.vid) and not args.force:
            prt("{} Bundle is already in library", bundle.identity.name)
            return
        elif bundle.is_built and not args.force and not args.clean:
            prt("{} Bundle is already built", bundle.identity.name)
            return
        else:

            if args.dryrun:
                prt("{} Would build but in dry run ", bundle.identity.name)
                return

            repo.bundle = bundle

            if args.clean:
                bundle.clean()

            # Re-create after cleaning is important for something ...

            bundle = bundle_class(bundle_dir)

            prt("{} Building ", bundle.identity.name)

            if not bundle.run_prepare():
                fatal("{} Prepare failed", bundle.identity.name)

            if not bundle.run_build():
                fatal("{} Build failed", bundle.identity.name)

        if args.install and not args.dryrun:
            if not bundle.run_install(force=True):
                fatal('{} Install failed', bundle.identity.name)

    build_dirs = {}

    # Find all of the dependencies for the named bundle, and make those first.
    for root, _, files in os.walk(rc.sourcerepo.dir):
        if 'bundle.yaml' in files:
            bundle_class = load_bundle(root)
            bundle = bundle_class(root)
            build_dirs[bundle.identity.name] = root

    if name:
        deps = repo.bundle_deps(name)
        deps.append(name)

    else:

        deps = []

        # Walk the subdirectory for the files to build, and
        # add all of their dependencies
        for root, _, files in os.walk(dir_):
            if 'bundle.yaml' in files:

                bundle_class = load_bundle(root)
                bundle = bundle_class(root)

                for dep in repo.bundle_deps(bundle.identity.name):
                    if dep not in deps:
                        deps.append(dep)

                deps.append(bundle.identity.name)

    for n in deps:
        try:
            dir_ = build_dirs[n]
        except KeyError:
            fatal("Failed to find directory for bundle {}".format(n))

        prt('')
        prt("{} Building in {}".format(n, dir_))
        build(dir_)
Пример #4
0
def source_build(args, l, st, rc):
    """Build a single bundle, or a set of bundles in a directory.

    The build process will build all dependencies for each bundle before
    buildng the bundle.

    """

    from ambry.identity import Identity
    from ..source.repository import new_repository

    repo = new_repository(rc.sourcerepo(args.name))

    dir_ = None
    name = None

    if args.dir:
        if os.path.exists(args.dir):
            dir_ = args.dir
            name = None
        else:
            name = args.dir
            try:
                Identity.parse_name(name)
            except:
                fatal(
                    "Argument '{}' must be either a bundle name or a directory"
                    .format(name))
                return

    if not dir_:
        dir_ = rc.sourcerepo.dir

    def build(bundle_dir):
        from ambry.library import new_library

        # Import the bundle file from the directory

        bundle_class = load_bundle(bundle_dir)
        bundle = bundle_class(bundle_dir)

        l = new_library(rc.library(args.library_name))

        if l.get(bundle.identity.vid) and not args.force:
            prt("{} Bundle is already in library", bundle.identity.name)
            return
        elif bundle.is_built and not args.force and not args.clean:
            prt("{} Bundle is already built", bundle.identity.name)
            return
        else:

            if args.dryrun:
                prt("{} Would build but in dry run ", bundle.identity.name)
                return

            repo.bundle = bundle

            if args.clean:
                bundle.clean()

            # Re-create after cleaning is important for something ...

            bundle = bundle_class(bundle_dir)

            prt("{} Building ", bundle.identity.name)

            if not bundle.run_prepare():
                fatal("{} Prepare failed", bundle.identity.name)

            if not bundle.run_build():
                fatal("{} Build failed", bundle.identity.name)

        if args.install and not args.dryrun:
            if not bundle.run_install(force=True):
                fatal('{} Install failed', bundle.identity.name)

    build_dirs = {}

    # Find all of the dependencies for the named bundle, and make those first.
    for root, _, files in os.walk(rc.sourcerepo.dir):
        if 'bundle.yaml' in files:
            bundle_class = load_bundle(root)
            bundle = bundle_class(root)
            build_dirs[bundle.identity.name] = root

    if name:
        deps = repo.bundle_deps(name)
        deps.append(name)

    else:

        deps = []

        # Walk the subdirectory for the files to build, and
        # add all of their dependencies
        for root, _, files in os.walk(dir_):
            if 'bundle.yaml' in files:

                bundle_class = load_bundle(root)
                bundle = bundle_class(root)

                for dep in repo.bundle_deps(bundle.identity.name):
                    if dep not in deps:
                        deps.append(dep)

                deps.append(bundle.identity.name)

    for n in deps:
        try:
            dir_ = build_dirs[n]
        except KeyError:
            fatal("Failed to find directory for bundle {}".format(n))

        prt('')
        prt("{} Building in {}".format(n, dir_))
        build(dir_)