Separate system_version and product_version.

system_version will be at /etc/os-release.d/system_version, no symlink.
product_version still at oem partition, but now has only one number.

Bug: 35364984
Test: m droid dist oem_image custom_images -j
Change-Id: If0f357d29c8dd0cec1ff4999a3c42b0362a45c01
(cherry picked from commit 9b173cccb8bdb750d4cf7855e5379ceee5ba030f)
diff --git a/brillo_config/Android.mk b/brillo_config/Android.mk
index b4d8c93..7c1dd6c 100644
--- a/brillo_config/Android.mk
+++ b/brillo_config/Android.mk
@@ -43,20 +43,49 @@
 LOCAL_MODULE_PATH := $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)
 include $(BUILD_SYSTEM)/base_rules.mk
 
-# The version is set to 0.0.0 if the user did not set the actual version and
+# The version is set to 0 if the user did not set the actual version and
 # a version cannot be loaded from the product cfgtree.
 # This allows us to have a valid version number while being easy to filter.
 ifeq ($(BRILLO_PRODUCT_VERSION),)
 # Load from file first
 BRILLO_PRODUCT_VERSION := $(call cfgtree-get-if-exists,brillo/product_version)
 endif
-# If the version is still empty, override it with 0.0.0
+# If the version is still empty, override it with 0
 ifeq ($(BRILLO_PRODUCT_VERSION),)
-BRILLO_PRODUCT_VERSION := "0.0.0"
+BRILLO_PRODUCT_VERSION := "0"
 endif
-ifeq ($(shell echo $(BRILLO_PRODUCT_VERSION) | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$$'),)
+ifeq ($(shell echo $(BRILLO_PRODUCT_VERSION) | grep -E '^[0-9]+$$'),)
 $(error Invalid BRILLO_PRODUCT_VERSION "$(BRILLO_PRODUCT_VERSION)", must be \
-  three numbers separated by dots. Example: "1.2.0")
+  a single number. Example: "1")
+endif
+
+$(LOCAL_BUILT_MODULE):
+	$(hide) mkdir -p $(dir $@)
+	echo $(BRILLO_PRODUCT_VERSION) > $@
+	$(hide) mkdir -p $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
+	ln -sf /oem/$(OSRELEASED_DIRECTORY)/product_version $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
+
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := system_version
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
+include $(BUILD_SYSTEM)/base_rules.mk
+
+# The version is set to 0.0 if the user did not set the actual version and
+# a version cannot be loaded from the product cfgtree.
+# This allows us to have a valid version number while being easy to filter.
+ifeq ($(BRILLO_SYSTEM_VERSION),)
+# Load from file first
+BRILLO_SYSTEM_VERSION := $(call cfgtree-get-if-exists,brillo/system_version)
+endif
+# If the version is still empty, override it with 0.0
+ifeq ($(BRILLO_SYSTEM_VERSION),)
+BRILLO_SYSTEM_VERSION := "0.0"
+endif
+ifeq ($(shell echo $(BRILLO_SYSTEM_VERSION) | grep -E '^[0-9]+\.[0-9]+$$'),)
+$(error Invalid BRILLO_SYSTEM_VERSION "$(BRILLO_SYSTEM_VERSION)", must be \
+  two numbers separated by dots. Example: "1.2")
 endif
 
 # Append BUILD_NUMBER if it is a number or a build timestamp otherwise.
@@ -67,11 +96,9 @@
 $(LOCAL_BUILT_MODULE):
 	$(hide) mkdir -p $(dir $@)
 ifeq ($(shell echo $(BUILD_NUMBER) | grep -E '[^0-9]'),)
-	echo $(BRILLO_PRODUCT_VERSION).$(BUILD_NUMBER) > $@
+	echo $(BRILLO_SYSTEM_VERSION).$(BUILD_NUMBER) > $@
 else
-	echo $(BRILLO_PRODUCT_VERSION).$(BUILD_DATETIME) > $@
+	echo $(BRILLO_SYSTEM_VERSION).$(BUILD_DATETIME) > $@
 endif
-	$(hide) mkdir -p $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
-	ln -sf /oem/$(OSRELEASED_DIRECTORY)/product_version $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
 
 endif