paycheck: truncate partitions resulting from applying a payload

Since the correctness of the result only encompasses the filesystem (or
otherwise "meaningful data") on the target partition, it is desirable to
actually get rid of whatever is past that point. There are different
reasons for the presence of such extra space in delta updates, including
remnants from a source partition that served as baseline for a delta
update, or scratch space used by MOVE operations for breaking cycles.

We make truncation the default behavior, although it can be suppressed
by passing the right flag (truncate_to_expected_size=False). Note that
this change is necessary for comparing the results of applying a payload
to the partitions as they are extracted from a target image, which is to
be attempted during payload generation.

This also fixes tiny gpylint complaints.

BUG=chromium:241283
TEST=Emitted partition files truncated as expected

Change-Id: Ibb71e4f2305ec41224afdc503168ae02c312f6fe
Reviewed-on: https://gerrit.chromium.org/gerrit/56532
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
2 files changed
tree: 5a3a186031be7d878a309eda61ac01ff97b8d820
  1. scripts/