summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-connectivity/ufw/ufw
diff options
context:
space:
mode:
authorSilcet <camorga1@gmail.com>2021-04-23 16:28:02 +0200
committerKhem Raj <raj.khem@gmail.com>2021-04-29 09:02:39 -0700
commit5194af1afd6b1e834af52e9b38d5ae6e19c637b0 (patch)
treecb7953a1533c7160ffef7b883901d1f24aa5d7d7 /meta-networking/recipes-connectivity/ufw/ufw
parent6725a3d3b28ae94a55737e9d0955ff64d81d95c0 (diff)
downloadmeta-openembedded-5194af1afd6b1e834af52e9b38d5ae6e19c637b0.tar.gz
ufw: fix python shebang
[meta-openembedded ticket #327] -- https://github.com/openembedded/meta-openembedded/issues/327 The python version in the shebang at the begining of the ufw script should be the same one as the version the setup.py script was called with. The fix in patch "setup-only-make-one-reference-to-env.patch" depends on sys.executable returning "/usr/bin/env pythonX". However, it returns "/usr/bin/pythonX". Using sys.version_info we can get the major version of the python used to called the script and append that to the shebang line so it works as intended. Signed-off-by: Silcet <camorga1@gmail.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-networking/recipes-connectivity/ufw/ufw')
-rw-r--r--meta-networking/recipes-connectivity/ufw/ufw/fix-dynamic-update-of-python-shebang.patch57
1 files changed, 57 insertions, 0 deletions
diff --git a/meta-networking/recipes-connectivity/ufw/ufw/fix-dynamic-update-of-python-shebang.patch b/meta-networking/recipes-connectivity/ufw/ufw/fix-dynamic-update-of-python-shebang.patch
new file mode 100644
index 000000000..0bb0315cc
--- /dev/null
+++ b/meta-networking/recipes-connectivity/ufw/ufw/fix-dynamic-update-of-python-shebang.patch
@@ -0,0 +1,57 @@
1From b961a7fceb5654c283c3f987bee593d52abaf1f5 Mon Sep 17 00:00:00 2001
2From: Silcet <camorga1@gmail.com>
3Date: Mon, 26 Apr 2021 07:47:02 +0000
4Subject: [PATCH] ufw: Fix dynamic update of python shebang
5
6[meta-openembedded ticket #327] -- https://github.com/openembedded/meta-openembedded/issues/327
7
8The python version in the shebang at the begining of the ufw script
9should be the same one as the version the setup.py script was called
10with.
11
12The fix in patch "setup-only-make-one-reference-to-env.patch"
13depends on sys.executable returning "/usr/bin/env pythonX". However,
14it returns "/usr/bin/pythonX". Using sys.version_info we can get the
15major version of the python used to called the script and append
16that to the shebang line so it works as intended.
17
18Upstream-status: Pending
19
20Signed-off-by: Silcet <camorga1@gmail.com>
21---
22 setup.py | 21 ++++++---------------
23 1 file changed, 6 insertions(+), 15 deletions(-)
24
25diff --git a/setup.py b/setup.py
26index ca730b7..941bbf6 100644
27--- a/setup.py
28+++ b/setup.py
29@@ -112,22 +112,13 @@ class Install(_install, object):
30 for f in [ script, manpage, manpage_f ]:
31 self.mkpath(os.path.dirname(f))
32
33- # if sys.executable == /usr/bin/env python* the result will be the top
34- # of ufw getting:
35- #
36- # #! /usr/bin/env /usr/bin/env python
37- #
38- # which is not ideal
39- #
40 # update the interpreter to that of the one the user specified for setup
41- print("Updating staging/ufw to use (%s)" % (sys.executable))
42-
43- if re.search("(/usr/bin/env)", sys.executable):
44- print("found 'env' in sys.executable (%s)" % (sys.executable))
45- subprocess.call(["sed",
46- "-i.jjm",
47- "1s%^#.*python.*%#! " + sys.executable + "%g",
48- 'staging/ufw'])
49+ python_major = sys.version_info.major
50+ print("Updating staging/ufw to use (python%s)" % (python_major))
51+ subprocess.call(["sed",
52+ "-i.jjm",
53+ "1s%^#.*python.*%#! " + sys.executable + "%g",
54+ 'staging/ufw'])
55
56 self.copy_file('staging/ufw', script)
57 self.copy_file('doc/ufw.8', manpage)