Merge remote branch 'cros/upstream' into autotest-rebase

Merged to upstream trunk@5066, from trunk@4749.

There is no way I could enlist each individual CL from the upstream here since it will blow up the changelist description field.

BUG=
TEST=
Had patched this CL into a fresh cut client to avoid any side effect.
run_remote_test bvt from both emerged location and third_party/autotest/file.

Both test passed!

We should also keep any eye on this to see how it gets propagated into cautotest server.
TBR=dalecurtis

Change-Id: I72f2bc7a9de530178484aea1bfb5ace68bcad029
diff --git a/client/bin/kernel.py b/client/bin/kernel.py
index f3f5a38..cb0ef99 100644
--- a/client/bin/kernel.py
+++ b/client/bin/kernel.py
@@ -332,15 +332,17 @@
             utils.extract_tarball_to_dir(tarball, self.build_dir)
 
 
-    def extraversion(self, tag, append=1):
+    def extraversion(self, tag, append=True):
         os.chdir(self.build_dir)
-        extraversion_sub = r's/^EXTRAVERSION =\s*\(.*\)/EXTRAVERSION = '
+        extraversion_sub = r's/^CONFIG_LOCALVERSION=\s*"\(.*\)"/CONFIG_LOCALVERSION='
+        cfg = self.build_dir + '/.config'
         if append:
-            p = extraversion_sub + '\\1-%s/' % tag
+            p = extraversion_sub + '"\\1-%s"/' % tag
         else:
-            p = extraversion_sub + '-%s/' % tag
-        utils.system('mv Makefile Makefile.old')
-        utils.system('sed "%s" < Makefile.old > Makefile' % p)
+            p = extraversion_sub + '"-%s"/' % tag
+        utils.system('mv %s %s.old' % (cfg, cfg))
+        utils.system("sed '%s' < %s.old > %s" % (p, cfg, cfg))
+        self.config(make='oldconfig')
 
 
     @log.record
diff --git a/client/bin/kernel_unittest.py b/client/bin/kernel_unittest.py
index 6761c05..4ed0d37 100755
--- a/client/bin/kernel_unittest.py
+++ b/client/bin/kernel_unittest.py
@@ -425,13 +425,17 @@
     def test_extraversion(self):
         self.construct_kernel()
         tag = "tag"
+        # setup
+        self.god.stub_function(self.kernel, "config")
 
         # record
         os.chdir.expect_call(self.build_dir)
-        extraversion_sub = r's/^EXTRAVERSION =\s*\(.*\)/EXTRAVERSION = '
-        p = extraversion_sub + '\\1-%s/' % tag
-        utils.system.expect_call('mv Makefile Makefile.old')
-        utils.system.expect_call('sed "%s" < Makefile.old > Makefile' % p)
+        extraversion_sub = r's/^CONFIG_LOCALVERSION=\s*"\(.*\)"/CONFIG_LOCALVERSION='
+        cfg = self.build_dir + '/.config'
+        p = extraversion_sub + '"\\1-%s"/' % tag
+        utils.system.expect_call('mv %s %s.old' % (cfg, cfg))
+        utils.system.expect_call("sed '%s' < %s.old > %s" % (p, cfg, cfg))
+        self.kernel.config.expect_call(make='oldconfig')
 
         # run and check
         self.kernel.extraversion(tag)
diff --git a/client/bin/partition.py b/client/bin/partition.py
index 355d1b3..7381f75 100644
--- a/client/bin/partition.py
+++ b/client/bin/partition.py
@@ -185,7 +185,7 @@
     mount_info = set()
     for p in partition_list:
         try:
-            uuid = utils.system_output('blkid -s UUID -o value %s' % p.device)
+            uuid = utils.system_output('blkid -p -s UUID -o value %s' % p.device)
         except error.CmdError:
             # fall back to using the partition
             uuid = p.device