From d0273411d1fa18ee0b39fd3e622c9e07e110c48d Mon Sep 17 00:00:00 2001 From: "J. Avila" Date: Tue, 4 May 2021 20:12:14 +0000 Subject: [PATCH] build_slider: Inform the user of aosp diffs if BUILD_KERNEL unset If BUILD_KERNEL is not set, it defaults to 0; i.e. it uses prebuilts. If the user, however, has changes in aosp/, they may not be aware that their changes didn't build. Add a check at the end to inform them and recommend explicitly setting BUILD_KERNEL if they're making any changes to the aosp/ directory. Bug: 184667897 Signed-off-by: J. Avila Change-Id: I2d9ca9283c34e6296007bb1b7eae26cc06b7a672 --- build_slider.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/build_slider.sh b/build_slider.sh index cfd49d4598f5..33a197476774 100755 --- a/build_slider.sh +++ b/build_slider.sh @@ -50,10 +50,12 @@ GKI_PREBUILTS_DIR=$(readlink -m "prebuilts/boot-artifacts/kernel/") DEFAULT_CONFIG="private/gs-google/build.config.slider" DEVICE_KERNEL_BUILD_CONFIG=${DEVICE_KERNEL_BUILD_CONFIG:-${DEFAULT_CONFIG}} TRIM_NONLISTED_KMI=${TRIM_NONLISTED_KMI:-1} +CHECK_DIRTY_AOSP=0 if [ -z "${BUILD_KERNEL}" ]; then if [ "${EXPERIMENTAL_BUILD}" != "0" -o -n "${GKI_DEFCONFIG_FRAGMENT}" ]; then BUILD_KERNEL=1 else + CHECK_DIRTY_AOSP=1 BUILD_KERNEL=0 fi fi @@ -115,3 +117,26 @@ else copy_gki_prebuilts fi build_pixel + +# If BUILD_KERNEL is not explicitly set, be sure that there are no aosp/ +# changes not present in the prebuilt. +if [ "${CHECK_DIRTY_AOSP}" != "0" ]; then + PREBUILTS_SHA=$(strings ${GKI_PREBUILTS_DIR}/vmlinux | + grep "Linux version 5.10" | + sed -n "s/^.*-g\([0-9a-f]\{12\}\)-.*/\1/p") + pushd aosp/ > /dev/null + # The AOSP sha can sometimes be longer than 12 characters; fix its length. + AOSP_SHA=$(git log -1 --abbrev=12 --pretty="format:%h") + if [ "${PREBUILTS_SHA}" != "${AOSP_SHA}" -o -n \ + "$(git --no-optional-locks status -uno --porcelain || + git diff-index --name-only HEAD)" ]; then + echo "WARNING: There are aosp/ changes which are not in the prebuilts." + echo " Because you did not specify BUILD_KERNEL=0 or 1, $0" + echo " defaulted to building with the prebuilts. Please be aware that" + echo " your changes to aosp/ will not be present in the final images. If" + echo " you have made changes to aosp/, it is recommended to explicitly" + echo " set BUILD_KERNEL=0 if you wish to use the prebuilts, or to 1 if" + echo " you wish to build any local changes you may have." + fi + popd > /dev/null +fi