def _create_dep_graph(self, formula_name, formula_path=[]): def _add_node(graph, formula): for dep_name, options in formula.depends_on.iteritems(): dep_formula = formulamanager.get(dep_name, self._context, options, formula_path) _add_node(self._dep_graph, dep_formula) self._dep_graph.add_node(formula.name, formula.depends_on.keys()) formula = formulamanager.get(formula_name, self._context, search_path=formula_path) for dep_name, options in formula.depends_on.iteritems(): _add_node(self._dep_graph, formulamanager.get(dep_name, self._context, options, formula_path))
def _install(self, formula_name, **kwargs): formula = formulamanager.get(formula_name, self._context) formula_options = {} force_install = False clean_src = False if kwargs.has_key("formula_options"): formula_options = kwargs["formula_options"] if kwargs.has_key("variant"): formula_options["variant"] = kwargs["variant"] if kwargs.has_key("force"): force_install = kwargs["force"] if kwargs.has_key("clean_src"): clean_src = kwargs["clean_src"] formula.set_options(formula_options) if not formula.is_kit and (force_install or not self._bundle.is_installed(formula.name)): if clean_src: build_src_dir = os.path.join(self._context.build_dir, "{0}-{1}".format(formula.name, formula.version)) if os.path.exists(build_src_dir): fileutils.remove(build_src_dir) src_dir = sourcemanager.get_source(config.global_config().build_dir(), formula.name, formula.version, formula.source) old_cwd = os.getcwd() os.chdir(src_dir) if formula.patches: path1 = os.path.join(formula.dir, "patches", formula.name) if formula.dir.endswith(config.os_name()): path2 = os.path.normpath(os.path.join(formula.dir, "..", "patches", formula.name)) else: path2 = os.path.join(formula.dir, config.os_name(), "patches", formula.name) patch_dirs = [path1, path2] sourcemanager.patch_source(formula.patches, patch_dirs, src_dir) #make sure we have clean install dir for each formula if os.path.exists(self._context.install_dir): fileutils.remove(self._context.install_dir) try: os.mkdir(self._context.install_dir) except OSError: #On Windows, it is sometimes necessary to wait a little after deleting a #directory before creating it again time.sleep(0.01) os.mkdir(self._context.install_dir) self._call_hook_functions(self.hooks.pre_build) logging.getLogger().info("Building {0}...".format(formula.name)) fileset = formula.build() self._call_hook_functions(self.hooks.post_build) logging.getLogger().info("Done") logging.getLogger().info("Installing {0}...".format(formula.name)) self._bundle.install(formula.name, formula.version, formula.depends_on.keys(), fileset, force_install) self._call_hook_functions(self.hooks.post_install) logging.getLogger().info("Done") os.chdir(old_cwd)