netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [nft PATCH] files: replace interpreter during installation
@ 2013-12-24  1:21 Arturo Borrero Gonzalez
  0 siblings, 0 replies; 12+ messages in thread
From: Arturo Borrero Gonzalez @ 2013-12-24  1:21 UTC (permalink / raw)
  To: netfilter-devel; +Cc: pablo

Many systems (for example Debian) don't recognice `#!nft -f' as a
valid interpreter.

A short way to handle this is to provide the full path to the interpreter
in the shebang.
That is what this patch does: update the shebang's path during installation.

For example, if you are installing under /usr/local, the shebang becomes:
 #!/usr/local/sbin/nft -f

If using --prefix=/, then:
 #!/sbin/nft -f

NOTE: If the shebang in source files are changed in a future, this sed script
should be updated as well.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 Makefile.defs.in  |    1 +
 configure.ac      |    1 +
 files/Makefile.in |    1 +
 3 files changed, 3 insertions(+)

diff --git a/Makefile.defs.in b/Makefile.defs.in
index 502f374..3fee9c2 100644
--- a/Makefile.defs.in
+++ b/Makefile.defs.in
@@ -5,6 +5,7 @@ LEX		= @LEX@
 YACC		= @YACC@
 MKDIR_P		= @MKDIR_P@
 INSTALL		= @INSTALL@
+SED		= @SED@
 
 PACKAGE_TARNAME	= @PACKAGE_TARNAME@
 
diff --git a/configure.ac b/configure.ac
index 811d7e2..ca14d83 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,7 @@ AC_SUBST([CONFIG_DEBUG])
 AC_PROG_CC
 AC_PROG_MKDIR_P
 AC_PROG_INSTALL
+AC_PROG_SED
 
 AC_CHECK_PROG(CONFIG_MAN, docbook2x-man, y, n)
 if test "$CONFIG_MAN" != "y"
diff --git a/files/Makefile.in b/files/Makefile.in
index cd67c37..563383b 100644
--- a/files/Makefile.in
+++ b/files/Makefile.in
@@ -2,3 +2,4 @@ install:
 	@echo -e "  INSTALL\tfiles"
 	$(MKDIR_P) $(DESTDIR)/$(confdir)
 	$(INSTALL) -m 755 -o root -g root $(SUBDIR)nftables/* $(DESTDIR)/$(confdir)/
+	$(SED) -i "s~#\! nft~#\!@sbindir@/nft~" $(DESTDIR)/$(confdir)/*


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

* [nft PATCH] files: replace interpreter during installation
@ 2014-01-13  9:16 Arturo Borrero Gonzalez
  2014-01-13  9:39 ` Patrick McHardy
  2014-01-14 15:00 ` Sam Liddicott
  0 siblings, 2 replies; 12+ messages in thread
From: Arturo Borrero Gonzalez @ 2014-01-13  9:16 UTC (permalink / raw)
  To: netfilter-devel; +Cc: kaber

Many systems (for example Debian) don't recognice `#!nft -f' as a
valid interpreter.

A short way to handle this is to provide the full path to the interpreter
in the shebang.
That is what this patch does: update the shebang's path during installation.

For example, if you are installing under /usr/local, the shebang becomes:
 #!/usr/local/sbin/nft -f

If using --prefix=/, then:
 #!/sbin/nft -f

NOTE: If the shebang in source files are changed in a future, this sed script
should be updated as well.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 Makefile.defs.in  |    1 +
 configure.ac      |    1 +
 files/Makefile.in |    1 +
 3 files changed, 3 insertions(+)

diff --git a/Makefile.defs.in b/Makefile.defs.in
index 502f374..3fee9c2 100644
--- a/Makefile.defs.in
+++ b/Makefile.defs.in
@@ -5,6 +5,7 @@ LEX		= @LEX@
 YACC		= @YACC@
 MKDIR_P		= @MKDIR_P@
 INSTALL		= @INSTALL@
+SED		= @SED@
 
 PACKAGE_TARNAME	= @PACKAGE_TARNAME@
 
diff --git a/configure.ac b/configure.ac
index 811d7e2..ca14d83 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,7 @@ AC_SUBST([CONFIG_DEBUG])
 AC_PROG_CC
 AC_PROG_MKDIR_P
 AC_PROG_INSTALL
+AC_PROG_SED
 
 AC_CHECK_PROG(CONFIG_MAN, docbook2x-man, y, n)
 if test "$CONFIG_MAN" != "y"
diff --git a/files/Makefile.in b/files/Makefile.in
index c3643df..dc237e2 100644
--- a/files/Makefile.in
+++ b/files/Makefile.in
@@ -2,3 +2,4 @@ install:
 	@echo -e "  INSTALL\tfiles"
 	$(MKDIR_P) $(DESTDIR)/$(confdir)
 	$(INSTALL) -m 755 -p $(SUBDIR)nftables/* $(DESTDIR)/$(confdir)/
+	$(SED) -i "s~#\! nft~#\!@sbindir@/nft~" $(DESTDIR)/$(confdir)/*


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

* Re: [nft PATCH] files: replace interpreter during installation
  2014-01-13  9:16 Arturo Borrero Gonzalez
@ 2014-01-13  9:39 ` Patrick McHardy
  2014-01-13  9:49   ` Arturo Borrero Gonzalez
  2014-01-14 15:00 ` Sam Liddicott
  1 sibling, 1 reply; 12+ messages in thread
From: Patrick McHardy @ 2014-01-13  9:39 UTC (permalink / raw)
  To: Arturo Borrero Gonzalez; +Cc: netfilter-devel

On Mon, Jan 13, 2014 at 10:16:23AM +0100, Arturo Borrero Gonzalez wrote:
> Many systems (for example Debian) don't recognice `#!nft -f' as a
> valid interpreter.
> 
> A short way to handle this is to provide the full path to the interpreter
> in the shebang.
> That is what this patch does: update the shebang's path during installation.
> 
> For example, if you are installing under /usr/local, the shebang becomes:
>  #!/usr/local/sbin/nft -f
> 
> If using --prefix=/, then:
>  #!/sbin/nft -f
> 
> NOTE: If the shebang in source files are changed in a future, this sed script
> should be updated as well.

I think we should use .in files instead and perform variable substition.

> 
> Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> ---
>  Makefile.defs.in  |    1 +
>  configure.ac      |    1 +
>  files/Makefile.in |    1 +
>  3 files changed, 3 insertions(+)
> 
> diff --git a/Makefile.defs.in b/Makefile.defs.in
> index 502f374..3fee9c2 100644
> --- a/Makefile.defs.in
> +++ b/Makefile.defs.in
> @@ -5,6 +5,7 @@ LEX		= @LEX@
>  YACC		= @YACC@
>  MKDIR_P		= @MKDIR_P@
>  INSTALL		= @INSTALL@
> +SED		= @SED@
>  
>  PACKAGE_TARNAME	= @PACKAGE_TARNAME@
>  
> diff --git a/configure.ac b/configure.ac
> index 811d7e2..ca14d83 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -23,6 +23,7 @@ AC_SUBST([CONFIG_DEBUG])
>  AC_PROG_CC
>  AC_PROG_MKDIR_P
>  AC_PROG_INSTALL
> +AC_PROG_SED
>  
>  AC_CHECK_PROG(CONFIG_MAN, docbook2x-man, y, n)
>  if test "$CONFIG_MAN" != "y"
> diff --git a/files/Makefile.in b/files/Makefile.in
> index c3643df..dc237e2 100644
> --- a/files/Makefile.in
> +++ b/files/Makefile.in
> @@ -2,3 +2,4 @@ install:
>  	@echo -e "  INSTALL\tfiles"
>  	$(MKDIR_P) $(DESTDIR)/$(confdir)
>  	$(INSTALL) -m 755 -p $(SUBDIR)nftables/* $(DESTDIR)/$(confdir)/
> +	$(SED) -i "s~#\! nft~#\!@sbindir@/nft~" $(DESTDIR)/$(confdir)/*

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

* Re: [nft PATCH] files: replace interpreter during installation
  2014-01-13  9:39 ` Patrick McHardy
@ 2014-01-13  9:49   ` Arturo Borrero Gonzalez
  2014-01-13  9:52     ` Patrick McHardy
  0 siblings, 1 reply; 12+ messages in thread
From: Arturo Borrero Gonzalez @ 2014-01-13  9:49 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: Netfilter Development Mailing list

On 13 January 2014 10:39, Patrick McHardy <kaber@trash.net> wrote:
>
> I think we should use .in files instead and perform variable substition.
>

Could you please elaborate this?

I have understood:

Use a variable in files/nftables/*, like:
<<
$shebang

table filter {
[...]

>>

And replace during install. Is this true?

regards
-- 
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [nft PATCH] files: replace interpreter during installation
  2014-01-13  9:49   ` Arturo Borrero Gonzalez
@ 2014-01-13  9:52     ` Patrick McHardy
  2014-01-13 16:30       ` Alex Elsayed
  2014-01-14 12:48       ` Arturo Borrero Gonzalez
  0 siblings, 2 replies; 12+ messages in thread
From: Patrick McHardy @ 2014-01-13  9:52 UTC (permalink / raw)
  To: Arturo Borrero Gonzalez; +Cc: Netfilter Development Mailing list

On Mon, Jan 13, 2014 at 10:49:51AM +0100, Arturo Borrero Gonzalez wrote:
> On 13 January 2014 10:39, Patrick McHardy <kaber@trash.net> wrote:
> >
> > I think we should use .in files instead and perform variable substition.
> >
> 
> Could you please elaborate this?
> 
> I have understood:
> 
> Use a variable in files/nftables/*, like:
> <<
> $shebang
> 
> table filter {
> [...]
> 
> >>
> 
> And replace during install. Is this true?

Use f.i. files/nftables/ipv4-filter.in and use

#! ${sbindir}/nft

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

* Re: [nft PATCH] files: replace interpreter during installation
  2014-01-13  9:52     ` Patrick McHardy
@ 2014-01-13 16:30       ` Alex Elsayed
  2014-01-14 12:48       ` Arturo Borrero Gonzalez
  1 sibling, 0 replies; 12+ messages in thread
From: Alex Elsayed @ 2014-01-13 16:30 UTC (permalink / raw)
  To: netfilter-devel

Patrick McHardy wrote:

> On Mon, Jan 13, 2014 at 10:49:51AM +0100, Arturo Borrero Gonzalez wrote:
>> On 13 January 2014 10:39, Patrick McHardy <kaber@trash.net> wrote:
>> >
>> > I think we should use .in files instead and perform variable
>> > substition.
>> >
>> 
>> Could you please elaborate this?
>> 
>> I have understood:
>> 
>> Use a variable in files/nftables/*, like:
>> <<
>> $shebang
>> 
>> table filter {
>> [...]
>> 
>> >>
>> 
>> And replace during install. Is this true?
> 
> Use f.i. files/nftables/ipv4-filter.in and use
> 
> #! ${sbindir}/nft

Another option would be the venerable

#!/usr/bin/env nft



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

* Re: [nft PATCH] files: replace interpreter during installation
  2014-01-13  9:52     ` Patrick McHardy
  2014-01-13 16:30       ` Alex Elsayed
@ 2014-01-14 12:48       ` Arturo Borrero Gonzalez
  2014-01-14 13:11         ` Patrick McHardy
  1 sibling, 1 reply; 12+ messages in thread
From: Arturo Borrero Gonzalez @ 2014-01-14 12:48 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: Netfilter Development Mailing list

On 13 January 2014 10:52, Patrick McHardy <kaber@trash.net> wrote:
> On Mon, Jan 13, 2014 at 10:49:51AM +0100, Arturo Borrero Gonzalez wrote:
>> On 13 January 2014 10:39, Patrick McHardy <kaber@trash.net> wrote:
>> >
>> > I think we should use .in files instead and perform variable substition.
>> >
>>
>> Could you please elaborate this?
>>
>> I have understood:
>>
>> Use a variable in files/nftables/*, like:
>> <<
>> $shebang
>>
>> table filter {
>> [...]
>>
>> >>
>>
>> And replace during install. Is this true?
>
> Use f.i. files/nftables/ipv4-filter.in and use
>
> #! ${sbindir}/nft

I'm OK with this.

But I see you pushed my patch to master [0]. Should I still work on
your .in approach?

Regards.

[0] https://git.netfilter.org/nftables/commit/?id=c54ce2e0fd25d79f5343792c1c620fecdc3b03bc
-- 
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [nft PATCH] files: replace interpreter during installation
  2014-01-14 12:48       ` Arturo Borrero Gonzalez
@ 2014-01-14 13:11         ` Patrick McHardy
  0 siblings, 0 replies; 12+ messages in thread
From: Patrick McHardy @ 2014-01-14 13:11 UTC (permalink / raw)
  To: Arturo Borrero Gonzalez; +Cc: Netfilter Development Mailing list

On Tue, Jan 14, 2014 at 01:48:46PM +0100, Arturo Borrero Gonzalez wrote:
> On 13 January 2014 10:52, Patrick McHardy <kaber@trash.net> wrote:
> > On Mon, Jan 13, 2014 at 10:49:51AM +0100, Arturo Borrero Gonzalez wrote:
> >> On 13 January 2014 10:39, Patrick McHardy <kaber@trash.net> wrote:
> >> >
> >> > I think we should use .in files instead and perform variable substition.
> >> >
> >>
> >> Could you please elaborate this?
> >>
> >> I have understood:
> >>
> >> Use a variable in files/nftables/*, like:
> >> <<
> >> $shebang
> >>
> >> table filter {
> >> [...]
> >>
> >> >>
> >>
> >> And replace during install. Is this true?
> >
> > Use f.i. files/nftables/ipv4-filter.in and use
> >
> > #! ${sbindir}/nft
> 
> I'm OK with this.
> 
> But I see you pushed my patch to master [0]. Should I still work on
> your .in approach?

Crap, that was actually a mistake, I committed it to my tree before
I replied to your email. Sorry. Please go ahead with the alternative
patch.

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

* Re: [nft PATCH] files: replace interpreter during installation
  2014-01-13  9:16 Arturo Borrero Gonzalez
  2014-01-13  9:39 ` Patrick McHardy
@ 2014-01-14 15:00 ` Sam Liddicott
  2014-01-14 15:16   ` Patrick McHardy
  1 sibling, 1 reply; 12+ messages in thread
From: Sam Liddicott @ 2014-01-14 15:00 UTC (permalink / raw)
  To: Arturo Borrero Gonzalez; +Cc: netfilter-devel, kaber

I realise a solution is reached, but an alternative in common use is
mentioned here for completeness;

#! /usr/bin/env nft -f

it is commonly used to invoke interpreters whose path is unknown but
which can be expected to be on the PATH

Sam

On Mon, Jan 13, 2014 at 9:16 AM, Arturo Borrero Gonzalez
<arturo.borrero.glez@gmail.com> wrote:
> Many systems (for example Debian) don't recognice `#!nft -f' as a
> valid interpreter.
>
> A short way to handle this is to provide the full path to the interpreter
> in the shebang.
> That is what this patch does: update the shebang's path during installation.
>
> For example, if you are installing under /usr/local, the shebang becomes:
>  #!/usr/local/sbin/nft -f
>
> If using --prefix=/, then:
>  #!/sbin/nft -f
>
> NOTE: If the shebang in source files are changed in a future, this sed script
> should be updated as well.
>
> Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> ---
>  Makefile.defs.in  |    1 +
>  configure.ac      |    1 +
>  files/Makefile.in |    1 +
>  3 files changed, 3 insertions(+)
>
> diff --git a/Makefile.defs.in b/Makefile.defs.in
> index 502f374..3fee9c2 100644
> --- a/Makefile.defs.in
> +++ b/Makefile.defs.in
> @@ -5,6 +5,7 @@ LEX             = @LEX@
>  YACC           = @YACC@
>  MKDIR_P                = @MKDIR_P@
>  INSTALL                = @INSTALL@
> +SED            = @SED@
>
>  PACKAGE_TARNAME        = @PACKAGE_TARNAME@
>
> diff --git a/configure.ac b/configure.ac
> index 811d7e2..ca14d83 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -23,6 +23,7 @@ AC_SUBST([CONFIG_DEBUG])
>  AC_PROG_CC
>  AC_PROG_MKDIR_P
>  AC_PROG_INSTALL
> +AC_PROG_SED
>
>  AC_CHECK_PROG(CONFIG_MAN, docbook2x-man, y, n)
>  if test "$CONFIG_MAN" != "y"
> diff --git a/files/Makefile.in b/files/Makefile.in
> index c3643df..dc237e2 100644
> --- a/files/Makefile.in
> +++ b/files/Makefile.in
> @@ -2,3 +2,4 @@ install:
>         @echo -e "  INSTALL\tfiles"
>         $(MKDIR_P) $(DESTDIR)/$(confdir)
>         $(INSTALL) -m 755 -p $(SUBDIR)nftables/* $(DESTDIR)/$(confdir)/
> +       $(SED) -i "s~#\! nft~#\!@sbindir@/nft~" $(DESTDIR)/$(confdir)/*
>
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [nft PATCH] files: replace interpreter during installation
  2014-01-14 15:00 ` Sam Liddicott
@ 2014-01-14 15:16   ` Patrick McHardy
  2014-01-22 16:45     ` Arturo Borrero Gonzalez
  0 siblings, 1 reply; 12+ messages in thread
From: Patrick McHardy @ 2014-01-14 15:16 UTC (permalink / raw)
  To: Sam Liddicott; +Cc: Arturo Borrero Gonzalez, netfilter-devel

On Tue, Jan 14, 2014 at 03:00:14PM +0000, Sam Liddicott wrote:
> I realise a solution is reached, but an alternative in common use is
> mentioned here for completeness;
> 
> #! /usr/bin/env nft -f
> 
> it is commonly used to invoke interpreters whose path is unknown but
> which can be expected to be on the PATH

I'm find either way. Unless there are arguments for not using env,
this seems like the simpler fix.

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

* Re: [nft PATCH] files: replace interpreter during installation
  2014-01-14 15:16   ` Patrick McHardy
@ 2014-01-22 16:45     ` Arturo Borrero Gonzalez
  2014-01-22 16:51       ` Patrick McHardy
  0 siblings, 1 reply; 12+ messages in thread
From: Arturo Borrero Gonzalez @ 2014-01-22 16:45 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: Sam Liddicott, Netfilter Development Mailing list

On 14 January 2014 16:16, Patrick McHardy <kaber@trash.net> wrote:
> On Tue, Jan 14, 2014 at 03:00:14PM +0000, Sam Liddicott wrote:
>> I realise a solution is reached, but an alternative in common use is
>> mentioned here for completeness;
>>
>> #! /usr/bin/env nft -f
>>
>> it is commonly used to invoke interpreters whose path is unknown but
>> which can be expected to be on the PATH
>
> I'm find either way. Unless there are arguments for not using env,
> this seems like the simpler fix.


Using env with an additional argument (the '-f') seems to fail in my system.

===8<===
#!/usr/bin/env nft -f
list table filter
===8<===

% ./test
/usr/bin/env: nft -f: No such file or directory

-- 
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [nft PATCH] files: replace interpreter during installation
  2014-01-22 16:45     ` Arturo Borrero Gonzalez
@ 2014-01-22 16:51       ` Patrick McHardy
  0 siblings, 0 replies; 12+ messages in thread
From: Patrick McHardy @ 2014-01-22 16:51 UTC (permalink / raw)
  To: Arturo Borrero Gonzalez; +Cc: Sam Liddicott, Netfilter Development Mailing list

On Wed, Jan 22, 2014 at 05:45:39PM +0100, Arturo Borrero Gonzalez wrote:
> On 14 January 2014 16:16, Patrick McHardy <kaber@trash.net> wrote:
> > On Tue, Jan 14, 2014 at 03:00:14PM +0000, Sam Liddicott wrote:
> >> I realise a solution is reached, but an alternative in common use is
> >> mentioned here for completeness;
> >>
> >> #! /usr/bin/env nft -f
> >>
> >> it is commonly used to invoke interpreters whose path is unknown but
> >> which can be expected to be on the PATH
> >
> > I'm find either way. Unless there are arguments for not using env,
> > this seems like the simpler fix.
> 
> 
> Using env with an additional argument (the '-f') seems to fail in my system.
> 
> ===8<===
> #!/usr/bin/env nft -f
> list table filter
> ===8<===
> 
> % ./test
> /usr/bin/env: nft -f: No such file or directory

I guess lets just keep it this way. Thanks.

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

end of thread, other threads:[~2014-01-22 16:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-24  1:21 [nft PATCH] files: replace interpreter during installation Arturo Borrero Gonzalez
  -- strict thread matches above, loose matches on Subject: below --
2014-01-13  9:16 Arturo Borrero Gonzalez
2014-01-13  9:39 ` Patrick McHardy
2014-01-13  9:49   ` Arturo Borrero Gonzalez
2014-01-13  9:52     ` Patrick McHardy
2014-01-13 16:30       ` Alex Elsayed
2014-01-14 12:48       ` Arturo Borrero Gonzalez
2014-01-14 13:11         ` Patrick McHardy
2014-01-14 15:00 ` Sam Liddicott
2014-01-14 15:16   ` Patrick McHardy
2014-01-22 16:45     ` Arturo Borrero Gonzalez
2014-01-22 16:51       ` Patrick McHardy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).