Re-land "Add ability to check /etc/lsb-release for HWID"

This reverts commit 33ab35b140d9d0da49d971cad26fb2f1b52215b0.


Add ability to check /etc/lsb-release for HWID

This is enabled by a compile-time option, only.

On certain boards HWID may not be available via normal means.
This functionality allows a compile-time choice to enable
behavior that will check /etc/lsb-release for an
HWID_OVERRIDE=<id> entry instead.

CQ-DEPEND=CL:186482
BUG=None
TEST=unit tests

Change-Id: I75a7bcf7219fbb19670647746735c814dacf7879
Reviewed-on: https://chromium-review.googlesource.com/187040
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Chris Masone <cmasone@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
diff --git a/hwid_override.h b/hwid_override.h
new file mode 100644
index 0000000..8f8dbc6
--- /dev/null
+++ b/hwid_override.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_HWID_OVERRIDE_H__
+#define CHROMEOS_PLATFORM_UPDATE_ENGINE_HWID_OVERRIDE_H__
+
+#include <map>
+#include <string>
+
+#include <base/basictypes.h>
+#include <base/file_path.h>
+
+namespace chromeos_update_engine {
+
+// Class that allows HWID to be read from <root>/etc/lsb-release.
+class HwidOverride {
+ public:
+  HwidOverride();
+  ~HwidOverride();
+
+  // Read HWID from an /etc/lsb-release file under given root.
+  // An empty string is returned if there is any error.
+  static std::string Read(const base::FilePath& root);
+
+  static const char kHwidOverrideKey[];
+ private:
+  DISALLOW_COPY_AND_ASSIGN(HwidOverride);
+};
+
+}  // namespace chromeos_update_engine
+
+#endif  // CHROMEOS_PLATFORM_UPDATE_ENGINE_HWID_OVERRIDE_H__