~apparmor-dev/apparmor/master

« back to all changes in this revision

Viewing changes to utils/python-tools-setup.py

  • Committer: Steve Beattie
  • Date: 2019-02-19 09:38:13 UTC
  • Revision ID: sbeattie@ubuntu.com-20190219093813-ud526ee6hwn8nljz
The AppArmor project has been converted to git and is now hosted on
gitlab.

To get the converted repository, please do
  git clone https://gitlab.com/apparmor/apparmor

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# ----------------------------------------------------------------------
2
 
#    Copyright (c) 2012 Canonical Ltd.
3
 
#
4
 
#    This program is free software; you can redistribute it and/or
5
 
#    modify it under the terms of version 2 of the GNU General Public
6
 
#    License published by the Free Software Foundation.
7
 
#
8
 
#    This program is distributed in the hope that it will be useful,
9
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
#    GNU General Public License for more details.
12
 
#
13
 
#    You should have received a copy of the GNU General Public License
14
 
#    along with this program; if not, contact Canonical, Ltd.
15
 
# ----------------------------------------------------------------------
16
 
#
17
 
# Usage:
18
 
# $ python ./python-tools-setup.py install --root=... --version=...
19
 
#
20
 
# Note: --version=... must be the last argument to this script
21
 
#
22
 
 
23
 
from distutils.command.install import install as _install
24
 
from distutils.core import setup
25
 
import os
26
 
import shutil
27
 
import sys
28
 
 
29
 
class Install(_install, object):
30
 
    '''Override distutils to install the files where we want them.'''
31
 
    def run(self):
32
 
        # Now byte-compile everything
33
 
        super(Install, self).run()
34
 
 
35
 
        prefix = self.prefix
36
 
        if self.root != None:
37
 
            prefix = self.root
38
 
 
39
 
        # Install scripts, configuration files and data
40
 
        scripts = ['/usr/bin/aa-easyprof']
41
 
        self.mkpath(prefix + os.path.dirname(scripts[0]))
42
 
        for s in scripts:
43
 
            f = prefix + s
44
 
            self.copy_file(os.path.basename(s), f)
45
 
 
46
 
        configs = ['easyprof/easyprof.conf']
47
 
        self.mkpath(prefix + "/etc/apparmor")
48
 
        for c in configs:
49
 
            self.copy_file(c, os.path.join(prefix + "/etc/apparmor", os.path.basename(c)))
50
 
 
51
 
        data = ['easyprof/templates', 'easyprof/policygroups']
52
 
        self.mkpath(prefix + "/usr/share/apparmor/easyprof")
53
 
        for d in data:
54
 
            self.copy_tree(d, os.path.join(prefix + "/usr/share/apparmor/easyprof", os.path.basename(d)))
55
 
 
56
 
 
57
 
if os.path.exists('staging'):
58
 
    shutil.rmtree('staging')
59
 
shutil.copytree('apparmor', 'staging')
60
 
 
61
 
# Support the --version=... since this will be part of a Makefile
62
 
version = "unknown-version"
63
 
if "--version=" in sys.argv[-1]:
64
 
    version=sys.argv[-1].split('=')[1]
65
 
    sys.argv = sys.argv[0:-1]
66
 
 
67
 
setup (name='apparmor',
68
 
       version=version,
69
 
       description='Python libraries for AppArmor utilities',
70
 
       long_description='Python libraries for AppArmor utilities',
71
 
       author='AppArmor Developers',
72
 
       author_email='apparmor@lists.ubuntu.com',
73
 
       url='https://launchpad.net/apparmor',
74
 
       license='GPL-2',
75
 
       cmdclass={'install': Install},
76
 
       package_dir={'apparmor': 'staging'},
77
 
       packages=['apparmor', 'apparmor.rule'],
78
 
       py_modules=['apparmor.easyprof']
79
 
)
80
 
 
81
 
shutil.rmtree('staging')