From c3c82f0f4438e63a55617219f611d5e44344c838 Mon Sep 17 00:00:00 2001 From: Matthias Maennich Date: Mon, 28 Oct 2019 15:13:59 +0000 Subject: [PATCH] build.sh: add repo meta information to kbuild build version If this was built out of a repo tree (which is usually the case for the prebuilt kernel images), compute KBUILD_BUILD_VERSION out of repo's current manifest branch. This creates an entry that can be inspected by `uname -v` at runtime or can be derived from the kernel binary: $ zgrep -a 'Linux version' Image.gz Linux version 5.4.0 .... #1 repo:common-android-mainline SMP PREEMPT .. Bug: 143359504 Change-Id: Ib6c2ce1f96e9a4003a74d448751750d61e97d584 Signed-off-by: Matthias Maennich --- _setup_env.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/_setup_env.sh b/_setup_env.sh index 379853f2ba..d0769464fe 100644 --- a/_setup_env.sh +++ b/_setup_env.sh @@ -32,6 +32,13 @@ export COMMON_OUT_DIR=$(readlink -m ${OUT_DIR:-${ROOT_DIR}/out/${BRANCH}}) export OUT_DIR=$(readlink -m ${COMMON_OUT_DIR}/${KERNEL_DIR}) export DIST_DIR=$(readlink -m ${DIST_DIR:-${COMMON_OUT_DIR}/dist}) +if which repo > /dev/null; then + # extract the repo branch name (e.g. common-android-mainline) + repo_branch=$(repo --color=never info -o | grep -E "Manifest merge branch" | + sed "s|.*refs/heads/\(.*\)|\1|") + export KBUILD_BUILD_VERSION="1 repo:$repo_branch" +fi + echo "========================================================" echo "= build config: ${ROOT_DIR}/${BUILD_CONFIG}" cat ${ROOT_DIR}/${BUILD_CONFIG}