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.ar...@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 via email to