예제 #1
0
def GrabLocalPackageIndex(package_path):
    """Read a local packages file from disk into a PackageIndex() object.

  Args:
    package_path: Directory containing Packages file.

  Returns:
    A PackageIndex object.
  """
    packages_file = file(os.path.join(package_path, 'Packages'))
    pkgindex = PackageIndex()
    pkgindex.Read(packages_file)
    packages_file.close()

    # List all debug symbols available in package_path.
    symbols = set()
    for f in cros_build_lib.ListFiles(package_path):
        if f.endswith('.debug.tbz2'):
            f = os.path.relpath(f, package_path)[:-len('.debug.tbz2')]
            symbols.add(f)

    for p in pkgindex.packages:
        # If the Packages file has DEBUG_SYMBOLS set but no debug symbols are
        # found, unset it.
        p.pop('DEBUG_SYMBOLS', None)
        if p['CPV'] in symbols:
            p['DEBUG_SYMBOLS'] = 'yes'

    return pkgindex
예제 #2
0
    def testTraverse(self):
        """Test that we are traversing the directory properly."""
        dir_structure = ['one/two/test.txt', 'one/blah.py', 'three/extra.conf']
        self._CreateNestedDir(dir_structure)

        files = cros_build_lib.ListFiles(self.tempdir)
        for f in files:
            f = f.replace(self.tempdir, '').lstrip('/')
            if f not in dir_structure:
                self.fail('%s was not found in %s' % (f, dir_structure))
예제 #3
0
 def testNoSuchDir(self):
     try:
         cros_build_lib.ListFiles(os.path.join(self.tempdir, 'missing'))
     except OSError, err:
         self.assertEqual(err.errno, errno.ENOENT)
예제 #4
0
 def testEmptyFilePath(self):
     """Test that we return nothing when directories are empty."""
     dir_structure = ['one/', 'two/', 'one/a/']
     self._CreateNestedDir(dir_structure)
     files = cros_build_lib.ListFiles(self.tempdir)
     self.assertEqual(files, [])