~jdstrand/ufw/trunk

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Jamie Strandboge
  • Date: 2008-01-20 23:02:35 UTC
  • Revision ID: jamie@ubuntu.com-20080120230235-8g7x8q3c0cikprf2
use distutils instead of install.py
 - created setup.py
 - removed install.py
 - updated run_tests.sh
 - updates README and TODO
 - updated debian/rules
bump version
moved stuff around
require python 2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# ufw: front-end for Linux firewalling
 
3
#
 
4
# Copyright (C) 2008 Canonical Ltd.
 
5
#
 
6
#    This program is free software: you can redistribute it and/or modify
 
7
#    it under the terms of the GNU General Public License version 3,
 
8
#    as published by the Free Software Foundation.
 
9
#
 
10
#    This program is distributed in the hope that it will be useful,
 
11
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
#    GNU General Public License for more details.
 
14
#
 
15
#    You should have received a copy of the GNU General Public License
 
16
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
#
 
18
 
 
19
# Install with:
 
20
# python ./setup.py install --root="/tmp/ufw"
 
21
 
 
22
from distutils.command.install import install as _install
 
23
from distutils.core import setup
 
24
import os
 
25
from popen2 import Popen3
 
26
import sys
 
27
 
 
28
ufw_version = "0.3"
 
29
 
 
30
class Install(_install, object):
 
31
    '''Override distutils to install the files where we want them.'''
 
32
    def run(self):
 
33
        super(Install, self).run()
 
34
 
 
35
        # Install script and data files
 
36
        prefix = os.path.join(self.root, 'usr')
 
37
        script = os.path.join(prefix, 'sbin', 'ufw')
 
38
        manpage = os.path.join(prefix, 'share', 'man', 'man8', 'ufw.8')
 
39
 
 
40
        for dir in [ script, manpage ]:
 
41
            self.mkpath(os.path.dirname(dir))
 
42
        
 
43
        self.copy_file('src/ufw', script)
 
44
        self.copy_file('doc/ufw.8', manpage)
 
45
 
 
46
        # Install configuration files
 
47
        confdir = os.path.join(self.root, 'etc')
 
48
        defaults = os.path.join(confdir, 'default', 'ufw')
 
49
        ufwconf = os.path.join(confdir, 'ufw', 'sysctl.conf')
 
50
        rules = os.path.join(confdir, 'ufw', 'ufw.rules')
 
51
        initscript = os.path.join(confdir, 'init.d', 'ufw')
 
52
 
 
53
        for dir in [ defaults, ufwconf, initscript ]:
 
54
            self.mkpath(os.path.dirname(dir))
 
55
        
 
56
        self.copy_file('conf/ufw.defaults', defaults)
 
57
        self.copy_file('conf/sysctl.conf', ufwconf)
 
58
        self.copy_file('conf/ufw.rules', rules)
 
59
        self.copy_file('conf/initscript', initscript)
 
60
 
 
61
        # Update the installed files' paths
 
62
        for file in [ defaults, ufwconf, rules, initscript, script, manpage ]:
 
63
            print "Updating " + file
 
64
            a = Popen3("sed -i 's%#CONFIG_PREFIX#%" + confdir + "%' " + file)
 
65
            while a.poll() == -1:
 
66
                pass
 
67
 
 
68
            a = Popen3("sed -i 's%#PREFIX#%" + prefix + "%' " + file)
 
69
            while a.poll() == -1:
 
70
                pass
 
71
        
 
72
            a = Popen3("sed -i 's%#VERSION#%" + ufw_version + "%' " + file)
 
73
            while a.poll() == -1:
 
74
                pass
 
75
        
 
76
 
 
77
setup (name='ufw',
 
78
      version=ufw_version,
 
79
      description='front-end for Linux firewalling',
 
80
      long_description='front-end for Linux firewalling',
 
81
      author='Jamie Strandboge',
 
82
      author_email='jamie@ubuntu.com',
 
83
      url='https://launchpad.net/ufw',
 
84
      license='GPL-3',
 
85
      cmdclass={'install': Install}
 
86
)
 
87