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 5482C138334 for ; Tue, 23 Jul 2019 19:47:20 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3B463E086D; Tue, 23 Jul 2019 19:47:19 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (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 092B4E086D for ; Tue, 23 Jul 2019 19:47:19 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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 CEC11348540 for ; Tue, 23 Jul 2019 19:47:17 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 73C41720 for ; Tue, 23 Jul 2019 19:47:16 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1563908901.a8ef5e91d91ca5292bc7381db11ab1153cb73ffc.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: / X-VCS-Repository: proj/genkernel X-VCS-Files: gen_configkernel.sh X-VCS-Directories: / X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: a8ef5e91d91ca5292bc7381db11ab1153cb73ffc X-VCS-Branch: master Date: Tue, 23 Jul 2019 19:47:16 +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: 5572dcc7-b5e5-474f-a202-1c4507877fde X-Archives-Hash: d1d0d02f6cbf086928c9e99f9fc96ac6 commit: a8ef5e91d91ca5292bc7381db11ab1153cb73ffc Author: Thomas Deutschmann gentoo org> AuthorDate: Tue Jul 23 19:08:21 2019 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Tue Jul 23 19:08:21 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=a8ef5e91 gen_configkernel.sh: Refactor kernel config handling in config_kernel() Make sure that we always end up with set kernel config when no kernel config exists in kernel outputdir. Signed-off-by: Thomas Deutschmann gentoo.org> gen_configkernel.sh | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/gen_configkernel.sh b/gen_configkernel.sh index a5ad953..9a4812f 100755 --- a/gen_configkernel.sh +++ b/gen_configkernel.sh @@ -72,9 +72,17 @@ determine_kernel_config_file() { } config_kernel() { + local diff_cmd="$(which zdiff 2>/dev/null)" + if [ -z "${diff_cmd}" ] + then + print_warning 5 "zdiff is not available." + diff_cmd="diff" + fi + cd "${KERNEL_DIR}" || gen_die "Failed to chdir to '${KERNEL_DIR}'!" print_info 1 "kernel: >> Initializing ..." + if isTrue "${CLEAN}" && isTrue "${MRPROPER}" then print_info 2 "$(get_indent 1)>> --mrproper is set; Skipping 'make clean' ..." @@ -92,16 +100,20 @@ config_kernel() { if [ -f "${KERNEL_OUTPUTDIR}/.config" ] then # Current .config is different then one we are going to use - if [ -n "${CMD_KERNEL_CONFIG}" -a "${CMD_KERNEL_CONFIG}" = "default" ] || \ - ! diff -q "${KERNEL_OUTPUTDIR}"/.config "${KERNEL_CONFIG}" >/dev/null + if [ -n "${CMD_KERNEL_CONFIG}" -a "${CMD_KERNEL_CONFIG}" = "default" ] \ + || ! "${diff_cmd}" -q "${KERNEL_OUTPUTDIR}"/.config "${KERNEL_CONFIG}" >/dev/null then NOW=$(date +--%Y-%m-%d--%H-%M-%S) cp "${KERNEL_OUTPUTDIR}/.config" "${KERNEL_OUTPUTDIR}/.config${NOW}.bak" \ || gen_die "Could not backup kernel config (${KERNEL_OUTPUTDIR}/.config)" print_info 1 "$(get_indent 1)>> Previous config backed up to .config${NOW}.bak" - [ -n "${CMD_KERNEL_CONFIG}" -a "${CMD_KERNEL_CONFIG}" = "default" ] && - rm "${KERNEL_OUTPUTDIR}/.config" >/dev/null + if [ -n "${CMD_KERNEL_CONFIG}" -a "${CMD_KERNEL_CONFIG}" = "default" ] + then + print_info 3 "$(get_indent 1)>> Default kernel config was forced; Deleting existing kernel config '${KERNEL_OUTPUTDIR}/.config' ..." + rm "${KERNEL_OUTPUTDIR}/.config" >/dev/null \ + || gen_die "Failed to delete '${KERNEL_OUTPUTDIR}/.config'!" + fi fi fi fi @@ -111,22 +123,15 @@ config_kernel() { print_info 1 "$(get_indent 1)>> Running 'make mrproper' ..." compile_generic mrproper kernel else - if [ -f "${KERNEL_OUTPUTDIR}/.config" ] - then - print_info 1 "$(get_indent 1)>> Using config from '${KERNEL_OUTPUTDIR}/.config' ..." - else - print_info 1 "$(get_indent 1)>> Using config from '${KERNEL_CONFIG}' ..." - fi print_info 1 "$(get_indent 1)>> --no-mrproper is set; Skipping 'make mrproper' ..." fi - # If we're not cleaning a la mrproper, then we don't want to try to overwrite the configs - # or we might remove configurations someone is trying to test. - if isTrue "${MRPROPER}" || [ ! -f "${KERNEL_OUTPUTDIR}/.config" ] + if [ ! -f "${KERNEL_OUTPUTDIR}/.config" ] then - print_info 1 "$(get_indent 1)>> Using config from '${KERNEL_CONFIG}' ..." + # We always need a kernel config file... + print_info 3 "$(get_indent 1)>> Copying '${KERNEL_CONFIG}' to '${KERNEL_OUTPUTDIR}/.config' ..." - local message="Could not copy configuration file '${KERNEL_CONFIG}'!" + local message="Failed to copy kernel config file '${KERNEL_CONFIG}' to '${KERNEL_OUTPUTDIR}/.config'!" if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}" 2>/dev/null)" == application/x-gzip ]] then # Support --kernel-config=/proc/config.gz, mainly @@ -134,6 +139,15 @@ config_kernel() { else cp -aL "${KERNEL_CONFIG}" "${KERNEL_OUTPUTDIR}/.config" || gen_die "${message}" fi + else + if ! "${diff_cmd}" -q "${KERNEL_OUTPUTDIR}"/.config "${KERNEL_CONFIG}" >/dev/null + then + print_warning 2 "$(get_indent 1)>> Will ignore kernel config from '${KERNEL_CONFIG}'" + print_warning 2 "$(get_indent 1) in favor of already existing but different kernel config" + print_warning 2 "$(get_indent 1) found in '${KERNEL_OUTPUTDIR}/.config' ..." + else + print_info 3 "$(get_indent 1)>> Can keep using already existing '${KERNEL_OUTPUTDIR}/.config' which is identical to --kernel-config file ..." + fi fi if isTrue "${OLDCONFIG}"