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 1/1] package/fakedate: Skip other fakedates in PATH
Date: Mon, 20 Apr 2020 23:17:24 +0200	[thread overview]
Message-ID: <20200420211724.GM5035@scaer> (raw)
In-Reply-To: <E260DE97-5F54-42B7-96EB-80FFABAD9775@cerebras.net>

Mark, All,

On 2020-04-20 18:56 +0000, Mark Huang spake thusly:
> If multiple buildroot SDKs are in PATH before /usr/bin (usually accidentally,
> but there may be some valid use cases for this), the first two copies of
> fakedate will go into a loop calling each other without ever finding
> /usr/bin/date. Grep for SOURCE_DATE_EPOCH in the candidate date binary, for
> additional verification that it's not another copy of fakedate.
> 
> Signed-off-by: Mark Huang <mark.huang@cerebras.net>
> ---
>  package/fakedate/fakedate | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/package/fakedate/fakedate b/package/fakedate/fakedate
> index a64d9b9..7b04568 100755
> --- a/package/fakedate/fakedate
> +++ b/package/fakedate/fakedate
> @@ -23,7 +23,7 @@ DATE_BIN=false
>  # Instead, find path of true `date' binary.
>  for P in `echo $PATH | tr ':' ' '`; do
>      if [ -x "$P/date" ]; then
> -        if ! [ "$P/date" -ef "$0" ]; then
> +        if ! [ "$P/date" -ef "$0" ] && ! grep -q SOURCE_DATE_EPOCH "$P/date" ; then

Thanks for this patch. I don't think this to be reliable enough, though.

Instead, what you want is iterate over PATH until you find ${0}, and
then take the next 'date' that matches, something like (to be tested!):

    # Find the 'date' executable that comes *after* us in PATH, to avoid
    # inifinite recursion:
    found_self=false
    for P in `echo $PATH | tr ':' ' '`; do
        if [ -x "$P/date"]; then
            ${found_self} && { DATE_BIN="$P/date"; break; }
            [ "$P/date" -ef "$0" ] && found_self=true
        fi
    done

Can you lok into tht, and respin, please? In the meantime, I've marked
the patch as chagnes requested in patchwork.

Regards,
Yann E. MORIN.

>              DATE_BIN="$P/date"
>              break;
>          fi
> --
> 1.8.3.1
> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

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

  reply	other threads:[~2020-04-20 21:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-20 18:56 [Buildroot] [PATCH 1/1] package/fakedate: Skip other fakedates in PATH Mark Huang
2020-04-20 21:17 ` Yann E. MORIN [this message]
2020-04-20 22:04   ` Mark Huang

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=20200420211724.GM5035@scaer \
    --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