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)
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()
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))
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
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)
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))
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, [])
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, [])
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()
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
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))
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
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)
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]
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)
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))
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)
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)
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))
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)
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 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))
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()
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))
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
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()
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))
def runargs(self, config, recipes, missing_files=False, force=False, no_deps=False, cookbook=None, dry_run=False, offline=False, deps_only=False): if cookbook is None: cookbook = CookBook(config, offline=offline) oven = Oven(recipes, cookbook, force=self.force, no_deps=self.no_deps, missing_files=missing_files, dry_run=dry_run, deps_only=deps_only) oven.start_cooking()
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)
def run(self, config, args): import cerbero import os from cerbero.build.recipe import BuildSteps cerbero.build.recipe.Recipe.package_name = os.path.basename( args.directory) cerbero.build.recipe.Recipe._default_steps = [] if args.fetch: cerbero.build.recipe.Recipe._default_steps.append(BuildSteps.FETCH) cerbero.build.recipe.Recipe._default_steps.append( BuildSteps.EXTRACT) if args.configure: cerbero.build.recipe.Recipe._default_steps.append( BuildSteps.CONFIGURE) if args.compile: cerbero.build.recipe.Recipe._default_steps.append( BuildSteps.COMPILE) if args.check: cerbero.build.recipe.Recipe._default_steps.append(BuildSteps.CHECK) if args.install: cerbero.build.recipe.Recipe._default_steps.append( BuildSteps.INSTALL) cerbero.build.recipe.Recipe._default_steps.append( BuildSteps.POST_INSTALL) config.sources = os.path.dirname(args.directory) config.local_sources = os.path.dirname(args.local_sources) config.repo_dir = os.path.dirname(args.local_sources) cookbook = CookBook(config) oven = Oven(args.recipe, cookbook, force=True, no_deps=True, missing_files=False, dry_run=args.dry_run) oven.start_cooking()