diff mbox

[2/2,v8] pkg-download: silence downloads if make is silent

Message ID 70490271dbf1774e87cc5dab1a5e907105afeb62.1420130984.git.yann.morin.1998@free.fr
State Changes Requested
Headers show

Commit Message

Yann E. MORIN Jan. 1, 2015, 4:50 p.m. UTC
From: Fabio Porcedda <fabio.porcedda@gmail.com>

If it is a silent build (make -s -> QUIET=-q) silence all downloads, as
well as the check-hash. Only stdout is redirected, stderr is still
visible, for errors and warning.

Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com>
[yann.morin.1998@free.fr: greatly simplify by simply consigning stdout
 to oblivion]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
 package/pkg-download.mk     | 8 ++++++++
 support/download/dl-wrapper | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)

Comments

Fabio Porcedda Jan. 1, 2015, 5:54 p.m. UTC | #1
On Thu, Jan 1, 2015 at 5:50 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> From: Fabio Porcedda <fabio.porcedda@gmail.com>
>
> If it is a silent build (make -s -> QUIET=-q) silence all downloads, as
> well as the check-hash. Only stdout is redirected, stderr is still
> visible, for errors and warning.

Hi Yann,
nice idea, i tried this patch but even if it works for check-hash and
svn it does not works for the git backend (e.g. libubox) and the wget
bakend (try it without the QUIET flags in the WGET variable).

I don't understand the reason for this behavior.
Do you have an idea for this strange behavior?

> Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com>
> [yann.morin.1998@free.fr: greatly simplify by simply consigning stdout
>  to oblivion]
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> ---
>  package/pkg-download.mk     | 8 ++++++++
>  support/download/dl-wrapper | 3 ++-
>  2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/package/pkg-download.mk b/package/pkg-download.mk
> index ba72fc1..9c782fe 100644
> --- a/package/pkg-download.mk
> +++ b/package/pkg-download.mk
> @@ -88,6 +88,7 @@ define DOWNLOAD_GIT
>         $(EXTRA_ENV) $(DL_WRAPPER) -b git \
>                 -o $(DL_DIR)/$($(PKG)_SOURCE) \
>                 -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
> +               $(QUIET) \
>                 -- \
>                 $($(PKG)_SITE) \
>                 $($(PKG)_DL_VERSION) \
> @@ -109,6 +110,7 @@ define DOWNLOAD_BZR
>         $(EXTRA_ENV) $(DL_WRAPPER) -b bzr \
>                 -o $(DL_DIR)/$($(PKG)_SOURCE) \
>                 -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
> +               $(QUIET) \
>                 -- \
>                 $($(PKG)_SITE) \
>                 $($(PKG)_DL_VERSION) \
> @@ -127,6 +129,7 @@ define DOWNLOAD_CVS
>         $(EXTRA_ENV) $(DL_WRAPPER) -b cvs \
>                 -o $(DL_DIR)/$($(PKG)_SOURCE) \
>                 -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
> +               $(QUIET) \
>                 -- \
>                 $(call stripurischeme,$(call qstrip,$($(PKG)_SITE))) \
>                 $($(PKG)_DL_VERSION) \
> @@ -147,6 +150,7 @@ define DOWNLOAD_SVN
>         $(EXTRA_ENV) $(DL_WRAPPER) -b svn \
>                 -o $(DL_DIR)/$($(PKG)_SOURCE) \
>                 -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
> +               $(QUIET) \
>                 -- \
>                 $($(PKG)_SITE) \
>                 $($(PKG)_DL_VERSION) \
> @@ -168,6 +172,7 @@ define DOWNLOAD_SCP
>         $(EXTRA_ENV) $(DL_WRAPPER) -b scp \
>                 -o $(DL_DIR)/$(2) \
>                 -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
> +               $(QUIET) \
>                 -- \
>                 '$(call stripurischeme,$(call qstrip,$(1)))'
>  endef
> @@ -185,6 +190,7 @@ define DOWNLOAD_HG
>         $(EXTRA_ENV) $(DL_WRAPPER) -b hg \
>                 -o $(DL_DIR)/$($(PKG)_SOURCE) \
>                 -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
> +               $(QUIET) \
>                 -- \
>                 $($(PKG)_SITE) \
>                 $($(PKG)_DL_VERSION) \
> @@ -206,6 +212,7 @@ define DOWNLOAD_WGET
>         $(EXTRA_ENV) $(DL_WRAPPER) -b wget \
>                 -o $(DL_DIR)/$(2) \
>                 -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
> +               $(QUIET) \
>                 -- \
>                 '$(call qstrip,$(1))'
>  endef
> @@ -222,6 +229,7 @@ define DOWNLOAD_LOCALFILES
>         $(EXTRA_ENV) $(DL_WRAPPER) -b cp \
>                 -o $(DL_DIR)/$(2) \
>                 -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
> +               $(QUIET) \
>                 -- \
>                 $(call stripurischeme,$(call qstrip,$(1)))
>  endef
> diff --git a/support/download/dl-wrapper b/support/download/dl-wrapper
> index cced8f6..57a799e 100755
> --- a/support/download/dl-wrapper
> +++ b/support/download/dl-wrapper
> @@ -24,12 +24,13 @@ main() {
>      local backend output hfile
>
>      # Parse our options; anything after '--' is for the backend
> -    while getopts :hb:o:H: OPT; do
> +    while getopts :hb:o:H:q OPT; do
>          case "${OPT}" in
>          h)  help; exit 0;;
>          b)  backend="${OPTARG}";;
>          o)  output="${OPTARG}";;
>          H)  hfile="${OPTARG}";;
> +        q)  exec >/dev/null;;
>          :)  error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
>          \?) error "unknown option '%s'\n" "${OPTARG}";;
>          esac
> --
> 1.9.1
>
Yann E. MORIN Jan. 1, 2015, 5:58 p.m. UTC | #2
Fabio, All,

On 2015-01-01 18:54 +0100, Fabio Porcedda spake thusly:
> On Thu, Jan 1, 2015 at 5:50 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > From: Fabio Porcedda <fabio.porcedda@gmail.com>
> >
> > If it is a silent build (make -s -> QUIET=-q) silence all downloads, as
> > well as the check-hash. Only stdout is redirected, stderr is still
> > visible, for errors and warning.
> 
> Hi Yann,
> nice idea, i tried this patch but even if it works for check-hash and
> svn it does not works for the git backend (e.g. libubox) and the wget
> bakend (try it without the QUIET flags in the WGET variable).
> 
> I don't understand the reason for this behavior.
> Do you have an idea for this strange behavior?

Damn, no. I'll have look.

Regards,
Yann E. MORIN.
Yann E. MORIN Jan. 1, 2015, 6:08 p.m. UTC | #3
Fabio, All,

On 2015-01-01 18:54 +0100, Fabio Porcedda spake thusly:
> On Thu, Jan 1, 2015 at 5:50 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > From: Fabio Porcedda <fabio.porcedda@gmail.com>
> >
> > If it is a silent build (make -s -> QUIET=-q) silence all downloads, as
> > well as the check-hash. Only stdout is redirected, stderr is still
> > visible, for errors and warning.
> 
> Hi Yann,
> nice idea, i tried this patch but even if it works for check-hash and
> svn it does not works for the git backend (e.g. libubox) and the wget
> bakend (try it without the QUIET flags in the WGET variable).
> 
> I don't understand the reason for this behavior.
> Do you have an idea for this strange behavior?

Ok, that's because git always sends its report status to stderr:

    --quiet, -q
        Operate quietly. Progress is not reported to the standard
        error stream. [...]

So, we need to pass -q to git. Sigh, fscking borked behaviour... stderr
is for failures, not normal reporting... :-(

OK, so we need to pass -q to some backends.

However, what I did not like in your original patch was the fact that
some backends were singled out in the wrapper script. We do not want
that, we want the wrapper to be backend-agnostic (that's the whole point
of having a wrapper and backends).

I'll rework that, then...

Regards,
Yann E. MORIN.
Fabio Porcedda Jan. 1, 2015, 6:14 p.m. UTC | #4
On Thu, Jan 1, 2015 at 7:08 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> Fabio, All,
>
> On 2015-01-01 18:54 +0100, Fabio Porcedda spake thusly:
>> On Thu, Jan 1, 2015 at 5:50 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>> > From: Fabio Porcedda <fabio.porcedda@gmail.com>
>> >
>> > If it is a silent build (make -s -> QUIET=-q) silence all downloads, as
>> > well as the check-hash. Only stdout is redirected, stderr is still
>> > visible, for errors and warning.
>>
>> Hi Yann,
>> nice idea, i tried this patch but even if it works for check-hash and
>> svn it does not works for the git backend (e.g. libubox) and the wget
>> bakend (try it without the QUIET flags in the WGET variable).
>>
>> I don't understand the reason for this behavior.
>> Do you have an idea for this strange behavior?
>
> Ok, that's because git always sends its report status to stderr:
>
>     --quiet, -q
>         Operate quietly. Progress is not reported to the standard
>         error stream. [...]
>
> So, we need to pass -q to git. Sigh, fscking borked behaviour... stderr
> is for failures, not normal reporting... :-(
So that's the reason...

>
> OK, so we need to pass -q to some backends.
>
> However, what I did not like in your original patch was the fact that
> some backends were singled out in the wrapper script. We do not want
> that, we want the wrapper to be backend-agnostic (that's the whole point
> of having a wrapper and backends).

Well that it's needed only until all backends support the "-q" flag,
do you prefer a big patch to convert all backends so that check is not
needed?

> I'll rework that, then...

BR
Fabio Porcedda Jan. 1, 2015, 6:16 p.m. UTC | #5
On Thu, Jan 1, 2015 at 7:14 PM, Fabio Porcedda <fabio.porcedda@gmail.com> wrote:
> On Thu, Jan 1, 2015 at 7:08 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>> Fabio, All,
>>
>> On 2015-01-01 18:54 +0100, Fabio Porcedda spake thusly:
>>> On Thu, Jan 1, 2015 at 5:50 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>>> > From: Fabio Porcedda <fabio.porcedda@gmail.com>
>>> >
>>> > If it is a silent build (make -s -> QUIET=-q) silence all downloads, as
>>> > well as the check-hash. Only stdout is redirected, stderr is still
>>> > visible, for errors and warning.
>>>
>>> Hi Yann,
>>> nice idea, i tried this patch but even if it works for check-hash and
>>> svn it does not works for the git backend (e.g. libubox) and the wget
>>> bakend (try it without the QUIET flags in the WGET variable).
>>>
>>> I don't understand the reason for this behavior.
>>> Do you have an idea for this strange behavior?
>>
>> Ok, that's because git always sends its report status to stderr:
>>
>>     --quiet, -q
>>         Operate quietly. Progress is not reported to the standard
>>         error stream. [...]
>>
>> So, we need to pass -q to git. Sigh, fscking borked behaviour... stderr
>> is for failures, not normal reporting... :-(
> So that's the reason...
>
>>
>> OK, so we need to pass -q to some backends.
>>
>> However, what I did not like in your original patch was the fact that
>> some backends were singled out in the wrapper script. We do not want
>> that, we want the wrapper to be backend-agnostic (that's the whole point
>> of having a wrapper and backends).
>
> Well that it's needed only until all backends support the "-q" flag,
> do you prefer a big patch to convert all backends so that check is not
> needed?
>
>> I'll rework that, then...

Even wget needs that flag, if it is fine for you i'll rework that patch set.

BR
Yann E. MORIN Jan. 1, 2015, 6:20 p.m. UTC | #6
Fabio, All,

On 2015-01-01 19:14 +0100, Fabio Porcedda spake thusly:
> On Thu, Jan 1, 2015 at 7:08 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > Fabio, All,
> >
> > On 2015-01-01 18:54 +0100, Fabio Porcedda spake thusly:
> >> On Thu, Jan 1, 2015 at 5:50 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> >> > From: Fabio Porcedda <fabio.porcedda@gmail.com>
> >> >
> >> > If it is a silent build (make -s -> QUIET=-q) silence all downloads, as
> >> > well as the check-hash. Only stdout is redirected, stderr is still
> >> > visible, for errors and warning.
> >>
> >> Hi Yann,
> >> nice idea, i tried this patch but even if it works for check-hash and
> >> svn it does not works for the git backend (e.g. libubox) and the wget
> >> bakend (try it without the QUIET flags in the WGET variable).
> >>
> >> I don't understand the reason for this behavior.
> >> Do you have an idea for this strange behavior?
> >
> > Ok, that's because git always sends its report status to stderr:
> >
> >     --quiet, -q
> >         Operate quietly. Progress is not reported to the standard
> >         error stream. [...]
> >
> > So, we need to pass -q to git. Sigh, fscking borked behaviour... stderr
> > is for failures, not normal reporting... :-(
> So that's the reason...
> 
> >
> > OK, so we need to pass -q to some backends.
> >
> > However, what I did not like in your original patch was the fact that
> > some backends were singled out in the wrapper script. We do not want
> > that, we want the wrapper to be backend-agnostic (that's the whole point
> > of having a wrapper and backends).
> 
> Well that it's needed only until all backends support the "-q" flag,
> do you prefer a big patch to convert all backends so that check is not
> needed?

I'm already on it... ;-)

Regards,
Yann E. MORIN.
diff mbox

Patch

diff --git a/package/pkg-download.mk b/package/pkg-download.mk
index ba72fc1..9c782fe 100644
--- a/package/pkg-download.mk
+++ b/package/pkg-download.mk
@@ -88,6 +88,7 @@  define DOWNLOAD_GIT
 	$(EXTRA_ENV) $(DL_WRAPPER) -b git \
 		-o $(DL_DIR)/$($(PKG)_SOURCE) \
 		-H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
+		$(QUIET) \
 		-- \
 		$($(PKG)_SITE) \
 		$($(PKG)_DL_VERSION) \
@@ -109,6 +110,7 @@  define DOWNLOAD_BZR
 	$(EXTRA_ENV) $(DL_WRAPPER) -b bzr \
 		-o $(DL_DIR)/$($(PKG)_SOURCE) \
 		-H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
+		$(QUIET) \
 		-- \
 		$($(PKG)_SITE) \
 		$($(PKG)_DL_VERSION) \
@@ -127,6 +129,7 @@  define DOWNLOAD_CVS
 	$(EXTRA_ENV) $(DL_WRAPPER) -b cvs \
 		-o $(DL_DIR)/$($(PKG)_SOURCE) \
 		-H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
+		$(QUIET) \
 		-- \
 		$(call stripurischeme,$(call qstrip,$($(PKG)_SITE))) \
 		$($(PKG)_DL_VERSION) \
@@ -147,6 +150,7 @@  define DOWNLOAD_SVN
 	$(EXTRA_ENV) $(DL_WRAPPER) -b svn \
 		-o $(DL_DIR)/$($(PKG)_SOURCE) \
 		-H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
+		$(QUIET) \
 		-- \
 		$($(PKG)_SITE) \
 		$($(PKG)_DL_VERSION) \
@@ -168,6 +172,7 @@  define DOWNLOAD_SCP
 	$(EXTRA_ENV) $(DL_WRAPPER) -b scp \
 		-o $(DL_DIR)/$(2) \
 		-H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
+		$(QUIET) \
 		-- \
 		'$(call stripurischeme,$(call qstrip,$(1)))'
 endef
@@ -185,6 +190,7 @@  define DOWNLOAD_HG
 	$(EXTRA_ENV) $(DL_WRAPPER) -b hg \
 		-o $(DL_DIR)/$($(PKG)_SOURCE) \
 		-H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
+		$(QUIET) \
 		-- \
 		$($(PKG)_SITE) \
 		$($(PKG)_DL_VERSION) \
@@ -206,6 +212,7 @@  define DOWNLOAD_WGET
 	$(EXTRA_ENV) $(DL_WRAPPER) -b wget \
 		-o $(DL_DIR)/$(2) \
 		-H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
+		$(QUIET) \
 		-- \
 		'$(call qstrip,$(1))'
 endef
@@ -222,6 +229,7 @@  define DOWNLOAD_LOCALFILES
 	$(EXTRA_ENV) $(DL_WRAPPER) -b cp \
 		-o $(DL_DIR)/$(2) \
 		-H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
+		$(QUIET) \
 		-- \
 		$(call stripurischeme,$(call qstrip,$(1)))
 endef
diff --git a/support/download/dl-wrapper b/support/download/dl-wrapper
index cced8f6..57a799e 100755
--- a/support/download/dl-wrapper
+++ b/support/download/dl-wrapper
@@ -24,12 +24,13 @@  main() {
     local backend output hfile
 
     # Parse our options; anything after '--' is for the backend
-    while getopts :hb:o:H: OPT; do
+    while getopts :hb:o:H:q OPT; do
         case "${OPT}" in
         h)  help; exit 0;;
         b)  backend="${OPTARG}";;
         o)  output="${OPTARG}";;
         H)  hfile="${OPTARG}";;
+        q)  exec >/dev/null;;
         :)  error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
         \?) error "unknown option '%s'\n" "${OPTARG}";;
         esac