Skip to content

Commit

Permalink
static binary creation supported in Makefile
Browse files Browse the repository at this point in the history
git-svn-id: https://showcase.fhstp.ac.at/republic/mmc/trunk@906 76e0c08c-8e14-4548-9514-92ecd803f47c
  • Loading branch information
rpoisel committed May 9, 2012
1 parent 4e0aec1 commit 6686e43
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 32 deletions.
39 changes: 27 additions & 12 deletions Makefile
Expand Up @@ -2,34 +2,49 @@ WORK_DIR=/tmp
PROG_NAME=mmc
VERSION=0.9
SUB_VER=-3
LD_LIBRARY_PATH := collating/fragment

all: fragment_context
#all: frag_mm_meta fragment_context
SVN=/usr/bin/svn
SVN_FLAGS=--force
TAR=/bin/tar
RM=/bin/rm
MV=/bin/mv
RM_FLAGS=-rf
PYTHON=/usr/bin/python
PYINSTALLER=/usr/local/pyinstaller/pyinstaller.py
PYINSTALLER_FLAGS=--onefile -o

DIR_FRAG_MM_META=collating/media
DIR_FRAGMENT_CONTEXT=collating/fragment
DIR_BUILD=build
DIR_DIST=dist

frag_mm_meta:
$(MAKE) -C $(DIR_FRAG_MM_META)
DIR_DIST_STATIC=/tmp/mmc

all: fragment_context

fragment_context:
$(MAKE) -C $(DIR_FRAGMENT_CONTEXT) -f Makefile_lnx.mk

.PHONY: clean fragment_context
#.PHONY: clean fragment_context frag_mm_meta

deb:
svn export --force ../trunk $(WORK_DIR)/$(PROG_NAME)-$(VERSION)$(SUB_VER)
(cd $(WORK_DIR) && tar -czvf $(PROG_NAME)-$(VERSION)$(SUB_VER).tar.gz $(PROG_NAME)-$(VERSION)$(SUB_VER))
(cd $(WORK_DIR) && tar -czvf $(PROG_NAME)_$(VERSION).orig.tar.gz $(PROG_NAME)-$(VERSION)$(SUB_VER))
$(SVN) export $(SVN_FLAGS) ../trunk $(WORK_DIR)/$(PROG_NAME)-$(VERSION)$(SUB_VER)
(cd $(WORK_DIR) && $(TAR) -czvf $(PROG_NAME)-$(VERSION)$(SUB_VER).tar.gz $(PROG_NAME)-$(VERSION)$(SUB_VER))
(cd $(WORK_DIR) && $(TAR) -czvf $(PROG_NAME)_$(VERSION).orig.tar.gz $(PROG_NAME)-$(VERSION)$(SUB_VER))
(cd $(WORK_DIR)/$(PROG_NAME)-$(VERSION)$(SUB_VER) && debuild -uc -us)

static: fragment_context
export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)
$(PYTHON) $(PYINSTALLER) $(PYINSTALLER_FLAGS) $(DIR_DIST_STATIC) mmc.py
$(SVN) export $(SVN_FLAGS) data $(DIR_DIST_STATIC)/dist/data
-$(RM) $(RM_FLAGS) $(DIR_DIST_STATIC)/dist/data/frags_ref
-(for i in animation jpeg png; do $(RM) $(RM_FLAGS) $(DIR_DIST_STATIC)/dist/data/magic/$$i ; done)
$(MV) $(DIR_DIST_STATIC)/dist $(DIR_DIST_STATIC)/$(PROG_NAME)-$(VERSION)$(SUB_VER)
$(TAR) -cjpf /tmp/$(PROG_NAME)-$(VERSION)$(SUB_VER).tar.bz2 -C $(DIR_DIST_STATIC) $(PROG_NAME)-$(VERSION)$(SUB_VER)

debclean:
-rm -rf $(WORK_DIR)/$(PROG_NAME)*

clean:
$(MAKE) -C $(DIR_FRAG_MM_META) clean
$(MAKE) -C $(DIR_FRAGMENT_CONTEXT) -f Makefile_lnx.mk clean
-rm -rf $(DIR_BUILD) $(DIR_DIST)
-$(RM) $(RM_FLAGS) $(DIR_DIST_STATIC)
-$(RM) $(RM_FLAGS) $(DIR_BUILD) $(DIR_DIST)
32 changes: 23 additions & 9 deletions README
@@ -1,5 +1,5 @@
### MM Carver Framework Invocation ###
# Rainer Poisel (rainer.poisel@fhstp.ac.at), 03062011
# Rainer Poisel (rainer.poisel@fhstp.ac.at), 09052012

# Preamble

Expand All @@ -13,17 +13,31 @@ also available as shared objects) running the framework requires some
environmental variables to be set. The following line has to be executed in
order to start the framework:

$ ./mm_carver --help
$ ./mmc_gui.local

Here is a short execution example:
# Building static binaries from the source-code

$ ./mm_carver -f /tmp/practical.floppy.dd
Python scripts can be compiled into stand-alone executables. All dependencies
like dynamic link libraires (even ctype-ones) are also compiled in.

# Caveats
Use the provided Makefile as follows:
$ make -j static

Manually, the following procedure is necessary:
* Install PyInstaller: http://www.pyinstaller.org/
* Setup LD_LIBRARY_PATH to enable PyInstaller to find your libraries:
$ export LD_LIBRARY_PATH=/home/rpoisel/svn/mmc/trunk/collating/fragment
* Compile the binary:
$ python pyinstaller.py --onefile -o /tmp/mmc /home/rpoisel/svn/mmc/trunk/mmc.py
* Add data files:
$ svn export /home/rpoisel/svn/mmc/trunk/data /tmp/mmc/dist/data
* Delete unnecessary files and directories:
$ rm -rf /tmp/mmc/data/frags_ref
$ rm -rf /tmp/mmc/data/{animation,png,jpeg}
* Bundle the whole thing:
$ tar -cjpf /tmp/mmc/mmc.tar.bz2 -C /tmp/mmc/dist .

Starting the framework without compilation (see INSTALL) results in the
following error message:
# Caveats

$ ./mm_carver -f /tmp/practical.floppy.dd
Error: __init__() takes exactly 1 argument (2 given)
None at the moment. ;-)

17 changes: 6 additions & 11 deletions collating/fragment/fragment_context.py
Expand Up @@ -113,13 +113,11 @@ def __del__(self):
class CBlockClassifier:

def __init__(self):
# open library handle
lLibname = r"libfragment_classifier"
# open library handle (do not change)
if platform.system().lower() == "windows":
lLibname += ".dll"
self.__mLH = cdll.LoadLibrary("libfragment_classifier.dll")
elif platform.system().lower() == "linux":
lLibname += ".so"
self.__mLH = cdll.LoadLibrary(lLibname)
self.__mLH = cdll.LoadLibrary("libfragment_classifier.so")

self.__mOpen = self.__mLH.fragment_classifier_new_ct
self.__mOpen.restype = CClassifyHandlerPointer
Expand Down Expand Up @@ -157,14 +155,11 @@ class CFragmentClassifier(object):
def __init__(self):
super(CFragmentClassifier, self).__init__()

# load library
lLibname = r"libblock_reader"

# load library (do not change)
if platform.system().lower() == "windows":
lLibname += ".dll"
self._mLH = cdll.LoadLibrary("libblock_reader.dll")
elif platform.system().lower() == "linux":
lLibname += ".so"
self._mLH = cdll.LoadLibrary(lLibname)
self._mLH = cdll.LoadLibrary("libblock_reader.so")

self._mClassify = self._mLH.classify
self._mClassify.restype = CFragmentCollectionPointer
Expand Down

0 comments on commit 6686e43

Please sign in to comment.