From 549e39bd6f399459d3bd4318a0e1ac305237a57d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 12 Dec 2016 12:54:28 +0100 Subject: makekernel now supports compiling from git --- makekernel.in | 70 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/makekernel.in b/makekernel.in index 8a788d2..e2dfb02 100644 --- a/makekernel.in +++ b/makekernel.in @@ -66,6 +66,7 @@ allowDownload=false forceVersion=false showVersion=false noAction=false +hasGit="[ -d "${kernelDir}/.git" ]" while true do @@ -73,6 +74,7 @@ do -a|--allowDownload) ${allowDownload} && usage ${showVersion} && usage + ${hasGit} && usage allowDownload=true ;; -c|--compileVersion) @@ -108,19 +110,29 @@ done if ${showVersion} then - mainVersion="$( - curl 'https://cdn.kernel.org/pub/linux/kernel/' 2> /dev/null | \ - tr '>/' '\n' | \ - grep '^v.*$' | \ + if ${hasGit} + then + git -C "${kernelDir}" fetch --all --tags &> /dev/null + git -C "${kernelDir}" tag --list | \ + grep '^v[0-9.]\+$' | \ + sed 's|^v||' | \ sort -V | \ tail -n1 - )" - curl "https://cdn.kernel.org/pub/linux/kernel/${mainVersion}/" 2> /dev/null | \ - tr '<>' '\n\n' | \ - grep '^linux-.*\.tar\.xz$' | \ - sed 's/^linux-\(.*\)\.tar\.xz$/\1/' | \ - sort -V | \ - tail -n1 + else + mainVersion="$( + curl 'https://cdn.kernel.org/pub/linux/kernel/' 2> /dev/null | \ + tr '>/' '\n' | \ + grep '^v.*$' | \ + sort -V | \ + tail -n1 + )" + curl "https://cdn.kernel.org/pub/linux/kernel/${mainVersion}/" 2> /dev/null | \ + tr '<>' '\n\n' | \ + grep '^linux-.*\.tar\.xz$' | \ + sed 's/^linux-\(.*\)\.tar\.xz$/\1/' | \ + sort -V | \ + tail -n1 + fi exit 0 fi @@ -146,7 +158,12 @@ fi # alternative (if allowed): # - download complete source -if [ -d "${kernelDir}/linux-${curVer}" ] +if ${hasGit} +then + updateType='git' + patchSrc='' + dlSrch='' +elif [ -d "${kernelDir}/linux-${curVer}" ] then updateType='recompile' patchSrc='' @@ -185,7 +202,16 @@ fi cd "${kernelDir}" echo "update type: ${updateType}" -if [ -n "${patchSrc}" ] +if ${hasGit} +then + if ${noAction} + then + echo "verify and checkout git tag 'v${curVer}'" + else + git verify-tag "v${curVer}" + git checkout "v${curVer}" + fi +elif [ -n "${patchSrc}" ] then dlExVer "${patchSrc}" "${patch}" if ${noAction} @@ -211,13 +237,18 @@ if ${noAction} then echo "copy config (can't say, from where, right now)" else - cd "${kernelDir}/linux-${curVer}" + if ${hasGit} + then + cd "${kernelDir}" + else + cd "${kernelDir}/linux-${curVer}" + fi [ ! -r .config ] && zcat /proc/config.gz > .config fi if ${noAction} then - echo "make clean" + ${hasGit} || echo "make clean" echo "make oldconfing" echo "make" echo "possibly: make modules_install" @@ -228,12 +259,17 @@ then echo " grub-mkconfig -o /boot/grub/grub.cfg &&" echo " after_install_hook" else - make clean + ${hasGit} || make clean make oldconfig make grep -q '^# CONFIG_MODULES is not set$' .config || make modules_install - kernelImg="$(find ${kernelDir}/linux-${curVer}/arch/ -type f -iname '*image')" + if ${hasGit} + then + kernelImg="$(find ${kernelDir}/arch/ -type f -iname '*image')" + else + kernelImg="$(find ${kernelDir}/linux-${curVer}/arch/ -type f -iname '*image')" + fi if [ $(echo "${kernelImg}" | wc -l) -ne 1 ] then >&2 echo 'ERROR: Did not find exactly one compiled kernel image:' -- cgit v1.2.3-54-g00ecf