Repository: fail2ban/fail2ban

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



Discussion:
I doubt, that this would be a thing of fail2ban... may be `python setup install`, but I don't see it...
Can you somehow debug this? I mean a more info about the error self.

Theoretically it is the issue of the packaging helpers/infrastructure.  We just need to have /var/run/fail2ban, which is we initiate in our setup.py.  Since apparently arch tools then freak out (although again -- path /var/run/fail2ban is legit, just canonical would be /run/fail2ban) you can either patch setup.py or if your init script takes care about creating that directory -- just remove that creation completely.  But alternatively -- we could within setup.py resolve the path for /var/run and use what it resolves to as the target directory (so might end up in /run).  Let me cook up a PR quickly


Resolving patch:
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


Test patch: