[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Bulletproof make process; add generic CLI code



Update of /home/minion/cvsroot/src/minion
In directory moria.seul.org:/tmp/cvs-serv12164

Modified Files:
	HACKING Makefile TODO setup.py 
Log Message:
Bulletproof make process; add generic CLI code

HACKING:
	Improve accuracy of build instructions

Makefile:
	- Search for the right python command *very* carefully
	- Detect missing ./contrib/openssl/libcrypto.a
	- Add 'download-openssl', 'build-openssl', and 'install-openssl' 
          targets. (Can't test download-openssl yet, since it openssl.org 
          seems to be down at the moment.)

setup.py:
	- Remove old ssl related stuff
	
Modules.py:
	- Rename classes

Main.py:
	- New file for generic CLI code to set up PYTHONPATH and launch 
          other modules.

testSupport:
	- New file for shhared code between test.py and benchmark.py
	- Add beginnings of simplified 'testing' module
	- Move mix_mktemp into testSupport

benchmark.py, test.py:
	- Add new CLI logic
	- Remove straggling unlink/rmdir calls.
	
	



Index: HACKING
===================================================================
RCS file: /home/minion/cvsroot/src/minion/HACKING,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- HACKING	12 Aug 2002 18:12:24 -0000	1.7
+++ HACKING	25 Aug 2002 03:48:47 -0000	1.8
@@ -3,16 +3,17 @@
 Requirements:
 	Python 2.0-2.2  (see PORTING NOTES below)
 
-	OpenSSL 0.9.7 (You'll need to download a beta. As of 5 July 2002,
-           that's http//www.openssl.org/source/openssl-0.9.7-beta2.tar.gz)
+	OpenSSL 0.9.7 (You'll need to download a beta. As of 24 August 2002,
+           that's http//www.openssl.org/source/openssl-0.9.7-beta3.tar.gz)
 
 	A working /dev/urandom (see PORTING NOTES below)
 
 Setting up:
-	Get python 2.2.  There are RPMs around.
-	Get the source.
-	Unpack openssl 0.9.7 into minion/contrib/openssl.
-	cd minion/contrib/openssl; ./config; make
+	1) Get python 2.2.  You can download RPMS from www.python.org.
+	2) Get the mixminion source.
+	3) EITHER Unpack openssl 0.9.7 into minion/contrib/openssl
+	          cd minion/contrib/openssl; ./config; make
+           OR make download-openssl; make build-openssl
 
 Things to try:
 	make
@@ -80,7 +81,7 @@
 
 PORTING TO NON-LINUX PLATFORMS:
     - If you need to run on a system without an acceptable /dev/*random, 
-      you'll nee to write an acceptable fallback for mixminion.Crypto.trng() 
+      you'll need to write an acceptable fallback for mixminion.Crypto.trng() 
       to use.  
     - We assume the existence of a /usr/bin/shred to securely delete
       files.  This is now configurable, but I'd like to know a few other
@@ -88,6 +89,6 @@
 
 CAVEATS:
     - If I haven't got a test for it in tests.py, assume it doesn't work.
-    - The code isn't threadsafe.  It will become so only when it must.
+    - The code isn't threadsafe.  It will become so only if it must.
 
 --Nick

Index: Makefile
===================================================================
RCS file: /home/minion/cvsroot/src/minion/Makefile,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile	12 Aug 2002 18:12:24 -0000	1.4
+++ Makefile	25 Aug 2002 03:48:47 -0000	1.5
@@ -1,14 +1,57 @@
 # Copyright 2002 Nick Mathewson.  See LICENSE for licensing information.
 # $Id$
-PYTHON=python2.2
 
+# Okay, we'll start with a little make magic.   The goal is to define the
+# make variable '$(FINDPYTHON)' as a chunk of shell script that sets
+# the shell variable '$PYTHON' to a working python2 interpreter.  
+#
+# (This is nontrivial because not all python2 installers install a command
+# called 'python2'.)
+#
+# (If anybody can think of a better way to do this, please let me know.)
+
+ifdef PYTHON
+FINDPYTHON = PYTHON=$(PYTHON)
+else
+PYTHON_CANDIDATES = python2.2 python2.2x python2.1 python2.1x python2.0      \
+	python2.0x python2 python
+FINDPYTHON = \
+	for n in $(PYTHON_CANDIDATES) ; do                                   \
+	  if [ 'x' = "x$$PYTHON" -a -x `which $$n` ]; then                   \
+	    PYTHON=$$n;                                                      \
+          fi ;                                                               \
+	done ;                                                               \
+	if [ 'x' = "x$$PYTHON" ]; then                                       \
+	    echo 'ERROR: couldn't find any of $(PYTHON_CANDIDATES) in PATH"; \
+	    echo '   Please install python in your path, or set the PYTHON"; \
+            echo '   environment variable';                                  \
+	    exit;                                                            \
+        fi;                                                                  \
+	if [ 'x' = `$$PYTHON -V 2>&1 | grep 'Python [23456789]'`x ]; then    \
+	   echo "WARNING: $$PYTHON doesn't seem to be version 2 or later.";  \
+	   echo ' If this fails, please set the PYTHON environment variable.';\
+	fi
+endif
+
+#
+# Here are the real make targets.
+#
 all: do_build
 
 do_build:
-	$(PYTHON) setup.py build
+	@if [ ! -e ./contrib/openssl/libcrypto.a ]; then \
+	   echo "I didn't find a prebuilt openssl in ./contrib/openssl." ;\
+	   echo "If this build fails, try "\
+	        "'make download-openssl; make build-openssl'"; \
+	fi
+	@$(FINDPYTHON); \
+	echo $$PYTHON setup.py build; \
+	$$PYTHON setup.py build
 
 clean:
-	$(PYTHON) setup.py clean
+	@$(FINDPYTHON); \
+	echo $$PYTHON setup.py clean; \
+	$$PYTHON setup.py clean
 	rm -rf build
 	rm -f lib/mixminion/_unittest.py
 	rm -f lib/mixminion/*.pyc
@@ -16,10 +59,14 @@
 	find . -name '*~' -print0 |xargs -0 rm -f
 
 test: do_build
-	( export PYTHONPATH=.; cd build/lib*; $(PYTHON) ./mixminion/test.py )
+	@$(FINDPYTHON); \
+	echo $$PYTHON build/lib*/mixminion/Main.py unittests; \
+	($$PYTHON build/lib*/mixminion/Main.py unittests)
 
 time: do_build
-	( export PYTHONPATH=.; cd build/lib*; $(PYTHON) ./mixminion/benchmark.py)
+	@$(FINDPYTHON); \
+	echo $$PYTHON build/lib*/mixminion/Main.py benchmarks; \
+	($$PYTHON build/lib*/mixminion/Main.py benchmarks)
 
 # FFFF coding style target
 
@@ -32,3 +79,63 @@
 xxxx:
 	find lib src \( -name '*.py' -or -name '*.[ch]' \) -print0 \
 	   | xargs -0 grep 'XXXX\|FFFF|\?\?\?\?'
+
+#
+# Targets to make openssl get built properly.  
+#
+OPENSSL_URL = http://www.openssl.org/source/openssl/openssl-0.9.7-beta3.tar.gz
+
+download-openssl:
+	@if [ -x `which wget` ] ; then \
+	  cd contrib; wget $(OPENSSL_URL); \
+	else; \
+          echo "You don't seem to have wget.  I can't download openssl."; \
+	fi
+
+destroy-openssl:
+	cd ./contrib; \
+	rm -rf `ls -d openssl* | grep -v .tar.gz`
+
+build-openssl: ./contrib/openssl/libcrypto.a
+
+./contrib/openssl/libcrypto.a: ./contrib/openssl/config
+	cd ./contrib/openssl; \
+	./config; \
+	make libcrypto.a libssl.a
+
+./contrib/openssl/config:
+	$(MAKE) unpack-openssl
+
+# This target assumes you have openssl-foo.tar.gz in contrib, and you
+# want to unpack it into ./contrib/openssl-foo, and symlink ./openssl to
+# ./openssl-foo.
+#
+# It checks 1) whether there is a single, unique openssl-foo.tar.gz
+#           2) whether contrib/openssl is a real file or directory
+unpack-openssl:
+	@cd ./contrib;                                                      \
+	if [ -e ./openssl -a ! -L ./openssl ]; then                         \
+	    echo "Ouch. contrib/openssl seems not to be a symlink: "        \
+	         "I'm afraid to delete it." ;                               \
+	    exit;                                                           \
+	fi;                                                                 \
+	TGZ=openssl-*.tar.gz ;                                              \
+	if [ ! -e $$TGZ ]; then                                             \
+	    echo "I didn't find any openssl-*.tar.gz in ./contrib/";        \
+	    exit;                                                           \
+	fi;                                                                 \
+	for n in $$TGZ; do                                                  \
+	    if [ $$n != $$TGZ ]; then                                       \
+	        echo "Found more than one openssl-*.tar.gz in ./contrib/";  \
+	        echo "(Remove all but the most recent.)";                   \
+		exit;                                                       \
+	    fi;                                                             \
+	done;                                                               \
+	UNPACKED=`echo $$TGZ | sed -e s/.tar.gz$$//`;                       \
+	echo "Unpacking $$TGZ...";                                          \
+	gunzip -c $$TGZ | tar xf -;                                         \
+	if [ ! -e $$UNPACKED ]; then                                        \
+	    echo "Oops.  I unpacked $$TGZ, but didn't find $$UNPACKED.";    \
+	fi;                                                                 \
+	rm -f ./openssl;                                                    \
+	ln -sf $$UNPACKED openssl

Index: TODO
===================================================================
RCS file: /home/minion/cvsroot/src/minion/TODO,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- TODO	21 Aug 2002 20:49:16 -0000	1.19
+++ TODO	25 Aug 2002 03:48:47 -0000	1.20
@@ -28,6 +28,7 @@
                   try sending some messages through.
 	- Better log messages at all points throughout system.
 	*- CLI for server
+		o Common CLI code.
 		*. Run server
 		*- Generate future key/publish to dirserver
 	- CLI client
@@ -41,8 +42,9 @@
 		- Example config
 		- Warn about unimplemented allow/deny
 		- Warn about all unimplemented features
-	- Build
-		- Ability to pull and build ssl.
+	. Build
+		- Ability to pull ssl.
+		o Ability to build ssl.
 		- Marginal 'make install'
 	- Integration testing
 		*- Fake delivery module for MBOX-less testing of core

Index: setup.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/setup.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- setup.py	12 Aug 2002 18:12:24 -0000	1.6
+++ setup.py	25 Aug 2002 03:48:47 -0000	1.7
@@ -18,13 +18,13 @@
 if USE_OPENSSL:
     # For now, we assume that openssl-0.9.7 hasn't been released.  When this
     # changes, we can fix this rigamarole.
-    openssl_lib = os.environ.get("MM_OPENSSL_LIB", "./contrib/openssl")
     openssl_inc = os.environ.get("MM_OPENSSL_INCLUDE", 
-				 "./contrib/openssl/include")
-    LIB_DIRS=[openssl_lib]
+ 				 "./contrib/openssl/include")
     INCLUDE_DIRS=[openssl_inc]
-    LIBRARIES=['ssl','crypto']
     STATIC_LIBS=['./contrib/openssl/libssl.a', './contrib/openssl/libcrypto.a']
+##      openssl_lib = os.environ.get("MM_OPENSSL_LIB", "./contrib/openssl")
+##      LIB_DIRS=[openssl_lib]
+##      LIBRARIES=['ssl','crypto']
 
 MACROS=[]
 MODULES=[]