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 68716138334 for ; Sun, 21 Jul 2019 16:26:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A6C5FE0841; Sun, 21 Jul 2019 16:26:39 +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 8C0D9E0841 for ; Sun, 21 Jul 2019 16:26:39 +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 8DB643483DB for ; Sun, 21 Jul 2019 16:26:38 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 07ED3715 for ; Sun, 21 Jul 2019 16:26:37 +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: <1563723536.2c91f07c4a459efb6a8fbc11ec2525cc3020b96f.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: / X-VCS-Repository: proj/genkernel X-VCS-Files: genkernel X-VCS-Directories: / X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: 2c91f07c4a459efb6a8fbc11ec2525cc3020b96f X-VCS-Branch: master Date: Sun, 21 Jul 2019 16:26:37 +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: 53430c59-5936-4131-bbd7-4fb1c8c21f2d X-Archives-Hash: 72f90ab3dc9880e2207ad52273b7808d commit: 2c91f07c4a459efb6a8fbc11ec2525cc3020b96f Author: Thomas Deutschmann gentoo org> AuthorDate: Sat Jul 20 15:33:44 2019 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Sun Jul 21 15:38:56 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=2c91f07c genkernel: Unset any already set non-empty variables named like a genkernel option This will ensure that we will always use genkernel's default value like expected if option isn't set in genkernel config file or on command-line. Signed-off-by: Thomas Deutschmann gentoo.org> genkernel | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/genkernel b/genkernel index 6bc477b..ccd0820 100755 --- a/genkernel +++ b/genkernel @@ -24,15 +24,40 @@ do [[ "${arg}" == --config=* ]] && CMD_GK_CONFIG=${arg#--config=} done -# Pull in our configuration +# Pull in our configuration to get GK_SHARE only... _GENKERNEL_CONF=${CMD_GK_CONFIG:-/etc/genkernel.conf} -source "${_GENKERNEL_CONF}" || small_die "Could not read ${_GENKERNEL_CONF}" +GK_SHARE=$(source "${_GENKERNEL_CONF}" &>/dev/null && echo ${GK_SHARE}) if [ -z "${GK_SHARE}" ] then small_die "GK_SHARE is not set. Please check used genkernel config file at '${_GENKERNEL_CONF}'!" fi +# Make sure that we do not clash with the environment +GK_DETERMINEARGS_FILE="${GK_SHARE}/gen_determineargs.sh" +GK_SETTINGS=( $(awk '/[^#]set_config_with_override/ { print $3 }' "${GK_DETERMINEARGS_FILE}" 2>/dev/null) ) +if [ ${#GK_SETTINGS[@]} -gt 0 ] +then + for GK_SETTING in "${GK_SETTINGS[@]}" + do + for var_to_unset in ${GK_SETTING} CMD_${GK_SETTING} + do + if [ -n "${!var_to_unset}" ] + then + echo "WARNING: Will unset existing variable '${var_to_unset}' to avoid clashing with genkernel config ..." >&2 + unset ${var_to_unset} || small_die "Failed to unset existing variable '${var_to_unset}'!" + fi + done + done + + unset GK_DETERMINEARGS_FILE GK_SETTINGS GK_SETTING var_to_unset +else + small_die "Failed to extract genkernel options from '${GK_DETERMINEARGS_FILE}'!" +fi + +# Now we can source our configuration... +source "${_GENKERNEL_CONF}" || small_die "Could not read ${_GENKERNEL_CONF}" + # set default LOGLEVEL if uninitialized LOGLEVEL=${LOGLEVEL:-1}