From 63e48db6d19a676edb56b32d9afc10de363d6122 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Wed, 2 Jan 2019 12:27:43 -0800 Subject: [PATCH] Add BUILD_USERNAME and BUILD_HOSTNAME These replace $USER and `hostname`, which will soon become stable values due to sandboxing the build on Linux. Bug: 122270019 Test: check build.prop Change-Id: I7493e45a2a2defbdba5d82596cb91d68480f0187 --- core/Makefile | 4 +++- core/main.mk | 2 +- core/version_defaults.mk | 2 +- tools/buildinfo.sh | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/Makefile b/core/Makefile index 179cf29de..56b45df69 100644 --- a/core/Makefile +++ b/core/Makefile @@ -317,7 +317,7 @@ $(intermediate_system_build_prop): PRIVATE_BUILD_DESC := $(build_desc) # The string used to uniquely identify the combined build and product; used by the OTA server. ifeq (,$(strip $(BUILD_FINGERPRINT))) ifeq ($(strip $(HAS_BUILD_NUMBER)),false) - BF_BUILD_NUMBER := $(USER)$$($(DATE_FROM_FILE) +%m%d%H%M) + BF_BUILD_NUMBER := $(BUILD_USERNAME)$$($(DATE_FROM_FILE) +%m%d%H%M) else BF_BUILD_NUMBER := $(file <$(BUILD_NUMBER_FILE)) endif @@ -420,6 +420,8 @@ endif BUILD_ID="$(BUILD_ID)" \ BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \ DATE="$(DATE_FROM_FILE)" \ + BUILD_USERNAME="$(BUILD_USERNAME)" \ + BUILD_HOSTNAME="$(BUILD_HOSTNAME)" \ BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \ BOARD_BUILD_SYSTEM_ROOT_IMAGE="$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)" \ AB_OTA_UPDATER="$(AB_OTA_UPDATER)" \ diff --git a/core/main.mk b/core/main.mk index 9fd1c35c5..4f81c2163 100644 --- a/core/main.mk +++ b/core/main.mk @@ -80,7 +80,7 @@ endif ifeq ($(strip $(HAS_BUILD_NUMBER)),false) # BUILD_NUMBER has a timestamp in it, which means that # it will change every time. Pick a stable value. - FILE_NAME_TAG := eng.$(USER) + FILE_NAME_TAG := eng.$(BUILD_USERNAME) else FILE_NAME_TAG := $(file <$(BUILD_NUMBER_FILE)) endif diff --git a/core/version_defaults.mk b/core/version_defaults.mk index 0fd40db12..c4f9a5229 100644 --- a/core/version_defaults.mk +++ b/core/version_defaults.mk @@ -314,7 +314,7 @@ ifndef BUILD_NUMBER # If no BUILD_NUMBER is set, create a useful "I am an engineering build # from this date/time" value. Make it start with a non-digit so that # anyone trying to parse it as an integer will probably get "0". - BUILD_NUMBER := eng.$(shell echo $${USER:0:6}).$(shell $(DATE) +%Y%m%d.%H%M%S) + BUILD_NUMBER := eng.$(shell echo $${BUILD_USERNAME:0:6}).$(shell $(DATE) +%Y%m%d.%H%M%S) HAS_BUILD_NUMBER := false endif .KATI_READONLY := BUILD_NUMBER HAS_BUILD_NUMBER diff --git a/tools/buildinfo.sh b/tools/buildinfo.sh index b76c08954..7286f95b3 100755 --- a/tools/buildinfo.sh +++ b/tools/buildinfo.sh @@ -18,8 +18,8 @@ echo "ro.build.version.min_supported_target_sdk=$PLATFORM_MIN_SUPPORTED_TARGET_S echo "ro.build.date=`$DATE`" echo "ro.build.date.utc=`$DATE +%s`" echo "ro.build.type=$TARGET_BUILD_TYPE" -echo "ro.build.user=$USER" -echo "ro.build.host=`hostname`" +echo "ro.build.user=$BUILD_USERNAME" +echo "ro.build.host=$BUILD_HOSTNAME" echo "ro.build.tags=$BUILD_VERSION_TAGS" echo "ro.build.flavor=$TARGET_BUILD_FLAVOR" if [ -n "$BOARD_BUILD_SYSTEM_ROOT_IMAGE" ] ; then