| OLD | NEW |
| 1 #!/usr/bin/env python2.6 | 1 #!/usr/bin/env python2.6 |
| 2 | 2 |
| 3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 import struct | 9 import struct |
| 10 import subprocess | 10 import subprocess |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 | 123 |
| 124 class EntryBlob(EntryFmapArea): | 124 class EntryBlob(EntryFmapArea): |
| 125 | 125 |
| 126 def __init__(self, **kwargs): | 126 def __init__(self, **kwargs): |
| 127 Entry._CheckFields(kwargs, ('path',)) | 127 Entry._CheckFields(kwargs, ('path',)) |
| 128 super(EntryBlob, self).__init__(**kwargs) | 128 super(EntryBlob, self).__init__(**kwargs) |
| 129 | 129 |
| 130 def Pack(self, firmware_image, entries): | 130 def Pack(self, firmware_image, entries): |
| 131 size = os.stat(self.path).st_size | 131 size = os.stat(self.path).st_size |
| 132 if size > 0: | 132 if size > self.length: |
| 133 size = min(size, self.length) | 133 raise PackError('blob too large: %d > %d' % (size, self.length)) |
| 134 else: | 134 if size == 0: # special case for files like /dev/zero |
| 135 size = self.length | 135 size = self.length |
| 136 with open(self.path, 'rb') as blob_image: | 136 with open(self.path, 'rb') as blob_image: |
| 137 firmware_image.seek(self.offset) | 137 firmware_image.seek(self.offset) |
| 138 firmware_image.write(blob_image.read(size)) | 138 firmware_image.write(blob_image.read(size)) |
| 139 | 139 |
| 140 | 140 |
| 141 class EntryKeyBlock(EntryFmapArea): | 141 class EntryKeyBlock(EntryFmapArea): |
| 142 | 142 |
| 143 stdout = None | 143 stdout = None |
| 144 stderr = None | 144 stderr = None |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 raise ConfigError('undefined variable: %s' % varname) | 257 raise ConfigError('undefined variable: %s' % varname) |
| 258 _Info('%s = %s' % (varname, repr(env[varname]))) | 258 _Info('%s = %s' % (varname, repr(env[varname]))) |
| 259 | 259 |
| 260 pack_firmware_image(env['ENTRIES'], env['OUTPUT'], env['SIZE']) | 260 pack_firmware_image(env['ENTRIES'], env['OUTPUT'], env['SIZE']) |
| 261 | 261 |
| 262 sys.exit(0) | 262 sys.exit(0) |
| 263 | 263 |
| 264 | 264 |
| 265 if __name__ == '__main__': | 265 if __name__ == '__main__': |
| 266 main() | 266 main() |
| OLD | NEW |