Genereate /etc/os-release during build_image

os-release fields can be set through /etc/os-release.d so we need to rebuild
os-release when building the image.

BUG=chromium:420784
TEST=Set a field in /etc/os-release.d. The image contains that field in
/etc/os-release.

CQ-DEPEND=CL:221761

Change-Id: I5f734323f16ea1ebcdd14fd12d32b46ff9ba3367
Reviewed-on: https://chromium-review.googlesource.com/221756
Commit-Ready: Andrey Ulanov <andreyu@google.com>
Tested-by: Andrey Ulanov <andreyu@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/build_library/base_image_util.sh b/build_library/base_image_util.sh
index 6c7de6a..014b53d 100755
--- a/build_library/base_image_util.sh
+++ b/build_library/base_image_util.sh
@@ -246,6 +246,13 @@
     --patch_number="${CHROMEOS_PATCH}" \
     ${arc_version}
 
+  # Set /etc/os-release on the image.
+  # Note: fields in /etc/os-release can come from different places:
+  # * /etc/os-release itself with docrashid
+  # * /etc/os-release.d for fields created with do_osrelease_field
+  sudo "${GCLIENT_ROOT}/chromite/bin/cros_generate_os_release" \
+    --root="${root_fs_dir}"
+
   # Create the boot.desc file which stores the build-time configuration
   # information needed for making the image bootable after creation with
   # cros_make_image_bootable.