[Piuparts-commits] [SCM] piuparts git repository branch, master, updated. eda668423fa87898c59d1075118693714aa5a053

Holger Levsen holger at layer-acht.org
Fri Dec 23 10:26:17 UTC 2011


The following commit has been merged in the master branch:
commit cf42b04308ff166abde4d55fad4fbb194950c1cf
Merge: 2e63ef1fa3ac3c749378abbaf8fb1cd083cb9efe 3c13916b32b6f085f451a5e09624def0b9d38e6a
Author: Holger Levsen <holger at layer-acht.org>
Date:   Mon Nov 21 20:28:39 2011 +0100

    Merge commit '3c13916b32b6f085f451a5e09624def0b9d38e6a' into develop

diff --combined piuparts.py
index 1de475b,a5c2eed..db96c53
--- a/piuparts.py
+++ b/piuparts.py
@@@ -381,9 -381,30 +381,30 @@@ def run(command, ignore_errors=False)
      env["LC_ALL"] = "C"
      env["LANGUAGES"] = ""
      env["PIUPARTS_OBJECTS"] = ' '.join(str(vobject) for vobject in settings.testobjects )
-     p = subprocess.Popen(command, env=env, stdin=subprocess.PIPE, 
+     devnull = open('/dev/null', 'r')
+     p = subprocess.Popen(command, env=env, stdin=devnull, 
                           stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-     (output, _) = p.communicate()
+     output = ""
+     excessive_output = False
+     while p.poll() is None:
+         """Read 64 KB chunks, but depending on the output buffering behavior
+         of the command we may get less even if more output is coming later.
+         Abort after reading 2 MB."""
+         output += p.stdout.read(1 << 16)
+         if (len(output) > (1 << 21)):
+             excessive_output = True
+             logging.error("Terminating command due to excessive output")
+             p.terminate()
+             for i in range(10):
+                 time.sleep(0.5)
+                 if p.poll() is not None:
+                     break
+             else:
+                 logging.error("Killing command due to excessive output")
+                 p.kill()
+             p.wait()
+             break
+     devnull.close()
  
      if output:
          dump("\n" + indent_string(output.rstrip("\n")))
@@@ -396,6 -417,8 +417,8 @@@
      else:
          logging.error("Command failed (status=%d): %s\n%s" % 
                (p.returncode, repr(command), indent_string(output)))
+         if excessive_output:
+             logging.error("Command was terminated while producing excessive output")
          panic()
      return p.returncode, output
  
@@@ -474,8 -497,8 +497,8 @@@ def make_metapackage(name, depends, con
      return os.path.join(tmpdir, name) + '.deb'
  
  
 -def is_broken_symlink(root, dirpath, filename):
 -    """Is symlink dirpath+filename broken?
 +def canonicalize_path(root, pathname):
 +    """Canonicalize a path name, simulating chroot at 'root'.
  
      When resolving the symlink, pretend (similar to chroot) that root is
      the root of the filesystem. Note that this does NOT work completely
@@@ -486,32 -509,17 +509,32 @@@
  
      """
  
 -    pathname = os.path.join(dirpath, filename)
 +    #print "CANONICALIZE: %s %s" % (root, pathname)
      i = 0
      while os.path.islink(pathname):
          if i >= 10: # let's avoid infinite loops...
              return True
          i += 1
          target = os.readlink(pathname)
 +        #print "LINK: %s -> %s" % (pathname, target)
          if os.path.isabs(target):
              pathname = os.path.join(root, target[1:]) # Assume Unix filenames
          else:
              pathname = os.path.join(os.path.dirname(pathname), target)
 +        #print "FOLLOW: %s" % pathname
 +    (dn, bn) = os.path.split(pathname)
 +    #print "DN: %s  BN: %s" % (dn, bn)
 +    if pathname != root and dn != root:
 +        dn = canonicalize_path(root, dn)
 +    pathname = os.path.join(dn, bn)
 +    #print "RETURN: %s EXISTS: %s" % (pathname, os.path.exists(pathname))
 +    return pathname
 +
 +
 +def is_broken_symlink(root, dirpath, filename):
 +    """Is symlink dirpath+filename broken?"""
 +
 +    pathname = canonicalize_path(root, os.path.join(dirpath, filename))
  
      # The symlink chain, if any, has now been resolved. Does the target
      # exist?
@@@ -583,17 -591,6 +606,17 @@@ class IsBrokenSymlinkTests(unittest.Tes
          self.failIf(is_broken_symlink(self.testdir, self.testdir,
                                        "target/first-link"))
  
 +    def testMultiLevelNestedAbsoluteSymlinks(self):
 +        # first-link -> /second-link/final-target
 +        # second-link -> /target-dir
 +
 +        os.mkdir(os.path.join(self.testdir, "final-dir"))
 +        os.mkdir(os.path.join(self.testdir, "final-dir/final-target"))
 +        self.symlink("/second-link/final-target", "first-link")
 +        self.symlink("/final-dir", "second-link")
 +        self.failIf(is_broken_symlink(self.testdir, self.testdir,
 +                                      "first-link"))
 +
  
  class Chroot:
  

-- 
piuparts git repository



More information about the Piuparts-commits mailing list