update_payload: use argparse

optparse is deprecated (or going to be). Change paycheck.py and
blockdiff.py to use argparse instead. Both of these files are being used
manually and it would be a good time to fix these before major changes
in update_payload.

paycheck.sh -h:

usage: paycheck.py [-h] [-c] [-D] [-r FILE] [-t {full,delta}] [-z NUM] [-u]
                   [-d] [-k FILE] [-m FILE] [-p NUM] [-P NUM] [-x]
                   [--bspatch-path FILE] [--puffpatch-path FILE]
                   [--dst_kern FILE] [--dst_root FILE] [--src_kern FILE]
                   [--src_root FILE] [-b BLOCK] [-B BLOCK] [-s NUM]
                   PAYLOAD

Applies a Chrome OS update PAYLOAD to src_kern and src_root emitting dst_kern and dst_root, respectively. src_kern and src_root are only needed for delta payloads. When no partitions are provided, verifies the payload integrity.

positional arguments:
  PAYLOAD               the payload file

optional arguments:
  -h, --help            show this help message and exit

Checking payload integrity:
  -c, --check           force payload integrity check (e.g. before applying)
  -D, --describe        Print a friendly description of the payload.
  -r FILE, --report FILE
                        dump payload report (`-' for stdout)
  -t {full,delta}, --type {full,delta}
                        assert the payload type
  -z NUM, --block-size NUM
                        assert a non-default (4096) payload block size
  -u, --allow-unhashed  allow unhashed operations
  -d , --disabled_tests
                        space separated list of tests to disable. allowed
                        options include: dst-pseudo-extents, move-same-src-
                        dst-block, payload-sig
  -k FILE, --key FILE   override standard key used for signature validation
  -m FILE, --meta-sig FILE
                        verify metadata against its signature
  -p NUM, --root-part-size NUM
                        override rootfs partition size auto-inference
  -P NUM, --kern-part-size NUM
                        override kernel partition size auto-inference

Applying payload:
  -x, --extract-bsdiff  use temp input/output files with BSDIFF operations
                        (not in-place)
  --bspatch-path FILE   use the specified bspatch binary
  --puffpatch-path FILE
                        use the specified puffpatch binary
  --dst_kern FILE       destination kernel partition file
  --dst_root FILE       destination root partition file
  --src_kern FILE       source kernel partition file
  --src_root FILE       source root partition file

Block tracing:
  -b BLOCK, --root-block BLOCK
                        trace the origin for a rootfs block
  -B BLOCK, --kern-block BLOCK
                        trace the origin for a kernel block
  -s NUM, --skip NUM    skip first NUM occurrences of traced block

Note: a payload may verify correctly but fail to apply, and vice versa; this is by design and can be thought of as static vs dynamic correctness. A payload that both verifies and applies correctly should be safe for use by the Chrome OS Update Engine. Use --check to verify a payload prior to applying it.

BUG=chromium:796338
TEST=unitests
TEST=test_paycheck.sh
TEST=blockdiff.py

Change-Id: I794b5f61e6ba6f92939947c97c432f9fea0b6b3c
Reviewed-on: https://chromium-review.googlesource.com/834876
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>
3 files changed
tree: 24ca54298fb7fb5da38123a73296571f331bacb6
  1. binder_bindings/
  2. client_library/
  3. common/
  4. dbus_bindings/
  5. init/
  6. payload_consumer/
  7. payload_generator/
  8. sample_images/
  9. scripts/
  10. update_manager/
  11. update_payload_key/
  12. .gitignore
  13. Android.mk
  14. binder_service_android.cc
  15. binder_service_android.h
  16. binder_service_brillo.cc
  17. binder_service_brillo.h
  18. boot_control_android.cc
  19. boot_control_android.h
  20. boot_control_chromeos.cc
  21. boot_control_chromeos.h
  22. boot_control_chromeos_unittest.cc
  23. boot_control_recovery.cc
  24. boot_control_recovery.h
  25. boot_control_recovery_stub.cc
  26. certificate_checker.cc
  27. certificate_checker.h
  28. certificate_checker_unittest.cc
  29. chrome_browser_proxy_resolver.cc
  30. chrome_browser_proxy_resolver.h
  31. COMMIT-QUEUE.ini
  32. common_service.cc
  33. common_service.h
  34. common_service_unittest.cc
  35. connection_manager.cc
  36. connection_manager.h
  37. connection_manager_android.cc
  38. connection_manager_android.h
  39. connection_manager_interface.h
  40. connection_manager_unittest.cc
  41. connection_utils.cc
  42. connection_utils.h
  43. CPPLINT.cfg
  44. daemon.cc
  45. daemon.h
  46. daemon_state_android.cc
  47. daemon_state_android.h
  48. daemon_state_interface.h
  49. dbus_connection.cc
  50. dbus_connection.h
  51. dbus_service.cc
  52. dbus_service.h
  53. dbus_test_utils.h
  54. fake_file_writer.h
  55. fake_p2p_manager.h
  56. fake_p2p_manager_configuration.h
  57. fake_shill_proxy.cc
  58. fake_shill_proxy.h
  59. fake_system_state.cc
  60. fake_system_state.h
  61. generate_pc_file.sh
  62. hardware_android.cc
  63. hardware_android.h
  64. hardware_chromeos.cc
  65. hardware_chromeos.h
  66. hardware_chromeos_unittest.cc
  67. image_properties.h
  68. image_properties_android.cc
  69. image_properties_chromeos.cc
  70. image_properties_chromeos_unittest.cc
  71. libcurl_http_fetcher.cc
  72. libcurl_http_fetcher.h
  73. libupdate_engine-client-test.pc.in
  74. libupdate_engine-client.pc.in
  75. local_coverage_rate
  76. main.cc
  77. metrics.cc
  78. metrics.h
  79. metrics_utils.cc
  80. metrics_utils.h
  81. metrics_utils_unittest.cc
  82. mock_certificate_checker.h
  83. mock_connection_manager.h
  84. mock_file_writer.h
  85. mock_omaha_request_params.h
  86. mock_p2p_manager.h
  87. mock_payload_state.h
  88. mock_power_manager.h
  89. mock_proxy_resolver.h
  90. mock_update_attempter.h
  91. MODULE_LICENSE_APACHE2
  92. network_selector.h
  93. network_selector_android.cc
  94. network_selector_android.h
  95. network_selector_interface.h
  96. network_selector_stub.cc
  97. network_selector_stub.h
  98. NOTICE
  99. omaha_request_action.cc
  100. omaha_request_action.h
  101. omaha_request_action_unittest.cc
  102. omaha_request_params.cc
  103. omaha_request_params.h
  104. omaha_request_params_unittest.cc
  105. omaha_response.h
  106. omaha_response_handler_action.cc
  107. omaha_response_handler_action.h
  108. omaha_response_handler_action_unittest.cc
  109. omaha_utils.cc
  110. omaha_utils.h
  111. omaha_utils_unittest.cc
  112. OWNERS
  113. p2p_manager.cc
  114. p2p_manager.h
  115. p2p_manager_unittest.cc
  116. parcelable_update_engine_status.cc
  117. parcelable_update_engine_status.h
  118. payload_state.cc
  119. payload_state.h
  120. payload_state_interface.h
  121. payload_state_unittest.cc
  122. power_manager_android.cc
  123. power_manager_android.h
  124. power_manager_chromeos.cc
  125. power_manager_chromeos.h
  126. power_manager_interface.h
  127. PRESUBMIT.cfg
  128. PREUPLOAD.cfg
  129. proxy_resolver.cc
  130. proxy_resolver.h
  131. proxy_resolver_unittest.cc
  132. pylintrc
  133. real_system_state.cc
  134. real_system_state.h
  135. run_unittests
  136. sample_omaha_v3_response.xml
  137. service_delegate_android_interface.h
  138. service_observer_interface.h
  139. shill_proxy.cc
  140. shill_proxy.h
  141. shill_proxy_interface.h
  142. sideload_main.cc
  143. system_state.h
  144. tar_bunzip2.gypi
  145. test_http_server.cc
  146. test_subprocess.cc
  147. testrunner.cc
  148. unittest_key.pem
  149. unittest_key2.pem
  150. update_attempter.cc
  151. update_attempter.h
  152. update_attempter_android.cc
  153. update_attempter_android.h
  154. update_attempter_unittest.cc
  155. update_engine-client.gyp
  156. update_engine.conf
  157. update_engine.gyp
  158. update_engine.rc
  159. update_engine_client.cc
  160. update_engine_client_android.cc
  161. update_metadata.proto
  162. update_status_utils.cc
  163. update_status_utils.h
  164. UpdateEngine.conf
  165. utils_android.cc
  166. utils_android.h
  167. WATCHLISTS