Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 4/4] pkg-download: check hasahes for locally cached files
Date: Sun, 7 Dec 2014 11:47:37 +0100	[thread overview]
Message-ID: <20141207104737.GA3794@free.fr> (raw)
In-Reply-To: <20141206135309.016c7151@free-electrons.com>

Thomas, All,

On 2014-12-06 13:53 +0100, Thomas Petazzoni spake thusly:
[--SNIP--]
> define DOWNLOAD_WGET
>         test -e $(DL_DIR)/$(2) || \
>         $(EXTRA_ENV) support/download/wrapper wget \
>                 $(DL_DIR)/$(2) \
>                 '$(call qstrip,$(1))' && \
>         $(call VERIFY_HASH,$(PKGDIR)/$($(PKG)_NAME).hash,$(DL_DIR)/$(2))
> endef
> 
> 
> Hum, the construct 
> 
> 	test -e <foo> || download && check-hash

Well, in shell, the || and && operators have the same priority. In fact,
POSIX does not state that there should be any priority or that there
should be one. The phrasing in POSIX is very ambiguous:

    AND Lists

    The control operator "&&" denotes an AND list. The format shall be:

        command1 [ && command2] ...

    First command1 shall be executed. If its exit status is zero, command2
    shall be executed, and so on, until a command has a non-zero exit status
    or there are no more commands left to execute. The commands are expanded
    only if they are executed.

    Exit Status

    The exit status of an AND list shall be the exit status of the last
    command that is executed in the list.

    OR Lists

    The control operator "||" denotes an OR List. The format shall be:

        command1 [ || command2] ...

    First, command1 shall be executed. If its exit status is non-zero,
    command2 shall be executed, and so on, until a command has a zero exit
    status or there are no more commands left to execute.

    Exit Status

    The exit status of an OR list shall be the exit status of the last
    command that is executed in the list.

So, if one wants priority to be allied, one should use a compund
command, either {compound-list;} or (compound-list).

Yes, this sucks.

The advantage of moving that to the download wrapper makes the Makefile
code shrink considerably and makes it easier to read, since we get rid
of these AND-OR lists, we are non-trivial to read.

(Note: I too was very surprised that || and && do not have a priority,
and was bitten by it more often than not in the past; still today I do
this mistake quite often.)

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.  |
'------------------------------^-------^------------------^--------------------'

      reply	other threads:[~2014-12-07 10:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-01 23:24 [Buildroot] [PATCH 0/4] pkg-download: check hashes before the download (branch yem/download-hash) Yann E. MORIN
2014-12-01 23:24 ` [Buildroot] [PATCH 1/4] pkg-download: check for already downloaded file in the download wrapper Yann E. MORIN
2014-12-02  8:26   ` Thomas Petazzoni
2014-12-03 18:43     ` Yann E. MORIN
2014-12-01 23:24 ` [Buildroot] [PATCH 2/4] pkg-download: fix arguments to hash checking script Yann E. MORIN
2014-12-01 23:24 ` [Buildroot] [PATCH 3/4] pkg-download: verify the hashes from the download wrapper Yann E. MORIN
2014-12-02  8:29   ` Thomas Petazzoni
2014-12-03 18:45     ` Yann E. MORIN
2014-12-01 23:24 ` [Buildroot] [PATCH 4/4] pkg-download: check hasahes for locally cached files Yann E. MORIN
2014-12-02  8:31   ` Thomas Petazzoni
2014-12-02  9:27     ` Peter Korsgaard
2014-12-02  9:30       ` Thomas Petazzoni
2014-12-03 18:51     ` Yann E. MORIN
2014-12-06 12:44       ` Yann E. MORIN
2014-12-06 12:53         ` Thomas Petazzoni
2014-12-07 10:47           ` Yann E. MORIN [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141207104737.GA3794@free.fr \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox