From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-wg0-x232.google.com ([2a00:1450:400c:c00::232]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1YSBJh-0005Lw-Sb for ptxdist@pengutronix.de; Sun, 01 Mar 2015 22:22:26 +0100 Received: by wggz12 with SMTP id z12so29988957wgg.2 for ; Sun, 01 Mar 2015 13:22:20 -0800 (PST) From: Alexander Aring Date: Sun, 1 Mar 2015 22:22:03 +0100 Message-Id: <1425244923-29216-1-git-send-email-alex.aring@gmail.com> Subject: [ptxdist] [PATCH] barebox: careful handling of wildcard Reply-To: ptxdist@pengutronix.de List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: ptxdist-bounces@pengutronix.de Errors-To: ptxdist-bounces@pengutronix.de To: ptxdist@pengutronix.de 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 --- 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