From be59cf5281d82b858135a9ac86b3c2f369da0e05 Mon Sep 17 00:00:00 2001 From: Michael Roth Date: Thu, 10 Feb 2022 15:25:24 -0600 Subject: common.sh: build/clone optimizations for kernel builds Currently kernel source repo is cloned twice; once for guest and once for host. Instead, clone guest repo, then copy the directory to use as host repo. Also add support for doing building latest commits from stable-commits without needing to remove/re-clone the kernel repo. Also remove existing linux deb/rpm packages prior to build so they don't end up in package tarball for new builds. --- common.sh | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/common.sh b/common.sh index 83b3e82..afa141b 100755 --- a/common.sh +++ b/common.sh @@ -18,6 +18,18 @@ build_kernel() mkdir -p linux pushd linux >/dev/null + if [ ! -d guest ]; then + run_cmd git clone ${KERNEL_GIT_URL} guest + pushd guest >/dev/null + run_cmd git remote add current ${KERNEL_GIT_URL} + popd + fi + + if [ ! -d host ]; then + # use a copy of guest repo as the host repo + run_cmd cp -r guest host + fi + for V in guest host; do # Check if only a "guest" or "host" or kernel build is requested if [ "$kernel_type" != "" ]; then @@ -26,15 +38,15 @@ build_kernel() fi fi - [ -d ${V} ] || { - if [ "${V}" = "guest" ]; then - BRANCH="${KERNEL_GUEST_BRANCH}" - else - BRANCH="${KERNEL_HOST_BRANCH}" - fi + if [ "${V}" = "guest" ]; then + BRANCH="${KERNEL_GUEST_BRANCH}" + else + BRANCH="${KERNEL_HOST_BRANCH}" + fi - run_cmd git clone --single-branch -b ${BRANCH} ${KERNEL_GIT_URL} ${V} - } + # Nuke any previously built packages so they don't end up in new tarballs + # when ./build.sh --package is specified + rm -f linux-*-snp-${V}* VER="-snp-${V}" @@ -43,7 +55,13 @@ build_kernel() run_cmd $MAKE distclean pushd ${V} >/dev/null - COMMIT=$(git log --format="%h" HEAD~1..HEAD) + # If ${KERNEL_GIT_URL} is ever changed, 'current' remote will be out + # of date, so always update the remote URL first + run_cmd git remote set-url current ${KERNEL_GIT_URL} + run_cmd git fetch current + run_cmd git checkout current/${BRANCH} + COMMIT=$(git log --format="%h" -1 HEAD) + run_cmd "cp /boot/config-$(uname -r) .config" run_cmd ./scripts/config --set-str LOCALVERSION "$VER-$COMMIT" run_cmd ./scripts/config --disable LOCALVERSION_AUTO -- cgit v1.2.3-71-gd317