#NEWLINE# def apply( self , justDatabase = False , noScripts = False , capsuleChangeSet = None ) : #NEWLINE# #INDENT# if capsuleChangeSet : #NEWLINE# #INDENT# capsuleChangeSet . reset ( ) #NEWLINE# #UNINDENT# tmpDir = os . path . join ( self . root , 'var/tmp' ) #NEWLINE# if ( not os . path . isdir ( tmpDir ) ) : #NEWLINE# #INDENT# tmpDir = self . root #NEWLINE# #UNINDENT# fileDict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( kind , obj ) in sorted ( self . capsuleClasses . items ( ) ) : #NEWLINE# #INDENT# fileDict . update ( dict ( ( ( ( x [ 0 ] , x [ 2 ] , x [ 3 ] ) , x [ 1 ] ) for x in obj . _filesNeeded ( ) ) ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# for ( ( pathId , fileId , sha1 ) , path ) in sorted ( fileDict . items ( ) ) : #NEWLINE# #INDENT# ( tmpfd , tmpname ) = tempfile . mkstemp ( dir = tmpDir , prefix = path , suffix = '.conary' ) #NEWLINE# ( fType , fContents ) = self . changeSet . getFileContents ( pathId , fileId ) #NEWLINE# if ( kind == changeset . ChangedFileTypes . hldr ) : #NEWLINE# #INDENT# if capsuleChangeSet : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# result = capsuleChangeSet . getFileContents ( pathId , fileId ) #NEWLINE# fObj = result [ 1 ] . get ( ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# raise errors . MissingRollbackCapsule ( ( 'Cannot find RPM %s to perform local rollback' % path ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# fObj = fContents . get ( ) #NEWLINE# #UNINDENT# d = digestlib . sha1 ( ) #NEWLINE# util . copyfileobj ( fObj , os . fdopen ( tmpfd , 'w' ) , digest = d ) #NEWLINE# actualSha1 = d . digest ( ) #NEWLINE# if ( actualSha1 != sha1 ) : #NEWLINE# #INDENT# raise files . Sha1Exception ( path ) #NEWLINE# #UNINDENT# fileDict [ ( pathId , fileId ) ] = tmpname #NEWLINE# #UNINDENT# for ( kind , obj ) in sorted ( self . capsuleClasses . items ( ) ) : #NEWLINE# #INDENT# obj . apply ( fileDict , justDatabase = justDatabase , noScripts = noScripts ) #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# for tmpPath in fileDict . values ( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# os . unlink ( tmpPath ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass