Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v3 0/3] apply-patches.sh: be quiet when "make -s" is used
@ 2014-07-31 17:08 Fabio Porcedda
  2014-07-31 17:08 ` [Buildroot] [PATCH v3 1/3] apply-patches.sh: Use the "APPLY_PATCHES" variable to call the script Fabio Porcedda
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Fabio Porcedda @ 2014-07-31 17:08 UTC (permalink / raw)
  To: buildroot

To reduce further the noise when "make -s" is used silence the
"apply-patches.sh" script.

v3:
 - Remove the already merged patch
 - Use double $$ inside hooks (Yann)
 - Add patch to use [[ ]] construct
v2:
 - move the second patch as first to easy up merging
 - split the first patch in two (Yann)
 - add BR_SILENT variable (Yann)

Fabio Porcedda (3):
  apply-patches.sh: Use the "APPLY_PATCHES" variable to call the script
  apply-patches.sh: Use [[...]] construct instead of [...] construct
  apply-patches.sh: don't print anything when "make -s" is used

 Makefile                              |  2 ++
 boot/at91bootstrap/at91bootstrap.mk   |  2 +-
 boot/at91bootstrap3/at91bootstrap3.mk |  2 +-
 boot/barebox/barebox.mk               |  2 +-
 boot/uboot/uboot.mk                   |  2 +-
 linux/linux-ext-rtai.mk               |  4 ++--
 linux/linux.mk                        |  6 +++---
 package/Makefile.in                   |  2 ++
 package/cvs/cvs.mk                    |  2 +-
 package/gcc/gcc.mk                    |  4 ++--
 package/input-tools/input-tools.mk    |  2 +-
 package/mii-diag/mii-diag.mk          |  2 +-
 package/pkg-autotools.mk              | 12 ++++++------
 package/pkg-generic.mk                |  6 +++---
 package/setserial/setserial.mk        |  2 +-
 package/sysklogd/sysklogd.mk          |  2 +-
 package/sysvinit/sysvinit.mk          |  2 +-
 package/thttpd/thttpd.mk              |  2 +-
 support/scripts/apply-patches.sh      | 31 +++++++++++++++++++++----------
 19 files changed, 52 insertions(+), 37 deletions(-)

-- 
2.0.3

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v3 1/3] apply-patches.sh: Use the "APPLY_PATCHES" variable to call the script
  2014-07-31 17:08 [Buildroot] [PATCH v3 0/3] apply-patches.sh: be quiet when "make -s" is used Fabio Porcedda
@ 2014-07-31 17:08 ` Fabio Porcedda
  2014-07-31 17:08 ` [Buildroot] [PATCH v3 2/3] apply-patches.sh: Use [[...]] construct instead of [...] construct Fabio Porcedda
  2014-07-31 17:08 ` [Buildroot] [PATCH v3 3/3] apply-patches.sh: don't print anything when "make -s" is used Fabio Porcedda
  2 siblings, 0 replies; 7+ messages in thread
From: Fabio Porcedda @ 2014-07-31 17:08 UTC (permalink / raw)
  To: buildroot

To easy up adding optional parameters when calling the
"apply-patches.sh" add and use the "APPLY_PATCHES" variable to execute
the script.

Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com>
---
 boot/at91bootstrap/at91bootstrap.mk   |  2 +-
 boot/at91bootstrap3/at91bootstrap3.mk |  2 +-
 boot/barebox/barebox.mk               |  2 +-
 boot/uboot/uboot.mk                   |  2 +-
 linux/linux-ext-rtai.mk               |  4 ++--
 linux/linux.mk                        |  6 +++---
 package/Makefile.in                   |  2 ++
 package/cvs/cvs.mk                    |  2 +-
 package/gcc/gcc.mk                    |  4 ++--
 package/input-tools/input-tools.mk    |  2 +-
 package/mii-diag/mii-diag.mk          |  2 +-
 package/pkg-autotools.mk              | 12 ++++++------
 package/pkg-generic.mk                |  6 +++---
 package/setserial/setserial.mk        |  2 +-
 package/sysklogd/sysklogd.mk          |  2 +-
 package/sysvinit/sysvinit.mk          |  2 +-
 package/thttpd/thttpd.mk              |  2 +-
 17 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/boot/at91bootstrap/at91bootstrap.mk b/boot/at91bootstrap/at91bootstrap.mk
index c5fd099..896804e 100644
--- a/boot/at91bootstrap/at91bootstrap.mk
+++ b/boot/at91bootstrap/at91bootstrap.mk
@@ -24,7 +24,7 @@ endef
 
 ifneq ($(call qstrip,$(BR2_TARGET_AT91BOOTSTRAP_CUSTOM_PATCH_DIR)),)
 define AT91BOOTSTRAP_APPLY_CUSTOM_PATCHES
-	support/scripts/apply-patches.sh $(@D) $(BR2_TARGET_AT91BOOTSTRAP_CUSTOM_PATCH_DIR) \
+	$(APPLY_PATCHES) $(@D) $(BR2_TARGET_AT91BOOTSTRAP_CUSTOM_PATCH_DIR) \
 		at91bootstrap-$(AT91BOOTSTRAP_VERSION)-\*.patch
 endef
 
diff --git a/boot/at91bootstrap3/at91bootstrap3.mk b/boot/at91bootstrap3/at91bootstrap3.mk
index 07df75d..be63252 100644
--- a/boot/at91bootstrap3/at91bootstrap3.mk
+++ b/boot/at91bootstrap3/at91bootstrap3.mk
@@ -21,7 +21,7 @@ AT91BOOTSTRAP3_MAKE_OPT = CROSS_COMPILE=$(TARGET_CROSS) DESTDIR=$(BINARIES_DIR)
 
 ifneq ($(AT91BOOTSTRAP3_CUSTOM_PATCH_DIR),)
 define AT91BOOTSTRAP3_APPLY_CUSTOM_PATCHES
-	support/scripts/apply-patches.sh $(@D) $(AT91BOOTSTRAP3_CUSTOM_PATCH_DIR) \
+	$(APPLY_PATCHES) $(@D) $(AT91BOOTSTRAP3_CUSTOM_PATCH_DIR) \
 		at91bootstrap3-\*.patch
 endef
 
diff --git a/boot/barebox/barebox.mk b/boot/barebox/barebox.mk
index f57d297..d970fbc 100644
--- a/boot/barebox/barebox.mk
+++ b/boot/barebox/barebox.mk
@@ -26,7 +26,7 @@ BAREBOX_LICENSE_FILES = COPYING
 
 ifneq ($(call qstrip,$(BR2_TARGET_BAREBOX_CUSTOM_PATCH_DIR)),)
 define BAREBOX_APPLY_CUSTOM_PATCHES
-	support/scripts/apply-patches.sh $(@D) \
+	$(APPLY_PATCHES) $(@D) \
 		$(BR2_TARGET_BAREBOX_CUSTOM_PATCH_DIR) \
 		barebox-$(BAREBOX_VERSION)-\*.patch
 endef
diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
index 532ac8b..522b531 100644
--- a/boot/uboot/uboot.mk
+++ b/boot/uboot/uboot.mk
@@ -87,7 +87,7 @@ UBOOT_POST_EXTRACT_HOOKS += UBOOT_COPY_OLD_LICENSE_FILE
 
 ifneq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_PATCH_DIR)),)
 define UBOOT_APPLY_CUSTOM_PATCHES
-	support/scripts/apply-patches.sh $(@D) $(BR2_TARGET_UBOOT_CUSTOM_PATCH_DIR) \
+	$(APPLY_PATCHES) $(@D) $(BR2_TARGET_UBOOT_CUSTOM_PATCH_DIR) \
 		uboot-\*.patch
 endef
 
diff --git a/linux/linux-ext-rtai.mk b/linux/linux-ext-rtai.mk
index dcfab49..bf998d5 100644
--- a/linux/linux-ext-rtai.mk
+++ b/linux/linux-ext-rtai.mk
@@ -25,7 +25,7 @@ ifeq ($(RTAI_PATCH),)
 define RTAI_PREPARE_KERNEL
 	kver=`$(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelversion` ; \
 	if test -f $(RTAI_DIR)/base/arch/$(RTAI_ARCH)/patches/hal-linux-$${kver}-*patch ; then \
-		support/scripts/apply-patches.sh $(LINUX_DIR) 		\
+		$(APPLY_PATCHES) $(LINUX_DIR)		 		\
 			$(RTAI_DIR)/base/arch/$(RTAI_ARCH)/patches/ 	\
 			hal-linux-$${kver}-*patch ; \
 	else \
@@ -35,7 +35,7 @@ define RTAI_PREPARE_KERNEL
 endef
 else
 define RTAI_PREPARE_KERNEL
-	support/scripts/apply-patches.sh 	\
+	$(APPLY_PATCHES) 			\
 		$(LINUX_DIR)			\
 		$(dir $(RTAI_PATCH))		\
 		$(notdir $(RTAI_PATCH))
diff --git a/linux/linux.mk b/linux/linux.mk
index 6c0b272..bf0c52b 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -154,11 +154,11 @@ LINUX_POST_DOWNLOAD_HOOKS += LINUX_DOWNLOAD_PATCHES
 define LINUX_APPLY_PATCHES
 	for p in $(LINUX_PATCHES) ; do \
 		if echo $$p | grep -q -E "^ftp://|^http://" ; then \
-			support/scripts/apply-patches.sh $(@D) $(DL_DIR) `basename $$p` ; \
+			$(APPLY_PATCHES) $(@D) $(DL_DIR) `basename $$p` ; \
 		elif test -d $$p ; then \
-			support/scripts/apply-patches.sh $(@D) $$p linux-\*.patch ; \
+			$(APPLY_PATCHES) $(@D) $$p linux-\*.patch ; \
 		else \
-			support/scripts/apply-patches.sh $(@D) `dirname $$p` `basename $$p` ; \
+			$(APPLY_PATCHES) $(@D) `dirname $$p` `basename $$p` ; \
 		fi \
 	done
 endef
diff --git a/package/Makefile.in b/package/Makefile.in
index 02f6e3d..d17115b 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -218,6 +218,8 @@ FLEX := $(shell which flex || type -p flex)
 BISON := $(shell which bison || type -p bison)
 SED := $(shell which sed || type -p sed) -i -e
 
+APPLY_PATCHES = support/scripts/apply-patches.sh
+
 HOST_CPPFLAGS  = -I$(HOST_DIR)/usr/include
 HOST_CFLAGS   ?= -O2
 HOST_CFLAGS   += $(HOST_CPPFLAGS)
diff --git a/package/cvs/cvs.mk b/package/cvs/cvs.mk
index 596eabf..3229e83 100644
--- a/package/cvs/cvs.mk
+++ b/package/cvs/cvs.mk
@@ -38,7 +38,7 @@ define CVS_DEBIAN_PATCHES
 		 do $(SED) 's,^\+\+\+ .*cvs-$(CVS_VERSION)/,+++ cvs-$(CVS_VERSION)/,' $$i; \
 		 done; \
 		); \
-		support/scripts/apply-patches.sh $(@D) $(@D)/debian/patches \*; \
+		$(APPLY_PATCHES) $(@D) $(@D)/debian/patches \*; \
 	fi
 endef
 endif
diff --git a/package/gcc/gcc.mk b/package/gcc/gcc.mk
index 5b60bc3..8be0233 100644
--- a/package/gcc/gcc.mk
+++ b/package/gcc/gcc.mk
@@ -44,14 +44,14 @@ endef
 ifeq ($(ARCH),powerpc)
 ifneq ($(BR2_SOFT_FLOAT),)
 define HOST_GCC_APPLY_POWERPC_PATCH
-	support/scripts/apply-patches.sh $(@D) package/gcc/$(GCC_VERSION) powerpc-link-with-math-lib.patch.conditional
+	$(APPLY_PATCHES) $(@D) package/gcc/$(GCC_VERSION) powerpc-link-with-math-lib.patch.conditional
 endef
 endif
 endif
 
 define HOST_GCC_APPLY_PATCHES
 	if test -d package/gcc/$(GCC_VERSION); then \
-	  support/scripts/apply-patches.sh $(@D) package/gcc/$(GCC_VERSION) \*.patch ; \
+	  $(APPLY_PATCHES) $(@D) package/gcc/$(GCC_VERSION) \*.patch ; \
 	fi;
 	$(HOST_GCC_APPLY_POWERPC_PATCH)
 endef
diff --git a/package/input-tools/input-tools.mk b/package/input-tools/input-tools.mk
index ae3f7d2..b1d0149 100644
--- a/package/input-tools/input-tools.mk
+++ b/package/input-tools/input-tools.mk
@@ -17,7 +17,7 @@ INPUT_TOOLS_TARGETS_$(BR2_PACKAGE_INPUT_TOOLS_JSTEST)      += jstest
 
 define INPUT_TOOLS_DEBIAN_PATCHES
 	if [ -d $(@D)/debian/patches ]; then \
-		support/scripts/apply-patches.sh $(@D) $(@D)/debian/patches \*.patch; \
+		$(APPLY_PATCHES) $(@D) $(@D)/debian/patches \*.patch; \
 	fi
 endef
 
diff --git a/package/mii-diag/mii-diag.mk b/package/mii-diag/mii-diag.mk
index 7a7bc7f..d2b3b9f 100644
--- a/package/mii-diag/mii-diag.mk
+++ b/package/mii-diag/mii-diag.mk
@@ -15,7 +15,7 @@ MII_DIAG_MAKE_OPT = $(TARGET_CONFIGURE_OPTS)
 
 define MII_DIAG_DEBIAN_PATCHES
 	if [ -d $(@D)/debian/patches ]; then \
-		support/scripts/apply-patches.sh $(@D) $(@D)/debian/patches \*.patch; \
+		$(APPLY_PATCHES) $(@D) $(@D)/debian/patches \*.patch; \
 	fi
 endef
 
diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk
index bcc648d..94d3008 100644
--- a/package/pkg-autotools.mk
+++ b/package/pkg-autotools.mk
@@ -196,11 +196,11 @@ define LIBTOOL_PATCH_HOOK
 			ltmain_version=`sed -n '/^[ 	]*VERSION=/{s/^[ 	]*VERSION=//;p;q;}' $$$$i | \
 			sed -e 's/\([0-9].[0-9]*\).*/\1/' -e 's/\"//'`; \
 			if test $$$${ltmain_version} = '1.5'; then \
-				support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v1.5.patch; \
+				$$(APPLY_PATCHES) $$$${i%/*} support/libtool buildroot-libtool-v1.5.patch; \
 			elif test $$$${ltmain_version} = "2.2"; then\
-				support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v2.2.patch; \
+				$$(APPLY_PATCHES) $$$${i%/*} support/libtool buildroot-libtool-v2.2.patch; \
 			elif test $$$${ltmain_version} = "2.4"; then\
-				support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v2.4.patch; \
+				$$(APPLY_PATCHES) $$$${i%/*} support/libtool buildroot-libtool-v2.4.patch; \
 			fi \
 		done \
 	fi
@@ -230,11 +230,11 @@ define AUTORECONF_HOOK
 			ltmain_version=`sed -n '/^[ 	]*VERSION=/{s/^[ 	]*VERSION=//;p;q;}' $$$$i | \
 			sed -e 's/\([0-9].[0-9]*\).*/\1/' -e 's/\"//'`; \
 			if test $$$${ltmain_version} = "1.5"; then \
-				support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v1.5.patch; \
+				$$(APPLY_PATCHES) $$$${i%/*} support/libtool buildroot-libtool-v1.5.patch; \
 			elif test $$$${ltmain_version} = "2.2"; then\
-				support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v2.2.patch; \
+				$$(APPLY_PATCHES) $$$${i%/*} support/libtool buildroot-libtool-v2.2.patch; \
 			elif test $$$${ltmain_version} = "2.4"; then\
-				support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v2.4.patch; \
+				$$(APPLY_PATCHES) $$$${i%/*} support/libtool buildroot-libtool-v2.4.patch; \
 			fi \
 		done \
 	fi
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index fb4b849..95a95b7 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -146,14 +146,14 @@ $(BUILD_DIR)/%/.stamp_patched:
 	@$(call step_start,patch)
 	@$(call MESSAGE,"Patching")
 	$(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
-	$(foreach p,$($(PKG)_PATCH),support/scripts/apply-patches.sh $(@D) $(DL_DIR) $(notdir $(p))$(sep))
+	$(foreach p,$($(PKG)_PATCH),$(APPLY_PATCHES) $(@D) $(DL_DIR) $(notdir $(p))$(sep))
 	$(Q)( \
 	for D in $(PATCH_BASE_DIRS); do \
 	  if test -d $${D}; then \
 	    if test -d $${D}/$($(PKG)_VERSION); then \
-	      support/scripts/apply-patches.sh $(@D) $${D}/$($(PKG)_VERSION) \*.patch \*.patch.$(ARCH) || exit 1; \
+	      $(APPLY_PATCHES) $(@D) $${D}/$($(PKG)_VERSION) \*.patch \*.patch.$(ARCH) || exit 1; \
 	    else \
-	      support/scripts/apply-patches.sh $(@D) $${D} \*.patch \*.patch.$(ARCH) || exit 1; \
+	      $(APPLY_PATCHES) $(@D) $${D} \*.patch \*.patch.$(ARCH) || exit 1; \
 	    fi; \
 	  fi; \
 	done; \
diff --git a/package/setserial/setserial.mk b/package/setserial/setserial.mk
index 9f28216..6900197 100644
--- a/package/setserial/setserial.mk
+++ b/package/setserial/setserial.mk
@@ -16,7 +16,7 @@ define SETSERIAL_APPLY_DEBIAN_PATCHES
 	if [ -d $(@D)/debian/patches ]; then \
 		touch $(@D)/gorhack.h; \
 		rm $(@D)/debian/patches/01_makefile.dpatch; \
-		support/scripts/apply-patches.sh $(@D) $(@D)/debian/patches *.dpatch; \
+		$(APPLY_PATCHES) $(@D) $(@D)/debian/patches *.dpatch; \
 	fi
 endef
 
diff --git a/package/sysklogd/sysklogd.mk b/package/sysklogd/sysklogd.mk
index 37293da..9c4895d 100644
--- a/package/sysklogd/sysklogd.mk
+++ b/package/sysklogd/sysklogd.mk
@@ -18,7 +18,7 @@ endif
 
 define SYSKLOGD_DEBIAN_PATCHES
 	if [ -d $(@D)/debian/patches ]; then \
-		support/scripts/apply-patches.sh $(@D) $(@D)/debian/patches \*.patch; \
+		$(APPLY_PATCHES) $(@D) $(@D)/debian/patches \*.patch; \
 	fi
 endef
 
diff --git a/package/sysvinit/sysvinit.mk b/package/sysvinit/sysvinit.mk
index 3a7eac2..ff1ba24 100644
--- a/package/sysvinit/sysvinit.mk
+++ b/package/sysvinit/sysvinit.mk
@@ -18,7 +18,7 @@ endif
 
 define SYSVINIT_DEBIAN_PATCHES
 	if [ -d $(@D)/debian/patches ]; then \
-		support/scripts/apply-patches.sh $(@D) $(@D)/debian/patches \*.patch; \
+		$(APPLY_PATCHES) $(@D) $(@D)/debian/patches \*.patch; \
 	fi
 endef
 
diff --git a/package/thttpd/thttpd.mk b/package/thttpd/thttpd.mk
index 7be264a..7d663b9 100644
--- a/package/thttpd/thttpd.mk
+++ b/package/thttpd/thttpd.mk
@@ -14,7 +14,7 @@ THTTPD_LICENSE_FILES = thttpd.c
 ifneq ($(THTTPD_PATCH),)
 define THTTPD_DEBIAN_PATCHES
 	if [ -d $(@D)/debian/patches ]; then \
-		support/scripts/apply-patches.sh $(@D) $(@D)/debian/patches \*.patch; \
+		$(APPLY_PATCHES) $(@D) $(@D)/debian/patches \*.patch; \
 	fi
 endef
 endif
-- 
2.0.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v3 2/3] apply-patches.sh: Use [[...]] construct instead of [...] construct
  2014-07-31 17:08 [Buildroot] [PATCH v3 0/3] apply-patches.sh: be quiet when "make -s" is used Fabio Porcedda
  2014-07-31 17:08 ` [Buildroot] [PATCH v3 1/3] apply-patches.sh: Use the "APPLY_PATCHES" variable to call the script Fabio Porcedda
@ 2014-07-31 17:08 ` Fabio Porcedda
  2014-07-31 17:19   ` Thomas De Schampheleire
  2014-07-31 17:08 ` [Buildroot] [PATCH v3 3/3] apply-patches.sh: don't print anything when "make -s" is used Fabio Porcedda
  2 siblings, 1 reply; 7+ messages in thread
From: Fabio Porcedda @ 2014-07-31 17:08 UTC (permalink / raw)
  To: buildroot

The [[...]] construct it's an improved and safer construct than the
[...] construct. It's safer because it doesn't do "word splitting" so
we don't need to enclose variable expansion with double quotes, e.g:

   [ -e "$file" ] -> [[ -e $file ]]
---
 support/scripts/apply-patches.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
index 37f2d81..a157398 100755
--- a/support/scripts/apply-patches.sh
+++ b/support/scripts/apply-patches.sh
@@ -37,11 +37,11 @@ patchpattern=${@-*}
 # use a well defined sorting order
 export LC_COLLATE=C
 
-if [ ! -d "${builddir}" ] ; then
+if [[ ! -d ${builddir} ]] ; then
     echo "Aborting.  '${builddir}' is not a directory."
     exit 1
 fi
-if [ ! -d "${patchdir}" ] ; then
+if [[ ! -d ${patchdir} ]] ; then
     echo "Aborting.  '${patchdir}' is not a directory."
     exit 1
 fi
@@ -79,13 +79,13 @@ function apply_patch {
     esac
     echo ""
     echo "Applying $patch using ${type}: "
-    if [ ! -e "${path}/$patch" ] ; then
+    if [[ ! -e ${path}/$patch ]] ; then
 	echo "Error: missing patch file ${path}/$patch"
 	exit 1
     fi
     echo $patch >> ${builddir}/.applied_patches_list
     ${uncomp} "${path}/$patch" | patch -g0 -p1 -E -d "${builddir}" -t -N
-    if [ $? != 0 ] ; then
+    if [[ $? != 0 ]] ; then
         echo "Patch failed!  Please fix ${patch}!"
 	exit 1
     fi
@@ -98,13 +98,13 @@ function scan_patchdir {
 
     # If there is a series file, use it instead of using ls sort order
     # to apply patches. Skip line starting with a dash.
-    if [ -e "${path}/series" ] ; then
+    if [[ -e ${path}/series ]] ; then
         for i in `grep -Ev "^#" ${path}/series 2> /dev/null` ; do
             apply_patch "$path" "$i"
         done
     else
         for i in `cd $path; ls -d $patches 2> /dev/null` ; do
-            if [ -d "${path}/$i" ] ; then
+            if [[ -d ${path}/$i ]] ; then
                 scan_patchdir "${path}/$i"
             elif echo "$i" | grep -q -E "\.tar(\..*)?$|\.tbz2?$|\.tgz$" ; then
                 unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked"
@@ -122,7 +122,7 @@ function scan_patchdir {
 scan_patchdir "$patchdir" "$patchpattern"
 
 # Check for rejects...
-if [ "`find $builddir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
+if [[ `find $builddir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print` ]] ; then
     echo "Aborting.  Reject files found."
     exit 1
 fi
-- 
2.0.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v3 3/3] apply-patches.sh: don't print anything when "make -s" is used
  2014-07-31 17:08 [Buildroot] [PATCH v3 0/3] apply-patches.sh: be quiet when "make -s" is used Fabio Porcedda
  2014-07-31 17:08 ` [Buildroot] [PATCH v3 1/3] apply-patches.sh: Use the "APPLY_PATCHES" variable to call the script Fabio Porcedda
  2014-07-31 17:08 ` [Buildroot] [PATCH v3 2/3] apply-patches.sh: Use [[...]] construct instead of [...] construct Fabio Porcedda
@ 2014-07-31 17:08 ` Fabio Porcedda
  2 siblings, 0 replies; 7+ messages in thread
From: Fabio Porcedda @ 2014-07-31 17:08 UTC (permalink / raw)
  To: buildroot

The make "-s" option is used to enable the "Silent operation" so if that
option is used don't print anything as far as there isn't any error.

Add the "-s" option to "apply-patches.sh" to enable silent operation.

Also add the "BR_SILENT" variable the contain "YES" when "make -s" is
used so others parts can use it to silence the build as well.

Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com>
---
 Makefile                         |  2 ++
 package/Makefile.in              |  2 +-
 support/scripts/apply-patches.sh | 17 ++++++++++++++---
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index c82b07f..73eb033 100644
--- a/Makefile
+++ b/Makefile
@@ -198,6 +198,8 @@ else
   Q = @
 endif
 
+BR_SILENT = $(if $(findstring s,$(MAKEFLAGS)),YES)
+
 # we want bash as shell
 SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
 	 else if [ -x /bin/bash ]; then echo /bin/bash; \
diff --git a/package/Makefile.in b/package/Makefile.in
index d17115b..c00c4f3 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -218,7 +218,7 @@ FLEX := $(shell which flex || type -p flex)
 BISON := $(shell which bison || type -p bison)
 SED := $(shell which sed || type -p sed) -i -e
 
-APPLY_PATCHES = support/scripts/apply-patches.sh
+APPLY_PATCHES = support/scripts/apply-patches.sh $(if $(BR_SILENT),-s)
 
 HOST_CPPFLAGS  = -I$(HOST_DIR)/usr/include
 HOST_CFLAGS   ?= -O2
diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
index a157398..a4cbf3e 100755
--- a/support/scripts/apply-patches.sh
+++ b/support/scripts/apply-patches.sh
@@ -6,6 +6,8 @@
 # (c) 2002 Erik Andersen <andersen@codepoet.org>
 #
 # Parameters:
+# - "-s",optional. Silent operation, don't print anything if there
+# isn't any error.
 # - the build directory, optional, default value is '.'. The place where are
 # the package sources.
 # - the patch directory, optional, default '../kernel-patches'. The place
@@ -28,6 +30,13 @@
 # applied. The list of the patches applied is stored in '.applied_patches_list'
 # file in the build directory.
 
+silent=
+if [[ $1 = "-s" ]] ; then
+    # add option to be used by the patch tool
+    silent=-s
+    shift
+fi
+
 # Set directories from arguments, or use defaults.
 builddir=${1-.}
 patchdir=${2-../kernel-patches}
@@ -77,14 +86,16 @@ function apply_patch {
 	return 0
 	;;
     esac
-    echo ""
-    echo "Applying $patch using ${type}: "
+    if [[ ! $silent ]] ; then
+	echo ""
+	echo "Applying $patch using ${type}: "
+    fi
     if [[ ! -e ${path}/$patch ]] ; then
 	echo "Error: missing patch file ${path}/$patch"
 	exit 1
     fi
     echo $patch >> ${builddir}/.applied_patches_list
-    ${uncomp} "${path}/$patch" | patch -g0 -p1 -E -d "${builddir}" -t -N
+    ${uncomp} "${path}/$patch" | patch $silent -g0 -p1 -E -d "${builddir}" -t -N
     if [[ $? != 0 ]] ; then
         echo "Patch failed!  Please fix ${patch}!"
 	exit 1
-- 
2.0.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v3 2/3] apply-patches.sh: Use [[...]] construct instead of [...] construct
  2014-07-31 17:08 ` [Buildroot] [PATCH v3 2/3] apply-patches.sh: Use [[...]] construct instead of [...] construct Fabio Porcedda
@ 2014-07-31 17:19   ` Thomas De Schampheleire
  2014-07-31 17:28     ` Yann E. MORIN
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas De Schampheleire @ 2014-07-31 17:19 UTC (permalink / raw)
  To: buildroot

Fabio Porcedda <fabio.porcedda@gmail.com> schreef:
>The [[...]] construct it's an improved and safer construct than the
>[...] construct. It's safer because it doesn't do "word splitting" so
>we don't need to enclose variable expansion with double quotes, e.g:
>
>   [ -e "$file" ] -> [[ -e $file ]]
>---


I'm not so convinced by this patch. [[]] is a bashism, it is not
 supported in all shells. 
Yes, using single brackets means that you need to take care, 
but anyway shell programming has many pitfalls.

In the past people have sent patches to make Buildroot 
more compatible with non-bash shells, so moving in the opposite
 direction is not a good idea IMO.

Best regards,
Thomas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v3 2/3] apply-patches.sh: Use [[...]] construct instead of [...] construct
  2014-07-31 17:19   ` Thomas De Schampheleire
@ 2014-07-31 17:28     ` Yann E. MORIN
  2014-08-01 10:34       ` Fabio Porcedda
  0 siblings, 1 reply; 7+ messages in thread
From: Yann E. MORIN @ 2014-07-31 17:28 UTC (permalink / raw)
  To: buildroot

Thomas, All,

On 2014-07-31 19:19 +0200, Thomas De Schampheleire spake thusly:
> Fabio Porcedda <fabio.porcedda@gmail.com> schreef:
> >The [[...]] construct it's an improved and safer construct than the
> >[...] construct. It's safer because it doesn't do "word splitting" so
> >we don't need to enclose variable expansion with double quotes, e.g:
> >
> >   [ -e "$file" ] -> [[ -e $file ]]
> >---
> 
> 
> I'm not so convinced by this patch. [[]] is a bashism, it is not
>  supported in all shells. 

Well, apply-patches is  bash script (it has the correct sha-bang.)
But it is almost POSIX. The only bashism currently used is the
'function' keyword to declare functions. REmove this, and we have a
POSIX script.

> Yes, using single brackets means that you need to take care, 
> but anyway shell programming has many pitfalls.
> 
> In the past people have sent patches to make Buildroot 
> more compatible with non-bash shells, so moving in the opposite
>  direction is not a good idea IMO.

Agreed. Besides, the gains from that change are not worth it, IMHO.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v3 2/3] apply-patches.sh: Use [[...]] construct instead of [...] construct
  2014-07-31 17:28     ` Yann E. MORIN
@ 2014-08-01 10:34       ` Fabio Porcedda
  0 siblings, 0 replies; 7+ messages in thread
From: Fabio Porcedda @ 2014-08-01 10:34 UTC (permalink / raw)
  To: buildroot

On Thu, Jul 31, 2014 at 7:28 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> Thomas, All,
>
> On 2014-07-31 19:19 +0200, Thomas De Schampheleire spake thusly:
>> Fabio Porcedda <fabio.porcedda@gmail.com> schreef:
>> >The [[...]] construct it's an improved and safer construct than the
>> >[...] construct. It's safer because it doesn't do "word splitting" so
>> >we don't need to enclose variable expansion with double quotes, e.g:
>> >
>> >   [ -e "$file" ] -> [[ -e $file ]]
>> >---
>>
>>
>> I'm not so convinced by this patch. [[]] is a bashism, it is not
>>  supported in all shells.
>
> Well, apply-patches is  bash script (it has the correct sha-bang.)
> But it is almost POSIX. The only bashism currently used is the
> 'function' keyword to declare functions. REmove this, and we have a
> POSIX script.
>
>> Yes, using single brackets means that you need to take care,
>> but anyway shell programming has many pitfalls.
>>
>> In the past people have sent patches to make Buildroot
>> more compatible with non-bash shells, so moving in the opposite
>>  direction is not a good idea IMO.


On the TODO list i didn't found a line about removing the use of bash:
 http://elinux.org/Buildroot

I've found just 4 commit made 4 years ago made by Yann, there are
recent commits about that effort?
right now bash is a requirement for buildroot:
Makefile:
# we want bash as shell
SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
         else if [ -x /bin/bash ]; then echo /bin/bash; \
         else echo sh; fi; fi)

It seems to me that right now there is no effort to remove the use of bash.

What are the advantage on removing the use of bash other that no
requring bash? There are platforms supported by buildroot  where is
not available bash?

>
> Agreed. Besides, the gains from that change are not worth it, IMHO.

It's worth or not based also on the effort, because the work is
already done, it's just a gain without effort so IMHO it's worth it.

IMHO rejecting this patch it is like proposing that removing the use
of bash it's worth it, so removing bash is worth it? it is really a
problem requiring bash? there is someone that is working on removing
the use of bash?

I just want to understand properly the situation.

Thanks for reviewing and best regards
-- 
Fabio Porcedda

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-08-01 10:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-31 17:08 [Buildroot] [PATCH v3 0/3] apply-patches.sh: be quiet when "make -s" is used Fabio Porcedda
2014-07-31 17:08 ` [Buildroot] [PATCH v3 1/3] apply-patches.sh: Use the "APPLY_PATCHES" variable to call the script Fabio Porcedda
2014-07-31 17:08 ` [Buildroot] [PATCH v3 2/3] apply-patches.sh: Use [[...]] construct instead of [...] construct Fabio Porcedda
2014-07-31 17:19   ` Thomas De Schampheleire
2014-07-31 17:28     ` Yann E. MORIN
2014-08-01 10:34       ` Fabio Porcedda
2014-07-31 17:08 ` [Buildroot] [PATCH v3 3/3] apply-patches.sh: don't print anything when "make -s" is used Fabio Porcedda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox