2
# ufw: front-end for Linux firewalling
4
# Copyright (C) 2008 Canonical Ltd.
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.
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.
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/>.
20
# python ./setup.py install --root="/tmp/ufw"
22
from distutils.command.install import install as _install
23
from distutils.core import setup
25
from popen2 import Popen3
30
class Install(_install, object):
31
'''Override distutils to install the files where we want them.'''
33
super(Install, self).run()
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')
40
for dir in [ script, manpage ]:
41
self.mkpath(os.path.dirname(dir))
43
self.copy_file('src/ufw', script)
44
self.copy_file('doc/ufw.8', manpage)
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')
53
for dir in [ defaults, ufwconf, initscript ]:
54
self.mkpath(os.path.dirname(dir))
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)
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)
68
a = Popen3("sed -i 's%#PREFIX#%" + prefix + "%' " + file)
72
a = Popen3("sed -i 's%#VERSION#%" + ufw_version + "%' " + file)
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',
85
cmdclass={'install': Install}