Skip to main content

Source code file content

Revision: 31

16764165 overlay files may be removed unexpectedly during pkg operations 16765529 preserve semantics ignored for overlay file updates
» Project Revision History

» Checkout URL

website-repo / webrev / srwalker / pkg-overlay-1 / src / modules / client / imageplan.py.cdiff.html

Size: 18530 bytes, 1 line
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><meta http-equiv="cache-control" content="no-cache"></meta>
<meta http-equiv="Pragma" content="no-cache"></meta>
<meta http-equiv="Expires" content="-1"></meta>
<!--
   Note to customizers: the body of the webrev is IDed as SUNWwebrev
   to allow easy overriding by users of webrev via the userContent.css
   mechanism available in some browsers.

   For example, to have all "removed" information be red instead of
   brown, set a rule in your userContent.css file like:

       body#SUNWwebrev span.removed { color: red ! important; }
-->
<style type="text/css" media="screen">
body {
    background-color: #eeeeee;
}
hr {
    border: none 0;
    border-top: 1px solid #aaa;
    height: 1px;
}
div.summary {
    font-size: .8em;
    border-bottom: 1px solid #aaa;
    padding-left: 1em;
    padding-right: 1em;
}
div.summary h2 {
    margin-bottom: 0.3em;
}
div.summary table th {
    text-align: right;
    vertical-align: top;
    white-space: nowrap;
}
span.lineschanged {
    font-size: 0.7em;
}
span.oldmarker {
    color: red;
    font-size: large;
    font-weight: bold;
}
span.newmarker {
    color: green;
    font-size: large;
    font-weight: bold;
}
span.removed {
    color: brown;
}
span.changed {
    color: blue;
}
span.new {
    color: blue;
    font-weight: bold;
}
span.chmod {
    font-size: 0.7em;
    color: #db7800;
}
a.print { font-size: x-small; }
a:hover { background-color: #ffcc99; }
</style>

<style type="text/css" media="print">
pre { font-size: 0.8em; font-family: courier, monospace; }
span.removed { color: #444; font-style: italic }
span.changed { font-weight: bold; }
span.new { font-weight: bold; }
span.newmarker { font-size: 1.2em; font-weight: bold; }
span.oldmarker { font-size: 1.2em; font-weight: bold; }
a.print {display: none}
hr { border: none 0; border-top: 1px solid #aaa; height: 1px; }
</style>

<title>pkg-gate Cdiff src/modules/client/imageplan.py</title>
</head>
<body id="SUNWwebrev">
        <a class="print" href="javascript:print()">Print this page</a>
<pre><a href="https://bug.oraclecorp.com/show?16764165">16764165</a> overlay files may be removed unexpectedly during pkg operations
<a href="https://bug.oraclecorp.com/show?16765529">16765529</a> preserve semantics ignored for overlay file updates</pre>
        <pre>
<hr></hr><span class="oldmarker">*** 1225,1238 ****</span>
<span class="newmarker">--- 1225,1252 ----</span>
                  value may be delivered."""
  
                  # We end up with no actions or start with one or none and end
                  # with exactly one.
                  if len(actions) == 0 or (len(oactions) &lt;= len(actions) == 1):
<span class="new">+                         if (len(oactions) &gt; 1 and </span>
<span class="new">+                             any(a[0].attrs.get("overlay") == "true"</span>
<span class="new">+                                 for a in oactions)):</span>
<span class="new">+                                 # If more than one action is being removed and</span>
<span class="new">+                                 # one of them is an overlay, then suppress</span>
<span class="new">+                                 # removal of the overlaid actions (if any) to</span>
<span class="new">+                                 # ensure preserve rules of overlay action apply.</span>
<span class="new">+                                 return "overlay", None</span>
                          return None
  
                  # Removing actions.
                  if len(actions) &lt; len(oactions):
<span class="new">+                         # If any of the new actions is an overlay, suppress</span>
<span class="new">+                         # the removal of the overlaid action.</span>
<span class="new">+                         if any(a[0].attrs.get("overlay") == "true"</span>
<span class="new">+                             for a in actions):</span>
<span class="new">+                                 return "overlay", None</span>
<span class="new">+ </span>
                          # If we still end up in a broken state, signal the
                          # caller that we should move forward, but not remove
                          # any actions.
                          if len(actions) &gt; 1 or \
                              any("preserve" in a[0].attrs for a in actions):
<hr></hr><span class="oldmarker">*** 1439,1471 ****</span>
                                  if ap and ap.src.attrs.get(ap.src.key_attr,
                                      None) == key:
                                          self.pd.removal_actions[i] = None
                  elif msg == "overlay":
                          pp_needs_trimming = {}
                          for al in (self.pd.install_actions,
                              self.pd.update_actions):
                                  for i, ap in enumerate(al):
<span class="changed">!                                         if not (ap and ap.dst.attrs.get(</span>
<span class="changed">!                                             ap.dst.key_attr, None) == key):</span>
                                                  continue
<span class="changed">!                                         if ap.dst.attrs.get("overlay") == \</span>
<span class="changed">!                                             "allow":</span>
<span class="changed">!                                                 # Remove overlaid actions from</span>
<span class="changed">!                                                 # plan.</span>
                                                  al[i] = None
                                                  pp_needs_trimming.setdefault(id(ap.p),
                                                      { "plan": ap.p, "trim": [] })
                                                  pp_needs_trimming[id(ap.p)]["trim"].append(
                                                      id(ap.dst))
                                                  break
  
                          for entry in pp_needs_trimming.values():
                                  p = entry["plan"]
                                  trim = entry["trim"]
                                  # Can't modify the p.actions tuple, so modify
                                  # the added member in-place.
<span class="changed">!                                 for prop in ("added", "changed"):</span>
                                          pval = getattr(p.actions, prop)
                                          pval[:] = [
                                              a
                                              for a in pval
                                              if id(a[1]) not in trim
<span class="newmarker">--- 1453,1538 ----</span>
                                  if ap and ap.src.attrs.get(ap.src.key_attr,
                                      None) == key:
                                          self.pd.removal_actions[i] = None
                  elif msg == "overlay":
                          pp_needs_trimming = {}
<span class="new">+                         moved = set()</span>
<span class="new">+                         # Suppress install and update of overlaid file.</span>
                          for al in (self.pd.install_actions,
                              self.pd.update_actions):
                                  for i, ap in enumerate(al):
<span class="changed">!                                         if not ap:</span>
<span class="changed">!                                                 # Action has been removed.</span>
                                                  continue
<span class="changed">! </span>
<span class="changed">!                                         attrs = ap.dst.attrs</span>
<span class="changed">!                                         if attrs.get(ap.dst.key_attr) != key:</span>
<span class="changed">!                                                 if ("preserve" in attrs and</span>
<span class="changed">!                                                     "original_name" in attrs):</span>
<span class="changed">!                                                         # Possible move to a</span>
<span class="changed">!                                                         # different location for</span>
<span class="changed">!                                                         # editable file.</span>
<span class="changed">!                                                         # Overlay attribute is</span>
<span class="changed">!                                                         # not checked in case it</span>
<span class="changed">!                                                         # was dropped as part of</span>
<span class="changed">!                                                         # move.</span>
<span class="changed">!                                                         moved.add(</span>
<span class="changed">!                                                             attrs["original_name"])</span>
<span class="changed">!                                                 continue</span>
<span class="changed">! </span>
<span class="changed">!                                         if attrs.get("overlay") != "allow":</span>
<span class="changed">!                                                     # Only care about overlaid</span>
<span class="changed">!                                                     # actions.</span>
<span class="changed">!                                                     continue</span>
<span class="changed">! </span>
<span class="changed">!                                         # Remove conflicting, overlaid actions</span>
<span class="changed">!                                         # from plan.</span>
                                          al[i] = None
                                          pp_needs_trimming.setdefault(id(ap.p),
                                              { "plan": ap.p, "trim": [] })
                                          pp_needs_trimming[id(ap.p)]["trim"].append(
                                              id(ap.dst))
                                          break
  
<span class="new">+                         # Suppress removal of overlaid file.</span>
<span class="new">+                         al = self.pd.removal_actions</span>
<span class="new">+                         for i, ap in enumerate(al):</span>
<span class="new">+                                 if not ap:</span>
<span class="new">+                                         continue</span>
<span class="new">+ </span>
<span class="new">+                                 attrs = ap.src.attrs</span>
<span class="new">+                                 if not attrs.get(ap.src.key_attr) == key:</span>
<span class="new">+                                         continue</span>
<span class="new">+ </span>
<span class="new">+                                 if attrs.get("overlay") != "allow":</span>
<span class="new">+                                         # Only interested in overlaid actions.</span>
<span class="new">+                                         continue</span>
<span class="new">+ </span>
<span class="new">+                                 orig_name = attrs.get("original_name",</span>
<span class="new">+                                     "%s:%s" % (ap.p.origin_fmri.get_name(),</span>
<span class="new">+                                         attrs["path"]))</span>
<span class="new">+                                 if orig_name in moved:</span>
<span class="new">+                                         # File has moved locations; removal will</span>
<span class="new">+                                         # be executed, but file will be saved</span>
<span class="new">+                                         # for the move skipping unlink.</span>
<span class="new">+                                         ap.src.attrs["save_file"] = \</span>
<span class="new">+                                             [orig_name, "false"]</span>
<span class="new">+                                         break</span>
<span class="new">+ </span>
<span class="new">+                                 al[i] = None</span>
<span class="new">+                                 pp_needs_trimming.setdefault(id(ap.p),</span>
<span class="new">+                                     { "plan": ap.p, "trim": [] })</span>
<span class="new">+                                 pp_needs_trimming[id(ap.p)]["trim"].append(</span>
<span class="new">+                                     id(ap.src))</span>
<span class="new">+                                 break</span>
<span class="new">+ </span>
                          for entry in pp_needs_trimming.values():
                                  p = entry["plan"]
                                  trim = entry["trim"]
                                  # Can't modify the p.actions tuple, so modify
                                  # the added member in-place.
<span class="changed">!                                 for prop in ("added", "changed", "removed"):</span>
                                          pval = getattr(p.actions, prop)
                                          pval[:] = [
                                              a
                                              for a in pval
                                              if id(a[1]) not in trim
<hr></hr><span class="oldmarker">*** 1802,1811 ****</span>
<span class="newmarker">--- 1869,1904 ----</span>
                                      actions, oactions,
                                      api_errors.InconsistentActionAttributeError,
                                      errs):
                                          continue
  
<span class="new">+                 # Ensure that overlay and preserve file semantics are handled</span>
<span class="new">+                 # as expected when conflicts only exist in packages that are</span>
<span class="new">+                 # being removed.</span>
<span class="new">+                 for key, oactions in old.iteritems():</span>
<span class="new">+                         self.__progtrack.plan_add_progress(</span>
<span class="new">+                             self.__progtrack.PLAN_ACTION_CONFLICT)</span>
<span class="new">+ </span>
<span class="new">+                         if len(oactions) &lt; 2:</span>
<span class="new">+                                 continue</span>
<span class="new">+ </span>
<span class="new">+                         if key in new:</span>
<span class="new">+                                 # Already processed.</span>
<span class="new">+                                 continue</span>
<span class="new">+ </span>
<span class="new">+                         if any(a[0].name != "file" for a in oactions):</span>
<span class="new">+                                 continue</span>
<span class="new">+ </span>
<span class="new">+                         entry = oactions[0][0]</span>
<span class="new">+                         if not entry.refcountable and entry.globally_identical:</span>
<span class="new">+                                 if self.__process_conflicts(key,</span>
<span class="new">+                                     self.__check_duplicate_actions,</span>
<span class="new">+                                     [], oactions,</span>
<span class="new">+                                     api_errors.DuplicateActionError,</span>
<span class="new">+                                     errs):</span>
<span class="new">+                                         continue</span>
<span class="new">+ </span>
          @staticmethod
          def _check_actions(nsd):
                  """Return the keys in the namespace dictionary ('nsd') which
                  map to actions that conflict with each other."""
  
<hr></hr><span class="oldmarker">*** 2988,2999 ****</span>
                                          # No need to handle it in cons_generic
                                          # anymore
                                          del cons_generic[("file", ra.attrs["path"])]
                                          dest_pkgplans[id(ap.dst)] = ap.p
                                  else:
<span class="changed">!                                         ra.attrs["save_file"] = cache_name</span>
<span class="changed">!                                         ap.dst.attrs["save_file"] = cache_name</span>
  
                                  cache_name = index = ra = None
  
                          # Similarly, try to prevent files (and other actions)
                          # from unnecessarily being deleted and re-created if
<span class="newmarker">--- 3081,3099 ----</span>
                                          # No need to handle it in cons_generic
                                          # anymore
                                          del cons_generic[("file", ra.attrs["path"])]
                                          dest_pkgplans[id(ap.dst)] = ap.p
                                  else:
<span class="changed">!                                         # The 'true' indicates the file should</span>
<span class="changed">!                                         # be removed from source.  The removal</span>
<span class="changed">!                                         # action is changed using setdefault so</span>
<span class="changed">!                                         # that any overlay rules applied during</span>
<span class="changed">!                                         # conflict checking remain intact.</span>
<span class="changed">!                                         ra.attrs.setdefault("save_file",</span>
<span class="changed">!                                             [cache_name, "true"])</span>
<span class="changed">!                                         ap.dst.attrs["save_file"] = [cache_name,</span>
<span class="changed">!                                             "true"]</span>
  
                                  cache_name = index = ra = None
  
                          # Similarly, try to prevent files (and other actions)
                          # from unnecessarily being deleted and re-created if
</pre></body></html>

 
 
Close
loading
Please Confirm
Close