Skip to contentSkip to conversation

files: replace interpreter during installation

PATCH In review Arturo Borrero Gonzalez 4 participants 11 messages Jan 13, 2014 – Jan 22, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 files: replace interpreter during installation

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.

---
 Makefile.defs.in  |    1 +
 configure.ac      |    1 +
 files/Makefile.in |    1 +
 3 files changed, 3 insertions(+)
Makefile.defs.in +1 -0
index 502f374..3fee9c2 100644
@@ -5,6 +5,7 @@ LEX		= @LEX@
 YACC		= @YACC@
 MKDIR_P		= @MKDIR_P@
 INSTALL		= @INSTALL@
+SED		= @SED@
 
 PACKAGE_TARNAME	= @PACKAGE_TARNAME@
 
configure.ac +1 -0
index 811d7e2..ca14d83 100644
@@ -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"
files/Makefile.in +1 -0
index c3643df..dc237e2 100644
@@ -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)/*
#1 lore raw
Quoted 7 lines · Arturo Borrero Gonzalez

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.

Quoted 8 lines

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.

Quoted 41 lines
---
 Makefile.defs.in  |    1 +
 configure.ac      |    1 +
 files/Makefile.in |    1 +
 3 files changed, 3 insertions(+)
Makefile.defs.in +1 -0
index 502f374..3fee9c2 100644
@@ -5,6 +5,7 @@ LEX		= @LEX@
 YACC		= @YACC@
 MKDIR_P		= @MKDIR_P@
 INSTALL		= @INSTALL@
+SED		= @SED@
 
 PACKAGE_TARNAME	= @PACKAGE_TARNAME@
 
configure.ac +1 -0
index 811d7e2..ca14d83 100644
@@ -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"
files/Makefile.in +1 -0
index c3643df..dc237e2 100644
@@ -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)/*
#2 lore raw
Quoted 3 lines · Patrick McHardy

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 {
[...]

Quoted 1 line
Quoted 1 line

And replace during install. Is this true?

regards

Signature · 5 lines
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
Quoted 13 lines · Arturo Borrero Gonzalez
Quoted 3 lines · Patrick McHardy

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

Quoted 6 lines

table filter {
[...]

Quoted 1 line
Quoted 1 line

And replace during install. Is this true?

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

#! ${sbindir}/nft

#4 lore raw
Quoted 19 lines · Patrick McHardy
Quoted 18 lines · Arturo Borrero Gonzalez
Quoted 3 lines · Patrick McHardy

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 {
[...]

Quoted 1 line
Quoted 1 line
Quoted 5 lines
Quoted 1 line

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

Signature · 5 lines
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
Quoted 22 lines · Arturo Borrero Gonzalez
Quoted 21 lines · Patrick McHardy
Quoted 19 lines · Arturo Borrero Gonzalez
Quoted 3 lines · Patrick McHardy

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 {
[...]

Quoted 1 line
Quoted 1 line

And replace during install. Is this true?

Quoted 8 lines
Quoted 3 lines

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.

#7 lore raw
In reply to Arturo Borrero Gonzalez

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

Quoted 61 lines · Arturo Borrero Gonzalez

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.

---
 Makefile.defs.in  |    1 +
 configure.ac      |    1 +
 files/Makefile.in |    1 +
 3 files changed, 3 insertions(+)
Makefile.defs.in +1 -0
index 502f374..3fee9c2 100644
@@ -5,6 +5,7 @@ LEX             = @LEX@
 YACC           = @YACC@
 MKDIR_P                = @MKDIR_P@
 INSTALL                = @INSTALL@
+SED            = @SED@
 
 PACKAGE_TARNAME        = @PACKAGE_TARNAME@
 
configure.ac +1 -0
index 811d7e2..ca14d83 100644
@@ -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"
files/Makefile.in +1 -1
index c3643df..dc237e2 100644
@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw
Quoted 7 lines · Sam Liddicott

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.

#6 lore raw
In reply to Patrick McHardy
Quoted 20 lines · Patrick McHardy
Quoted 19 lines · Arturo Borrero Gonzalez
Quoted 4 lines · Patrick McHardy

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 {
[...]

Quoted 1 line
Quoted 1 line
Quoted 5 lines
Quoted 1 line

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

#9 lore raw
In reply to Patrick McHardy
Quoted 11 lines · Patrick McHardy
Quoted 7 lines · Sam Liddicott

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

Signature · 5 lines
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw
Quoted 16 lines · Arturo Borrero Gonzalez
Quoted 11 lines · Patrick McHardy
Quoted 7 lines · Sam Liddicott

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.

Quoted 7 lines

===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.