Beispiel #1
0
 def __init__(self, repository_base):
     super().__init__()
     json_file = os.path.join(repository_base, REPO_INFO_FILENAME)
     path = Path(json_file)
     if not path.exists():
         # If there is no .json file in the repo, it might be an old version
         # checked out. We can still do best-effort with a default file
         # that is located in this repo.
         json_file = self._failback_file()
         path = Path(json_file)
         if not path.exists():
             sys.exit("Could not find a .json repository info file to use.")
     path.assert_is_file()
     path.assert_mode(os.R_OK)
     content = read_file(json_file)
     self.update(json.loads(content))
Beispiel #2
0
 def clone_or_fetch(self, repository_base):
     """
     Clones a fresh repository at the given base unless it exists already.
     If it exists already, it will fetch the latest upstream state (which is
     less abusive of the github servers than a full clone). The result will
     be returned as a GitRepository instance.
     """
     p = Path(repository_base)
     return (self._fetch(repository_base) if p.exists() else
             self.clone(repository_base))
Beispiel #3
0
 def _find_binaries(self, search_directories):
     binaries = {}
     for directory in search_directories:
         for binary in CLANG_BINARIES:
             path = Path(os.path.join(directory, binary))
             if not path.exists():
                 continue
             path.assert_is_file()
             path.assert_mode(os.R_OK | os.X_OK)
             if path.filename() not in binaries:
                 binaries[path.filename()] = []
             version = str(ClangVersion(str(path)))
             binaries[path.filename()].append({
                 'path': str(path),
                 'version': version
             })
     return binaries
Beispiel #4
0
 def assert_has_makefile(self):
     makefile = Path(os.path.join(self.repository_base, "Makefile"))
     if not makefile.exists():
         sys.exit("*** no Makefile found in %s. You must ./autogen.sh "
                  "and/or ./configure first" % self.repository_base)