def _start(self): if self.phase == 'prerm': env_extractor = BinpkgEnvExtractor(background=self.background, scheduler=self.scheduler, settings=self.settings) if env_extractor.saved_env_exists(): self._start_task(env_extractor, self._env_extractor_exit) return # If the environment.bz2 doesn't exist, then ebuild.sh will # source the ebuild as a fallback. self._start_ebuild()
def _async_start_exit(self, task): task.future.cancelled() or task.future.result() if self._default_exit(task) != os.EX_OK: self.wait() return if self.phase in ("pretend", "prerm"): env_extractor = BinpkgEnvExtractor(background=self.background, scheduler=self.scheduler, settings=self.settings) if env_extractor.saved_env_exists(): self._start_task(env_extractor, self._env_extractor_exit) return # If the environment.bz2 doesn't exist, then ebuild.sh will # source the ebuild as a fallback. self._start_lock()
def _clean_exit(self, clean_phase): if self._default_exit(clean_phase) != os.EX_OK: self._unlock_builddir() self.wait() return dir_path = self.settings['PORTAGE_BUILDDIR'] infloc = self._infloc pkg = self.pkg pkg_path = self._pkg_path dir_mode = 0o755 for mydir in (dir_path, self._image_dir, infloc): portage.util.ensure_dirs(mydir, uid=portage.data.portage_uid, gid=portage.data.portage_gid, mode=dir_mode) # This initializes PORTAGE_LOG_FILE. portage.prepare_build_dirs(self.settings["ROOT"], self.settings, 1) self._writemsg_level(">>> Extracting info\n") pkg_xpak = portage.xpak.tbz2(self._pkg_path) check_missing_metadata = ("CATEGORY", "PF") missing_metadata = set() for k in check_missing_metadata: v = pkg_xpak.getfile( _unicode_encode(k, encoding=_encodings['repo.content'])) if not v: missing_metadata.add(k) pkg_xpak.unpackinfo(infloc) for k in missing_metadata: if k == "CATEGORY": v = pkg.category elif k == "PF": v = pkg.pf else: continue f = io.open(_unicode_encode(os.path.join(infloc, k), encoding=_encodings['fs'], errors='strict'), mode='w', encoding=_encodings['content'], errors='backslashreplace') try: f.write(_unicode_decode(v + "\n")) finally: f.close() # Store the md5sum in the vdb. f = io.open(_unicode_encode(os.path.join(infloc, 'BINPKGMD5'), encoding=_encodings['fs'], errors='strict'), mode='w', encoding=_encodings['content'], errors='strict') try: f.write( _unicode_decode( str(portage.checksum.perform_md5(pkg_path)) + "\n")) finally: f.close() env_extractor = BinpkgEnvExtractor(background=self.background, scheduler=self.scheduler, settings=self.settings) self._start_task(env_extractor, self._env_extractor_exit)
def _start(self): need_builddir = self.phase not in EbuildProcess._phases_without_builddir if need_builddir: phase_completed_file = os.path.join( self.settings['PORTAGE_BUILDDIR'], ".%sed" % self.phase.rstrip('e')) if not os.path.exists(phase_completed_file): # If the phase is really going to run then we want # to eliminate any stale elog messages that may # exist from a previous run. try: os.unlink( os.path.join(self.settings['T'], 'logging', self.phase)) except OSError: pass if self.phase in ('nofetch', 'pretend', 'setup'): use = self.settings.get('PORTAGE_BUILT_USE') if use is None: use = self.settings['PORTAGE_USE'] maint_str = "" upstr_str = "" metadata_xml_path = os.path.join( os.path.dirname(self.settings['EBUILD']), "metadata.xml") if MetaDataXML is not None and os.path.isfile(metadata_xml_path): herds_path = os.path.join(self.settings['PORTDIR'], 'metadata/herds.xml') try: metadata_xml = MetaDataXML(metadata_xml_path, herds_path) maint_str = metadata_xml.format_maintainer_string() upstr_str = metadata_xml.format_upstream_string() except SyntaxError: maint_str = "<invalid metadata.xml>" msg = [] msg.append("Package: %s" % self.settings.mycpv) if self.settings.get('PORTAGE_REPO_NAME'): msg.append("Repository: %s" % self.settings['PORTAGE_REPO_NAME']) if maint_str: msg.append("Maintainer: %s" % maint_str) if upstr_str: msg.append("Upstream: %s" % upstr_str) msg.append("USE: %s" % use) relevant_features = [] enabled_features = self.settings.features for x in self._features_display: if x in enabled_features: relevant_features.append(x) if relevant_features: msg.append("FEATURES: %s" % " ".join(relevant_features)) # Force background=True for this header since it's intended # for the log and it doesn't necessarily need to be visible # elsewhere. self._elog('einfo', msg, background=True) if self.phase == 'package': if 'PORTAGE_BINPKG_TMPFILE' not in self.settings: self.settings['PORTAGE_BINPKG_TMPFILE'] = \ os.path.join(self.settings['PKGDIR'], self.settings['CATEGORY'], self.settings['PF']) + '.tbz2' if self.phase in ("pretend", "prerm"): env_extractor = BinpkgEnvExtractor(background=self.background, scheduler=self.scheduler, settings=self.settings) if env_extractor.saved_env_exists(): self._start_task(env_extractor, self._env_extractor_exit) return # If the environment.bz2 doesn't exist, then ebuild.sh will # source the ebuild as a fallback. self._start_lock()
def _start(self): need_builddir = self.phase not in EbuildProcess._phases_without_builddir if need_builddir: phase_completed_file = os.path.join( self.settings['PORTAGE_BUILDDIR'], ".%sed" % self.phase.rstrip('e')) if not os.path.exists(phase_completed_file): # If the phase is really going to run then we want # to eliminate any stale elog messages that may # exist from a previous run. try: os.unlink(os.path.join(self.settings['T'], 'logging', self.phase)) except OSError: pass if self.phase in ('nofetch', 'pretend', 'setup'): use = self.settings.get('PORTAGE_BUILT_USE') if use is None: use = self.settings['PORTAGE_USE'] maint_str = "" upstr_str = "" metadata_xml_path = os.path.join(os.path.dirname(self.settings['EBUILD']), "metadata.xml") if MetaDataXML is not None and os.path.isfile(metadata_xml_path): herds_path = os.path.join(self.settings['PORTDIR'], 'metadata/herds.xml') try: metadata_xml = MetaDataXML(metadata_xml_path, herds_path) maint_str = metadata_xml.format_maintainer_string() upstr_str = metadata_xml.format_upstream_string() except SyntaxError: maint_str = "<invalid metadata.xml>" msg = [] msg.append("Package: %s" % self.settings.mycpv) if self.settings.get('PORTAGE_REPO_NAME'): msg.append("Repository: %s" % self.settings['PORTAGE_REPO_NAME']) if maint_str: msg.append("Maintainer: %s" % maint_str) if upstr_str: msg.append("Upstream: %s" % upstr_str) msg.append("USE: %s" % use) relevant_features = [] enabled_features = self.settings.features for x in self._features_display: if x in enabled_features: relevant_features.append(x) if relevant_features: msg.append("FEATURES: %s" % " ".join(relevant_features)) # Force background=True for this header since it's intended # for the log and it doesn't necessarily need to be visible # elsewhere. self._elog('einfo', msg, background=True) if self.phase == 'package': if 'PORTAGE_BINPKG_TMPFILE' not in self.settings: self.settings['PORTAGE_BINPKG_TMPFILE'] = \ os.path.join(self.settings['PKGDIR'], self.settings['CATEGORY'], self.settings['PF']) + '.tbz2' if self.phase in ("pretend", "prerm"): env_extractor = BinpkgEnvExtractor(background=self.background, scheduler=self.scheduler, settings=self.settings) if env_extractor.saved_env_exists(): self._start_task(env_extractor, self._env_extractor_exit) return # If the environment.bz2 doesn't exist, then ebuild.sh will # source the ebuild as a fallback. self._start_lock()
def _unpack_metadata(self): dir_path = self.settings['PORTAGE_BUILDDIR'] infloc = self._infloc pkg = self.pkg pkg_path = self._pkg_path dir_mode = 0o755 for mydir in (dir_path, self._image_dir, infloc): portage.util.ensure_dirs(mydir, uid=portage.data.portage_uid, gid=portage.data.portage_gid, mode=dir_mode) # This initializes PORTAGE_LOG_FILE. portage.prepare_build_dirs(self.settings["ROOT"], self.settings, 1) self._writemsg_level(">>> Extracting info\n") yield self._bintree.dbapi.unpack_metadata(self.settings, infloc) check_missing_metadata = ("CATEGORY", "PF") for k, v in zip( check_missing_metadata, self._bintree.dbapi.aux_get(self.pkg.cpv, check_missing_metadata)): if v: continue elif k == "CATEGORY": v = pkg.category elif k == "PF": v = pkg.pf else: continue f = io.open(_unicode_encode(os.path.join(infloc, k), encoding=_encodings['fs'], errors='strict'), mode='w', encoding=_encodings['content'], errors='backslashreplace') try: f.write(_unicode_decode(v + "\n")) finally: f.close() # Store the md5sum in the vdb. if pkg_path is not None: md5sum, = self._bintree.dbapi.aux_get(self.pkg.cpv, ['MD5']) if not md5sum: md5sum = portage.checksum.perform_md5(pkg_path) with io.open(_unicode_encode(os.path.join(infloc, 'BINPKGMD5'), encoding=_encodings['fs'], errors='strict'), mode='w', encoding=_encodings['content'], errors='strict') as f: f.write(_unicode_decode('{}\n'.format(md5sum))) env_extractor = BinpkgEnvExtractor(background=self.background, scheduler=self.scheduler, settings=self.settings) env_extractor.start() yield env_extractor.async_wait() if env_extractor.returncode != os.EX_OK: raise portage.exception.PortageException( 'failed to extract environment for {}'.format(self.pkg.cpv))