Beispiel #1
0
 def _yyoom(self, arglist, on_completed=None):
     if not on_completed:
         on_completed = lambda data, errored: None
     if not sh.isdir(self._logs_dir):
         sh.mkdirslist(self._logs_dir)
     with tempfile.NamedTemporaryFile(suffix=".json") as fh:
         cmdline = [
             self.yyoom_executable,
             "--output-file", fh.name,
             "--verbose",
         ]
         cmdline.extend(arglist)
         log_filename = sh.joinpths(self._logs_dir,
                                    _generate_log_filename(arglist))
         LOG.debug("Running yyoom: log output will be placed in %s",
                   log_filename)
         try:
             sh.execute_save_output(cmdline, log_filename)
         except excp.ProcessExecutionError:
             with excp.reraise():
                 try:
                     fh.seek(0)
                     data = utils.parse_json(fh.read())
                 except Exception:
                     LOG.exception("Failed to parse YYOOM output")
                 else:
                     on_completed(data, True)
         else:
             fh.seek(0)
             data = utils.parse_json(fh.read())
             on_completed(data, False)
             return data
Beispiel #2
0
 def _yyoom(self, arglist, on_completed=None):
     if not on_completed:
         on_completed = lambda data, errored: None
     if not sh.isdir(self._logs_dir):
         sh.mkdirslist(self._logs_dir)
     with tempfile.NamedTemporaryFile(suffix=".json") as fh:
         cmdline = [
             self.yyoom_executable,
             "--output-file",
             fh.name,
             "--verbose",
         ]
         cmdline.extend(arglist)
         log_filename = sh.joinpths(self._logs_dir,
                                    _generate_log_filename(arglist))
         LOG.debug("Running yyoom: log output will be placed in %s",
                   log_filename)
         try:
             sh.execute_save_output(cmdline, log_filename)
         except excp.ProcessExecutionError:
             with excp.reraise():
                 try:
                     fh.seek(0)
                     data = utils.parse_json(fh.read())
                 except Exception:
                     LOG.exception("Failed to parse YYOOM output")
                 else:
                     on_completed(data, True)
         else:
             fh.seek(0)
             data = utils.parse_json(fh.read())
             on_completed(data, False)
             return data
Beispiel #3
0
 def _fetch_epoch_mapping(self):
     epoch_map = self.distro.get_dependency_config("epoch_map", quiet=True)
     if not epoch_map:
         epoch_map = {}
     epoch_skips = self.distro.get_dependency_config("epoch_skips",
                                                     quiet=True)
     if not epoch_skips:
         epoch_skips = _DEFAULT_SKIP_EPOCHS
     if not isinstance(epoch_skips, (list, tuple)):
         epoch_skips = [i.strip() for i in epoch_skips.split(",")]
     built_epochs = {}
     for name in self.python_names:
         if name in epoch_map:
             built_epochs[name] = str(epoch_map.pop(name))
         else:
             built_epochs[name] = str(self.OPENSTACK_EPOCH)
     # Ensure epochs set by a yum searching (that are not in the list of
     # epochs to provide) are correctly set when building dependent
     # packages...
     keep_names = set()
     try:
         yum_satisfies = sh.load_file(self.yum_satisfies_filename)
     except IOError as e:
         if e.errno != errno.ENOENT:
             raise
     else:
         for line in yum_satisfies.splitlines():
             raw_req_rpm = utils.parse_json(line)
             req = pip_helper.extract_requirement(raw_req_rpm['requirement'])
             if req.key in epoch_map:
                 LOG.debug("Ensuring manually set epoch is retained for"
                           " requirement '%s' with epoch %s", req,
                           epoch_map[req.key])
                 keep_names.add(req.key)
             else:
                 rpm_info = raw_req_rpm['rpm']
                 rpm_epoch = rpm_info.get('epoch')
                 if rpm_epoch and str(rpm_epoch) not in epoch_skips:
                     LOG.debug("Adding in yum satisfiable package %s for"
                               " requirement '%s' with epoch %s from repo %s",
                               rpm_info['name'], req, rpm_epoch, rpm_info['repo'])
                     keep_names.add(req.key)
                     epoch_map[req.key] = str(rpm_epoch)
     # Exclude names from the epoch map that we never downloaded in the
     # first place or that we did not just set automatically (since these
     # are not useful and should not be set in the first place).
     try:
         _pip_reqs, downloaded_reqs = pip_helper.read_requirement_files([self.build_requires_filename])
     except IOError as e:
         if e.errno != errno.ENOENT:
             raise
     else:
         downloaded_names = set([req.key for req in downloaded_reqs])
         tmp_epoch_map = {}
         for (name, epoch) in six.iteritems(epoch_map):
             name = name.lower()
             if name in downloaded_names or name in keep_names:
                 tmp_epoch_map[name] = str(epoch)
             else:
                 LOG.debug("Discarding %s:%s from the epoch mapping since"
                           " it was not part of the downloaded (or automatically"
                           " included) build requirements", name, epoch)
         epoch_map = tmp_epoch_map
     epoch_map.update(built_epochs)
     return epoch_map