We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Fail2ban git fails to install from PKGBUILD on Arch Linux /var/run/ exists
Hi there.

I wrote (re-wrote / modified / plagiarized...) PKGBUILD a while back:

http://pastebin.com/raw.php?i=5E4cpjNq

It used to work fine and sweet... but now:

[andrzejl@andrzejl fail2ban-git]$ makepkg -s -i ./
==> WARNING: Cannot find the sudo binary. Will use su to acquire root privileges.
==> Making package: fail2ban-git 0.9.2.r132.gc37009a-1 (Thu Jul 30 18:25:25 IST 2015)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Updating fail2ban-git git repo...
Fetching origin
==> Validating source files with sha512sums...
    fail2ban-git ... Skipped
==> Extracting sources...
  -> Creating working copy of fail2ban git repo...
Switched to a new branch 'makepkg'
==> Starting pkgver()...
==> WARNING: A package has already been built, installing existing package...
==> Installing package fail2ban-git with pacman -U...
Password:
loading packages...
resolving dependencies...
looking for conflicting packages...

Packages (1) fail2ban-git-0.9.2.r132.gc37009a-1

Total Installed Size:  1.87 MiB
Net Upgrade Size:      0.03 MiB

:: Proceed with installation? [Y/n](1/1) checking keys in keyring                                              [##########################################] 100%
(1/1) checking package integrity                                            [##########################################] 100%
(1/1) loading package files                                                 [##########################################] 100%
(1/1) checking for file conflicts                                           [##########################################] 100%
error: failed to commit transaction (conflicting files)
fail2ban-git: /var/run exists in filesystem
Errors occurred, no packages were upgraded.
==> WARNING: Failed to install built package(s).
[andrzejl@andrzejl fail2ban-git]$ 

The problem is that:

[root@andrzejl andrzejl]# ls --full /var/ | grep run
lrwxrwxrwx  1 root       root          11 2015-02-15 21:58:46.000000000 +0000 lock -> ../run/lock
lrwxrwxrwx  1 root       root           6 2015-02-15 21:58:46.000000000 +0000 run -> ../run
[root@andrzejl andrzejl]# 

/var/run is a symlink pointing to /run.

Anyone knows how to bite this thing?

Cheers.

Andrzej


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 #!/usr/bin/python
2 # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*-
3 # vi: set ft=python sts=4 ts=4 sw=4 noet :
4 
5 # This file is part of Fail2Ban.
6 #
7 # Fail2Ban is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # Fail2Ban is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Fail2Ban; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 
21 __author__ = "Cyril Jaquier, Steven Hiscocks, Yaroslav Halchenko"
22 __copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2008-2013 Fail2Ban Contributors"
23 __license__ = "GPL"
24 
25 try:
26 	import setuptools
27 	from setuptools import setup
28 except ImportError:
29 	setuptools = None
30 	from distutils.core import setup
31 
32 try:
33 	# python 3.x
34 	from distutils.command.build_py import build_py_2to3 as build_py
35 	from distutils.command.build_scripts \
36 		import build_scripts_2to3 as build_scripts
37 except ImportError:
38 	# python 2.x
39 	from distutils.command.build_py import build_py
40 	from distutils.command.build_scripts import build_scripts
41 import os
42 from os.path import isfile, join, isdir
43 import sys
44 import warnings
45 from glob import glob
46 
47 if setuptools and "test" in sys.argv:
48 	import logging
49 	logSys = logging.getLogger("fail2ban")
50 	hdlr = logging.StreamHandler(sys.stdout)
51 	fmt = logging.Formatter("%(asctime)-15s %(message)s")
52 	hdlr.setFormatter(fmt)
53 	logSys.addHandler(hdlr)
54 	if set(["-q", "--quiet"]) & set(sys.argv):
55 		logSys.setLevel(logging.CRITICAL)
56 		warnings.simplefilter("ignore")
57 		sys.warnoptions.append("ignore")
58 	elif set(["-v", "--verbose"]) & set(sys.argv):
59 		logSys.setLevel(logging.DEBUG)
60 	else:
61 		logSys.setLevel(logging.INFO)
62 elif "test" in sys.argv:
63 	print("python distribute required to execute fail2ban tests")
64 	print("")
65 
66 longdesc = '''
67 Fail2Ban scans log files like /var/log/pwdfail or
68 /var/log/apache/error_log and bans IP that makes
69 too many password failures. It updates firewall rules
70 to reject the IP address or executes user defined
71 commands.'''
72 
73 if setuptools:
74 	setup_extra = {
75 		'test_suite': "fail2ban.tests.utils.gatherTests",
76 		'use_2to3': True,
77 	}
78 else:
79 	setup_extra = {}
80 
81 data_files_extra = []
82 if os.path.exists('/var/run'):
83 	# if we are on the system with /var/run -- we are to use it for having fail2ban/
84 	# directory there for socket file etc
85 	data_files_extra += [('/var/run/fail2ban', '')]
86 
87 # Get version number, avoiding importing fail2ban.
88 # This is due to tests not functioning for python3 as 2to3 takes place later
89 exec(open(join("fail2ban", "version.py")).read())
90 
91 setup(
92 	name = "fail2ban",
93 	version = version,
94 	description = "Ban IPs that make too many password failures",
95 	long_description = longdesc,
96 	author = "Cyril Jaquier & Fail2Ban Contributors",
97 	author_email = "cyril.jaquier@fail2ban.org",
98 	url = "http://www.fail2ban.org",
99 	license = "GPL",
100 	platforms = "Posix",
101 	cmdclass = {'build_py': build_py, 'build_scripts': build_scripts},
102 	scripts = [
103 		'bin/fail2ban-client',
104 		'bin/fail2ban-server',
105 		'bin/fail2ban-regex',
106 		'bin/fail2ban-testcases',
107 	],
108 	packages = [
109 		'fail2ban',
110 		'fail2ban.client',
111 		'fail2ban.server',
112 		'fail2ban.tests',
113 		'fail2ban.tests.action_d',
114 	],
115 	package_data = {
116 		'fail2ban.tests':
117 			[ join(w[0], f).replace("fail2ban/tests/", "", 1)
118 				for w in os.walk('fail2ban/tests/files')
119 				for f in w[2]] +
120 			[ join(w[0], f).replace("fail2ban/tests/", "", 1)
121 				for w in os.walk('fail2ban/tests/config')
122 				for f in w[2]] +
123 			[ join(w[0], f).replace("fail2ban/tests/", "", 1)
124 				for w in os.walk('fail2ban/tests/action_d')
125 				for f in w[2]]
126 	},
127 	data_files = [
128 		('/etc/fail2ban',
129 			glob("config/*.conf")
130 		),
131 		('/etc/fail2ban/filter.d',
132 			glob("config/filter.d/*.conf")
133 		),
134 		('/etc/fail2ban/filter.d/ignorecommands',
135 			glob("config/filter.d/ignorecommands/*")
136 		),
137 		('/etc/fail2ban/action.d',
138 			glob("config/action.d/*.conf") +
139 			glob("config/action.d/*.py")
140 		),
141 		('/etc/fail2ban/fail2ban.d',
142 			''
143 		),
144 		('/etc/fail2ban/jail.d',
145 			''
146 		),
147 		('/var/lib/fail2ban',
148 			''
149 		),
150 		('/usr/share/doc/fail2ban',
151 			['README.md', 'README.Solaris', 'DEVELOP', 'FILTERS',
152 			 'doc/run-rootless.txt']
153 		)
154 	] + data_files_extra,
155 	**setup_extra
156 )
157 
158 # Do some checks after installation
159 # Search for obsolete files.
160 obsoleteFiles = []
161 elements = {
162 	"/etc/":
163 		[
164 			"fail2ban.conf"
165 		],
166 	"/usr/bin/":
167 		[
168 			"fail2ban.py"
169 		],
170 	"/usr/lib/fail2ban/":
171 		[
172 			"version.py",
173 			"protocol.py"
174 		]
175 }
176 
177 for directory in elements:
178 	for f in elements[directory]:
179 		path = join(directory, f)
180 		if isfile(path):
181 			obsoleteFiles.append(path)
182 
183 if obsoleteFiles:
184 	print("")
185 	print("Obsolete files from previous Fail2Ban versions were found on "
186 		  "your system.")
187 	print("Please delete them:")
188 	print("")
189 	for f in obsoleteFiles:
190 		print("\t" + f)
191 	print("")
192 
193 if isdir("/usr/lib/fail2ban"):
194 	print("")
195 	print("Fail2ban is not installed under /usr/lib anymore. The new "
196 		  "location is under /usr/share. Please remove the directory "
197 		  "/usr/lib/fail2ban and everything under this directory.")
198 	print("")
199 
200 # Update config file
201 if sys.argv[1] == "install":
202 	print("")
203 	print("Please do not forget to update your configuration files.")
204 	print("They are in /etc/fail2ban/.")
205 	print("")
206
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -39,7 +39,7 @@
 	from distutils.command.build_py import build_py
 	from distutils.command.build_scripts import build_scripts
 import os
-from os.path import isfile, join, isdir
+from os.path import isfile, join, isdir, realpath
 import sys
 import warnings
 from glob import glob
@@ -81,8 +81,9 @@
 data_files_extra = []
 if os.path.exists('/var/run'):
 	# if we are on the system with /var/run -- we are to use it for having fail2ban/
-	# directory there for socket file etc
-	data_files_extra += [('/var/run/fail2ban', '')]
+	# directory there for socket file etc.
+	# realpath is used to possibly resolve /var/run -> /run symlink
+	data_files_extra += [(realpath('/var/run/fail2ban'), '')]
 
 # Get version number, avoiding importing fail2ban.
 # This is due to tests not functioning for python3 as 2to3 takes place later

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -39,7 +39,7 @@\n \tfrom distutils.command.build_py import build_py\n \tfrom distutils.command.build_scripts import build_scripts\n import os\n-from os.path import isfile, join, isdir\n+from os.path import isfile, join, isdir, realpath\n import sys\n import warnings\n from glob import glob\n@@ -81,8 +81,9 @@\n data_files_extra = []\n if os.path.exists('/var/run'):\n \t# if we are on the system with /var/run -- we are to use it for having fail2ban/\n-\t# directory there for socket file etc\n-\tdata_files_extra += [('/var/run/fail2ban', '')]\n+\t# directory there for socket file etc.\n+\t# realpath is used to possibly resolve /var/run -> /run symlink\n+\tdata_files_extra += [(realpath('/var/run/fail2ban'), '')]\n \n # Get version number, avoiding importing fail2ban.\n # This is due to tests not functioning for python3 as 2to3 takes place later\n", "issue": "Fail2ban git fails to install from PKGBUILD on Arch Linux /var/run/ exists\nHi there.\n\nI wrote (re-wrote / modified / plagiarized...) PKGBUILD a while back:\n\nhttp://pastebin.com/raw.php?i=5E4cpjNq\n\nIt used to work fine and sweet... but now:\n\n[andrzejl@andrzejl fail2ban-git]$ makepkg -s -i ./\n==> WARNING: Cannot find the sudo binary. Will use su to acquire root privileges.\n==> Making package: fail2ban-git 0.9.2.r132.gc37009a-1 (Thu Jul 30 18:25:25 IST 2015)\n==> Checking runtime dependencies...\n==> Checking buildtime dependencies...\n==> Retrieving sources...\n  -> Updating fail2ban-git git repo...\nFetching origin\n==> Validating source files with sha512sums...\n    fail2ban-git ... Skipped\n==> Extracting sources...\n  -> Creating working copy of fail2ban git repo...\nSwitched to a new branch 'makepkg'\n==> Starting pkgver()...\n==> WARNING: A package has already been built, installing existing package...\n==> Installing package fail2ban-git with pacman -U...\nPassword:\nloading packages...\nresolving dependencies...\nlooking for conflicting packages...\n\nPackages (1) fail2ban-git-0.9.2.r132.gc37009a-1\n\nTotal Installed Size:  1.87 MiB\nNet Upgrade Size:      0.03 MiB\n\n:: Proceed with installation? [Y/n](1/1) checking keys in keyring                                              [##########################################] 100%\n(1/1) checking package integrity                                            [##########################################] 100%\n(1/1) loading package files                                                 [##########################################] 100%\n(1/1) checking for file conflicts                                           [##########################################] 100%\nerror: failed to commit transaction (conflicting files)\nfail2ban-git: /var/run exists in filesystem\nErrors occurred, no packages were upgraded.\n==> WARNING: Failed to install built package(s).\n[andrzejl@andrzejl fail2ban-git]$ \n\nThe problem is that:\n\n[root@andrzejl andrzejl]# ls --full /var/ | grep run\nlrwxrwxrwx  1 root       root          11 2015-02-15 21:58:46.000000000 +0000 lock -> ../run/lock\nlrwxrwxrwx  1 root       root           6 2015-02-15 21:58:46.000000000 +0000 run -> ../run\n[root@andrzejl andrzejl]# \n\n/var/run is a symlink pointing to /run.\n\nAnyone knows how to bite this thing?\n\nCheers.\n\nAndrzej\n\n", "before_files": [{"content": "#!/usr/bin/python\n# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*-\n# vi: set ft=python sts=4 ts=4 sw=4 noet :\n\n# This file is part of Fail2Ban.\n#\n# Fail2Ban is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2 of the License, or\n# (at your option) any later version.\n#\n# Fail2Ban is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Fail2Ban; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n\n__author__ = \"Cyril Jaquier, Steven Hiscocks, Yaroslav Halchenko\"\n__copyright__ = \"Copyright (c) 2004 Cyril Jaquier, 2008-2013 Fail2Ban Contributors\"\n__license__ = \"GPL\"\n\ntry:\n\timport setuptools\n\tfrom setuptools import setup\nexcept ImportError:\n\tsetuptools = None\n\tfrom distutils.core import setup\n\ntry:\n\t# python 3.x\n\tfrom distutils.command.build_py import build_py_2to3 as build_py\n\tfrom distutils.command.build_scripts \\\n\t\timport build_scripts_2to3 as build_scripts\nexcept ImportError:\n\t# python 2.x\n\tfrom distutils.command.build_py import build_py\n\tfrom distutils.command.build_scripts import build_scripts\nimport os\nfrom os.path import isfile, join, isdir\nimport sys\nimport warnings\nfrom glob import glob\n\nif setuptools and \"test\" in sys.argv:\n\timport logging\n\tlogSys = logging.getLogger(\"fail2ban\")\n\thdlr = logging.StreamHandler(sys.stdout)\n\tfmt = logging.Formatter(\"%(asctime)-15s %(message)s\")\n\thdlr.setFormatter(fmt)\n\tlogSys.addHandler(hdlr)\n\tif set([\"-q\", \"--quiet\"]) & set(sys.argv):\n\t\tlogSys.setLevel(logging.CRITICAL)\n\t\twarnings.simplefilter(\"ignore\")\n\t\tsys.warnoptions.append(\"ignore\")\n\telif set([\"-v\", \"--verbose\"]) & set(sys.argv):\n\t\tlogSys.setLevel(logging.DEBUG)\n\telse:\n\t\tlogSys.setLevel(logging.INFO)\nelif \"test\" in sys.argv:\n\tprint(\"python distribute required to execute fail2ban tests\")\n\tprint(\"\")\n\nlongdesc = '''\nFail2Ban scans log files like /var/log/pwdfail or\n/var/log/apache/error_log and bans IP that makes\ntoo many password failures. It updates firewall rules\nto reject the IP address or executes user defined\ncommands.'''\n\nif setuptools:\n\tsetup_extra = {\n\t\t'test_suite': \"fail2ban.tests.utils.gatherTests\",\n\t\t'use_2to3': True,\n\t}\nelse:\n\tsetup_extra = {}\n\ndata_files_extra = []\nif os.path.exists('/var/run'):\n\t# if we are on the system with /var/run -- we are to use it for having fail2ban/\n\t# directory there for socket file etc\n\tdata_files_extra += [('/var/run/fail2ban', '')]\n\n# Get version number, avoiding importing fail2ban.\n# This is due to tests not functioning for python3 as 2to3 takes place later\nexec(open(join(\"fail2ban\", \"version.py\")).read())\n\nsetup(\n\tname = \"fail2ban\",\n\tversion = version,\n\tdescription = \"Ban IPs that make too many password failures\",\n\tlong_description = longdesc,\n\tauthor = \"Cyril Jaquier & Fail2Ban Contributors\",\n\tauthor_email = \"cyril.jaquier@fail2ban.org\",\n\turl = \"http://www.fail2ban.org\",\n\tlicense = \"GPL\",\n\tplatforms = \"Posix\",\n\tcmdclass = {'build_py': build_py, 'build_scripts': build_scripts},\n\tscripts = [\n\t\t'bin/fail2ban-client',\n\t\t'bin/fail2ban-server',\n\t\t'bin/fail2ban-regex',\n\t\t'bin/fail2ban-testcases',\n\t],\n\tpackages = [\n\t\t'fail2ban',\n\t\t'fail2ban.client',\n\t\t'fail2ban.server',\n\t\t'fail2ban.tests',\n\t\t'fail2ban.tests.action_d',\n\t],\n\tpackage_data = {\n\t\t'fail2ban.tests':\n\t\t\t[ join(w[0], f).replace(\"fail2ban/tests/\", \"\", 1)\n\t\t\t\tfor w in os.walk('fail2ban/tests/files')\n\t\t\t\tfor f in w[2]] +\n\t\t\t[ join(w[0], f).replace(\"fail2ban/tests/\", \"\", 1)\n\t\t\t\tfor w in os.walk('fail2ban/tests/config')\n\t\t\t\tfor f in w[2]] +\n\t\t\t[ join(w[0], f).replace(\"fail2ban/tests/\", \"\", 1)\n\t\t\t\tfor w in os.walk('fail2ban/tests/action_d')\n\t\t\t\tfor f in w[2]]\n\t},\n\tdata_files = [\n\t\t('/etc/fail2ban',\n\t\t\tglob(\"config/*.conf\")\n\t\t),\n\t\t('/etc/fail2ban/filter.d',\n\t\t\tglob(\"config/filter.d/*.conf\")\n\t\t),\n\t\t('/etc/fail2ban/filter.d/ignorecommands',\n\t\t\tglob(\"config/filter.d/ignorecommands/*\")\n\t\t),\n\t\t('/etc/fail2ban/action.d',\n\t\t\tglob(\"config/action.d/*.conf\") +\n\t\t\tglob(\"config/action.d/*.py\")\n\t\t),\n\t\t('/etc/fail2ban/fail2ban.d',\n\t\t\t''\n\t\t),\n\t\t('/etc/fail2ban/jail.d',\n\t\t\t''\n\t\t),\n\t\t('/var/lib/fail2ban',\n\t\t\t''\n\t\t),\n\t\t('/usr/share/doc/fail2ban',\n\t\t\t['README.md', 'README.Solaris', 'DEVELOP', 'FILTERS',\n\t\t\t 'doc/run-rootless.txt']\n\t\t)\n\t] + data_files_extra,\n\t**setup_extra\n)\n\n# Do some checks after installation\n# Search for obsolete files.\nobsoleteFiles = []\nelements = {\n\t\"/etc/\":\n\t\t[\n\t\t\t\"fail2ban.conf\"\n\t\t],\n\t\"/usr/bin/\":\n\t\t[\n\t\t\t\"fail2ban.py\"\n\t\t],\n\t\"/usr/lib/fail2ban/\":\n\t\t[\n\t\t\t\"version.py\",\n\t\t\t\"protocol.py\"\n\t\t]\n}\n\nfor directory in elements:\n\tfor f in elements[directory]:\n\t\tpath = join(directory, f)\n\t\tif isfile(path):\n\t\t\tobsoleteFiles.append(path)\n\nif obsoleteFiles:\n\tprint(\"\")\n\tprint(\"Obsolete files from previous Fail2Ban versions were found on \"\n\t\t  \"your system.\")\n\tprint(\"Please delete them:\")\n\tprint(\"\")\n\tfor f in obsoleteFiles:\n\t\tprint(\"\\t\" + f)\n\tprint(\"\")\n\nif isdir(\"/usr/lib/fail2ban\"):\n\tprint(\"\")\n\tprint(\"Fail2ban is not installed under /usr/lib anymore. The new \"\n\t\t  \"location is under /usr/share. Please remove the directory \"\n\t\t  \"/usr/lib/fail2ban and everything under this directory.\")\n\tprint(\"\")\n\n# Update config file\nif sys.argv[1] == \"install\":\n\tprint(\"\")\n\tprint(\"Please do not forget to update your configuration files.\")\n\tprint(\"They are in /etc/fail2ban/.\")\n\tprint(\"\")\n", "path": "setup.py"}], "after_files": [{"content": "#!/usr/bin/python\n# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*-\n# vi: set ft=python sts=4 ts=4 sw=4 noet :\n\n# This file is part of Fail2Ban.\n#\n# Fail2Ban is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2 of the License, or\n# (at your option) any later version.\n#\n# Fail2Ban is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Fail2Ban; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n\n__author__ = \"Cyril Jaquier, Steven Hiscocks, Yaroslav Halchenko\"\n__copyright__ = \"Copyright (c) 2004 Cyril Jaquier, 2008-2013 Fail2Ban Contributors\"\n__license__ = \"GPL\"\n\ntry:\n\timport setuptools\n\tfrom setuptools import setup\nexcept ImportError:\n\tsetuptools = None\n\tfrom distutils.core import setup\n\ntry:\n\t# python 3.x\n\tfrom distutils.command.build_py import build_py_2to3 as build_py\n\tfrom distutils.command.build_scripts \\\n\t\timport build_scripts_2to3 as build_scripts\nexcept ImportError:\n\t# python 2.x\n\tfrom distutils.command.build_py import build_py\n\tfrom distutils.command.build_scripts import build_scripts\nimport os\nfrom os.path import isfile, join, isdir, realpath\nimport sys\nimport warnings\nfrom glob import glob\n\nif setuptools and \"test\" in sys.argv:\n\timport logging\n\tlogSys = logging.getLogger(\"fail2ban\")\n\thdlr = logging.StreamHandler(sys.stdout)\n\tfmt = logging.Formatter(\"%(asctime)-15s %(message)s\")\n\thdlr.setFormatter(fmt)\n\tlogSys.addHandler(hdlr)\n\tif set([\"-q\", \"--quiet\"]) & set(sys.argv):\n\t\tlogSys.setLevel(logging.CRITICAL)\n\t\twarnings.simplefilter(\"ignore\")\n\t\tsys.warnoptions.append(\"ignore\")\n\telif set([\"-v\", \"--verbose\"]) & set(sys.argv):\n\t\tlogSys.setLevel(logging.DEBUG)\n\telse:\n\t\tlogSys.setLevel(logging.INFO)\nelif \"test\" in sys.argv:\n\tprint(\"python distribute required to execute fail2ban tests\")\n\tprint(\"\")\n\nlongdesc = '''\nFail2Ban scans log files like /var/log/pwdfail or\n/var/log/apache/error_log and bans IP that makes\ntoo many password failures. It updates firewall rules\nto reject the IP address or executes user defined\ncommands.'''\n\nif setuptools:\n\tsetup_extra = {\n\t\t'test_suite': \"fail2ban.tests.utils.gatherTests\",\n\t\t'use_2to3': True,\n\t}\nelse:\n\tsetup_extra = {}\n\ndata_files_extra = []\nif os.path.exists('/var/run'):\n\t# if we are on the system with /var/run -- we are to use it for having fail2ban/\n\t# directory there for socket file etc.\n\t# realpath is used to possibly resolve /var/run -> /run symlink\n\tdata_files_extra += [(realpath('/var/run/fail2ban'), '')]\n\n# Get version number, avoiding importing fail2ban.\n# This is due to tests not functioning for python3 as 2to3 takes place later\nexec(open(join(\"fail2ban\", \"version.py\")).read())\n\nsetup(\n\tname = \"fail2ban\",\n\tversion = version,\n\tdescription = \"Ban IPs that make too many password failures\",\n\tlong_description = longdesc,\n\tauthor = \"Cyril Jaquier & Fail2Ban Contributors\",\n\tauthor_email = \"cyril.jaquier@fail2ban.org\",\n\turl = \"http://www.fail2ban.org\",\n\tlicense = \"GPL\",\n\tplatforms = \"Posix\",\n\tcmdclass = {'build_py': build_py, 'build_scripts': build_scripts},\n\tscripts = [\n\t\t'bin/fail2ban-client',\n\t\t'bin/fail2ban-server',\n\t\t'bin/fail2ban-regex',\n\t\t'bin/fail2ban-testcases',\n\t],\n\tpackages = [\n\t\t'fail2ban',\n\t\t'fail2ban.client',\n\t\t'fail2ban.server',\n\t\t'fail2ban.tests',\n\t\t'fail2ban.tests.action_d',\n\t],\n\tpackage_data = {\n\t\t'fail2ban.tests':\n\t\t\t[ join(w[0], f).replace(\"fail2ban/tests/\", \"\", 1)\n\t\t\t\tfor w in os.walk('fail2ban/tests/files')\n\t\t\t\tfor f in w[2]] +\n\t\t\t[ join(w[0], f).replace(\"fail2ban/tests/\", \"\", 1)\n\t\t\t\tfor w in os.walk('fail2ban/tests/config')\n\t\t\t\tfor f in w[2]] +\n\t\t\t[ join(w[0], f).replace(\"fail2ban/tests/\", \"\", 1)\n\t\t\t\tfor w in os.walk('fail2ban/tests/action_d')\n\t\t\t\tfor f in w[2]]\n\t},\n\tdata_files = [\n\t\t('/etc/fail2ban',\n\t\t\tglob(\"config/*.conf\")\n\t\t),\n\t\t('/etc/fail2ban/filter.d',\n\t\t\tglob(\"config/filter.d/*.conf\")\n\t\t),\n\t\t('/etc/fail2ban/filter.d/ignorecommands',\n\t\t\tglob(\"config/filter.d/ignorecommands/*\")\n\t\t),\n\t\t('/etc/fail2ban/action.d',\n\t\t\tglob(\"config/action.d/*.conf\") +\n\t\t\tglob(\"config/action.d/*.py\")\n\t\t),\n\t\t('/etc/fail2ban/fail2ban.d',\n\t\t\t''\n\t\t),\n\t\t('/etc/fail2ban/jail.d',\n\t\t\t''\n\t\t),\n\t\t('/var/lib/fail2ban',\n\t\t\t''\n\t\t),\n\t\t('/usr/share/doc/fail2ban',\n\t\t\t['README.md', 'README.Solaris', 'DEVELOP', 'FILTERS',\n\t\t\t 'doc/run-rootless.txt']\n\t\t)\n\t] + data_files_extra,\n\t**setup_extra\n)\n\n# Do some checks after installation\n# Search for obsolete files.\nobsoleteFiles = []\nelements = {\n\t\"/etc/\":\n\t\t[\n\t\t\t\"fail2ban.conf\"\n\t\t],\n\t\"/usr/bin/\":\n\t\t[\n\t\t\t\"fail2ban.py\"\n\t\t],\n\t\"/usr/lib/fail2ban/\":\n\t\t[\n\t\t\t\"version.py\",\n\t\t\t\"protocol.py\"\n\t\t]\n}\n\nfor directory in elements:\n\tfor f in elements[directory]:\n\t\tpath = join(directory, f)\n\t\tif isfile(path):\n\t\t\tobsoleteFiles.append(path)\n\nif obsoleteFiles:\n\tprint(\"\")\n\tprint(\"Obsolete files from previous Fail2Ban versions were found on \"\n\t\t  \"your system.\")\n\tprint(\"Please delete them:\")\n\tprint(\"\")\n\tfor f in obsoleteFiles:\n\t\tprint(\"\\t\" + f)\n\tprint(\"\")\n\nif isdir(\"/usr/lib/fail2ban\"):\n\tprint(\"\")\n\tprint(\"Fail2ban is not installed under /usr/lib anymore. The new \"\n\t\t  \"location is under /usr/share. Please remove the directory \"\n\t\t  \"/usr/lib/fail2ban and everything under this directory.\")\n\tprint(\"\")\n\n# Update config file\nif sys.argv[1] == \"install\":\n\tprint(\"\")\n\tprint(\"Please do not forget to update your configuration files.\")\n\tprint(\"They are in /etc/fail2ban/.\")\n\tprint(\"\")\n", "path": "setup.py"}]}