From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0] ident=Debian-exim) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Yb3RF-0001GF-AI for ptxdist@pengutronix.de; Thu, 26 Mar 2015 09:46:53 +0100 Received: from mol by ptx.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1Yb3RF-0006x1-8g for ptxdist@pengutronix.de; Thu, 26 Mar 2015 09:46:53 +0100 Date: Thu, 26 Mar 2015 09:46:53 +0100 From: Michael Olbrich Message-ID: <20150326084653.GD3000@pengutronix.de> References: <1425244923-29216-1-git-send-email-alex.aring@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1425244923-29216-1-git-send-email-alex.aring@gmail.com> Subject: Re: [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: , 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 On Sun, Mar 01, 2015 at 10:22:03PM +0100, Alexander Aring wrote: > 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. Thanks, applied with a minor change: added 'sort' to keep the old order. (It's already in ptxdist-2015.03.0). Michael > > 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 > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -- ptxdist mailing list ptxdist@pengutronix.de