[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#325460: glibc: Fails to notice build failures due to | tee



Package: glibc
Severity: normal
Tags: patch

Hi,

while patching around glibc I noticed that certain errors don't stop
the build process, those with '| tee' constructs. The attached patch
adds a makro that logs the output while preserving the retrun code of
the command being run.

MfG
	Goswin

-- System Information:
Debian Release: 3.1
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.8-frosties-2
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
diff -u glibc-2.3.5/debian/rules.d/build.mk glibc-2.3.5/debian/rules.d/build.mk
--- glibc-2.3.5/debian/rules.d/build.mk
+++ glibc-2.3.5/debian/rules.d/build.mk
@@ -3,6 +3,15 @@
 # This little bit of magic makes it possible:
 xx=$(if $($(curpass)_$(1)),$($(curpass)_$(1)),$($(1)))
 
+# We want to log output to a logfile but we also need to preserve the
+# return code of the command being run.
+# This little bit of magic makes it possible:
+# $(call logme, [-a] <log file>, <cmd>)
+define logme
+(exec 3>&1; exit `( ( ( $(2) ) 2>&1 3>&-; echo $$? >&4) | tee $(1) >&3) 4>&1`)
+endef
+
+
 $(patsubst %,mkbuilddir_%,$(GLIBC_PASSES)) :: mkbuilddir_% : $(stamp)mkbuilddir_%
 $(stamp)mkbuilddir_%: $(stamp)patch-stamp $(LINUX_HEADER_DIR)
 	@echo Making builddir for $(curpass)
@@ -42,21 +57,22 @@
 	    echo "No.  Forcing cross-compile by setting build to $$configure_build."; \
 	  fi; \
 	fi; \
-	cd $(DEB_BUILDDIR) && \
+	$(call logme, -a $(log_build), \
+		cd $(DEB_BUILDDIR) && \
 		CC="$(call xx,CC)" \
 		AUTOCONF=false \
 		$(CURDIR)/$(DEB_SRCDIR)/configure \
 		--host=$(call xx,configure_target) \
 		--build=$$configure_build --prefix=/usr --without-cvs \
 		--enable-add-ons="$(call xx,add-ons)" --without-selinux \
-		$(call xx,with_headers) $(call xx,extra_config_options) 2>&1 | tee -a $(log_build)
+		$(call xx,with_headers) $(call xx,extra_config_options))
 
 	touch $@
 
 $(patsubst %,build_%,$(GLIBC_PASSES)) :: build_% : $(stamp)build_%
 $(stamp)build_%: $(stamp)configure_%
 	@echo Building $(curpass)
-	$(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS) 2>&1 | tee -a $(log_build)
+	$(call logme, -a $(log_build), $(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS))
 	touch $@
 
 $(patsubst %,check_%,$(GLIBC_PASSES)) :: check_% : $(stamp)check_%
@@ -71,7 +87,7 @@
 	  echo "Testsuite disabled for $(curpass), skipping tests."; \
 	else \
 	  echo Testing $(curpass); \
-	  $(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS) -k check 2>&1 | tee -a $(log_test); \
+	  $(call logme, -a $(log_test), $(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS) -k check) \
 	fi
 	touch $@
 

Reply to: