diff options
| author | Michael Roth <michael.roth@amd.com> | 2022-02-10 15:25:24 -0600 |
|---|---|---|
| committer | Michael Roth <michael.roth@amd.com> | 2022-02-10 16:02:27 -0600 |
| commit | be59cf5281d82b858135a9ac86b3c2f369da0e05 (patch) | |
| tree | 601e27a4d04262e062d37c4db1aa3252b55b80d8 | |
| parent | 9ea95bf59e1d9e50c9a5b121a5d5be9841b7f23b (diff) | |
| download | cachepc-amdsev-be59cf5281d82b858135a9ac86b3c2f369da0e05.tar.gz cachepc-amdsev-be59cf5281d82b858135a9ac86b3c2f369da0e05.zip | |
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.
| -rwxr-xr-x | common.sh | 36 |
1 files changed, 27 insertions, 9 deletions
@@ -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 |
