paycheck: allow to pass an explicit path to bspatch

The bspatch binary is used when applying update payloads. By default, we
were using whatever bspatch that was found via path expansion in
os.execvp, however there are cases where we want to be specific about
where the bspatch binary is that we need to be using (such as during
paygen runs).

BUG=chromium:277072
TEST=Non-default bspatch binary used

Change-Id: I85ffd28aeb26938cbf5ea428fa97d29af0353a7d
Reviewed-on: https://gerrit.chromium.org/gerrit/66736
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/scripts/paycheck.py b/scripts/paycheck.py
index e199a7c..380809e 100755
--- a/scripts/paycheck.py
+++ b/scripts/paycheck.py
@@ -97,6 +97,8 @@
                         default=False,
                         help=('use temp input/output files with BSDIFF '
                               'operations (not in-place)'))
+  trace_opts.add_option('--bspatch-path', metavar='FILE',
+                        help=('use the specified bspatch binary'))
   parser.add_option_group(trace_opts)
 
   trace_opts = optparse.OptionGroup(parser, 'Block tracing')
@@ -152,6 +154,8 @@
       opts.check = True
     if opts.extract_bsdiff:
       parser.error('--extract-bsdiff can only be used when applying payloads')
+    if opts.bspatch_path:
+      parser.error('--bspatch-path can only be used when applying payloads')
   else:
     parser.error('unexpected number of arguments')
 
@@ -218,6 +222,8 @@
       # Apply payload.
       if extra_args:
         dargs = {'bsdiff_in_place': not options.extract_bsdiff}
+        if options.bspatch_path:
+          dargs['bspatch_path'] = options.bspatch_path
         if options.assert_type == _TYPE_DELTA:
           dargs['old_kernel_part'] = extra_args[2]
           dargs['old_rootfs_part'] = extra_args[3]