Skip to content

Commit 88fe89a

Browse files
committed
kbuild: remove *.tmp file when filechk fails
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 <file>..." 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 <bgolaszewski@baylibre.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 94f7345 commit 88fe89a

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

‎scripts/Kbuild.include‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,13 @@ kecho := $($(quiet)kecho)
5959
# - stdin is piped in from the first prerequisite ($<) so one has
6060
# to specify a valid file as first prerequisite (often the kbuild file)
6161
define filechk
62-
$(Q)set -e; \
63-
mkdir -p $(dir $@); \
64-
{ $(filechk_$(1)); } > $@.tmp; \
65-
if [ -r $@ ] && cmp -s $@ $@.tmp; then \
66-
rm -f $@.tmp; \
67-
else \
68-
$(kecho) ' UPD $@'; \
69-
mv -f $@.tmp $@; \
62+
$(Q)set -e; \
63+
mkdir -p $(dir $@); \
64+
trap "rm -f $(dot-target).tmp" EXIT; \
65+
{ $(filechk_$(1)); } > $(dot-target).tmp; \
66+
if [ ! -r $@ ] || ! cmp -s $@ $(dot-target).tmp; then \
67+
$(kecho) ' UPD $@'; \
68+
mv -f $(dot-target).tmp $@; \
7069
fi
7170
endef
7271

0 commit comments

Comments
 (0)