diff mbox

[v2] infra: fix autotools .la fixing when no .la files are present

Message ID bb03ffeaa528d3c99f51.1404659451@localhost
State Accepted
Commit 18a0e073507e03eaba80c25017f9f28bd830a48a
Headers show

Commit Message

Thomas De Schampheleire July 6, 2014, 3:10 p.m. UTC
Commit 6f638ea9c9c7bacc646430a74ad3dd2740eae676 ("infra: /usr support:
STAGING_DIR can be outside BASE_DIR") changed a for-construct around 'sed
-i' in a 'find | xargs sed -i'. However, if the find returns no results,
sed complains with:
    '/bin/sed: no input files'

This commit adds the extra parameter -r / --no-run-if-empty to the xargs
call, effectively fixing this problem case.

Reported-by: Rohit Kumar <rkthebest@gmail.com>
Fix-suggested-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>

---
 package/pkg-autotools.mk |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Thomas De Schampheleire July 6, 2014, 3:21 p.m. UTC | #1
All,

On Sun, Jul 6, 2014 at 5:10 PM, Thomas De Schampheleire
<patrickdepinguin@gmail.com> wrote:
> Commit 6f638ea9c9c7bacc646430a74ad3dd2740eae676 ("infra: /usr support:
> STAGING_DIR can be outside BASE_DIR") changed a for-construct around 'sed
> -i' in a 'find | xargs sed -i'. However, if the find returns no results,
> sed complains with:
>     '/bin/sed: no input files'
>
> This commit adds the extra parameter -r / --no-run-if-empty to the xargs
> call, effectively fixing this problem case.
>
> Reported-by: Rohit Kumar <rkthebest@gmail.com>
> Fix-suggested-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
>
> ---
>  package/pkg-autotools.mk |  2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff -r c8ed6565ea09 -r bb03ffeaa528 package/pkg-autotools.mk
> --- a/package/pkg-autotools.mk  Thu Jul 03 12:35:57 2014 +0300
> +++ b/package/pkg-autotools.mk  Sun Jul 06 16:19:04 2014 +0200
> @@ -281,7 +281,7 @@
>  ifndef $(2)_INSTALL_STAGING_CMDS
>  define $(2)_INSTALL_STAGING_CMDS
>         $$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_STAGING_OPT) -C $$($$(PKG)_SRCDIR)
> -       find $$(STAGING_DIR)/usr/lib* -name "*.la" | xargs \
> +       find $$(STAGING_DIR)/usr/lib* -name "*.la" | xargs --no-run-if-empty \
>                 $$(SED) "s:$$(BASE_DIR):@BASE_DIR@:g" \
>                         -e "s:$$(STAGING_DIR):@STAGING_DIR@:g" \
>                         -e "s:\(['= ]\)/usr:\\1@STAGING_DIR@/usr:g" \

Note that I chose for the xargs solution here.
Do you prefer the xargs-like find solution instead?
    find DIR PREDICATES -exec commands +

Let me know,

Thanks,
Thomas
Yann E. MORIN July 6, 2014, 3:27 p.m. UTC | #2
Thomas, All,

On 2014-07-06 17:10 +0200, Thomas De Schampheleire spake thusly:
> Commit 6f638ea9c9c7bacc646430a74ad3dd2740eae676 ("infra: /usr support:
> STAGING_DIR can be outside BASE_DIR") changed a for-construct around 'sed
> -i' in a 'find | xargs sed -i'. However, if the find returns no results,
> sed complains with:
>     '/bin/sed: no input files'
> 
> This commit adds the extra parameter -r / --no-run-if-empty to the xargs
> call, effectively fixing this problem case.
> 
> Reported-by: Rohit Kumar <rkthebest@gmail.com>
> Fix-suggested-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>

Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

Regards,
Yann E. MORIN.

> ---
>  package/pkg-autotools.mk |  2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff -r c8ed6565ea09 -r bb03ffeaa528 package/pkg-autotools.mk
> --- a/package/pkg-autotools.mk	Thu Jul 03 12:35:57 2014 +0300
> +++ b/package/pkg-autotools.mk	Sun Jul 06 16:19:04 2014 +0200
> @@ -281,7 +281,7 @@
>  ifndef $(2)_INSTALL_STAGING_CMDS
>  define $(2)_INSTALL_STAGING_CMDS
>  	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_STAGING_OPT) -C $$($$(PKG)_SRCDIR)
> -	find $$(STAGING_DIR)/usr/lib* -name "*.la" | xargs \
> +	find $$(STAGING_DIR)/usr/lib* -name "*.la" | xargs --no-run-if-empty \
>  		$$(SED) "s:$$(BASE_DIR):@BASE_DIR@:g" \
>  			-e "s:$$(STAGING_DIR):@STAGING_DIR@:g" \
>  			-e "s:\(['= ]\)/usr:\\1@STAGING_DIR@/usr:g" \
Yann E. MORIN July 6, 2014, 3:28 p.m. UTC | #3
Thomas, All,

On 2014-07-06 17:21 +0200, Thomas De Schampheleire spake thusly:
> On Sun, Jul 6, 2014 at 5:10 PM, Thomas De Schampheleire
> <patrickdepinguin@gmail.com> wrote:
> > Commit 6f638ea9c9c7bacc646430a74ad3dd2740eae676 ("infra: /usr support:
> > STAGING_DIR can be outside BASE_DIR") changed a for-construct around 'sed
> > -i' in a 'find | xargs sed -i'. However, if the find returns no results,
> > sed complains with:
> >     '/bin/sed: no input files'
> >
> > This commit adds the extra parameter -r / --no-run-if-empty to the xargs
> > call, effectively fixing this problem case.
> >
> > Reported-by: Rohit Kumar <rkthebest@gmail.com>
> > Fix-suggested-by: Yann E. MORIN <yann.morin.1998@free.fr>
> > Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
> >
> > ---
> >  package/pkg-autotools.mk |  2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff -r c8ed6565ea09 -r bb03ffeaa528 package/pkg-autotools.mk
> > --- a/package/pkg-autotools.mk  Thu Jul 03 12:35:57 2014 +0300
> > +++ b/package/pkg-autotools.mk  Sun Jul 06 16:19:04 2014 +0200
> > @@ -281,7 +281,7 @@
> >  ifndef $(2)_INSTALL_STAGING_CMDS
> >  define $(2)_INSTALL_STAGING_CMDS
> >         $$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_STAGING_OPT) -C $$($$(PKG)_SRCDIR)
> > -       find $$(STAGING_DIR)/usr/lib* -name "*.la" | xargs \
> > +       find $$(STAGING_DIR)/usr/lib* -name "*.la" | xargs --no-run-if-empty \
> >                 $$(SED) "s:$$(BASE_DIR):@BASE_DIR@:g" \
> >                         -e "s:$$(STAGING_DIR):@STAGING_DIR@:g" \
> >                         -e "s:\(['= ]\)/usr:\\1@STAGING_DIR@/usr:g" \
> 
> Note that I chose for the xargs solution here.
> Do you prefer the xargs-like find solution instead?
>     find DIR PREDICATES -exec commands +

As I said on IRC, I'm fine with the xargs solution.

If people are more accustomed to using 'find |xargs' rather than using
'find -exec {} +', then no problem.

Regards,
Yann E. MORIN.
Peter Korsgaard July 6, 2014, 8:22 p.m. UTC | #4
>>>>> "Thomas" == Thomas De Schampheleire <patrickdepinguin@gmail.com> writes:

 > Commit 6f638ea9c9c7bacc646430a74ad3dd2740eae676 ("infra: /usr support:
 > STAGING_DIR can be outside BASE_DIR") changed a for-construct around 'sed
 > -i' in a 'find | xargs sed -i'. However, if the find returns no results,
 > sed complains with:
 >     '/bin/sed: no input files'

 > This commit adds the extra parameter -r / --no-run-if-empty to the xargs
 > call, effectively fixing this problem case.

 > Reported-by: Rohit Kumar <rkthebest@gmail.com>
 > Fix-suggested-by: Yann E. MORIN <yann.morin.1998@free.fr>
 > Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>

Committed, thanks.
diff mbox

Patch

diff -r c8ed6565ea09 -r bb03ffeaa528 package/pkg-autotools.mk
--- a/package/pkg-autotools.mk	Thu Jul 03 12:35:57 2014 +0300
+++ b/package/pkg-autotools.mk	Sun Jul 06 16:19:04 2014 +0200
@@ -281,7 +281,7 @@ 
 ifndef $(2)_INSTALL_STAGING_CMDS
 define $(2)_INSTALL_STAGING_CMDS
 	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_STAGING_OPT) -C $$($$(PKG)_SRCDIR)
-	find $$(STAGING_DIR)/usr/lib* -name "*.la" | xargs \
+	find $$(STAGING_DIR)/usr/lib* -name "*.la" | xargs --no-run-if-empty \
 		$$(SED) "s:$$(BASE_DIR):@BASE_DIR@:g" \
 			-e "s:$$(STAGING_DIR):@STAGING_DIR@:g" \
 			-e "s:\(['= ]\)/usr:\\1@STAGING_DIR@/usr:g" \