From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 0EE29138359 for ; Tue, 20 Oct 2020 04:31:58 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 02889E086E; Tue, 20 Oct 2020 04:31:55 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C9063E086E for ; Tue, 20 Oct 2020 04:31:54 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A0876340D0C for ; Tue, 20 Oct 2020 04:31:53 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 28A053BC for ; Tue, 20 Oct 2020 04:31:51 +0000 (UTC) From: "Matt Turner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" Message-ID: <1603166147.34102fa16251ae14e55e43bdc2976304d06e2f59.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:pending/mattst88 commit in: targets/support/ X-VCS-Repository: proj/catalyst X-VCS-Files: targets/support/kmerge.sh X-VCS-Directories: targets/support/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: 34102fa16251ae14e55e43bdc2976304d06e2f59 X-VCS-Branch: pending/mattst88 Date: Tue, 20 Oct 2020 04:31:51 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: f4f92197-79e7-4d30-b9f3-0c3076477b0f X-Archives-Hash: f43c27421ea6f288dab6b371087ee879 commit: 34102fa16251ae14e55e43bdc2976304d06e2f59 Author: Matt Turner gentoo org> AuthorDate: Tue Oct 20 02:38:39 2020 +0000 Commit: Matt Turner gentoo org> CommitDate: Tue Oct 20 03:55:47 2020 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=34102fa1 targets: Rewrite kerncache support I cannot see how the code added in the undermentioned commit could have possibly worked. Fixes: fed3b45b ("Fix and improve kernel build when kerncache is enabled.") Signed-off-by: Matt Turner gentoo.org> targets/support/kmerge.sh | 148 +++++++++++++++------------------------------- 1 file changed, 47 insertions(+), 101 deletions(-) diff --git a/targets/support/kmerge.sh b/targets/support/kmerge.sh index a9a2a72a..3b1230db 100755 --- a/targets/support/kmerge.sh +++ b/targets/support/kmerge.sh @@ -85,11 +85,6 @@ genkernel_compile() { else genkernel "${GK_ARGS[@]}" || exit 1 fi - if [ -n "${clst_KERNCACHE}" -a -e /var/tmp/${kname}.config ] - then - md5sum /var/tmp/${kname}.config | awk '{print $1}' > \ - /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.CONFIG - fi } [ -n "${clst_ENVSCRIPT}" ] && source /tmp/envscript @@ -106,112 +101,51 @@ eval eval kernel_gk_kernargs=( \$clst_boot_kernel_${kname}_gk_kernargs ) eval "ksource=\$clst_boot_kernel_${kname}_sources" [[ -z ${ksource} ]] && ksource="sys-kernel/gentoo-sources" -# Check if we have a match in kerncach +kernel_version=$(portageq best_visible / "${ksource}") -if [ -n "${clst_KERNCACHE}" ] -then - USE_MATCH=0 - if [ -e /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.USE ] - then - STR1=$(for i in `cat /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.USE`; do echo $i; done|sort) - STR2=$(for i in ${kernel_use}; do echo $i; done|sort) - if [ "${STR1}" = "${STR2}" ] - then - USE_MATCH=1 - else - [ -e /tmp/kerncache/${kname}/usr/src/linux/.config ] && \ - rm /tmp/kerncache/${kname}/usr/src/linux/.config - fi - fi +if [[ -n ${clst_KERNCACHE} ]]; then + mkdir "/tmp/kerncache/${kname}" + pushd "/tmp/kerncache/${kname}" >/dev/null - EXTRAVERSION_MATCH=0 - if [ -e /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.EXTRAVERSION ] - then - STR1=`cat /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.EXTRAVERSION` - STR2=${clst_kextraversion} - if [ "${STR1}" = "${STR2}" ] - then - EXTRAVERSION_MATCH=1 - fi - fi + echo "${kernel_use}" > /tmp/USE + echo "${kernel_version}" > /tmp/VERSION + echo "${clst_kextraversion}" > /tmp/EXTRAVERSION - CONFIG_MATCH=0 - if [ -e /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.CONFIG ] - then - if [ ! -e /var/tmp/${kname}.config ] - then - CONFIG_MATCH=1 - else - STR1=`cat /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.CONFIG` - STR2=`md5sum /var/tmp/${kname}.config|awk '{print $1}'` - if [ "${STR1}" = "${STR2}" ] - then - CONFIG_MATCH=1 - fi - fi - fi - - # install dependencies of kernel sources ahead of time in case - # package.provided generated below causes them not to be (re)installed - run_merge --onlydeps "${ksource}" - - # Create the kerncache directory if it doesn't exists - mkdir -p /tmp/kerncache/${kname} - - if [ -e /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.KERNELVERSION ] - then - KERNELVERSION=$( ${clst_port_conf}/profile/package.provided - else - rm -f ${clst_port_conf}/profile/package.provided + if cmp -s {/tmp/,}USE && \ + cmp -s {/tmp/,}VERSION && \ + cmp -s {/tmp/,}EXTRAVERSION && \ + cmp -s /var/tmp/${kname}.config CONFIG; then + cached_kernel_found="true" fi - # Don't use package.provided if there's a pending up/downgrade - if [[ "$(portageq best_visible / ${ksource})" == "${KERNELVERSION}" ]]; then - echo "No pending updates for ${ksource}" - else - echo "Pending updates for ${ksource}, removing package.provided" - rm -f ${clst_port_conf}/profile/package.provided - fi + rm -f /tmp/{USE,VERSION,EXTRAVERSION} + popd >/dev/null +fi +if [[ ! ${cached_kernel_found} ]]; then USE=symlink run_merge --update "${ksource}" +fi +if [[ -n ${clst_KERNCACHE} && ! ${cached_kernel_found} ]]; then SOURCESDIR="/tmp/kerncache/${kname}/sources" - if [ -L /usr/src/linux ] - then - # A kernel was merged, move it to $SOURCESDIR - [ -e ${SOURCESDIR} ] && rm -Rf ${SOURCESDIR} + echo "Moving kernel sources to ${SOURCESDIR} ..." - KERNELVERSION=`portageq best_visible / "${ksource}"` - echo "${KERNELVERSION}" > /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.KERNELVERSION + # FINISHME: Use rsync instead? + rm -rf "${SOURCESDIR}" + mv $(readlink -f /usr/src/linux) "${SOURCESDIR}" + ln -snf "${SOURCESDIR}" /usr/src/linux +fi - echo "Moving kernel sources to ${SOURCESDIR} ..." - mv `readlink -f /usr/src/linux` ${SOURCESDIR} - fi - ln -sf ${SOURCESDIR} /usr/src/linux +if [[ -n ${clst_kextraversion} ]]; then + echo "Setting extraversion to ${clst_kextraversion}" - # If catalyst has set to a empty string, extraversion wasn't specified so we - # skip this part - if [ "${EXTRAVERSION_MATCH}" = "0" ] - then - if [ ! "${clst_kextraversion}" = "" ] - then - echo "Setting extraversion to ${clst_kextraversion}" - sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" /usr/src/linux/Makefile - echo ${clst_kextraversion} > /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.EXTRAVERSION - else - touch /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.EXTRAVERSION - fi - fi -else - USE=symlink run_merge --update "${ksource}" - - if [ ! "${clst_kextraversion}" = "" ] - then - echo "Setting extraversion to ${clst_kextraversion}" - sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" /usr/src/linux/Makefile + if [[ -e /usr/src/linux/Makefile.bak ]]; then + cp /usr/src/linux/Makefile{.bak,} + else + cp /usr/src/linux/Makefile{,.bak} fi + sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" \ + /usr/src/linux/Makefile fi # Update USE flag in make.conf @@ -222,7 +156,19 @@ genkernel_compile sed -i "/USE=\"\${USE} ${kernel_use} \"/d" ${clst_make_conf} -if [ -n "${clst_KERNCACHE}" ] -then - echo ${kernel_use} > /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.USE +# Write out CONFIG, USE, VERSION, and EXTRAVERSION files +if [[ -n ${clst_KERNCACHE} && ! ${cached_kernel_found} ]]; then + pushd "/tmp/kerncache/${kname}" >/dev/null + + cp /usr/src/linux/.config CONFIG + echo "${kernel_use}" > USE + echo "${kernel_version}" > VERSION + echo "${clst_kextraversion}" > EXTRAVERSION + + popd >/dev/null +fi + +if [[ ! ${cached_kernel_found} ]]; then + run_merge -C "${ksource}" + rm /usr/src/linux fi