From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38F261A9FBA for ; Tue, 6 Oct 2026 16:12:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791303154; cv=none; b=FLl2GC8MnAbtNLat8xpHUyOllpLiuPytZitiRE0hdAnUKDADBoqCAgii+t2a5w13MI4aSxxO7TirsYU0UZog+L2rAvWds+JCWHh3v6wuJZ10ykLhreKXBAugmgna5iTTPx54kKMZunSUa7HEehfxDN3gyBXCxXMi1J1oqvKlHdQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791303154; c=relaxed/simple; bh=pzKjQW/5wv5ZV9V2mhGX3XNvxdEG4JnLPbjh3QDWwuY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Y0Y8eFLsHBE1Gakm3z6UFhPwzQnqI7t8kbdKblSK3LApw2Zuq+I7lgPzRNeiUm1m3rbl2b0Dk/JjCBGZIpA06R9+om3UvOT5Rz4GBdGTC1AOXznCg5Q78aS4KWbOY2LoIsN/m2m9TMaBjPqLr1cQn5vgeJS3scudMsreISJBzVo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=tMte3Lvf; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tMte3Lvf" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4a171b677d2so6779015e9.0 for ; Tue, 06 Oct 2026 09:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791303151; x=1791907951; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=YK1JCuzca0AjqMNfZi2xFLLH8cZvTcTPq46uhTC4eYw=; b=tMte3LvfXkONe7Dlmj11co8kzKVEOBEqgw0gR6Jo/EQJ6Gow9gUuwAMTk0Lj/a+juW e3EBNNibrYX68bJYsBEcOgiFTnxoEBy5jjpCdfzgnohdZS1FLscwQAhi4lSAFBZBU2Fc oAodKGiJaKmvIlMvh/yTs7XOkoSa0Hyse2waC/xEzyecx2LD7/a8t+LkVU93MxEdHE5a YG/qw2669HWuUIrcwRYPSSqbcTMZFIsV7GaCFjCKrkUnkKbQqK5R+j79+H6MdStY2v8d SRQwbgVafnZrNoURlD5zTE8YyoHs/kAJY2R+4CatUEzbZza3o24w98hVmWrwrk1P5kgf CO6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791303151; x=1791907951; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YK1JCuzca0AjqMNfZi2xFLLH8cZvTcTPq46uhTC4eYw=; b=1kGYfzU3dwC9RPxXzsUEG1ERZKepyTvb1x9brup3Ro8ysgbn8ZL9F3dzU9VBcHNXV0 RSQRZl5OVEfvW/X9vTkscJgu37OuUVQlCTcAjvyEN6QeztiFFxCHAMpG0Y+luWJFerO7 04zqiFieoq3ElhWiuFcFhz9En3DRvLU3tvbtnASqkgWtsVXlm9Bksm4N+paRiDh1xrhn QXIvzoO498oumBYsZhNlCEdkSGhkZoLqfePHFI/fbP2/X8VrVjeCPN13vgDPGCEbIyrS z22n1cMw+/1EqtpLYcxQvVXiFJBjumYa41OLd0RadVk81sN2MQrTxhO2IG2ircy9QAys IwYg== X-Forwarded-Encrypted: i=1; AKwUvBxhgfKdrzn9CCkiSrKfklSd91WNzvFN5OQ2nMQ/hdtCT+8gQ+QT3NigIiBaNXcAdz2c4p3k+UsR4CDww04=@vger.kernel.org X-Gm-Message-State: AFuF++lMAMPPXIV/zQXDpQ62ALjFGny47mVkTWrOz5BPjM/4FTF46Ke5 xppIDXnRug4eavOthXRyXDyNocQttLf7fA3TrupxBDUpLR8mbiwTOl5uWuEJAxyWkwQGWw== X-Gm-Gg: AYBFou2JMcU0X74Dw7WzPi8K9nH9C9oqmVpUJ+GH7UlO7BkgkhtNJrEFxvVRSMUAjaM K0kL935lHXkQ3wC4BqdRGoTP2poDm8C4uvA9Fp90V5psOklUgMJIj7e8uEvhoCpTwuOlsZhSWBG Ma/mPjvkj1bBMm1dSRDQIvj1Ci71Vq6sEWokPQid6BGhDypUyOi4g4OVSQb3tae3Al8f2aeqryF pEIWWhFaFPDuZZmdamoRZz0oGNGtCNjhG6khyKmyeeYCTuIF2WlZQdxOHR5KqIiHTrKsWCUAOT5 ffdDMv1oqFfU+fvhhSxgrvmiEBRdW9SX7NyjSAv+2Q54XN6QDQq3plcn3HwkEAyvSv86Si1d3Gy Xx7NrzWAIyL/uWKkZbvlstIYbdUtfNbMglqhAl1ebtmqWzHgJ6uCFt/et18kQr5XwF9zILCv54F qzh8ZsUV36zgTV+HiS3jnru3uv9e3zdiuhHMeztHqL3FgbfF083pEjZ8frAfSqX/vWWWzJE0vPr RVzMdj//xV95pSmyJUMxMYxlKOrmJUzFaWYtFbX4x9i5eS+ce9lXm1p78EwowvYRF6Q65IZarl3 BrR+jg== X-Received: by 2002:a05:600c:468d:b0:49e:7a10:1b71 with SMTP id 5b1f17b1804b1-4a17b52d29fmr33481165e9.11.1791303151037; Tue, 06 Oct 2026 09:12:31 -0700 (PDT) Received: from voyt-laptop-dell.fritz.box ([2001:9e8:bd51:6800:c199:bb10:b06d:d65]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a178c49c35sm89242555e9.9.2026.10.06.09.12.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 09:12:29 -0700 (PDT) From: Dmitry Voytik To: Nathan Chancellor , Nicolas Schier Cc: Nicolas Schier , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Dmitry Voytik Subject: [PATCH v7] scripts/config: honor $KBUILD_OUTPUT by default Date: Tue, 6 Oct 2026 18:11:55 +0200 Message-ID: <20261006161155.862736-1-voytikd@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If $KBUILD_OUTPUT is set, use it by default if --file is not passed. Fix the issue when the script silently updates a stale .config in the root directory, while the user expects ${KBUILD_OUTPUT}/.config to be updated. Handle properly if the config file is a relative path. The problem can be worked around with --file, but this is easy to miss, and is inconsistent with how the Makefile and other tools work (e.g., scripts/diffconfig). How to reproduce the issue: make mrproper export KBUILD_OUTPUT=.out make defconfig ./scripts/config \ -e CONFIG_UBSAN Error reported: grep: .config: No such file or directory How the patch was tested: make mrproper export KBUILD_OUTPUT=.out make defconfig grep "CONFIG_UBSAN=y" $KBUILD_OUTPUT/.config || echo "OK" Test the basic usage: ./scripts/config -e CONFIG_UBSAN grep "CONFIG_UBSAN=y" $KBUILD_OUTPUT/.config && echo "OK" Test --refresh picks up correct config file by using $KBUILD_OUTPUT: ./scripts/config -d CONFIG_UBSAN grep "CONFIG_UBSAN=y" $KBUILD_OUTPUT/.config && echo "FAIL" ./scripts/config --refresh -e CONFIG_UBSAN grep "CONFIG_UBSAN=y" $KBUILD_OUTPUT/.config && echo "OK" Test --file takes precedence over $KBUILD_OUTPUT and a relative path is handled properly: ./scripts/config -d CONFIG_UBSAN mkdir .out2 cp .out/.config .out2/.my_config grep "CONFIG_UBSAN=y" .out2/.my_config && echo "FAIL" ./scripts/config --file .out2/.my_config --refresh \ -e CONFIG_UBSAN grep "CONFIG_UBSAN=y" .out2/.my_config && echo "OK" ls .out/.out2 && echo "FAIL" ls .out/.out && echo "FAIL" Test --file can accept files with hyphen: ./scripts/config -d CONFIG_UBSAN cp .out/.config -- -my_config grep "CONFIG_UBSAN=y" -- -my_config && echo "FAIL" ./scripts/config --refresh \ -e CONFIG_UBSAN --file -my_config grep "CONFIG_UBSAN=y" -- -my_config && echo "OK" Signed-off-by: Dmitry Voytik --- v7: * Adressed https://sashiko.dev/#/patchset/20261006142337.821859-1-voytikd%40gmail.com v6: * Per Nathan Chancellor's suggestions, simplified * https://lore.kernel.org/lkml/179121581235.2275809.12565811683284940522.b4-review@b4/ v5: * Per Nathan Chancellor's suggestion, improved handling $FN path by realpath * https://lore.kernel.org/lkml/179097210878.309835.10523307262544578337.b4-review@b4/ * Documented the new test scenario in the git commit message v4: * Addressed Nicolas Schier's comments - dropped the change how '--refresh' is handled * Implemented conversion of $FN to the absolute path which helps with '--refresh' and relative paths * Documented testing steps in the commit message v3: * Added an example in the commit message how to reproduce the issue v2: * Addressed comments by sashiko: * https://sashiko.dev/#/patchset/20260920064350.17999-1-voytikd%40gmail.com * use basename when --refresh is used * remove echo which can be misleading when --file is passed v1: * https://lore.kernel.org/all/20260920064350.17999-1-voytikd@gmail.com/ --- scripts/config | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/config b/scripts/config index 32428ea909c2..1e29e449077c 100755 --- a/scripts/config +++ b/scripts/config @@ -130,13 +130,15 @@ on_exit() { trap on_exit EXIT FN=.config + + CMDS=() while [[ $# -gt 0 ]]; do if [ "$1" = "--file" ]; then if [ "$2" = "" ]; then usage fi - FN="$2" + FN=$(realpath -q -- "$2" || printf -- "%s\n" "$2") shift 2 else CMDS+=("$1") @@ -144,6 +146,16 @@ while [[ $# -gt 0 ]]; do fi done +# ignore $KBUILD_OUTPUT if "--file" option is present +if [[ "$FN" == ".config" && -n "$KBUILD_OUTPUT" ]]; then + if [[ ! -d "$KBUILD_OUTPUT" ]]; then + echo "KBUILD_OUTPUT is set but does not exist or is not a " >&2 + echo "directory. Create it before running $myname." >&2 + exit 1 + fi + FN=$(realpath -- "$KBUILD_OUTPUT")/"$FN" +fi + set -- "${CMDS[@]}" if [ "$1" = "" ] ; then usage @@ -200,7 +212,7 @@ while [ "$1" != "" ] ; do ;; --state|-s) - if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then + if grep -q "# ${CONFIG_}$ARG is not set" "$FN" ; then echo n else V="$(grep "^${CONFIG_}$ARG=" $FN)" @@ -229,7 +241,7 @@ while [ "$1" != "" ] ; do ;; --refresh) - yes "" | make oldconfig KCONFIG_CONFIG=$FN + yes "" | make oldconfig KCONFIG_CONFIG="$FN" ;; *) -- 2.55.0