mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Alexander Aring <alex.aring@gmail.com>
To: ptxdist@pengutronix.de
Cc: Alexander Aring <alex.aring@gmail.com>
Subject: [ptxdist] [PATCH] barebox: careful handling of wildcard
Date: Sun,  1 Mar 2015 22:22:03 +0100	[thread overview]
Message-ID: <1425244923-29216-1-git-send-email-alex.aring@gmail.com> (raw)

Some barebox images are not placed into barebox image directory, this
will end in a failure of ls with the wildcard expression. Something
like:

ls: cannot access ..foobar.../barebox-2015.02.0/images/barebox-*.img:
No such file or directory

This patch will improve the handling with wildcard if no image is
found by using find.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
Please review carefully! I tested in my case with dropping targetinstall
and add some "dummy" file into barebox image directory. Both cases works
on my side (no file and some dummy "barebox-*.img" file).

Also I can't no guarantee that the sequence of ls and find are the same
and it looks like that the sequence is important because the:
"if [ ! -e $(IMAGEDIR)/barebox-image ]; then \" part.

A general question would be is this always safe? What happens if somebody
do an "alias ls='ls $SORTOPTIONS'" somewhere where $USED_SHELL source some
general file? I suppose ptxdist has some mechanism to handle with something
like that.

 rules/barebox.make | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/rules/barebox.make b/rules/barebox.make
index 5c596a5..46d8e95 100644
--- a/rules/barebox.make
+++ b/rules/barebox.make
@@ -138,7 +138,9 @@ ifdef PTXCONF_BAREBOX_BAREBOXENV
 	@$(call install_finish, barebox)
 endif
 	@rm -f $(IMAGEDIR)/barebox-image
-	@for image in `ls $(BAREBOX_DIR)/images/barebox-*.img`; do \
+	@find $(BAREBOX_DIR)/images/ -name "barebox-*.img" \
+		| \
+		while read image; do \
 		install -D -m644 $$image $(IMAGEDIR)/`basename $$image`; \
 		if [ ! -e $(IMAGEDIR)/barebox-image ]; then \
 			ln -sf `basename $$image` $(IMAGEDIR)/barebox-image; \
-- 
2.3.0


-- 
ptxdist mailing list
ptxdist@pengutronix.de

             reply	other threads:[~2015-03-01 21:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-01 21:22 Alexander Aring [this message]
2015-03-26  8:46 ` Michael Olbrich

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=1425244923-29216-1-git-send-email-alex.aring@gmail.com \
    --to=alex.aring@gmail.com \
    --cc=ptxdist@pengutronix.de \
    /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