libupgrade: Ensure main/backup partition in sync

For r/w variables, hnvram maintains a main and a backup partition which
should be identical under normal circumstances. For read operations, it
looks at the main partition first and only reads the backup partition if
it fails to read the main partition.  Inconsistencies go unnoticed. For
write operations, it would only write to the flash if the value being
written is different from the value that is already stored on the flash.
With this approach, we might end up in a situation where the main and
the backup partitions contain different values for the same variable,
but still, a write operation would not fix the problem.

Example: Let's say the main and backup partitions contain VAR=abc and
VAR=xyz, respectively. Previously, the command "hnvram -w VAR=abc" would
not write VAR=abc to the backup partition because a read operation
yields VAR=abc which is why it decides that no write operation is
necessary.

Let's move the logic that skips unnecessary writes a few levels down
where it checks the main and backup partitions separately.

Change-Id: I6c120b9cb537da2097681a619a568a1ca917509f
2 files changed
tree: 39431d30a43b7e270b582a8f87bf02428f3d9da6
  1. libupgrade/
  2. makehdf