Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use libnids as git submodule instead of static tarball #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
libnids-1.25
dist
MANIFEST
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "libnids"]
path = libnids
url = https://github.com/mitrecnd/libnids.git
branch = master
7 changes: 0 additions & 7 deletions MANIFEST

This file was deleted.

3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include CHANGES COPYING Example nidsmodule.c README setup.py
graft libnids
global-exclude .git
Binary file removed dist/pynids-0.6.2.tar.gz
Binary file not shown.
1 change: 1 addition & 0 deletions libnids
Submodule libnids added at d47c9d
Binary file removed libnids-1.25.tar.gz
Binary file not shown.
32 changes: 20 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,25 @@

pathjoin = os.path.join

PKGNAME = 'libnids-1.25'
PKGTAR = PKGNAME + '.tar.gz'
BUILDDIR = PKGNAME
BUILDDIR = 'libnids'

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)
for extra_obj in self.extra_objects:
if os.path.exists(extra_obj):
return None # assume already built

os.chdir(self.NIDSDIR)
spawn([pathjoin('.','configure'), 'CFLAGS=-fPIC', '--disable-libglib', '--disable-libnet'])
spawn(['make'], search_path = 1)
Expand All @@ -45,6 +40,19 @@ def run(self):
self.buildNids()
build.run(self)


class nidsClean(build):
NIDSDIR = BUILDDIR

def cleanNids(self):
os.chdir(self.NIDSDIR)
spawn(['make','distclean'], search_path=1)
os.chdir('..')

def run(self):
self.cleanNids()


INCLUDE_DIRS = nidsMaker.include_dirs + INCLUDE_DIRS
EXTRA_OBJECTS = nidsMaker.extra_objects + EXTRA_OBJECTS

Expand All @@ -61,7 +69,7 @@ def run(self):
port scan detection.
-------
''',
cmdclass = {'build': nidsMaker},
cmdclass = {'build': nidsMaker, 'distclean': nidsClean},
ext_modules = [ Extension(
"nidsmodule",
#define_macros = [ ("DEBUG", None), ],
Expand All @@ -72,5 +80,5 @@ def run(self):
extra_objects = EXTRA_OBJECTS
)
],
url = "http://jon.oberheide.org/pynids/",
url = "http://github.com/mitrecnd/pynids/",
)