packager: Compare checksum before skipping tar in upload

Earlier, we solely checked if a tarball was present before skipping
the tarring of the autotest tarball. But this tarball might be stale.
So, we additionally compare the checksum of the tarball against what
checksum the pacakger dictionary has. If there is a mismatch,
then we perform the tar again, and upload the new tarball (and update
the corresponding checksum).

This is a speculative patch. There doesn't seem to be a way to reproduce
the Bug in question locally, and so this CL is being pushed.

At the very least it should not lead to any further degradation in
performance or functionality.

BUG=chromium:716151
TEST='emerge-veyron_minnie chromeos-base/autotest-tests-wimax'

Change-Id: I20212e3a0c7159da0716b641a4573d00761584a9
Reviewed-on: https://chromium-review.googlesource.com/507008
Commit-Ready: Prashant Malani <pmalani@google.com>
Tested-by: Prashant Malani <pmalani@google.com>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/utils/packager.py b/utils/packager.py
index fdf0abf..4d9c1c1 100755
--- a/utils/packager.py
+++ b/utils/packager.py
@@ -169,10 +169,11 @@
                            "enough space available: %s" % (temp_dir, e))
                     raise error.RepoDiskFullError(msg)
 
-                # Check if tarball already exists. If it does, don't duplicate
-                # the effort.
+                # Check if tarball already exists. If it does, and the checksum
+                # is the same as what is in the checksum dictionary, then don't
+                # create a tarball again.
                 tarball_path = os.path.join(pkg_dir, pkg_name);
-                if os.path.exists(tarball_path):
+                if os.path.exists(tarball_path) and pkgmgr.compare_checksum(tarball_path):
                     print("process_packages: Tarball %s already exists" %
                           tarball_path)
                 else: