示例#1
0
 def store(self, chrootFingerprint, root):
     path = self._fingerPrintToPath(chrootFingerprint)
     prefix = sha1ToString(chrootFingerprint) + '.'
     util.mkdirChain(self.cacheDir)
     lock = locking.LockFile(path + '.lock')
     if not lock.acquire(wait=False):
         # Busy, just do nothing
         return
     fd, fn = tempfile.mkstemp(self.suffix, prefix, self.cacheDir)
     os.close(fd)
     try:
         subprocess.call('tar -cC %s . | %s > %s' % (root, self.compress,
             fn), shell=True)
         os.rename(fn, path)
     finally:
         util.removeIfExists(fn)
         lock.release()
     ChrootManifest.store(root, path)
     self.prune()
示例#2
0
 def store(self, chrootFingerprint, root):
     path = self._fingerPrintToPath(chrootFingerprint)
     prefix = sha1ToString(chrootFingerprint) + '.'
     util.mkdirChain(self.cacheDir)
     lock = locking.LockFile(path + '.lock')
     if not lock.acquire(wait=False):
         # Busy, just do nothing
         return
     fd, fn = tempfile.mkstemp(self.suffix, prefix, self.cacheDir)
     os.close(fd)
     try:
         subprocess.call('tar -cC %s . | %s > %s' %
                         (root, self.compress, fn),
                         shell=True)
         os.rename(fn, path)
     finally:
         util.removeIfExists(fn)
         lock.release()
     ChrootManifest.store(root, path)
     self.prune()
示例#3
0
 def _getManifest(self, client):
     job = (sorted(self.jobList) + sorted(self.crossJobList) +
            sorted(self.bootstrapJobList))
     fingerprints = client.repos.getChangeSetFingerprints(
         job,
         recurse=False,
         withFiles=True,
         withFileContents=True,
         excludeAutoSource=True,
         mirrorMode=False)
     a = len(self.jobList)
     b = a + len(self.crossJobList)
     return ChrootManifest(
         jobFingerprints=fingerprints[:a],
         crossFingerprints=fingerprints[a:b],
         bootstrapFingerprints=fingerprints[b:],
         rpmRequirements=self.cfg.rpmRequirements,
     )
示例#4
0
    def findPartialMatch(self, manifest):
        """
        Scan through existing cached chroots for one with a subset of the
        needed troves.

        Returns the fingerprint of the partial match that is closest to
        C{manifest} without any extra troves.
        """
        bestScore = -1
        bestFingerprint = None
        for name in os.listdir(self.cacheDir):
            if len(name) != (40 + len(self.suffix)) or not name.endswith(self.suffix):
                continue
            cached = ChrootManifest.read(os.path.join(self.cacheDir, name))
            if not cached:
                continue
            score = manifest.score(cached)
            if score > bestScore:
                bestScore = score
                bestFingerprint = sha1FromString(name[:40])
        return bestFingerprint
示例#5
0
    def findPartialMatch(self, manifest):
        """
        Scan through existing cached chroots for one with a subset of the
        needed troves.

        Returns the fingerprint of the partial match that is closest to
        C{manifest} without any extra troves.
        """
        bestScore = -1
        bestFingerprint = None
        for name in os.listdir(self.cacheDir):
            if len(name) != (40 + len(self.suffix)) or not name.endswith(
                    self.suffix):
                continue
            cached = ChrootManifest.read(os.path.join(self.cacheDir, name))
            if not cached:
                continue
            score = manifest.score(cached)
            if score > bestScore:
                bestScore = score
                bestFingerprint = sha1FromString(name[:40])
        return bestFingerprint