diff options
Diffstat (limited to 'scripts/update_payload/applier.py')
-rw-r--r-- | scripts/update_payload/applier.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/scripts/update_payload/applier.py b/scripts/update_payload/applier.py index e470ac4e..8af89e79 100644 --- a/scripts/update_payload/applier.py +++ b/scripts/update_payload/applier.py @@ -18,6 +18,20 @@ import array import bz2 import hashlib import itertools +# Not everywhere we can have the lzma library so we ignore it if we didn't have +# it because it is not going to be used. For example, 'cros flash' uses +# devserver code which eventually loads this file, but the lzma library is not +# included in the client test devices, and it is not necessary to do so. But +# lzma is not used in 'cros flash' so it should be fine. Python 3.x include +# lzma, but for backward compatibility with Python 2.7, backports-lzma is +# needed. +try: + import lzma +except ImportError: + try: + from backports import lzma + except ImportError: + pass import os import shutil import subprocess @@ -216,7 +230,7 @@ class PayloadApplier(object): self.truncate_to_expected_size = truncate_to_expected_size def _ApplyReplaceOperation(self, op, op_name, out_data, part_file, part_size): - """Applies a REPLACE{,_BZ} operation. + """Applies a REPLACE{,_BZ,_XZ} operation. Args: op: the operation object @@ -235,6 +249,10 @@ class PayloadApplier(object): if op.type == common.OpType.REPLACE_BZ: out_data = bz2.decompress(out_data) data_length = len(out_data) + elif op.type == common.OpType.REPLACE_XZ: + # pylint: disable=no-member + out_data = lzma.decompress(out_data) + data_length = len(out_data) # Write data to blocks specified in dst extents. data_start = 0 @@ -508,7 +526,8 @@ class PayloadApplier(object): # Read data blob. data = self.payload.ReadDataBlob(op.data_offset, op.data_length) - if op.type in (common.OpType.REPLACE, common.OpType.REPLACE_BZ): + if op.type in (common.OpType.REPLACE, common.OpType.REPLACE_BZ, + common.OpType.REPLACE_XZ): self._ApplyReplaceOperation(op, op_name, data, new_part_file, part_size) elif op.type == common.OpType.MOVE: self._ApplyMoveOperation(op, op_name, new_part_file) |