Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1592674ybv; Thu, 20 Feb 2020 23:55:22 -0800 (PST) X-Google-Smtp-Source: APXvYqwZvHXNOYS/fGbyLMG6bXJeRplLCjVSSnS63ZDEUp9gSF4yorFTQe51L7k+0thWkbt5oXeL X-Received: by 2002:a9d:7498:: with SMTP id t24mr27733493otk.290.1582271722081; Thu, 20 Feb 2020 23:55:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582271722; cv=none; d=google.com; s=arc-20160816; b=CuY3LTkytKKqu5akrpkUJM3Warc5HATO2c4074zp6A5s1GuUUiAXTq8GnhXPi0320M j2bDX6b9CQv3eu591kXhwXIESiDC3VPkJIdP5yJ0NHjqsmuQM7vga4v+DXdie0Rq/cR4 lU+u6i0Cy/SgxdIgcPc+QhyUuw5gNP/LjE5RNzIMQgRk/z3la88YnuFYRfVziuJidANK YQSVYxt7qi3E9cn04361wD5N0annsNJgvoJOdAo1t9pGkOBb4dCdyModbTkmQQnwtl+k Gj7JnPo3N3CalqPVh7Cvf8jDkYg5b07ceKzXcgCbnwwapL0UkPXdALrzWEcfif5YQHmk aX/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TozuFfW51WcNDEBiBiumihL4MIP84bxgpCgMqhkrPA0=; b=ZbQcIw6xYRh64C5R0wIpjAFOtI99vgJgg8lmFWDqdiwDLd/wLwsWR7PO2KzpSZcJ+o JdAYeNH/JOI3omh+BDMl6mz/C7+qCDUrIIton7Fq3RMhGnsw2uwENRAq/ET2FeQSQPJg FRLEpbkpYd2juXurEweKozZ+O0cYbF+yPhSGk/NXZEFxQHmgtmPIHqHIotCBwQeFABhh Lw+ZCgrTfKzuL3TLQoxR7Dv/6nH+3ShF85ah6I5gOfWj+LbSqGAxrlpfMkcnz+CDcpHI rQM6wB3ourCuwgbEtm9hILyJ8dhf9kgW0Nu94AnI+VCHNzCO8uCSCZp3zXrN34xAcAx9 K9tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eTkAHPAl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c130si426982oib.182.2020.02.20.23.55.10; Thu, 20 Feb 2020 23:55:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eTkAHPAl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729702AbgBUHzH (ORCPT + 99 others); Fri, 21 Feb 2020 02:55:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:53854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729352AbgBUHzF (ORCPT ); Fri, 21 Feb 2020 02:55:05 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DD47C24650; Fri, 21 Feb 2020 07:55:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582271705; bh=HKeMxL5ZUVTWH4JoSyoUUnaQXnce4b+RfVZRfN5KBUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eTkAHPAljuzgYUxLvTl1HHawr+obm30kaBWrNEjx7c1kbsFIFbflLgMu6O2G+kYwq xxOLM4Ats5nmsQqUrcKxcYs/G7rg9ggZWhKo8+Beeu05UsdVHqnpa38e8qL+w2zU2N 2b1Rj9uUp+LufC5ThEnazY4F4fM8PwF7qwzq10YM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bartosz Golaszewski , Masahiro Yamada , Sasha Levin Subject: [PATCH 5.5 266/399] kbuild: remove *.tmp file when filechk fails Date: Fri, 21 Feb 2020 08:39:51 +0100 Message-Id: <20200221072428.173332045@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada [ Upstream commit 88fe89a47153facd8cb2d06d5c8727f7224c43c2 ] Bartosz Golaszewski reports that when "make {menu,n,g,x}config" fails due to missing packages, a temporary file is left over, which is not ignored by git. For example, if GTK+ is not installed: $ make gconfig * * Unable to find the GTK+ installation. Please make sure that * the GTK+ 2.0 development package is correctly installed. * You need gtk+-2.0 gmodule-2.0 libglade-2.0 * scripts/kconfig/Makefile:208: recipe for target 'scripts/kconfig/gconf-cfg' failed make[1]: *** [scripts/kconfig/gconf-cfg] Error 1 Makefile:567: recipe for target 'gconfig' failed make: *** [gconfig] Error 2 $ git status HEAD detached at v5.4 Untracked files: (use "git add ..." to include in what will be committed) scripts/kconfig/gconf-cfg.tmp nothing added to commit but untracked files present (use "git add" to track) This is because the check scripts are run with filechk, which misses to clean up the temporary file on failure. When the line { $(filechk_$(1)); } > $@.tmp; ... fails, it exits immediately due to the 'set -e'. Use trap to make sure to delete the temporary file on exit. For extra safety, I replaced $@.tmp with $(dot-target).tmp to make it a hidden file. Reported-by: Bartosz Golaszewski Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- scripts/Kbuild.include | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index bc5f25763c1b9..f3155af04d859 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -55,14 +55,13 @@ kecho := $($(quiet)kecho) # - stdin is piped in from the first prerequisite ($<) so one has # to specify a valid file as first prerequisite (often the kbuild file) define filechk - $(Q)set -e; \ - mkdir -p $(dir $@); \ - { $(filechk_$(1)); } > $@.tmp; \ - if [ -r $@ ] && cmp -s $@ $@.tmp; then \ - rm -f $@.tmp; \ - else \ - $(kecho) ' UPD $@'; \ - mv -f $@.tmp $@; \ + $(Q)set -e; \ + mkdir -p $(dir $@); \ + trap "rm -f $(dot-target).tmp" EXIT; \ + { $(filechk_$(1)); } > $(dot-target).tmp; \ + if [ ! -r $@ ] || ! cmp -s $@ $(dot-target).tmp; then \ + $(kecho) ' UPD $@'; \ + mv -f $(dot-target).tmp $@; \ fi endef -- 2.20.1