blob: ff704b5a465f738dc61013a1e15e13480dd1d4ad [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001From be53eea06a5655fdc98f47a73be8277b65bb42ed Mon Sep 17 00:00:00 2001
2From: Joe MacDonald <joe_macdonald@mentor.com>
3Date: Tue, 11 Nov 2014 21:41:14 -0500
4Subject: [PATCH] setup: only make one reference to env
5
6If sys.executable happens to be '/usr/bin/env python' or something
7similar, the setup script will result in 'ufw' getting /usr/bin/env
8repeated on the top line. This causes an error at runtime. Perform a
9quick sanity check on sys.executable before doing the substitution.
10
11While we're at it, change the default value of 'exe' to the one we either
12detected or specified on the build line.
13
14Upstream-Status: Inappropriate [ embedded specific ]
15
16Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
17---
18 setup.py | 34 ++++++++++++++++++++++++++++------
19 1 file changed, 28 insertions(+), 6 deletions(-)
20
21diff --git a/setup.py b/setup.py
22index b13d11c..73acdef 100644
23--- a/setup.py
24+++ b/setup.py
25@@ -64,7 +64,7 @@ class Install(_install, object):
26 real_sharedir = os.path.join(real_prefix, 'share', 'ufw')
27
28 # Update the modules' paths
29- for file in [ 'common.py' ]:
30+ for file in [ 'common.py', 'util.py' ]:
31 print("Updating " + file)
32 subprocess.call(["sed",
33 "-i",
34@@ -91,6 +91,11 @@ class Install(_install, object):
35 "s%#SHARE_DIR#%" + real_sharedir + "%g",
36 os.path.join('staging', file)])
37
38+ subprocess.call(["sed",
39+ "-i.jjm",
40+ "s%/sbin/iptables%" + iptables_exe + "%g",
41+ os.path.join('staging', file)])
42+
43 # Now byte-compile everything
44 super(Install, self).run()
45
46@@ -107,12 +112,23 @@ class Install(_install, object):
47 for f in [ script, manpage, manpage_f ]:
48 self.mkpath(os.path.dirname(f))
49
50+ # if sys.executable == /usr/bin/env python* the result will be the top
51+ # of ufw getting:
52+ #
53+ # #! /usr/bin/env /usr/bin/env python
54+ #
55+ # which is not ideal
56+ #
57 # update the interpreter to that of the one the user specified for setup
58- print("Updating staging/ufw to use %s" % (sys.executable))
59- subprocess.call(["sed",
60- "-i",
61- "1s%^#.*python.*%#! /usr/bin/env " + sys.executable + "%g",
62- 'staging/ufw'])
63+ print("Updating staging/ufw to use (%s)" % (sys.executable))
64+
65+ if re.search("(/usr/bin/env)", sys.executable):
66+ print("found 'env' in sys.executable (%s)" % (sys.executable))
67+ subprocess.call(["sed",
68+ "-i.jjm",
69+ "1s%^#.*python.*%#! " + sys.executable + "%g",
70+ 'staging/ufw'])
71+
72 self.copy_file('staging/ufw', script)
73 self.copy_file('doc/ufw.8', manpage)
74 self.copy_file('doc/ufw-framework.8', manpage_f)
75--
761.9.1
77