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 BDC9F138334 for ; Tue, 26 Mar 2019 08:07:17 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 70A46E087E; Tue, 26 Mar 2019 08:07:16 +0000 (UTC) Received: from smtp.gentoo.org (dev.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 46589E0864 for ; Tue, 26 Mar 2019 08:07:16 +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 E7474335C77 for ; Tue, 26 Mar 2019 08:07:14 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5E6B857B for ; Tue, 26 Mar 2019 08:07:13 +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: <1553577945.146de30d358d92a10bab9888898e43735baf4af2.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: / X-VCS-Repository: proj/genkernel X-VCS-Files: gen_funcs.sh X-VCS-Directories: / X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: 146de30d358d92a10bab9888898e43735baf4af2 X-VCS-Branch: master Date: Tue, 26 Mar 2019 08:07:13 +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: c4a03225-4f84-44c9-95e0-5b2a133c9997 X-Archives-Hash: 3dc50aa1ed3e7057d4965d78b2417aae commit: 146de30d358d92a10bab9888898e43735baf4af2 Author: Thomas Deutschmann gentoo org> AuthorDate: Tue Mar 26 03:34:40 2019 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Tue Mar 26 05:25:45 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=146de30d kconfig_set_opt(): add possibility to add new kernel options Bug: https://bugs.gentoo.org/669412 Signed-off-by: Thomas Deutschmann gentoo.org> gen_funcs.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/gen_funcs.sh b/gen_funcs.sh index b105d64..95c8f30 100755 --- a/gen_funcs.sh +++ b/gen_funcs.sh @@ -570,7 +570,24 @@ function kconfig_set_opt() { kconfig="$1" optname="$2" optval="$3" - sed -i "${kconfig}" \ - -e "s/^#\? \?${optname}[ =].*/${optname}=${optval}/g" \ - || gen_die "Failed to set ${optname}=${optval} in $kconfig" + + curropt=$(grep -E "^#? ?${optname}[ =].*$" "${kconfig}") + if [[ -z "${curropt}" ]] + then + print_info 2 "$(getIndent 2) - Adding option '${optname}' with value '${optval}' to '${kconfig}'..." + echo "${optname}=${optval}" >> "${kconfig}" || + gen_die "Failed to add '${optname}=${optval}' to '$kconfig'" + + [ ! -f "${TEMP}/.kconfig_modified" ] && touch "${TEMP}/.kconfig_modified" + elif [[ "${curropt}" != "*#*" && "${curropt#*=}" == "${optval}" ]] + then + print_info 2 "$(getIndent 2) - Option '${optname}=${optval}' already exists in '${kconfig}'; Skipping..." + else + print_info 2 "$(getIndent 2) - Setting option '${optname}' to '${optval}' in '${kconfig}'..." + sed -i "${kconfig}" \ + -e "s/^#\? \?${optname}[ =].*/${optname}=${optval}/g" || + gen_die "Failed to set '${optname}=${optval}' in '$kconfig'" + + [ ! -f "${TEMP}/.kconfig_modified" ] && touch "${TEMP}/.kconfig_modified" + fi }