Package: kernel-package
Version: 10.057
Severity: wishlist
Tags: patch

        Hi there,

 While debugging #390182, I thought it would be easier to see what
 make-kpkg is doing if it could be made to print all commands.
 Similarly to debhelper's doit(), I propose the following macro:
    # macro outputing $(1) if KPKG_DEBUG is set, and resolving it in all
    # cases
    doit = $(if $(KPKG_DEBUG),$(warning DEBUG: $(1)))$(shell $(1))

 I've converted the relevant file I was debugging to this macro, and the
 result of an internal is something like:

    % make -f /usr/share/kernel-package/ruleset/minimal.mk debian \
    DEBIAN_REVISION=1  KPKG_ARCH=um   KPKG_STEM=linux  \
    ROOT_CMD=fakeroot KPKG_DEBUG=1
/usr/share/kernel-package/ruleset/misc/version_vars.mk:58: DEBUG: make  
--no-print-directory -sf /usr/share/kernel-package/ruleset/kernel_version.mk 
debian_VERSION
.config:10:warning: trying to assign nonexistent symbol IRQ_RELEASE_METHOD
.config:15:warning: trying to assign nonexistent symbol MODE_TT
.config:16:warning: trying to assign nonexistent symbol STATIC_LINK
.config:700:warning: trying to assign nonexistent symbol UML_NET_SLIRP
[...]
make[2]: *** [silentoldconfig] Erreur 1
make[1]: *** [silentoldconfig] Erreur 2
/usr/share/kernel-package/ruleset/misc/version_vars.mk:60: DEBUG: make  
--no-print-directory -sf /usr/share/kernel-package/ruleset/kernel_version.mk 
debian_PATCHLEVEL
[...]

 I noted your concern:

19:06 < lool> Manoj: I will try to provide a patch with $(call doit), albeit 
              I'm sure it's going to be less funny than writing that macro :)
19:07 < Manoj> atually, the tricky part might be in inferior invocations of 
               make, if the debug output gets into a variable in the outer make

 hence I checked usage of this Makefile via "grep -r version_vars.mk
/usr/share/kernel-package/ruleset/local-vars.mk:include 
$(DEBDIR)/ruleset/misc/version_vars.mk
/usr/share/kernel-package/ruleset/minimal.mk:  include 
$(DEBDIR)/ruleset/misc/version_vars.mk

 => only a couple of includes.  Theoritically, I should look at Makefile
 including these etc. recurively, but I think the potential that commands
 output anything on their stderr is already high enough.  Beside, this
 would only affect debug runs, but I agree there is a potential of
 disruption when spamming stderr with DEBUG lines.

 So, I wish you'll consider the macro for merging and the attached
 patch.  Perhaps it makes sense to promote a way in make-kpkg to switch
 in debug mode, since after all, a lot of files and code is involved in
 a typical run.

   Bye,
-- 
Loïc Minier <[EMAIL PROTECTED]>
--- /usr/share/kernel-package/ruleset/misc/version_vars.mk.orig2        
2006-09-29 22:10:32.000000000 +0200
+++ /usr/share/kernel-package/ruleset/misc/version_vars.mk      2006-09-29 
23:03:58.000000000 +0200
@@ -34,6 +34,8 @@
 ##
 ###############################################################################
 
+# macro outputing $(1) if KPKG_DEBUG is set, and resolving it in all cases
+doit = $(if $(KPKG_DEBUG),$(warning DEBUG: $(1)))$(shell $(1))
 
 ifeq ($(DEB_HOST_GNU_SYSTEM), linux-gnu)
   localversion_files := $(wildcard localversion*)
@@ -53,40 +55,40 @@
   # Could have used :=, but some patches do seem to patch the
   # Makefile. perhaps deferring the rule makes that better
   $(eval $(which_debdir))
-  VERSION      :=$(shell $(MAKE) $(CROSS_ARG) ARCH=$(KERNEL_ARCH) 
--no-print-directory -sf            \
+  VERSION      := $(call doit,$(MAKE) $(CROSS_ARG) --no-print-directory -sf    
        \
                          $(DEBDIR)/ruleset/kernel_version.mk debian_VERSION)
-  PATCHLEVEL   :=$(shell $(MAKE) $(CROSS_ARG) ARCH=$(KERNEL_ARCH) 
--no-print-directory -sf            \
+  PATCHLEVEL   := $(call doit,$(MAKE) $(CROSS_ARG) --no-print-directory -sf    
        \
                          $(DEBDIR)/ruleset/kernel_version.mk debian_PATCHLEVEL)
-  SUBLEVEL     :=$(shell $(MAKE) $(CROSS_ARG) ARCH=$(KERNEL_ARCH) 
--no-print-directory -sf            \
+  SUBLEVEL     := $(call doit,$(MAKE) $(CROSS_ARG) ARCH=$(KERNEL_ARCH) 
--no-print-directory -sf            \
                          $(DEBDIR)/ruleset/kernel_version.mk debian_SUBLEVEL)
-  EXTRA_VERSION:=$(shell $(MAKE) $(CROSS_ARG) ARCH=$(KERNEL_ARCH) 
--no-print-directory -sf            \
+  EXTRA_VERSION:= $(call doit,$(MAKE) $(CROSS_ARG) ARCH=$(KERNEL_ARCH) 
--no-print-directory -sf            \
                          $(DEBDIR)/ruleset/kernel_version.mk 
debian_EXTRAVERSION)
-  LOCALVERSION :=$(shell $(MAKE) $(CROSS_ARG) ARCH=$(KERNEL_ARCH) 
--no-print-directory -sf            \
+  LOCALVERSION := $(call doit,$(MAKE) $(CROSS_ARG) ARCH=$(KERNEL_ARCH) 
--no-print-directory -sf            \
                          $(DEBDIR)/ruleset/kernel_version.mk 
debian_LOCALVERSION)
 else
   ifeq ($(DEB_HOST_GNU_SYSTEM), kfreebsd-gnu)
-    VERSION        =$(shell grep '^REVISION=' conf/newvers.sh |                
   \
+    VERSION        = $(call doit,grep '^REVISION=' conf/newvers.sh |           
        \
       sed -e 's/[^0-9]*\([0-9]\)\..*/\1/')
-    PATCHLEVEL =$(shell grep '^REVISION=' conf/newvers.sh |                    
   \
+    PATCHLEVEL = $(call doit,grep '^REVISION=' conf/newvers.sh |               
        \
      sed -e 's/[^0-9]*[0-9]*\.\([0-9]*\)[^0-9]*/\1/')
     SUBLEVEL =0
-    EXTRA_VERSION =$(shell grep '^RELEASE=' conf/newvers.sh |                  
   \
+    EXTRA_VERSION = $(call doit,grep '^RELEASE=' conf/newvers.sh |             
        \
      sed -e 's/[^0-9]*\([0-9]*\)[^0-9]*/\1/')
     LOCALVERSION = $(subst $(space),,                                          
   \
-       $(shell cat /dev/null $(localversion_files)) $(CONFIG_LOCALVERSION))
+       $(call doit,cat /dev/null $(localversion_files)) $(CONFIG_LOCALVERSION))
   endif
 endif
 
-KERNELRELEASE = $(shell if [ -f .kernelrelease ]; then          \
+KERNELRELEASE = $(call doit,if [ -f .kernelrelease ]; then          \
                            cat .kernelrelease 2> /dev/null ;    \
                         else                                    \
                           echo "";                              \
                        fi;)  
 
-HAVE_NEW_MODLIB =$(shell grep -E '\(INSTALL_MOD_PATH\)' Makefile 2>/dev/null )
+HAVE_NEW_MODLIB = $(call doit, grep -E '\(INSTALL_MOD_PATH\)' Makefile 
2>/dev/null )
 
 ifneq ($(strip $(EXTRA_VERSION)),)
-HAS_ILLEGAL_EXTRA_VERSION =$(shell                                             
     \
+HAS_ILLEGAL_EXTRA_VERSION = $(call doit,
     perl -e '$$i="$(EXTRA_VERSION)"; $$i !~ m/^[a-z\.\-\+][a-z\d\.\-\+]*$$/o 
&& print YES;')
   ifneq ($(strip $(HAS_ILLEGAL_EXTRA_VERSION)),)
     $(error Error: The EXTRAVERSION may only contain lowercase alphanumerics   
     \
@@ -94,7 +96,7 @@
   endif
 endif
 
-EXTRAVERSION =$(strip $(EXTRA_VERSION))
+EXTRAVERSION = $(strip $(EXTRA_VERSION))
 ifneq ($(strip $(APPEND_TO_VERSION)),)
 iatv := $(strip $(APPEND_TO_VERSION))
 EXTRAV_ARG := EXTRAVERSION=${EXTRA_VERSION}${iatv}
@@ -103,12 +105,12 @@
 EXTRAV_ARG :=
 endif
 
-UTS_RELEASE_HEADER=$(shell if [ -f include/linux/utsrelease.h ]; then \
+UTS_RELEASE_HEADER = $(call doit,if [ -f include/linux/utsrelease.h ]; then \
                               echo include/linux/utsrelease.h;       \
                           else                                       \
                                echo include/linux/version.h ; \
                           fi)
-UTS_RELEASE_VERSION=$(shell if [ -f $(UTS_RELEASE_HEADER) ]; then              
          \
+UTS_RELEASE_VERSION = $(call doit,if [ -f $(UTS_RELEASE_HEADER) ]; then        
                \
                  grep 'define UTS_RELEASE' $(UTS_RELEASE_HEADER) |             
          \
                  perl -nle  'm/^\s*\#define\s+UTS_RELEASE\s+("?)(\S+)\1/g && 
print $$2;';\
                  else echo "" ;                                                
          \
@@ -117,7 +119,7 @@
 version = 
$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(iatv)$(LOCALVERSION)
 
 # Bug out if the version number id not all lowercase
-lc_version = $(shell echo $(version) | tr A-Z a-z)
+lc_version = $(call doit,echo $(version) | tr A-Z a-z)
 ifneq ($(strip $(version)),$(strip $(lc_version)))
   ifeq ($(strip $(IGNORE_UPPERCASE_VERSION)),)
     $(error Error. The version number $(strip $(version)) is not all \
@@ -135,12 +137,12 @@
 endif
 
 
-AM_OFFICIAL := $(shell if [ -f debian/official ]; then echo YES; fi )
+AM_OFFICIAL := $(call doit, if [ -f debian/official ]; then echo YES; fi )
 
 # See if we are being run in the kernel directory
 ifeq ($(DEB_HOST_GNU_SYSTEM), linux-gnu)
   define check_kernel_dir
-  IN_KERNEL_DIR := $(shell if test -d drivers && test -d kernel && test -d fs 
&& test \
+  IN_KERNEL_DIR := $(call doit,if test -d drivers && test -d kernel && test -d 
fs && test \
                                    -d include/linux ; then                     
       \
                                       echo YES;                                
       \
                            fi )
@@ -148,14 +150,14 @@
 else
   ifeq ($(DEB_HOST_GNU_SYSTEM), kfreebsd-gnu)
     define check_kernel_dir
-    IN_KERNEL_DIR := $(shell if test -d dev && test -d kern && test -d fs &&   
       \
+    IN_KERNEL_DIR := $(call doit,if test -d dev && test -d kern && test -d fs 
&&          \
                              test -d i386/include ; then echo YES; fi)
     endef
   endif
 endif
 
 define check_kernel_headers
-IN_KERNEL_HEADERS=$(shell if [ -f $(INT_STEM)-headers.revision ]; then         
       \
+IN_KERNEL_HEADERS=$(call doit,if [ -f $(INT_STEM)-headers.revision ]; then     
           \
                                cat $(INT_STEM)-headers.revision;               
       \
                             else echo "" ;                                     
       \
                             fi)

Reply via email to