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