Pass the correct major_version when generating updates.

All Chrome OS updaters support major payload version 1 (or newer) and
all Brillo updaters support major payload version 2, so this patch
passes those version numbers to the delta_generator.

When generating delta payloads, we use the major_version specified by
the old updater.

BUG=b:22024447
TEST=`brillo_generate_update_payload` generate, hash and sign for a recent build.

Change-Id: Ib7509296a3bab79868e4fd718a0aaac163b29f69
Reviewed-on: https://chromium-review.googlesource.com/306101
Commit-Ready: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Jason Kusuma <jkusuma@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
diff --git a/scripts/brillo_update_payload b/scripts/brillo_update_payload
index 50102c7..935dc73 100755
--- a/scripts/brillo_update_payload
+++ b/scripts/brillo_update_payload
@@ -267,6 +267,10 @@
     --kern_path "${kernel}" --root_path "${root}" \
     --work_dir "${FLAGS_work_dir}" --outside_chroot
 
+  # Chrome OS uses major_version 1 payloads for all versions, even if the
+  # updater supports a newer major version.
+  FORCE_MAJOR_VERSION="1"
+
   # When generating legacy Chrome OS images, we need to use "boot" and "system"
   # for the partition names to be compatible with updating Brillo devices with
   # Chrome OS images.
@@ -293,6 +297,9 @@
   # sanitize the list of partition names to be in [a-zA-Z0-9-]+.
   local partitions=( "boot" "system" )
 
+  # All Brillo updaters support major version 2.
+  FORCE_MAJOR_VERSION="2"
+
   if [[ "${partitions_array}" == "SRC_PARTITIONS" ]]; then
     ue_config=$(create_tempfile "ue_config.XXXXXX")
     CLEANUP_FILES+=("${ue_config}")
@@ -301,8 +308,12 @@
       warn "No update_engine_config.txt found. Assuming pre-release image, \
 using payload minor version 2"
     fi
+    # For delta payloads, we use the major and minor version supported by the
+    # old updater.
     FORCE_MINOR_VERSION=$(read_option_uint "${ue_config}" \
       "PAYLOAD_MINOR_VERSION" 2)
+    FORCE_MAJOR_VERSION=$(read_option_uint "${ue_config}" \
+      "PAYLOAD_MAJOR_VERSION" 2)
   fi
 
   local part part_file temp_raw filesize