def loadMetadata(metadataFile, archive=None): """ loadMetadata """ # Extracts metadata file from the distribution archive: # if os.path.isfile (archive): result = readFileFromArchive(archive, metadataFile) metadata = pickle.loads(result) return metadata
def prepareDistribution(self, method = 'copy'): """ Manager.prepareDistribution: Creates DARball structure according to current request, using copy, or link method. """ # Check how much space is left in tmp dir, # where the darball will be built: spaceLeft(self.tmpdir) self.timingLog('Checked space left in '+self.tmpdir) # If incremental darbal was requested, get its metadata, # and fill up base bomdictionary baseDar = self.currentRequest.baseDar self.darMeta.setBaseDar(baseDar) if baseDar: if os.path.isdir(baseDar): # This should be an installation directory: bomFile = baseDar+'/' + getBOMFileName() if os.path.isfile(bomFile): # Create base bom dictionary directly from file for entry in open(bomFile,'r').readlines(): # a list of lines (md5, entryPath) = string.split(entry) self.baseBomDict[entryPath] = md5 else: raise InputError(baseDar, 'Could not find ' + getBOMFileName() + ' here.') else: if os.path.isfile(baseDar): # This should be a DARball: baseDarball = baseDar else: # This should be a release tag of a base darball # available from the dar pool. # Lookup for base darball in the distribution pool: if notReadable(self.distPool): sys.exit(notReadable(self.distPool)) baseDarball = self.findBaseDarball(self.distPool, baseDar) if not baseDarball: sys.exit( 'Could not find base distribution for ' \ +baseDar+' in '+self.sharedPool) # Create base bom dictionary on the flight from the archive: result = readFileFromArchive(baseDarball, getBOMFileName()) for entry in string.split(result,'\n'): md5, entryPath = string.split(entry) self.baseBomDict[entryPath] = md5 # Now create DAR directory structure: self.dar = Structure(self.blddir, self.currentRequest, method, baseBom = self.baseBomDict) self.timingLog('Created DAR in ' + self.blddir + ' using ' + method + ' method') instDir = self.dar.getTopInstDir() if method == 'copy': self.timingLog('Counted install. size ' + 'before cleanup in shared dir') # Make cleanup and create BOM only for the FSO image (shared # between the environment variables): cleanup(self.dar.getSharedTop(), os.path.join(self.dar.getTopInstDir(), getBOMFileName())) self.timingLog('Removed duplicates and created BOM for ' + self.dar.getSharedTop()) size = noteSize(instDir) self.timingLog('Counted size after cleanup in ' + self.dar.getSharedTop()) self.darMeta.setInstallationSize(size) # fakeScram() # including scram runtime command, which may replace setup scripts. self.saveMetadata(os.path.join(self.dar.getTopInstDir(), getMetaDataFile())) # - saves into metadata file info about creation of a darball, # project conifguration info. Adds a spec file (and darInput in # scram mode). DAR info and its source code go here. self.createReadmeFile()