Пример #1
0
def list_gstreamer_1_0_plugins_by_category(config):
    cookbook = CookBook(config)
    plugins = defaultdict(list)
    for r in [
            'gstreamer-1.0', 'gst-plugins-base-1.0', 'gst-plugins-good-1.0',
            'gst-plugins-bad-1.0', 'gst-plugins-ugly-1.0', 'gst-libav-1.0',
            'gst-editing-services-1.0', 'gst-rtsp-server-1.0'
    ]:
        r = cookbook.get_recipe(r)
        for attr_name in dir(r):
            if attr_name.startswith('files_plugins_'):
                cat_name = attr_name[len('files_plugins_'):]
                plugins_list = getattr(r, attr_name)
            elif attr_name.startswith('platform_files_plugins_'):
                cat_name = attr_name[len('platform_files_plugins_'):]
                plugins_dict = getattr(r, attr_name)
                plugins_list = plugins_dict.get(config.target_platform, [])
            else:
                continue
            for e in plugins_list:
                if not e.startswith('lib/gstreamer-'):
                    continue
                c = e.split('/')
                if len(c) != 3:
                    continue
                e = c[2]
                if e.startswith('libgst'):
                    e = e[6:-8]
                else:
                    e = e[3:-8]
                plugins[cat_name].append(e)
    return plugins
Пример #2
0
    def run(self, config, args):
        cookbook = CookBook(config)
        failed = []
        p_name = args.package[0]

        store = PackagesStore(config)
        p = store.get_package(p_name)
        ordered_recipes = map(lambda x: cookbook.get_recipe(x),
                              p.recipes_dependencies())

        for recipe in ordered_recipes:
            if cookbook.recipe_needs_build(recipe.name):
                raise CommandError(
                    _("Recipe %s is not built yet" % recipe.name))

        for recipe in ordered_recipes:
            # call step function
            stepfunc = None
            try:
                stepfunc = getattr(recipe, 'check')
            except:
                m.message('%s has no check step, skipped' % recipe.name)

            if stepfunc:
                try:
                    m.message('Running checks for recipe %s' % recipe.name)
                    stepfunc()
                except Exception as ex:
                    failed.append(recipe.name)
                    m.warning(_("%s checks failed: %s") % (recipe.name, ex))
        if failed:
            raise CommandError(
                _("Error running %s checks on:\n    " + "\n    ".join(failed))
                % p_name)
Пример #3
0
def list_gstreamer_1_0_plugins_by_category(config):
        cookbook = CookBook(config)
        plugins = defaultdict(list)
        for r in ['gstreamer-1.0', 'gst-plugins-base-1.0', 'gst-plugins-good-1.0',
                  'gst-plugins-bad-1.0', 'gst-plugins-ugly-1.0',
                  'gst-libav-1.0', 'gst-editing-services-1.0', 'gst-rtsp-server-1.0']:
            r = cookbook.get_recipe(r)
            for attr_name in dir(r):
                if attr_name.startswith('files_plugins_'):
                    cat_name = attr_name[len('files_plugins_'):]
                    plugins_list = getattr(r, attr_name)
                elif attr_name.startswith('platform_files_plugins_'):
                    cat_name = attr_name[len('platform_files_plugins_'):]
                    plugins_dict = getattr(r, attr_name)
                    plugins_list = plugins_dict.get(config.target_platform, [])
                else:
                    continue
                for e in plugins_list:
                    if not e.startswith('lib/gstreamer-'):
                        continue
                    c = e.split('/')
                    if len(c) != 3:
                        continue
                    e = c[2]
                    # we only care about files with the replaceable %(mext)s extension
                    if not e.endswith ('%(mext)s'):
                        continue
                    if e.startswith('libgst'):
                        e = e[6:-8]
                    else:
                        e = e[3:-8]
                    plugins[cat_name].append(e)
        return plugins
Пример #4
0
    def run(self, config, args):
        cookbook = CookBook(config)
        if args.recipe == 'all':
            recipes = cookbook.get_recipes_list()
        else:
            recipes = [cookbook.get_recipe(args.recipe)]
        if len(recipes) == 0:
            m.message(_("No recipes found"))
        tagname = args.tagname
        tagdescription = args.tagdescription
        force = args.force
        for recipe in recipes:
            if recipe.stype != SourceType.GIT and \
               recipe.stype != SourceType.GIT_TARBALL:
                m.message(
                    _("Recipe '%s' has a custom source repository, "
                      "skipping") % recipe.name)
                continue

            recipe.fetch(checkout=False)

            tags = git.list_tags(recipe.repo_dir)
            exists = (tagname in tags)
            if exists:
                if not force:
                    m.warning(
                        _("Recipe '%s' tag '%s' already exists, "
                          "not updating" % (recipe.name, tagname)))
                    continue
                git.delete_tag(recipe.repo_dir, tagname)

            commit = 'origin/sdk-%s' % recipe.version
            git.create_tag(recipe.repo_dir, tagname, tagdescription, commit)
Пример #5
0
 def run(self, config, args):
     cookbook = CookBook(config)
     recipes = cookbook.get_recipes_list()
     if len(recipes) == 0:
         m.message(_("No recipes found"))
     for recipe in recipes:
         m.message("%s - %s" % (recipe.name, recipe.version))
Пример #6
0
    def run(self, config, args):
        cookbook = CookBook(config)
        recipe_name = args.recipe[0]
        recursive = args.recursive

        recipe = cookbook.get_recipe(recipe_name)

        if recursive:
            ordered_recipes = cookbook.list_recipe_deps(recipe_name)
        else:
            ordered_recipes = [recipe]

        for recipe in ordered_recipes:
            if cookbook.recipe_needs_build(recipe.name):
                raise FatalError(_("Recipe %s is not built yet" % recipe.name))

        for recipe in ordered_recipes:
            # call step function
            stepfunc = None
            try:
                stepfunc = getattr(recipe, 'check')
            except:
                m.message('%s has no check step, skipped' % recipe.name)

            if stepfunc:
                try:
                    stepfunc()
                except FatalError as e:
                    raise e
                except Exception as ex:
                    raise FatalError(_("Error running %s checks: %s") %
                        (recipe.name, ex))
Пример #7
0
    def run(self, config, args):
        cookbook = CookBook(config)
        recipe_name = args.recipe[0]
        all_deps = args.all
        graph = args.graph

        if all_deps:
            recipes = cookbook.list_recipe_deps(recipe_name)
        else:
            recipes = [cookbook.get_recipe(x) for x in
                        cookbook.get_recipe(recipe_name).list_deps()]

        if len(recipes) == 0:
            m.message(_('%s has 0 dependencies') % recipe_name)
            return
        if not graph:
            for recipe in recipes:
                # Don't print the recipe we asked for
                if recipe.name == recipe_name:
                    continue
                m.message(recipe.name)
        else:
            def print_dep(cookbook, recipe, level=0, already_shown=[]):
                m.message("%s%s" %( " " * 3 * level, recipe.name))
                already_shown.append(recipe)
                for r in [cookbook.get_recipe(x) for x in recipe.list_deps()]:
                    if not r in already_shown:
                        print_dep(cookbook, r, level + 1, already_shown)
                    elif not r.name == recipe.name:
                        m.message("%s(%s)" % ( " " * 3 * (level + 1), r.name))
            print_dep(cookbook, cookbook.get_recipe(recipe_name))
Пример #8
0
    def run(self, config, args):
        cookbook = CookBook(config)
        if args.recipe == 'all':
            recipes = cookbook.get_recipes_list()
        else:
            recipes = [cookbook.get_recipe(args.recipe)]
        if len(recipes) == 0:
            m.message(_("No recipes found"))
        tagname = args.tagname
        tagdescription = args.tagdescription
        force = args.force
        for recipe in recipes:
            if recipe.stype != SourceType.GIT and \
               recipe.stype != SourceType.GIT_TARBALL:
                m.message(_("Recipe '%s' has a custom source repository, "
                        "skipping") % recipe.name)
                continue

            recipe.fetch(checkout=False)

            tags = git.list_tags(recipe.repo_dir)
            exists = (tagname in tags)
            if exists:
                if not force:
                    m.warning(_("Recipe '%s' tag '%s' already exists, "
                            "not updating" % (recipe.name, tagname)))
                    continue
                git.delete_tag(recipe.repo_dir, tagname)

            commit = 'origin/sdk-%s' % recipe.version
            git.create_tag(recipe.repo_dir, tagname, tagdescription,
                    commit)
Пример #9
0
def list_gstreamer_plugins_by_category(config):
        cookbook = CookBook(config)
        # For plugins named differently
        replacements = {'decodebin2': 'uridecodebin', 'playbin': 'playback',
                        'encodebin': 'encoding', 'souphttpsrc': 'soup',
                        'siren': 'gstsiren', 'sdpelem': 'sdp',
                        'rtpmanager': 'gstrtpmanager', 'scaletempoplugin' : 'scaletempo',
                        'mpegdemux': 'mpegdemux2', 'rmdemux': 'realmedia'}
        plugins = defaultdict(list)
        for r in ['gstreamer', 'gst-plugins-base', 'gst-plugins-good',
                  'gst-plugins-bad', 'gst-plugins-ugly', 'gst-ffmpeg', 'gst-rtsp-server']:
            r = cookbook.get_recipe(r)
            for attr_name in dir(r):
                if attr_name.startswith('files_plugins_'):
                    cat_name = attr_name[len('files_plugins_'):]
                    plugins_list = getattr(r, attr_name)
                elif attr_name.startswith('platform_files_plugins_'):
                    cat_name = attr_name[len('platform_files_plugins_'):]
                    plugins_dict = getattr(r, attr_name)
                    plugins_list = plugins_dict.get(config.target_platform, [])
                else:
                    continue
                for e in plugins_list:
                    if not e.startswith('lib/gstreamer-'):
                        continue
                    plugins[cat_name].append(e[25:-8])
        return plugins, replacements
Пример #10
0
    def run(self, config, args):
        cookbook = CookBook(config)
        recipe_name = args.recipe[0]
        recursive = args.recursive

        recipe = cookbook.get_recipe(recipe_name)

        if recursive:
            ordered_recipes = cookbook.list_recipe_deps(recipe_name)
        else:
            ordered_recipes = [recipe]

        for recipe in ordered_recipes:
            if cookbook.recipe_needs_build(recipe.name):
                raise FatalError(_("Recipe %s is not built yet" % recipe.name))

        for recipe in ordered_recipes:
            # call step function
            stepfunc = None
            try:
                stepfunc = getattr(recipe, 'check')
            except:
                m.message('%s has no check step, skipped' % recipe.name)

            if stepfunc:
                try:
                    if asyncio.iscoroutinefunction(stepfunc):
                        run_until_complete(stepfunc())
                    else:
                        stepfunc()
                except FatalError as e:
                    raise e
                except Exception as ex:
                    raise FatalError(
                        _("Error running %s checks: %s") % (recipe.name, ex))
Пример #11
0
    def run(self, config, args):
        cookbook = CookBook(config)
        failed = []
        p_name = args.package[0]

        store = PackagesStore(config)
        p = store.get_package(p_name)
        ordered_recipes = map(lambda x: cookbook.get_recipe(x),
                    p.recipes_dependencies())

        for recipe in ordered_recipes:
            if cookbook.recipe_needs_build(recipe.name):
                raise CommandError(_("Recipe %s is not built yet" % recipe.name))

        for recipe in ordered_recipes:
            # call step function
            stepfunc = None
            try:
                stepfunc = getattr(recipe, 'check')
            except:
                m.message('%s has no check step, skipped' % recipe.name)

            if stepfunc:
                try:
                    m.message('Running checks for recipe %s' % recipe.name)
                    stepfunc()
                except Exception, ex:
                    failed.append(recipe.name)
                    m.warning(_("%s checks failed: %s") % (recipe.name, ex))
Пример #12
0
def create_cookbook(config):
    cb = CookBook(config, False)

    for klass in [Recipe1, Recipe2, Recipe3, Recipe4, Recipe5]:
        r = klass(config)
        r.__file__ = 'test/test_build_common.py'
        cb.add_recipe(r)
    return cb
Пример #13
0
def create_cookbook(config):
    cb = CookBook(config, False)

    for klass in [Recipe1, Recipe2, Recipe3, Recipe4, Recipe5]:
        r = klass(config)
        r.__file__ = "test/test_build_common.py"
        cb.add_recipe(r)
    return cb
Пример #14
0
    def run(self, config, args):
        cookbook = CookBook(config)
        recipe_name = args.recipe[0]

        recipes = cookbook.list_recipe_reverse_deps(recipe_name)
        if len(recipes) == 0:
            m.error(_('%s has 0 reverse dependencies') % recipe_name)
            return
        for recipe in recipes:
            m.message(recipe.name)
Пример #15
0
    def run(self, config, args):
        name = args.name[0]
        version = args.version[0]
        filename = os.path.join(config.recipes_dir, '%s.recipe' % name)
        if not args.force and os.path.exists(filename):
            m.warning(
                _("Recipe '%s' (%s) already exists, "
                  "use -f to replace" % (name, filename)))
            return

        template_args = {}

        template = RECEIPT_TPL
        template_args['name'] = name
        template_args['version'] = version

        if args.licenses:
            licenses = args.licenses.split(',')
            self.validate_licenses(licenses)
            template += LICENSES_TPL
            template_args['licenses'] = ', '.join(
                    ['License.' + self.supported_licenses[l] \
                        for l in licenses])

        if args.commit:
            template += COMMIT_TPL
            template_args['commit'] = args.commit

        if args.origin:
            template += ORIGIN_TPL
            template_args['origin'] = args.origin

        if args.deps:
            template += DEPS_TPL
            deps = args.deps.split(',')
            cookbook = CookBook(config)
            for dname in deps:
                try:
                    recipe = cookbook.get_recipe(dname)
                except RecipeNotFoundError as ex:
                    raise UsageError(
                        _("Error creating recipe: "
                          "dependant recipe %s does not exist") % dname)
            template_args['deps'] = deps

        try:
            f = open(filename, 'w')
            f.write(template % template_args)
            f.close()

            m.action(
                _("Recipe '%s' successfully created in %s") % (name, filename))
        except IOError as ex:
            raise FatalError(_("Error creating recipe: %s") % ex)
Пример #16
0
 def run(self, config, args):
     cookbook = CookBook(config)
     recipes = []
     for recipe in args.recipes:
         found = cookbook.get_closest_recipe(recipe)
         if found:
             recipes.append(found)
         else:
             recipes.append(recipe)
     return self.fetch(cookbook, recipes, args.no_deps, args.reset_rdeps,
                       args.full_reset, args.print_only, args.jobs)
Пример #17
0
    def run(self, config, args):
        cookbook = CookBook(config)
        recipes = cookbook.get_recipes_list()
        if len(recipes) == 0:
            m.message(_("No recipes found"))
        for recipe in recipes:
            try:
                current = recipe.built_version().split("\n")[0]
            except:
                current = "Not checked out"

            m.message("%s - %s (current checkout: %s)" % (recipe.name, recipe.version, current))
Пример #18
0
    def run(self, config, args):
        cookbook = CookBook(config)
        recipes = cookbook.get_recipes_list()
        if len(recipes) == 0:
            m.message(_("No recipes found"))
        for recipe in recipes:
            try:
                current = recipe.built_version().split("\n")[0]
            except:
                current = "Not checked out"

            m.message("%s - %s (current checkout: %s)" % (recipe.name, recipe.version, current))
Пример #19
0
    def run(self, config, args):
        name = args.name[0]
        version = args.version[0]
        filename = os.path.join(config.recipes_dir, '%s.recipe' % name)
        if not args.force and os.path.exists(filename):
            m.warning(_("Recipe '%s' (%s) already exists, "
                "use -f to replace" % (name, filename)))
            return

        template_args = {}

        template = RECEIPT_TPL
        template_args['name'] = name
        template_args['version'] = version

        if args.licenses:
            licenses = args.licenses.split(',')
            self.validate_licenses(licenses)
            template += LICENSES_TPL
            template_args['licenses'] = ', '.join(
                    ['License.' + self.supported_licenses[l] \
                        for l in licenses])

        if args.commit:
            template += COMMIT_TPL
            template_args['commit'] = args.commit

        if args.origin:
            template += ORIGIN_TPL
            template_args['origin'] = args.origin

        if args.deps:
            template += DEPS_TPL
            deps = args.deps.split(',')
            cookbook = CookBook(config)
            for dname in deps:
                try:
                    recipe = cookbook.get_recipe(dname)
                except RecipeNotFoundError as ex:
                    raise UsageError(_("Error creating recipe: "
                            "dependant recipe %s does not exist") % dname)
            template_args['deps'] = deps

        try:
            f = open(filename, 'w')
            f.write(template % template_args)
            f.close()

            m.action(_("Recipe '%s' successfully created in %s") %
                    (name, filename))
        except IOError as ex:
            raise FatalError(_("Error creating recipe: %s") % ex)
Пример #20
0
    def __init__(self, config, load=True):
        self._config = config

        self._packages = {}  # package_name -> package

        self.cookbook = CookBook(config, load)
        # used in tests to skip loading a dir with packages definitions
        if not load:
            return

        if not os.path.exists(config.packages_dir):
            raise FatalError(
                _("Packages dir %s not found") % config.packages_dir)
        self._load_packages()
Пример #21
0
    def run(self, config, args):
        if config.target_platform != Platform.WINDOWS:
            raise UsageError(_('%s command can only be used targetting '
                             'Windows platforms') % self.name)

        if args.output_dir is not None and not os.path.exists(args.output_dir):
            os.makedirs(args.output_dir)

        cookbook = CookBook(config)
        recipes = cookbook.get_recipes_list()
        for recipe in recipes:
            try:
                recipe.gen_library_file(args.output_dir)
            except Exception, e:
                m.message(_("Error generaring library files for %s:\n %s") %
                          (recipe.name, e))
Пример #22
0
    def start(self):
        # Use a common prefix for the build tools for all the configurations
        # so that it can be reused
        config = Config()
        os.environ.clear()
        os.environ.update(self.config._pre_environ)
        config.prefix = self.config.build_tools_prefix
        config.home_dir = self.config.home_dir
        config.load()

        config.prefix = self.config.build_tools_prefix
        config.build_tools_prefix = self.config.build_tools_prefix
        config.sources = self.config.build_tools_sources
        config.build_tools_sources = self.config.build_tools_sources
        config.cache_file = self.config.build_tools_cache
        config.build_tools_cache = self.config.build_tools_cache
        config.external_recipes = self.config.external_recipes

        if config.toolchain_prefix and not os.path.exists(
                config.toolchain_prefix):
            raise ConfigurationError(
                _("Please run bootstrap without any '-c' arguments first to setup build-tools for this machine"
                  ))
        if not os.path.exists(config.prefix):
            os.makedirs(config.prefix)
        if not os.path.exists(config.sources):
            os.makedirs(config.sources)

        config.do_setup_env()
        cookbook = CookBook(config)
        recipes = self.BUILD_TOOLS
        recipes += self.PLAT_BUILD_TOOLS.get(self.config.platform, [])
        oven = Oven(recipes, cookbook)
        oven.start_cooking()
        self.config.do_setup_env()
Пример #23
0
    def _setup_env(self):
        # Use a common prefix for the build tools for all the configurations
        # so that it can be reused
        config = Config()
        config.prefix = self.config.build_tools_prefix
        config.home_dir = self.config.home_dir
        config.local_sources = self.config.local_sources
        config.load()

        config.prefix = self.config.build_tools_prefix
        config.build_tools_prefix = self.config.build_tools_prefix
        config.sources = self.config.build_tools_sources
        config.build_tools_sources = self.config.build_tools_sources
        config.cache_file = self.config.build_tools_cache
        config.build_tools_cache = self.config.build_tools_cache
        config.external_recipes = self.config.external_recipes
        config.extra_mirrors = self.config.extra_mirrors
        config.cached_sources = self.config.cached_sources
        config.vs_install_path = self.config.vs_install_path
        config.vs_install_version = self.config.vs_install_version

        if config.toolchain_prefix and not os.path.exists(
                config.toolchain_prefix):
            os.makedirs(config.toolchain_prefix)
        if not os.path.exists(config.prefix):
            os.makedirs(config.prefix)
        if not os.path.exists(config.sources):
            os.makedirs(config.sources)

        config.do_setup_env()
        self.cookbook = CookBook(config, offline=self.offline)
        self.recipes = self.BUILD_TOOLS
        self.recipes += self.PLAT_BUILD_TOOLS.get(self.config.platform, [])
Пример #24
0
    def _setup_env(self):
        # Start with the original env that cerbero was called with
        os.environ.clear()
        os.environ.update(self.config._pre_environ)
        # Use a common prefix for the build tools for all the configurations
        # so that it can be reused
        config = Config()
        config.prefix = self.config.build_tools_prefix
        config.home_dir = self.config.home_dir
        config.local_sources = self.config.local_sources
        config.load()

        config.prefix = self.config.build_tools_prefix
        config.build_tools_prefix = self.config.build_tools_prefix
        config.sources = self.config.build_tools_sources
        config.build_tools_sources = self.config.build_tools_sources
        config.cache_file = self.config.build_tools_cache
        config.build_tools_cache = self.config.build_tools_cache
        config.external_recipes = self.config.external_recipes

        if config.toolchain_prefix and not os.path.exists(config.toolchain_prefix):
            os.makedirs(config.toolchain_prefix)
        if not os.path.exists(config.prefix):
            os.makedirs(config.prefix)
        if not os.path.exists(config.sources):
            os.makedirs(config.sources)

        config.do_setup_env()
        self.cookbook = CookBook(config, offline=self.offline)
        self.recipes = self.BUILD_TOOLS
        self.recipes += self.PLAT_BUILD_TOOLS.get(self.config.platform, [])
Пример #25
0
    def start(self):
        # Use a common prefix for the build tools for all the configurations
        # so that it can be reused
        config = Config()
        os.environ.clear()
        os.environ.update(self.config._pre_environ)
        config.prefix = self.config.build_tools_prefix
        config.home_dir = self.config.home_dir
        config.load()
        config.variants.python3 = False

        config.prefix = self.config.build_tools_prefix
        config.build_tools_prefix = self.config.build_tools_prefix
        config.sources = self.config.build_tools_sources
        config.build_tools_sources = self.config.build_tools_sources
        config.cache_file = self.config.build_tools_cache
        config.build_tools_cache = self.config.build_tools_cache
        config.external_recipes = self.config.external_recipes

        if not os.path.exists(config.prefix):
            os.makedirs(config.prefix)
        if not os.path.exists(config.sources):
            os.makedirs(config.sources)

        config.do_setup_env()
        cookbook = CookBook(config)
        recipes = self.BUILD_TOOLS
        recipes += self.PLAT_BUILD_TOOLS.get(self.config.platform, [])
        oven = Oven(recipes, cookbook)
        oven.start_cooking()
        self.config.do_setup_env()
Пример #26
0
    def run(self, config, args):
        if config.target_platform != Platform.WINDOWS:
            raise UsageError(_('%s command can only be used targetting '
                             'Windows platforms') % self.name)

        if args.output_dir is not None and not os.path.exists(args.output_dir):
            os.makedirs(args.output_dir)

        cookbook = CookBook(config)
        recipes = cookbook.get_recipes_list()
        for recipe in recipes:
            try:
                recipe.gen_library_file(args.output_dir)
            except Exception as e:
                m.message(_("Error generaring library files for %s:\n %s") %
                          (recipe.name, e))
Пример #27
0
    def run(self, config, args):
        if args.recipe + args.package + args.package_recipes == 0:
            m.error(
                'Error: You need to specify either recipe, package or package-recipes '
                'mode to generate the dependency graph')
            return

        if args.recipe + args.package + args.package_recipes > 1:
            m.error(
                'Error: You can only specify recipe, package or package-recipes but not more than one'
            )
            return

        if not shutil.which('dot'):
            m.error(
                'Error: dot command not found. Please install graphviz it using '
                'your package manager. e.g. apt/dnf/brew install graphviz')
            return

        label = ''
        if args.recipe:
            self.graph_type = GraphType.RECIPE
            label = 'recipe'
        elif args.package:
            self.graph_type = GraphType.PACKAGE
            label = 'package'
        elif args.package_recipes:
            self.graph_type = GraphType.PACKAGE_RECIPES
            label = 'package\'s recipes'

        if self.graph_type == GraphType.RECIPE or self.graph_type == GraphType.PACKAGE_RECIPES:
            self.cookbook = CookBook(config)
        if self.graph_type == GraphType.PACKAGE or self.graph_type == GraphType.PACKAGE_RECIPES:
            self.package_store = PackagesStore(config)

        name = args.name[0]
        output = args.output[0] if args.output else name + '.svg'

        tmp = tempfile.NamedTemporaryFile()
        dot = 'digraph {{\n\tlabel="{} {}";\n{}}}\n'.format(
            name, label, self._dot_gen(name, self.graph_type))
        with open(tmp.name, 'w') as f:
            f.write(dot)

        shell.new_call(['dot', '-Tsvg', tmp.name, '-o', output])
        m.message("Dependency graph for %s generated at %s" % (name, output))
Пример #28
0
def list_gstreamer_1_0_plugins_by_category(config):
    cookbook = CookBook(config)
    # For plugins named differently
    replacements = {
        'decodebin': 'playback',
        'playbin': 'playback',
        'uridecodebin': 'playback',
        'sdpelem': 'sdp',
        'encodebin': 'encoding',
        'souphttpsrc': 'soup',
        'siren': 'gstsiren',
        'scaletempoplugin': 'scaletempo',
        'rmdemux': 'realmedia',
        'camerabin2': 'camerabin'
    }
    plugins = defaultdict(list)
    for r in [
            'gstreamer-1.0', 'gst-plugins-base-1.0', 'gst-plugins-good-1.0',
            'gst-plugins-bad-1.0', 'gst-plugins-ugly-1.0', 'gst-libav-1.0',
            'gst-editing-services-1.0', 'gst-rtsp-server-1.0'
    ]:
        r = cookbook.get_recipe(r)
        for attr_name in dir(r):
            if attr_name.startswith('files_plugins_'):
                cat_name = attr_name[len('files_plugins_'):]
                plugins_list = getattr(r, attr_name)
            elif attr_name.startswith('platform_files_plugins_'):
                cat_name = attr_name[len('platform_files_plugins_'):]
                plugins_dict = getattr(r, attr_name)
                plugins_list = plugins_dict.get(config.target_platform, [])
            else:
                continue
            for e in plugins_list:
                if not e.startswith('lib/gstreamer-'):
                    continue
                c = e.split('/')
                if len(c) != 3:
                    continue
                e = c[2]
                if e.startswith('libgst'):
                    e = e[6:-8]
                else:
                    e = e[3:-8]
                plugins[cat_name].append(e)
    return plugins, replacements
Пример #29
0
    def runargs(self, config, fuzzy_recipes, missing_files=False, force=False,
                no_deps=False, cookbook=None, dry_run=False, offline=False,
                deps_only=False, jobs=None):
        if cookbook is None:
            cookbook = CookBook(config, offline=offline)

        recipes = []
        for recipe in fuzzy_recipes:
          found = cookbook.get_closest_recipe(recipe)
          if found:
            recipes.append(found)
          else:
            recipes.append(recipe)

        oven = Oven(recipes, cookbook, force=self.force,
                    no_deps=self.no_deps, missing_files=missing_files,
                    dry_run=dry_run, deps_only=deps_only, jobs=jobs)
        oven.start_cooking()
Пример #30
0
    def run(self, config, args):
        cookbook = CookBook(config)
        recipe_name = args.recipe[0]

        recipe = cookbook.get_recipe(recipe_name)
        # call step function
        stepfunc = None
        try:
            stepfunc = getattr(recipe, "clean")
        except:
            print "%s has no clean step, skipped" % recipe.name

        if stepfunc:
            try:
                stepfunc()
            except FatalError, e:
                raise e
            except Exception, ex:
                raise FatalError(_("Error running %s checks: %s") % (recipe.name, ex))
Пример #31
0
    def __getattr__(self, name):
        if name not in self.__dict__:

            if name == 'store':
                self.__dict__[name] = PackagesStore(self.config)

            if name == 'cookbook':
                self.__dict__[name] = CookBook(self.config)

        return self.__dict__[name]
Пример #32
0
    def run(self, config, args):
        # Load the cookbook which will parse all recipes and update config.bash_completions
        cookbook = CookBook(config)
        env = config.env.copy()
        if args.use_system_libs:
            add_system_libs(config, env, config.env)

        shell.enter_build_environment(config.target_platform,
                config.target_arch, sourcedir=None, env=env,
                bash_completions=config.bash_completions)
Пример #33
0
    def run(self, config, args):
        cookbook = CookBook(config)
        recipe_name = args.recipe[0]
        all_deps = args.all

        if all_deps:
            recipes = cookbook.list_recipe_deps(recipe_name)
        else:
            recipes = [cookbook.get_recipe(x) for x in
                        cookbook.get_recipe(recipe_name).list_deps()]

        if len(recipes) == 0:
            m.message(_('%s has 0 dependencies') % recipe_name)
            return
        for recipe in recipes:
            # Don't print the recipe we asked for
            if recipe.name == recipe_name:
                continue
            m.message(recipe.name)
Пример #34
0
    def run(self, config, args):
        cookbook = CookBook(config)
        recipe_name = args.recipe[0]

        recipe = cookbook.get_recipe(recipe_name)
        # call step function
        stepfunc = None
        try:
            stepfunc = getattr(recipe, 'clean')
        except:
            print('%s has no clean step, skipped' % recipe.name)

        if stepfunc:
            try:
                stepfunc()
            except FatalError as e:
                raise e
            except Exception as ex:
                raise FatalError(
                    _("Error running %s checks: %s") % (recipe.name, ex))
Пример #35
0
    def run(self, config, args):
        cookbook = CookBook(config)
        recipe_name = args.recipe[0]
        all_deps = args.all

        if all_deps:
            recipes = cookbook.list_recipe_deps(recipe_name)
        else:
            recipes = [
                cookbook.get_recipe(x)
                for x in cookbook.get_recipe(recipe_name).list_deps()
            ]

        if len(recipes) == 0:
            m.message(_('%s has 0 dependencies') % recipe_name)
            return
        for recipe in recipes:
            # Don't print the recipe we asked for
            if recipe.name == recipe_name:
                continue
            m.message(recipe.name)
Пример #36
0
    def run(self, config, args):
        cookbook = CookBook(config)
        recipe_name = args.recipe[0]
        all_deps = args.all
        graph = args.graph

        if all_deps:
            recipes = cookbook.list_recipe_deps(recipe_name)
        else:
            recipes = [
                cookbook.get_recipe(x)
                for x in cookbook.get_recipe(recipe_name).list_deps()
            ]

        if len(recipes) == 0:
            m.message(_('%s has 0 dependencies') % recipe_name)
            return
        if not graph:
            for recipe in recipes:
                # Don't print the recipe we asked for
                if recipe.name == recipe_name:
                    continue
                m.message(recipe.name)
        else:

            def print_dep(cookbook, recipe, level=0, already_shown=[]):
                m.message("%s%s" % (" " * 3 * level, recipe.name))
                already_shown.append(recipe)
                for r in [cookbook.get_recipe(x) for x in recipe.list_deps()]:
                    if not r in already_shown:
                        print_dep(cookbook, r, level + 1, already_shown)
                    elif not r.name == recipe.name:
                        m.message("%s(%s)" % (" " * 3 * (level + 1), r.name))

            print_dep(cookbook, cookbook.get_recipe(recipe_name))
Пример #37
0
    def run(self, config, args):
        # Load the cookbook which will parse all recipes and update config.bash_completions
        # We don't care about errors while loading recipes, which can happen
        # just because of the current configuration not matching what the
        # recipe supports
        cookbook = CookBook(config, skip_errors=True)
        env = config.env.copy()
        if args.use_system_libs:
            add_system_libs(config, env, config.env)

        shell.enter_build_environment(config.target_platform,
                config.target_arch, sourcedir=None, env=env,
                bash_completions=config.bash_completions)
Пример #38
0
    def _get(self):

        tools = Build_Tools(self.config)
        store  = PackagesStore(self.config)
        cookbook = CookBook(self.config)

        names  = tools.BUILD_TOOLS
        names += tools.PLAT_BUILD_TOOLS.get(self.config.platform, [])
        recipes ={}
        path = os.path.join(self.config.packages_dir,'custom.py')
        d={}
        parse_file(path,d )
        version = d['GStreamer'].version

        for name in names:
            recipes[name] = cookbook.get_recipe(name).version

        pkgname ='build-tools'

        tarball = '%s-%s-%s-%s'%( pkgname,
            self.config.platform,
            self.config.arch,
            version
        )

        return {
            'name':pkgname,
            'version': version,
            'prefix':self.config.build_tools_prefix,
            'deps':[],
            'platform':self.config.platform,
            'arch':self.config.arch,

            'tarball':{
                'runtime':{ 'filename':tarball +'.tar.bz2'}
            },
            'recipes': recipes
        }
Пример #39
0
    def __init__(self, config, load=True):
        self._config = config

        self._packages = {}  # package_name -> package

        self.cookbook = CookBook(config, load)
        # used in tests to skip loading a dir with packages definitions
        if not load:
            return

        if not os.path.exists(config.packages_dir):
            raise FatalError(_("Packages dir %s not found") %
                             config.packages_dir)
        self._load_packages()
Пример #40
0
def list_gstreamer_1_0_plugins_by_category(config):
        cookbook = CookBook(config)
        # For plugins named differently
        replacements = {'decodebin': 'playback', 'playbin': 'playback',
                        'uridecodebin': 'playback', 'sdpelem': 'sdp',
                        'encodebin': 'encoding', 'souphttpsrc': 'soup',
                        'siren': 'gstsiren', 'scaletempoplugin' : 'scaletempo',
                        'rmdemux': 'realmedia', 'camerabin2': 'camerabin'}
        plugins = defaultdict(list)
        for r in ['gstreamer-1.0', 'gst-plugins-base-1.0', 'gst-plugins-good-1.0',
                  'gst-plugins-bad-1.0', 'gst-plugins-ugly-1.0',
                  'gst-libav-1.0', 'gst-editing-services-1.0', 'gst-rtsp-server-1.0',
                  'gst-omx', 'gst-rpicamsrc']:
            r = cookbook.get_recipe(r)
            for attr_name in dir(r):
                if attr_name.startswith('files_plugins_'):
                    cat_name = attr_name[len('files_plugins_'):]
                    plugins_list = getattr(r, attr_name)
                elif attr_name.startswith('platform_files_plugins_'):
                    cat_name = attr_name[len('platform_files_plugins_'):]
                    plugins_dict = getattr(r, attr_name)
                    plugins_list = plugins_dict.get(config.target_platform, [])
                else:
                    continue
                for e in plugins_list:
                    if not e.startswith('lib/gstreamer-'):
                        continue
                    c = e.split('/')
                    if len(c) != 3:
                        continue
                    e = c[2]
                    if e.startswith('libgst'):
                        e = e[6:-8]
                    else:
                        e = e[3:-8]
                    plugins[cat_name].append(e)
        return plugins, replacements
Пример #41
0
    def start(self):
        # Use a common prefix for the build tools for all the configurations
        # so that it can be reused
        config = Config()
        os.environ.clear()
        os.environ.update(self.config._pre_environ)
        config.prefix = self.config.build_tools_prefix
        config.load()
        config.build_tools_prefix = self.config.build_tools_prefix
        config.sources = self.config.build_tools_sources
        config.build_tools_sources = self.config.build_tools_sources
        config.cache_file = self.config.build_tools_cache
        config.build_tools_cache = self.config.build_tools_cache
        config.external_recipes = self.config.external_recipes
        config.home_dir = self.config.home_dir
        config.local_sources = self.config.local_sources
        # We use a different repo to prevent clashes between the same recipe
        # compiled with different prefixes
        config.binary_repo = self.config.binary_repo + '/build-tools'
        config.binary_repo_username = self.config.binary_repo_username
        config.binary_repo_password = self.config.binary_repo_password
        config.cache_url = self.config.cache_url

        if not os.path.exists(config.prefix):
            os.makedirs(config.prefix)
        if not os.path.exists(config.sources):
            os.makedirs(config.sources)

        config.do_setup_env()
        cookbook = CookBook(config)
        recipes = self.BUILD_TOOLS
        recipes += self.PLAT_BUILD_TOOLS.get(self.config.platform, [])
        oven = Oven(cookbook)
        ordered_recipes = cookbook.list_recipes_deps(recipes)
        oven.start_cooking(ordered_recipes, self.use_binaries,
                self.upload_binaries, self.build_missing)
        self.config.do_setup_env()
Пример #42
0
    def start(self):
        # Use a common prefix for the build tools for all the configurations
        # so that it can be reused
        config = Config()
        os.environ.clear()
        os.environ.update(self.config._pre_environ)
        config.prefix = self.config.build_tools_prefix
        config.load()
        config.build_tools_prefix = self.config.build_tools_prefix
        config.sources = self.config.build_tools_sources
        config.build_tools_sources = self.config.build_tools_sources
        config.cache_file = self.config.build_tools_cache
        config.build_tools_cache = self.config.build_tools_cache
        config.external_recipes = self.config.external_recipes
        config.home_dir = self.config.home_dir
        config.local_sources = self.config.local_sources
        # We use a different repo to prevent clashes between the same recipe
        # compiled with different prefixes
        config.binary_repo = self.config.binary_repo + '/build-tools'
        config.binary_repo_username = self.config.binary_repo_username
        config.binary_repo_password = self.config.binary_repo_password
        config.cache_url = self.config.cache_url

        if not os.path.exists(config.prefix):
            os.makedirs(config.prefix)
        if not os.path.exists(config.sources):
            os.makedirs(config.sources)

        config.do_setup_env()
        cookbook = CookBook(config)
        recipes = self.BUILD_TOOLS
        recipes += self.PLAT_BUILD_TOOLS.get(self.config.platform, [])
        oven = Oven(cookbook)
        ordered_recipes = cookbook.list_recipes_deps(recipes)
        oven.start_cooking(ordered_recipes, self.use_binaries,
                           self.upload_binaries, self.build_missing)
        self.config.do_setup_env()
Пример #43
0
    def run(self, config, args):
        if args.bootstrap:
            config.cache_file = config.build_tools_cache
        cookbook = CookBook(config)

        is_modifying = False or args.touch or args.reset
        if not is_modifying:
            for attr in self.recipe_attributes:
                if getattr(args, attr) is not None:
                    is_modifying = True
                    break

        global_status = cookbook.status
        recipes = args.recipe or list(global_status.keys())

        m.message('{} cache values for recipes: {}'.format(
            'Showing' if not is_modifying else 'Modifying',
            ', '.join(recipes)))

        for recipe in recipes:
            if recipe not in global_status.keys():
                m.error('Recipe {} not in cookbook'.format(recipe))
                continue
            status = global_status[recipe]
            print('[{}]'.format(recipe))
            text = ''
            if is_modifying:
                text = 'Before\n'
            print('{}{}\n'.format(text, status))
            if is_modifying:
                if args.reset:
                    cookbook.reset_recipe_status(recipe)
                    m.message('Recipe {} reset'.format(recipe))
                else:
                    if args.touch:
                        status.touch()

                    for attr in self.recipe_attributes:
                        var = getattr(args, attr)
                        if var is not None:
                            if isinstance(getattr(self.recipe_status, attr),
                                          bool):
                                if var.lower() == 'true':
                                    var = True
                                elif var.lower() == 'false':
                                    var = False
                                else:
                                    m.error(
                                        'Error: Attribute "{}" needs to be either "True" or "False"'
                                        .format(attr))
                                    return
                            setattr(status, attr, var)

                    cookbook.save()
                    print('After\n{}\n'.format(status))
Пример #44
0
    def runargs(self,
                config,
                recipes,
                missing_files=False,
                force=False,
                no_deps=False,
                cookbook=None):
        if cookbook is None:
            cookbook = CookBook(config)

        oven = Oven(recipes,
                    cookbook,
                    force=self.force,
                    no_deps=self.no_deps,
                    missing_files=missing_files)
        oven.start_cooking()
class PackageTest(unittest.TestCase):

    def setUp(self):
        self.config = Config()
        self.config.cache_file = '/dev/null'
        self.cookbook = CookBook(self.config, False)

    def testSetGetConfig(self):
        self.assertEquals(self.config, self.cookbook.get_config())
        self.cookbook.set_config(None)
        self.assertIsNone(self.cookbook._config)

    def testCacheMissing(self):
        status = {'test': 'test'}
        self.cookbook.set_status(status)
        self.cookbook._restore_cache()
        self.assertEquals(self.cookbook.status, {})

    def testSaveCache(self):
        tmp = tempfile.NamedTemporaryFile()
        status = {'test': 'test'}
        self.cookbook.set_status(status)
        self.cookbook.get_config().cache_file = tmp.name
        self.cookbook.save()
        with open(self.cookbook._cache_file(self.config), 'rb') as f:
            loaded_status = pickle.load(f)
            self.assertEquals(status, loaded_status)

    def testLoad(self):
        tmp = tempfile.NamedTemporaryFile()
        status = {'test': 'test'}
        self.cookbook.get_config().cache_file = tmp.name
        with open(tmp.name, 'wb') as f:
            pickle.dump(status, f)
        self.cookbook._restore_cache()
        self.assertEquals(status, self.cookbook.status)

    def testAddGetRecipe(self):
        recipe = Recipe1(self.config)
        self.failUnlessRaises(RecipeNotFoundError, self.cookbook.get_recipe,
                              recipe.name)
        self.cookbook.add_recipe(recipe)
        self.assertEquals(recipe, self.cookbook.recipes[recipe.name])
        self.assertEquals(recipe, self.cookbook.get_recipe(recipe.name))
        self.assertEquals(self.cookbook.get_recipes_list(), [recipe])

    def testGetRecipesStatus(self):
        recipe = Recipe1(self.config)
        self.cookbook._restore_cache()
        self.assertEquals(self.cookbook.status, {})
        self.cookbook.add_recipe(recipe)
        self.assertEquals(len(self.cookbook.status), 0)
        status = self.cookbook._recipe_status(recipe.name)
        self.assertEquals(len(self.cookbook.status), 1)
        self.assertEquals(status.steps, [])
        status.steps.append('1')
        status = self.cookbook._recipe_status(recipe.name)
        self.assertEquals(len(self.cookbook.status), 1)
        self.assertEquals(status.steps[0], '1')

    def testUpdateStatus(self):
        recipe = Recipe1(self.config)
        self.cookbook.add_recipe(recipe)
        self.cookbook._restore_cache()
        self.cookbook.update_step_status(recipe.name, 'fetch')
        status = self.cookbook._recipe_status(recipe.name)
        self.assertEquals(status.steps, ['fetch'])
        self.cookbook.update_step_status(recipe.name, 'build')
        status = self.cookbook._recipe_status(recipe.name)
        self.assertEquals(status.steps, ['fetch', 'build'])
        self.cookbook.update_step_status(recipe.name, 'install')
        status = self.cookbook._recipe_status(recipe.name)
        self.assertEquals(status.steps, ['fetch', 'build', 'install'])
        for step in ['fetch', 'build', 'install']:
            self.assertTrue(self.cookbook.step_done(recipe.name, step))

    def testBuildStatus(self):
        recipe = Recipe1(self.config)
        self.cookbook.add_recipe(recipe)
        self.cookbook._restore_cache()
        self.cookbook.update_build_status(recipe.name, True)
        self.assertTrue(self.cookbook.status[recipe.name].needs_build)
        self.cookbook.update_build_status(recipe.name, False)
        self.assertFalse(self.cookbook.status[recipe.name].needs_build)

    def testResetRecipeStatus(self):
        recipe = Recipe1(self.config)
        self.cookbook.add_recipe(recipe)
        self.cookbook._restore_cache()
        self.cookbook.reset_recipe_status(recipe.name)
        status = self.cookbook._recipe_status(recipe.name)
        self.assertEquals(status.steps, [])
        self.assertTrue(self.cookbook.status[recipe.name].needs_build)
Пример #46
0
class PackagesStore (object):
    '''
    Stores a list of L{cerbero.packages.package.Package}
    '''

    PKG_EXT = '.package'

    def __init__(self, config, load=True):
        self._config = config

        self._packages = {}  # package_name -> package

        self.cookbook = CookBook(config, load)
        # used in tests to skip loading a dir with packages definitions
        if not load:
            return

        if not os.path.exists(config.packages_dir):
            raise FatalError(_("Packages dir %s not found") %
                             config.packages_dir)
        self._load_packages()

    def get_packages_list(self):
        '''
        Gets the list of packages

        @return: list of packages
        @rtype: list
        '''
        packages = self._packages.values()
        packages.sort(key=lambda x: x.name)
        return packages

    def get_package(self, name):
        '''
        Gets a recipe from its name

        @param name: name of the package
        @type name: str
        @return: the package instance
        @rtype: L{cerbero.packages.package.Package}
        '''
        if name not in self._packages:
            raise PackageNotFoundError(name)
        return self._packages[name]

    def get_package_deps(self, pkg, recursive=False):
        '''
        Gets the dependencies of a package

        @param package: name of the package or package instance
        @type package: L{cerbero.packages.package.Package}
        @return: a list with the package dependencies
        @rtype: list
        '''
        if isinstance(pkg, str):
            pkg = self.get_package(pkg)
        if isinstance(pkg, package.MetaPackage):
            ret = self._list_metapackage_deps(pkg)
        else:
            ret = [self.get_package(x) for x in pkg.deps]
        # get deps recursively
        if recursive:
            for p in ret:
                ret.extend(self.get_package_deps(p, recursive))
        return remove_list_duplicates(ret)

    def get_package_files_list(self, name):
        '''
        Gets the list of files provided by a package

        @param name: name of the package
        @type name: str
        @return: the package instance
        @rtype: L{cerbero.packages.package.PackageBase}
        '''
        p = self.get_package(name)

        if isinstance(p, package.MetaPackage):
            return sorted(self._list_metapackage_files(p))
        else:
            return sorted(p.files_list())

    def add_package(self, package):
        '''
        Adds a new package to the store

        @param package: the package to add
        @type  package: L{cerbero.packages.package.PackageBase}
        '''
        self._packages[package.name] = package

    def get_package_recipes_deps(self, package_name):
        '''
        Gets the list of recipes needed to create this package

        @param name: name of the package
        @type name: str
        @return: a list with the recipes required to build this package
        @rtype: list
        '''
        deps = self.get_package_deps(package_name)
        return [self.cookbok.get_recipe(x) for x in deps]

    def _list_metapackage_deps(self, metapackage):

        def get_package_deps(package_name, visited=[], depslist=[]):
            if package_name in visited:
                return
            visited.append(package_name)
            p = self.get_package(package_name)
            depslist.append(p)
            for p_name in p.deps:
                get_package_deps(p_name, visited, depslist)
            return depslist

        deps = []
        for p in metapackage.list_packages():
            deps.extend(get_package_deps(p, [], []))
        return remove_list_duplicates(deps)

    def _list_metapackage_files(self, metapackage):
        l = []
        for p in self._list_metapackage_deps(metapackage):
            l.extend(p.files_list())
        # remove duplicates and sort
        return sorted(list(set(l)))

    def _load_packages(self):
        self._packages = {}
        packages = defaultdict(dict)
        repos = self._config.get_packages_repos()
        for reponame, (repodir, priority) in repos.iteritems():
            packages[int(priority)].update(
                    self._load_packages_from_dir(repodir))
        # Add packages by ascending pripority
        for key in sorted(packages.keys()):
            self._packages.update(packages[key])
        # Add a package for every recipe
        for recipe in self.cookbook.get_recipes_list():
            if not recipe.allow_package_creation:
                continue
            p = self._package_from_recipe(recipe)
            if p.name in self._packages.keys():
                m.warning("Package with name '%s' already exists, not including it", p.name)
            else:
                self._packages[p.name] = p

    def _package_from_recipe(self, recipe):
        p = package.Package(self._config, self, self.cookbook)
        p.name = '%s-pkg' % recipe.name
        p.license = recipe.licenses
        if recipe.built_version():
            version = recipe.built_version()
        else:
            version = recipe.version
        p.version = '%s-%s' % (version, self.cookbook.recipe_file_hash(recipe.name))
        p.files = ['%s' % recipe.name]
        p.load_files()
        return p

    def _load_packages_from_dir(self, repo):
        packages_dict = {}
        packages = shell.find_files('*%s' % self.PKG_EXT, repo)
        packages.extend(shell.find_files('*/*%s' % self.PKG_EXT, repo))
        for f in packages:
            p = self._load_package_from_file(f)
            if p is None:
                m.warning(_("Could not found a valid package in %s") % f)
                continue
            packages_dict[p.name] = p
        return packages_dict


    def _load_package_from_file(self, filepath):
        mod_name, file_ext = os.path.splitext(os.path.split(filepath)[-1])

        try:
            d = {'Platform': Platform, 'Architecture': Architecture,
                 'Distro': Distro, 'DistroVersion': DistroVersion,
                 'License': License, 'package': package,
                 'PackageType': PackageType}
            parse_file(filepath, d)
            if 'Package' in d:
                p = d['Package'](self._config, self, self.cookbook)
            elif 'SDKPackage' in d:
                p = d['SDKPackage'](self._config, self)
            elif 'InstallerPackage' in d:
                p = d['InstallerPackage'](self._config, self)
            elif 'App' in d:
                p = d['App'](self._config, self, self.cookbook)
            elif 'AppExtensionPackage' in d:
                p = d['AppExtensionPackage'](self._config, self, self.cookbook)
            else:
                raise Exception('Package, SDKPackage, InstallerPackage or App '
                                'class not found')
            p.__file__ = os.path.abspath(filepath)
            p.prepare()
            # reload files from package now that we called prepare that
            # may have changed it
            p.load_files()
            return p
        except Exception, ex:
            import traceback
            traceback.print_exc()
            m.warning("Error loading package %s" % ex)
        return None
 def setUp(self):
     self.config = Config()
     self.config.cache_file = '/dev/null'
     self.cookbook = CookBook(self.config, False)
Пример #48
0
    def run(self, config, args):
        packages = []
        recipes = []
        bundle_recipes = []
        bundle_dirs = []
        setup_args = ['sdist']

        if not config.uninstalled:
            m.error("Can only be run on cerbero-uninstalled")

        store = PackagesStore(config)
        cookbook = CookBook(config)

        packages = list(args.bundlepackages)

        for p in packages:
            package = store.get_package(p)
            if hasattr(package, 'list_packages'):
                packages += package.list_packages()
        packages = remove_list_duplicates(packages)

        for p in packages:
            package = store.get_package(p)
            if hasattr(package, 'deps'):
                packages += package.deps
        packages = remove_list_duplicates(packages)

        for p in packages:
            package = store.get_package(p)
            recipes += package.recipes_dependencies()
        recipes += args.add_recipe

        for r in recipes:
            bundle_recipes += cookbook.list_recipe_deps(r)
        bundle_recipes = remove_list_duplicates(bundle_recipes)

        for p in packages:
            setup_args.append('--package=' + p)

        for r in bundle_recipes:
            setup_args.append('--recipe=' + r.name)
            if r.stype != SourceType.CUSTOM:
                bundle_dirs.append(r.repo_dir)

        if not args.no_bootstrap:
            build_tools = BuildTools(config)
            bs_recipes = build_tools.BUILD_TOOLS + \
                         build_tools.PLAT_BUILD_TOOLS.get(config.platform, [])
            b_recipes = []
            for r in bs_recipes:
                b_recipes += cookbook.list_recipe_deps(r)
            b_recipes = remove_list_duplicates(b_recipes)

            for r in b_recipes:
                if r.stype != SourceType.CUSTOM:
                    bundle_dirs.append(r.repo_dir)

        setup_args.append('--source-dirs=' + ','.join(bundle_dirs))

        command = str(config._relative_path('setup.py'))
        run_setup(command, setup_args)