dlc_lib: Check for lsb-release file before opening it

If the lsb-release file is missing, the exception message is not very
useful. Adding a check for the file and showing a more detailed message
will save time troubleshooting when the file is not there.

BUG=None
TEST=build image and make it fail.

Change-Id: Id80bb0ed1a59d4fcbefee117b57ed2cdeda50172
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2339400
Tested-by: Andrew Lassalle <andrewlassalle@chromium.org>
Commit-Queue: Andrew Lassalle <andrewlassalle@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
diff --git a/lib/dlc_lib.py b/lib/dlc_lib.py
index 86a093b..4f3eac4 100644
--- a/lib/dlc_lib.py
+++ b/lib/dlc_lib.py
@@ -316,17 +316,19 @@
     Args:
       dlc_dir: (str) The path to the mounted point during image creation.
     """
-    # Reading the platform APPID and creating the DLC APPID.
-    platform_lsb_release = osutils.ReadFile(
-        os.path.join(self.sysroot, LSB_RELEASE))
     app_id = None
-    for line in platform_lsb_release.split('\n'):
-      if line.startswith(cros_set_lsb_release.LSB_KEY_APPID_RELEASE):
-        app_id = line.split('=')[1]
+    platform_lsb_rel_path = os.path.join(self.sysroot, LSB_RELEASE)
+    if os.path.isfile(platform_lsb_rel_path):
+      # Reading the platform APPID and creating the DLC APPID.
+      platform_lsb_release = osutils.ReadFile(platform_lsb_rel_path)
+      for line in platform_lsb_release.split('\n'):
+        if line.startswith(cros_set_lsb_release.LSB_KEY_APPID_RELEASE):
+          app_id = line.split('=')[1]
+
     if app_id is None:
       raise Exception(
           '%s does not have a valid key %s' %
-          (platform_lsb_release, cros_set_lsb_release.LSB_KEY_APPID_RELEASE))
+          (platform_lsb_rel_path, cros_set_lsb_release.LSB_KEY_APPID_RELEASE))
 
     fields = (
         (DLC_ID_KEY, self.ebuild_params.dlc_id),