-
Notifications
You must be signed in to change notification settings - Fork 28
/
setup.py
76 lines (64 loc) · 2.44 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#! /usr/bin/env python
# setup.py - Distutils instructions for the pynids package
# This file is part of the pynids package, a python interface to libnids.
# See the file COPYING for license information.
from distutils.core import setup, Extension
from distutils.command.build import build # nidsMaker
from distutils.spawn import spawn # nidsMaker.run()
import os, os.path
pathjoin = os.path.join
PKGNAME = 'libnids-1.25'
PKGTAR = PKGNAME + '.tar.gz'
BUILDDIR = PKGNAME
INCLUDE_DIRS = ['/usr/local/include', '/opt/local/include']
LIBRARY_DIRS = ['/usr/local/lib', '/opt/local/lib']
EXTRA_OBJECTS = []
class nidsMaker(build):
NIDSTAR = PKGTAR
NIDSDIR = BUILDDIR
include_dirs = [ pathjoin(NIDSDIR, 'src') ]
library_dirs = []
extra_objects = [ pathjoin(NIDSDIR, 'src', 'libnids.a') ]
def buildNids(self):
# extremely crude package builder
try:
os.stat(self.NIDSDIR)
return None # assume already built
except OSError:
pass
spawn(['tar', '-zxf', self.NIDSTAR], search_path = 1)
os.chdir(self.NIDSDIR)
spawn([pathjoin('.','configure'), 'CFLAGS=-fPIC', '--disable-libglib', '--disable-libnet'])
spawn(['make'], search_path = 1)
os.chdir('..')
def run(self):
self.buildNids()
build.run(self)
INCLUDE_DIRS = nidsMaker.include_dirs + INCLUDE_DIRS
EXTRA_OBJECTS = nidsMaker.extra_objects + EXTRA_OBJECTS
setup (# Distribution meta-data
name = "pynids",
version = "0.6.2",
description = "libnids wrapper",
author = "Wesley Shields",
author_email = "wxs@atarininja.org",
license = "GPL",
long_description = \
'''pynids is a python wrapper for libnids, a Network Intrusion Detection System
library offering sniffing, IP defragmentation, TCP stream reassembly and TCP
port scan detection.
-------
''',
cmdclass = {'build': nidsMaker},
ext_modules = [ Extension(
"nidsmodule",
#define_macros = [ ("DEBUG", None), ],
sources=["nidsmodule.c"],
include_dirs = INCLUDE_DIRS,
libraries = ["pcap"],
library_dirs = LIBRARY_DIRS,
extra_objects = EXTRA_OBJECTS
)
],
url = "http://jon.oberheide.org/pynids/",
)