With the recent merge to update AppArmor to support python3, there
remains the issue of setting up the shebang in python scripts to use
PYTHON_VERSIONS if it is defined. This is important for aa-easyprof
since it installs a python module. Currently, it is possible that the
module is installed for python3, but the system defaults to python2, so
it can't find the module. Attached is a patch to python-tools-setup.py
to honor allow distributions to set PYTHON_VERSIONS in their build
environment and have everything work the way they expect..

Note that aa-status is also written in python, but it doesn't use
python-tools-setup.py. This isn't a big problem though since it is a
standalone bi-lingual script.

-- 
Jamie Strandboge             | http://www.canonical.com
Author: Jamie Strandboge <[email protected]>
Description: use PYTHON_VERSIONS in utils/python-tools-setup.py if it is
 defined
Forwarded: yes

Index: apparmor-2.8.0/utils/python-tools-setup.py
===================================================================
--- apparmor-2.8.0.orig/utils/python-tools-setup.py	2012-06-29 13:21:49.000000000 -0500
+++ apparmor-2.8.0/utils/python-tools-setup.py	2012-06-29 13:29:29.000000000 -0500
@@ -40,7 +40,15 @@
         scripts = ['/usr/bin/aa-easyprof']
         self.mkpath(prefix + os.path.dirname(scripts[0]))
         for s in scripts:
-            self.copy_file(os.path.basename(s), prefix + s)
+            f = prefix + s
+            # If we have a defined python version, use it instead of the system
+            # default
+            if 'PYTHON_VERSIONS' in os.environ:
+                lines = open(os.path.basename(s)).readlines()
+                lines[0] = '#! /usr/bin/env %s\n' % os.environ['PYTHON_VERSIONS'].split()[0]
+                open(f, 'w').write("".join(lines))
+            else:
+                self.copy_file(os.path.basename(s), f)
 
         configs = ['easyprof/easyprof.conf']
         self.mkpath(prefix + "/etc/apparmor")

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
AppArmor mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor

Reply via email to