mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] barebox: careful handling of wildcard
@ 2015-03-01 21:22 Alexander Aring
  2015-03-26  8:46 ` Michael Olbrich
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Aring @ 2015-03-01 21:22 UTC (permalink / raw)
  To: ptxdist; +Cc: Alexander Aring

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

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

end of thread, other threads:[~2015-03-26  8:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-01 21:22 [ptxdist] [PATCH] barebox: careful handling of wildcard Alexander Aring
2015-03-26  8:46 ` Michael Olbrich

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