Mark McLoughlin
2007-Dec-20 09:44 UTC
[Xen-devel] [PATCH] Force build failure if modules build fails
# HG changeset patch # User Mark McLoughlin <markmc@redhat.com> # Date 1198143499 0 # Node ID 77d3a8ef20ffbd8275c4c7341b255e3049122ce4 # Parent f12da56acc577ac48a997c10480b220ec2a3d44d Force build failure if modules build fails When building a linux kernel, if the modules build fails, then the build carries on regardless. The problem is simple - the "make modules" failure is not seen by the calling make since its return value is not what is returned. Signed-off-by: Mark McLoughlin <markmc@redhat.com> diff -r f12da56acc57 -r 77d3a8ef20ff buildconfigs/mk.linux-2.6-common --- a/buildconfigs/mk.linux-2.6-common Wed Dec 19 15:56:10 2007 +0000 +++ b/buildconfigs/mk.linux-2.6-common Thu Dec 20 09:38:19 2007 +0000 @@ -59,7 +59,7 @@ ifneq ($(XEN_LINUX_ALLOW_INTERFACE_MISMA fi endif if grep "^CONFIG_MODULES=" $(LINUX_DIR)/.config ; then \ - $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) modules ; \ + $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) modules || exit 1 ; \ $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) INSTALL_MOD_PATH=$(DESTDIR) modules_install ; \ fi $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) INSTALL_PATH=$(DESTDIR) $(IMAGE_TARGET) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2007-Dec-20 11:28 UTC
Re: [Xen-devel] [PATCH] Force build failure if modules build fails
Mark McLoughlin writes ("[Xen-devel] [PATCH] Force build failure if modules build fails"):> if grep "^CONFIG_MODULES=" $(LINUX_DIR)/.config ; then \ > - $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) modules ; \ > + $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) modules || exit 1 ; \Usually a better way to do this is to add `set -e'' to the start of the multi-statement shell command, like this: - if grep "^CONFIG_MODULES=" $(LINUX_DIR)/.config ; then \ + set -e; if grep "^CONFIG_MODULES=" $(LINUX_DIR)/.config ; then \ Doing it that way means you don''t have to keep track of exactly which parts need `|| exit 1''. Best practice is to start any nontrivial command in a makefile with `set -e''. I''ve done some searching through the code and come up with the patch below which fixes a number of similar mistakes. I''ve only intended to change places where the code was definitely wrong, rather than the IMO much larger set of places where set -e would have been good style but is technically unnecessary. I''ve also checked that at least `make all'' still works. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel