Revert "update_payload: Add XZ compression support"

This reverts commit f1d6ceaedbcf81044d6af6b716c63ed79996f0a4.

Reason for revert: <canaries failing>

Original change's description:
> update_payload: Add XZ compression support
>
> This patch adds support for checking a payload that has REPLACE_XZ
> operations. REPLACE_XZ was added in minor version 3.
>
> BUG=chromium:758792
> TEST=unittests pass; paycheck.py with a xz generated payload pass;
> CQ-DEPEND=CL:823234
>
> Change-Id: If82c767a201b189e464f459d5c19485e5278d9b1
> Reviewed-on: https://chromium-review.googlesource.com/823227
> Commit-Ready: Amin Hassani <ahassani@chromium.org>
> Tested-by: Amin Hassani <ahassani@chromium.org>
> Reviewed-by: Ben Chan <benchan@chromium.org>
> Reviewed-by: Sen Jiang <senj@chromium.org>

TBR=benchan@chromium.org,senj@chromium.org,ahassani@chromium.org

Change-Id: I931ff3be081a41fe5fceef0e049ba4165c6acb49
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:795313
Reviewed-on: https://chromium-review.googlesource.com/830054
Commit-Ready: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
diff --git a/scripts/update_payload/applier.py b/scripts/update_payload/applier.py
index eeb2e42..3cb9741 100644
--- a/scripts/update_payload/applier.py
+++ b/scripts/update_payload/applier.py
@@ -18,10 +18,6 @@
 import bz2
 import hashlib
 import itertools
-try:
-    import lzma
-except ImportError:
-    from backports import lzma
 import os
 import shutil
 import subprocess
@@ -221,7 +217,7 @@
     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,_XZ} operation.
+    """Applies a REPLACE{,_BZ} operation.
 
     Args:
       op: the operation object
@@ -240,9 +236,6 @@
     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:
-      out_data = lzma.decompress(out_data)
-      data_length = len(out_data)
 
     # Write data to blocks specified in dst extents.
     data_start = 0
@@ -514,8 +507,7 @@
       # Read data blob.
       data = self.payload.ReadDataBlob(op.data_offset, op.data_length)
 
-      if op.type in (common.OpType.REPLACE, common.OpType.REPLACE_BZ,
-                     common.OpType.REPLACE_XZ):
+      if op.type in (common.OpType.REPLACE, common.OpType.REPLACE_BZ):
         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)
diff --git a/scripts/update_payload/checker.py b/scripts/update_payload/checker.py
index 3cf98ca..c710c47 100644
--- a/scripts/update_payload/checker.py
+++ b/scripts/update_payload/checker.py
@@ -322,10 +322,6 @@
     self.new_rootfs_fs_size = 0
     self.new_kernel_fs_size = 0
     self.minor_version = None
-    # TODO(*): When fixing crbug.com/794404, the major version should be
-    # correclty handled in update_payload scripts. So stop forcing
-    # major_verions=1 here and set it to the correct value.
-    self.major_version = 1;
 
   @staticmethod
   def _CheckElem(msg, name, report, is_mandatory, is_submsg, convert=str,
@@ -705,7 +701,7 @@
     return total_num_blocks
 
   def _CheckReplaceOperation(self, op, data_length, total_dst_blocks, op_name):
-    """Specific checks for REPLACE/REPLACE_BZ/REPLACE_XZ operations.
+    """Specific checks for REPLACE/REPLACE_BZ operations.
 
     Args:
       op: The operation object from the manifest.
@@ -1002,9 +998,6 @@
     # Type-specific checks.
     if op.type in (common.OpType.REPLACE, common.OpType.REPLACE_BZ):
       self._CheckReplaceOperation(op, data_length, total_dst_blocks, op_name)
-    elif op.type == common.OpType.REPLACE_XZ and (self.minor_version >= 3 or
-                                                  self.major_version >= 2):
-      self._CheckReplaceOperation(op, data_length, total_dst_blocks, op_name)
     elif op.type == common.OpType.MOVE and self.minor_version == 1:
       self._CheckMoveOperation(op, data_offset, total_src_blocks,
                                total_dst_blocks, op_name)
@@ -1077,7 +1070,6 @@
     op_counts = {
         common.OpType.REPLACE: 0,
         common.OpType.REPLACE_BZ: 0,
-        common.OpType.REPLACE_XZ: 0,
         common.OpType.MOVE: 0,
         common.OpType.ZERO: 0,
         common.OpType.BSDIFF: 0,
@@ -1090,7 +1082,6 @@
     op_blob_totals = {
         common.OpType.REPLACE: 0,
         common.OpType.REPLACE_BZ: 0,
-        common.OpType.REPLACE_XZ: 0,
         # MOVE operations don't have blobs.
         common.OpType.BSDIFF: 0,
         # SOURCE_COPY operations don't have blobs.
diff --git a/scripts/update_payload/checker_unittest.py b/scripts/update_payload/checker_unittest.py
index a38e334..245da55 100755
--- a/scripts/update_payload/checker_unittest.py
+++ b/scripts/update_payload/checker_unittest.py
@@ -634,44 +634,6 @@
         payload_checker._CheckReplaceOperation,
         op, data_length, (data_length + block_size - 1) / block_size, 'foo')
 
-  def testCheckReplaceXzOperation(self):
-    """Tests _CheckReplaceOperation() where op.type == REPLACE_XZ."""
-    payload_checker = checker.PayloadChecker(self.MockPayload())
-    block_size = payload_checker.block_size
-    data_length = block_size * 3
-
-    op = self.mox.CreateMock(
-        update_metadata_pb2.InstallOperation)
-    op.type = common.OpType.REPLACE_XZ
-
-    # Pass.
-    op.src_extents = []
-    self.assertIsNone(
-        payload_checker._CheckReplaceOperation(
-            op, data_length, (data_length + block_size - 1) / block_size + 5,
-            'foo'))
-
-    # Fail, src extents founds.
-    op.src_extents = ['bar']
-    self.assertRaises(
-        update_payload.PayloadError,
-        payload_checker._CheckReplaceOperation,
-        op, data_length, (data_length + block_size - 1) / block_size + 5, 'foo')
-
-    # Fail, missing data.
-    op.src_extents = []
-    self.assertRaises(
-        update_payload.PayloadError,
-        payload_checker._CheckReplaceOperation,
-        op, None, (data_length + block_size - 1) / block_size, 'foo')
-
-    # Fail, too few blocks to justify XZ.
-    op.src_extents = []
-    self.assertRaises(
-        update_payload.PayloadError,
-        payload_checker._CheckReplaceOperation,
-        op, data_length, (data_length + block_size - 1) / block_size, 'foo')
-
   def testCheckMoveOperation_Pass(self):
     """Tests _CheckMoveOperation(); pass case."""
     payload_checker = checker.PayloadChecker(self.MockPayload())
@@ -857,8 +819,8 @@
     """Parametric testing of _CheckOperation().
 
     Args:
-      op_type_name: 'REPLACE', 'REPLACE_BZ', 'REPLACE_XZ', 'MOVE', 'BSDIFF',
-        'SOURCE_COPY', 'SOURCE_BSDIFF', BROTLI_BSDIFF or 'PUFFDIFF'.
+      op_type_name: 'REPLACE', 'REPLACE_BZ', 'MOVE', 'BSDIFF', 'SOURCE_COPY',
+        'SOURCE_BSDIFF', BROTLI_BSDIFF or 'PUFFDIFF'.
       is_last: Whether we're testing the last operation in a sequence.
       allow_signature: Whether we're testing a signature-capable operation.
       allow_unhashed: Whether we're allowing to not hash the data.
@@ -913,8 +875,6 @@
       payload_checker.minor_version = 2 if fail_bad_minor_version else 1
     elif op_type in (common.OpType.SOURCE_COPY, common.OpType.SOURCE_BSDIFF):
       payload_checker.minor_version = 1 if fail_bad_minor_version else 2
-    if op_type == common.OpType.REPLACE_XZ:
-      payload_checker.minor_version = 2 if fail_bad_minor_version else 3
     elif op_type in (common.OpType.ZERO, common.OpType.DISCARD,
                      common.OpType.PUFFDIFF, common.OpType.BROTLI_BSDIFF):
       payload_checker.minor_version = 3 if fail_bad_minor_version else 4
@@ -1235,13 +1195,10 @@
   """Returns True iff the combination of arguments represents a valid test."""
   op_type = _OpTypeByName(op_type_name)
 
-  # REPLACE/REPLACE_BZ/REPLACE_XZ operations don't read data from src
-  # partition. They are compatible with all valid minor versions, so we don't
-  # need to check that.
-  if (op_type in (common.OpType.REPLACE, common.OpType.REPLACE_BZ,
-                  common.OpType.REPLACE_XZ) and (fail_src_extents or
-                                                 fail_src_length or
-                                                 fail_bad_minor_version)):
+  # REPLACE/REPLACE_BZ operations don't read data from src partition. They are
+  # compatible with all valid minor versions, so we don't need to check that.
+  if (op_type in (common.OpType.REPLACE, common.OpType.REPLACE_BZ) and (
+      fail_src_extents or fail_src_length or fail_bad_minor_version)):
     return False
 
   # MOVE and SOURCE_COPY operations don't carry data.
@@ -1327,8 +1284,8 @@
 
   # Add all _CheckOperation() test cases.
   AddParametricTests('CheckOperation',
-                     {'op_type_name': ('REPLACE', 'REPLACE_BZ', 'REPLACE_XZ',
-                                       'MOVE', 'BSDIFF', 'SOURCE_COPY',
+                     {'op_type_name': ('REPLACE', 'REPLACE_BZ', 'MOVE',
+                                       'BSDIFF', 'SOURCE_COPY',
                                        'SOURCE_BSDIFF', 'PUFFDIFF',
                                        'BROTLI_BSDIFF'),
                       'is_last': (True, False),
diff --git a/scripts/update_payload/test_utils.py b/scripts/update_payload/test_utils.py
index bfdc40e..61a91f5 100644
--- a/scripts/update_payload/test_utils.py
+++ b/scripts/update_payload/test_utils.py
@@ -282,7 +282,7 @@
 
     Args:
       is_kernel: whether this is a kernel (True) or rootfs (False) operation
-      op_type: one of REPLACE, REPLACE_BZ, REPLACE_XZ, MOVE or BSDIFF
+      op_type: one of REPLACE, REPLACE_BZ, MOVE or BSDIFF
       src_extents: list of (start, length) pairs indicating src block ranges
       src_length: size of the src data in bytes (needed for BSDIFF)
       dst_extents: list of (start, length) pairs indicating dst block ranges