def bundle(self): # If not devel wanted, we make a clean bundle with only # file needed to execute steps = [ ("prepare-install-dir", [(_("Copy install path"), self._copy_installdir, True), (_("Installing bundle files"), self._install_bundle_specific_files, True), (_("Make all paths relatives"), self._make_paths_relative, True), ] ), ("generate-tarball", [(_("Running AppImageAssistant"), self._generate_bundle, True), (_("Generating md5"), self._generate_md5sum, True) ] ), ("clean-install-dir", [(_("Clean tmp dirs"), self._clean_tmps, not self.keep_temp)] ) ] for step in steps: shell.set_logfile_output("%s/%s-bundle-%s.log" % (self.config.logs, self.package.name, step[0])) for substep in step[1]: m.build_step('1', '1', self.package.name + " linux bundle", substep[0]) if substep[2] is True: substep[1]() else: m.action(_("Step not wanted")) shell.close_logfile_output()
def _cook_recipe(self, recipe, count, total): if not self.cookbook.recipe_needs_build(recipe.name) and \ not self.force: m.build_step(count, total, recipe.name, _("already built")) return if self.missing_files: # create a temp file that will be used to find newer files tmp = tempfile.NamedTemporaryFile() recipe.force = self.force for desc, step in recipe.steps: m.build_step(count, total, recipe.name, step) # check if the current step needs to be done if self.cookbook.step_done(recipe.name, step) and not self.force: m.action(_("Step done")) continue try: # call step function stepfunc = getattr(recipe, step) if not stepfunc: raise FatalError(_('Step %s not found') % step) stepfunc() # update status successfully self.cookbook.update_step_status(recipe.name, step) except FatalError: self._handle_build_step_error(recipe, step) except Exception: raise BuildStepError(recipe, step, traceback.format_exc()) self.cookbook.update_build_status(recipe.name, recipe.built_version()) if self.missing_files: self._print_missing_files(recipe, tmp)
def _cook_recipe(self, recipe, count, total): if not self.cookbook.recipe_needs_build(recipe.name) and \ not self.force: m.build_step(count, total, recipe.name, _("already built")) return if self.missing_files: # create a temp file that will be used to find newer files tmp = tempfile.NamedTemporaryFile() recipe.force = self.force for desc, step in recipe.steps: m.build_step(count, total, recipe.name, step) # check if the current step needs to be done if self.cookbook.step_done(recipe.name, step) and not self.force: m.action(_("Step done")) continue try: # call step function stepfunc = getattr(recipe, step) if not stepfunc: raise FatalError(_('Step %s not found') % step) shell.set_logfile_output("%s/%s-%s.log" % (recipe.config.logs, recipe, step)) stepfunc() # update status successfully self.cookbook.update_step_status(recipe.name, step) shell.close_logfile_output() except FatalError, e: shell.close_logfile_output(dump=True) self._handle_build_step_error(recipe, step, e.arch) except Exception: shell.close_logfile_output(dump=True) raise BuildStepError(recipe, step, traceback.format_exc())
def bundle(self): # If not devel wanted, we make a clean bundle with only # file needed to execute steps = [("prepare-install-dir", [ (_("Copy install path"), self._copy_installdir, True), (_("Installing bundle files"), self._install_bundle_specific_files, True), (_("Make all paths relatives"), self._make_paths_relative, True), ]), ("generate-tarball", [(_("Running AppImageAssistant"), self._generate_bundle, True), (_("Generating md5"), self._generate_md5sum, True)]), ("clean-install-dir", [(_("Clean tmp dirs"), self._clean_tmps, not self.keep_temp)])] for step in steps: shell.set_logfile_output( "%s/%s-bundle-%s.log" % (self.config.logs, self.package.name, step[0])) for substep in step[1]: m.build_step('1', '1', self.package.name + " linux bundle", substep[0]) if substep[2] is True: substep[1]() else: m.action(_("Step not wanted")) shell.close_logfile_output()
def fetch(self, cookbook, recipes, no_deps, reset_rdeps): fetch_recipes = [] if not recipes: fetch_recipes = cookbook.get_recipes_list() elif no_deps: fetch_recipes = [cookbook.get_recipe(x) for x in recipes] else: for recipe in recipes: fetch_recipes += cookbook.list_recipe_deps(recipe) fetch_recipes = remove_list_duplicates (fetch_recipes) m.message(_("Fetching the following recipes: %s") % ' '.join([x.name for x in fetch_recipes])) to_rebuild = [] for i in range(len(fetch_recipes)): recipe = fetch_recipes[i] m.build_step(i + 1, len(fetch_recipes), recipe, 'Fetch') recipe.fetch() bv = cookbook.recipe_built_version(recipe.name) cv = recipe.built_version() if bv != cv: to_rebuild.append(recipe) cookbook.reset_recipe_status(recipe.name) if reset_rdeps: for r in cookbook.list_recipe_reverse_deps(recipe.name): to_rebuild.append(r) cookbook.reset_recipe_status(r.name) if to_rebuild: m.message(_("These recipes have been updated and will " "be rebuilt:\n%s") % '\n'.join([x.name for x in to_rebuild]))
def already_built(self, count, total, recipe_name): self.count += 1 if self.interactive: m.build_step(self.count, self.total, recipe_name, _("already built")) else: m.build_step(count, total, recipe_name, _("already built")) self.output_status_line()
def update_recipe_step(self, count, total, recipe_name, step): if not self.interactive: m.build_step(count, total, recipe_name, step) return self.remove_recipe(recipe_name) self.step_to_recipe[step].append(recipe_name) self.recipe_to_step[recipe_name] = step self.output_status_line()
def _cook_recipe(self, recipe, count, total): # A Recipe depending on a static library that has been rebuilt # also needs to be rebuilt to pick up the latest build. if recipe.library_type != LibraryType.STATIC: if len(set(self._static_libraries_built) & set(recipe.deps)) != 0: self.cookbook.reset_recipe_status(recipe.name) if not self.cookbook.recipe_needs_build(recipe.name) and \ not self.force: m.build_step(count, total, recipe.name, _("already built")) return if self.missing_files: # create a temp file that will be used to find newer files tmp = tempfile.NamedTemporaryFile() recipe.force = self.force for desc, step in recipe.steps: m.build_step(count, total, recipe.name, step) # check if the current step needs to be done if self.cookbook.step_done(recipe.name, step) and not self.force: m.action(_("Step done")) continue try: # call step function stepfunc = getattr(recipe, step) if not stepfunc: raise FatalError(_('Step %s not found') % step) if asyncio.iscoroutinefunction(stepfunc): run_until_complete(stepfunc()) else: stepfunc() # update status successfully self.cookbook.update_step_status(recipe.name, step) except FatalError as e: exc_traceback = sys.exc_info()[2] trace = '' # Don't print trace if the FatalError is merely that the # subprocess exited with a non-zero status. The traceback # is just confusing and useless in that case. if not isinstance(e.__context__, CalledProcessError): tb = traceback.extract_tb(exc_traceback)[-1] if tb.filename.endswith('.recipe'): # Print the recipe and line number of the exception # if it starts in a recipe trace += 'Exception at {}:{}\n'.format( tb.filename, tb.lineno) trace += e.args[0] + '\n' self._handle_build_step_error(recipe, step, trace, e.arch) except Exception: raise BuildStepError(recipe, step, traceback.format_exc()) self.cookbook.update_build_status(recipe.name, recipe.built_version()) if recipe.library_type == LibraryType.STATIC: self._static_libraries_built.append(recipe.name) if self.missing_files: self._print_missing_files(recipe, tmp) tmp.close()
def _cook_recipe(self, recipe, count, total): if not self.cookbook.recipe_needs_build(recipe.name) and \ not self.force: m.build_step(count, total, recipe.name, _("already built")) return if self.missing_files: # create a temp file that will be used to find newer files tmp = tempfile.NamedTemporaryFile() recipe.force = self.force for desc, step in recipe.steps: m.build_step(count, total, recipe.name, step) # check if the current step needs to be done if self.cookbook.step_done(recipe.name, step) and not self.force: m.action(_("Step done")) continue try: # call step function stepfunc = getattr(recipe, step) if not stepfunc: raise FatalError(_('Step %s not found') % step) if asyncio.iscoroutinefunction(stepfunc): loop = asyncio.get_event_loop() # On Windows the default SelectorEventLoop is not available: # https://docs.python.org/3.5/library/asyncio-subprocess.html#windows-event-loop if recipe.config.platform == Platform.WINDOWS and \ not isinstance(loop, asyncio.ProactorEventLoop): loop = asyncio.ProactorEventLoop() asyncio.set_event_loop(loop) loop.run_until_complete(stepfunc(recipe)) else: stepfunc() # update status successfully self.cookbook.update_step_status(recipe.name, step) except FatalError as e: exc_traceback = sys.exc_info()[2] trace = '' # Don't print trace if the FatalError is merely that the # subprocess exited with a non-zero status. The traceback # is just confusing and useless in that case. if not isinstance(e.__context__, CalledProcessError): tb = traceback.extract_tb(exc_traceback)[-1] if tb.filename.endswith('.recipe'): # Print the recipe and line number of the exception # if it starts in a recipe trace += 'Exception at {}:{}\n'.format( tb.filename, tb.lineno) trace += e.args[0] + '\n' self._handle_build_step_error(recipe, step, trace, e.arch) except Exception: raise BuildStepError(recipe, step, traceback.format_exc()) self.cookbook.update_build_status(recipe.name, recipe.built_version()) if self.missing_files: self._print_missing_files(recipe, tmp) tmp.close()
def _cook_recipe(self, recipe, count, total): if not self.force and \ self.cookbook._installed_recipes.has_key(recipe.name): from cerbero.utils import messages as m m.build_step(count, total, recipe.name, "installed") return _old_cook_recipe(self, recipe, count, total)
def update_recipe_step(self, count, recipe_name, step): self.remove_recipe(recipe_name) self.step_to_recipe[step].append(recipe_name) self.recipe_to_step[recipe_name] = step if not self.interactive: m.build_step(count, self.total, self._get_completion_percent(), recipe_name, step) else: self.output_status_line()
def fetch(cookbook, recipes, no_deps, reset_rdeps, full_reset, print_only, jobs): fetch_recipes = [] if not recipes: fetch_recipes = cookbook.get_recipes_list() elif no_deps: fetch_recipes = [cookbook.get_recipe(x) for x in recipes] else: for recipe in recipes: fetch_recipes += cookbook.list_recipe_deps(recipe) fetch_recipes = remove_list_duplicates(fetch_recipes) m.message( _("Fetching the following recipes using %s async job(s): %s") % (jobs, ' '.join([x.name for x in fetch_recipes]))) shell.set_max_non_cpu_bound_calls(jobs) to_rebuild = [] tasks = [] for i in range(len(fetch_recipes)): recipe = fetch_recipes[i] if print_only: # For now just print tarball URLs if isinstance(recipe, Tarball): m.message("TARBALL: {} {}".format(recipe.url, recipe.tarball_name)) continue stepfunc = getattr(recipe, 'fetch') if asyncio.iscoroutinefunction(stepfunc): tasks.append(stepfunc()) else: m.build_step(i + 1, len(fetch_recipes), recipe, 'fetch started') stepfunc() bv = cookbook.recipe_built_version(recipe.name) cv = recipe.built_version() if bv != cv: # On different versions, only reset recipe if: # * forced # * OR it was fully built already if full_reset or not cookbook.recipe_needs_build(recipe.name): to_rebuild.append(recipe) cookbook.reset_recipe_status(recipe.name) if recipe.library_type == LibraryType.STATIC or reset_rdeps: for r in cookbook.list_recipe_reverse_deps( recipe.name): to_rebuild.append(r) cookbook.reset_recipe_status(r.name) run_until_complete(tasks) m.message("All async fetch jobs finished") if to_rebuild: to_rebuild = sorted(list(set(to_rebuild)), key=lambda r: r.name) m.message( _("These recipes have been updated and will " "be rebuilt:\n%s") % '\n'.join([x.name for x in to_rebuild]))
def _cook_recipe(self, recipe, count, total): if not self.cookbook.recipe_needs_build(recipe.name) and \ not self.force: m.build_step(count, total, recipe.name, _("already built")) return if self.missing_files: # create a temp file that will be used to find newer files tmp = tempfile.NamedTemporaryFile() recipe.force = self.force for desc, step in recipe.steps: m.build_step(count, total, recipe.name, step) # check if the current step needs to be done if self.cookbook.step_done(recipe.name, step) and not self.force: m.action(_("Step done")) continue try: # call step function stepfunc = getattr(recipe, step) if not stepfunc: raise FatalError(_('Step %s not found') % step) shell.set_logfile_output("%s/%s-%s.log" % (recipe.config.logs, recipe, step)) stepfunc() # update status successfully self.cookbook.update_step_status(recipe.name, step) shell.close_logfile_output() except FatalError as e: shell.close_logfile_output(dump=True) exc_traceback = sys.exc_info()[2] trace = '' # Don't print trace if the FatalError is merely that the # subprocess exited with a non-zero status. The traceback # is just confusing and useless in that case. if not isinstance(e.__context__, CalledProcessError): tb = traceback.extract_tb(exc_traceback)[-1] if tb.filename.endswith('.recipe'): # Print the recipe and line number of the exception # if it starts in a recipe trace += 'Exception at {}:{}\n'.format( tb.filename, tb.lineno) trace += e.args[0] + '\n' self._handle_build_step_error(recipe, step, trace, e.arch) except Exception: shell.close_logfile_output(dump=True) raise BuildStepError(recipe, step, traceback.format_exc()) self.cookbook.update_build_status(recipe.name, recipe.built_version()) if self.missing_files: self._print_missing_files(recipe, tmp) tmp.close()
def fetch(cookbook, recipes, no_deps, reset_rdeps, full_reset, print_only): fetch_recipes = [] if not recipes: fetch_recipes = cookbook.get_recipes_list() elif no_deps: fetch_recipes = [cookbook.get_recipe(x) for x in recipes] else: for recipe in recipes: fetch_recipes += cookbook.list_recipe_deps(recipe) fetch_recipes = remove_list_duplicates(fetch_recipes) m.message( _("Fetching the following recipes: %s") % ' '.join([x.name for x in fetch_recipes])) to_rebuild = [] for i in range(len(fetch_recipes)): recipe = fetch_recipes[i] if print_only: # For now just print tarball URLs if isinstance(recipe, Tarball): m.message("TARBALL: {} {}".format(recipe.url, recipe.tarball_name)) continue m.build_step(i + 1, len(fetch_recipes), recipe, 'Fetch') stepfunc = getattr(recipe, 'fetch') if asyncio.iscoroutinefunction(stepfunc): loop = asyncio.get_event_loop() loop.run_until_complete(stepfunc(recipe)) else: stepfunc() bv = cookbook.recipe_built_version(recipe.name) cv = recipe.built_version() if bv != cv: # On different versions, only reset recipe if: # * forced # * OR it was fully built already if full_reset or not cookbook.recipe_needs_build(recipe.name): to_rebuild.append(recipe) cookbook.reset_recipe_status(recipe.name) if reset_rdeps: for r in cookbook.list_recipe_reverse_deps( recipe.name): to_rebuild.append(r) cookbook.reset_recipe_status(r.name) if to_rebuild: to_rebuild = sorted(list(set(to_rebuild)), key=lambda r: r.name) m.message( _("These recipes have been updated and will " "be rebuilt:\n%s") % '\n'.join([x.name for x in to_rebuild]))
def fetch(self, cookbook, recipes, no_deps, reset_rdeps, full_reset, print_only): fetch_recipes = [] if not recipes: fetch_recipes = cookbook.get_recipes_list() elif no_deps: fetch_recipes = [cookbook.get_recipe(x) for x in recipes] else: for recipe in recipes: fetch_recipes += cookbook.list_recipe_deps(recipe) fetch_recipes = remove_list_duplicates (fetch_recipes) m.message(_("Fetching the following recipes: %s") % ' '.join([x.name for x in fetch_recipes])) to_rebuild = [] for i in range(len(fetch_recipes)): recipe = fetch_recipes[i] if print_only: # For now just print tarball URLs if isinstance(recipe, Tarball): m.message("TARBALL: {} {}".format(recipe.url, recipe.tarball_name)) continue m.build_step(i + 1, len(fetch_recipes), recipe, 'Fetch') recipe.fetch() bv = cookbook.recipe_built_version(recipe.name) cv = recipe.built_version() if bv != cv: # On different versions, only reset recipe if: # * forced # * OR it was fully built already if full_reset or not cookbook.recipe_needs_build(recipe.name): to_rebuild.append(recipe) cookbook.reset_recipe_status(recipe.name) if reset_rdeps: for r in cookbook.list_recipe_reverse_deps(recipe.name): to_rebuild.append(r) cookbook.reset_recipe_status(r.name) if to_rebuild: to_rebuild = sorted(list(set(to_rebuild)), key=lambda r:r.name) m.message(_("These recipes have been updated and will " "be rebuilt:\n%s") % '\n'.join([x.name for x in to_rebuild]))
def fetch(self, cookbook, recipes, no_deps, reset_rdeps, full_reset): fetch_recipes = [] if not recipes: fetch_recipes = cookbook.get_recipes_list() elif no_deps: fetch_recipes = [cookbook.get_recipe(x) for x in recipes] else: for recipe in recipes: fetch_recipes += cookbook.list_recipe_deps(recipe) fetch_recipes = remove_list_duplicates(fetch_recipes) m.message( _("Fetching the following recipes: %s") % ' '.join([x.name for x in fetch_recipes])) to_rebuild = [] for i in range(len(fetch_recipes)): recipe = fetch_recipes[i] m.build_step(i + 1, len(fetch_recipes), recipe, 'Fetch') recipe.fetch() bv = cookbook.recipe_built_version(recipe.name) cv = recipe.built_version() if bv != cv: # On different versions, only reset recipe if: # * forced # * OR it was fully built already if full_reset or not cookbook.recipe_needs_build(recipe.name): to_rebuild.append(recipe) cookbook.reset_recipe_status(recipe.name) if reset_rdeps: for r in cookbook.list_recipe_reverse_deps( recipe.name): to_rebuild.append(r) cookbook.reset_recipe_status(r.name) if to_rebuild: to_rebuild = sorted(list(set(to_rebuild)), key=lambda r: r.name) m.message( _("These recipes have been updated and will " "be rebuilt:\n%s") % '\n'.join([x.name for x in to_rebuild]))
def _apply_steps(self, recipe, steps, count, total): for desc, step in steps: m.build_step(count, total, recipe.name, step) # check if the current step needs to be done if self.cookbook.step_done(recipe.name, step) and not self.force: m.action(_("Step done")) continue # call step function stepfunc = getattr(self, step) if not stepfunc: raise FatalError(_('Step %s not found') % step) try: stepfunc(recipe) # update status successfully self.cookbook.update_step_status(recipe.name, step) except Exception as e: m.warning(str(e)) raise BuildStepError(recipe, step, traceback.format_exc()) # Update the recipe status p = self.store.get_package('%s-pkg' % recipe.name) v = p.version.rsplit('-')[0] self.cookbook.update_build_status(recipe.name, v)
def _apply_steps(self, recipe, steps, count, total): for desc, step in steps: m.build_step(count, total, recipe.name, step) # check if the current step needs to be done if self.cookbook.step_done(recipe.name, step) and not self.force: m.action(_("Step done")) continue # call step function stepfunc = getattr(self, step) if not stepfunc: raise FatalError(_('Step %s not found') % step) try: stepfunc(recipe) # update status successfully self.cookbook.update_step_status(recipe.name, step) except Exception as e: m.warning(str(e)) raise BuildStepError(recipe, step, traceback.format_exc()) # Update the recipe status p = self.store.get_package('%s-pkg' % recipe.name) v =p.version.rsplit('-')[0] self.cookbook.update_build_status(recipe.name, v)
def built(self, count, total, recipe_name): self.count += 1 if self.interactive: m.build_step(self.count, self.total, recipe_name, _("built")) self.remove_recipe(recipe_name)