[or-cvs] r17042: {torvm} Add support for fully automated builds from sources out to c (in torvm/trunk: . build/win32 build/win32/files)

coderman at seul.org coderman at seul.org
Sun Oct 5 12:17:50 UTC 2008


Author: coderman
Date: 2008-10-05 08:17:49 -0400 (Sun, 05 Oct 2008)
New Revision: 17042

Modified:
   torvm/trunk/Makefile
   torvm/trunk/README
   torvm/trunk/build/win32/Makefile
   torvm/trunk/build/win32/files/buildall.sh
   torvm/trunk/build/win32/files/install.bat
Log:
Add support for fully automated builds from sources out to compiled win32 package.  Include setup requirements in README file.

Modified: torvm/trunk/Makefile
===================================================================
--- torvm/trunk/Makefile	2008-10-05 04:55:08 UTC (rev 17041)
+++ torvm/trunk/Makefile	2008-10-05 12:17:49 UTC (rev 17042)
@@ -133,17 +133,32 @@
 		exit 1; \
 	fi
 
-buildw32src: buildkern
+
+W32MK=WDLDIR=$(WDLDIR) all
+ifneq (,$(BUILD_SCP_USER))
+  W32MK:=BUILD_SCP_USER=$(BUILD_SCP_USER) BUILD_SCP_IDF=$(BUILD_SCP_IDF) BUILD_SCP_HOST=$(BUILD_SCP_HOST) BUILD_SCP_DIR=$(BUILD_SCP_DIR) $(W32MK)
+endif
+ifeq (TRUE,$(AUTO_SHUTDOWN))
+  W32MK:=AUTO_SHUTDOWN=TRUE $(W32MK)
+endif
+ifneq (TRUE,$(DEBUG_NO_STRIP))
+  W32MK:=DEBUG_NO_STRIP=TRUE $(W32MK)
+endif
+ifneq (,$(W32AUTO_BUILD_CMD))
+  W32MK:=W32AUTO_BUILD_CMD="$(W32AUTO_BUILD_CMD)" $(W32MK)
+endif
+
+buildw32src: 
 	@cd build/win32; \
 	chown -R $(BUSER):$(BGROUP) . ; \
-	time su $(BUSER) -c "( $(MAKE) WDLDIR=$(WDLDIR) )"; \
+	time su $(BUSER) -c "( $(MAKE) $(W32MK) )"; \
 	if (( $$? != 0 )); then \
 		echo "ERROR: Unable to create win32 build ISO image." >&2; \
 		exit 1; \
 	fi
 
 package: buildw32src buildvmiso
-	@echo "package build target does not do anything with build products yet. XXX"
+	@echo "Automated packaging of completed win32 build is not yet implemented."
 
 .PHONY: clean prereq import buildkern buildvmiso buildw32src package
 

Modified: torvm/trunk/README
===================================================================
--- torvm/trunk/README	2008-10-05 04:55:08 UTC (rev 17041)
+++ torvm/trunk/README	2008-10-05 12:17:49 UTC (rev 17042)
@@ -10,6 +10,7 @@
 basic features are not yet avilable; edit the Makefile to adjust manually.
 
 
+
 NOTE: Two subversion repositories are accessed via SSL with keys that may need
 to be accepted manually.  To confirm that you have authenticated the keys used
 issue the following commands and approve the keys if needed:
@@ -21,6 +22,7 @@
     # Fingerprint: a1:0a:d8:2d:af:4e:67:92:18:a0:27:b6:9f:2b:e1:12:08:28:a0:b1
 
 
+
 Run 'make' to build the VM kernel image and Windows build ISO image.  Once the
 Windows build is done a complete Tor virtual machine package should be zipped
 up ready for distribution in the C:\Tor_VM folder.  You will need to have the
@@ -30,6 +32,7 @@
     http://download.microsoft.com/download/9/0/f/90f019ac-8243-48d3-91cf-81fc4093ecfd/1830_usa_ddk.iso
 
 
+
 If you have trouble with the build process downloading the various sources
 from mirrors and upstream repositories a current copy of all the kamikaze and
 win32 archives is available as: http://peertech.org/files/torvmdlcache.tar
@@ -40,6 +43,7 @@
     make DLDIR=./dl WDLDIR=./wdl all
 
 
+
 Some files and paths of interest:
 
 ./build/kamikaze/x86-uclibc-vm/bin/openwrt-x86-vmlinuz
@@ -61,3 +65,36 @@
 > this directory contains the patches applied to Qemu for bridged ethernet
 > support via WinPcap and modifications for the WinPcap and TAP-Win32 drivers
 > to prevent collision with any existing installed packages.
+
+
+
+Fully automated builds are supported with some minor modifications to both the
+Linux build host and the win32 build VM.  There are three steps to this setup:
+
+First, create a restricted user where the build targets will be copied to from
+the win32 build VM OS.  You can use the /bin/rbash restricted shell or similar
+utility to ensure that scp privileges and not much else are provided.  Create an
+SSH identity key for this user and copy the private key where the build user can
+access it.
+
+Second, configure the win32 build VM OS with a Startup script that invokes the
+install.bat script on the win32 build ISO image.  This image is assumed to be
+mounted when the win32 build VM OS boots up.
+
+Last, pass the requisite information to the build script so that the necessary
+commands are invoked during build to launch the win32 build VM and have the
+completed build files copied back out to the host.  For example:
+
+    make DLDIR=/var/build/dl WDLDIR=/var/build/wdl  \
+         W32AUTO_BUILD_CMD=/var/build/runbldvm.sh   \
+         AUTO_SHUTDOWN=TRUE                         \
+         BUILD_SCP_IDF=/var/build/build_id_rsa      \
+         BUILD_SCP_USER=build                       \
+         BUILD_SCP_HOST=192.168.1.2                 \
+         BUILD_SCP_DIR=/home/build                  \
+         all
+
+When the build completes a Tor_VM_<timestamp> directory will be created in the
+requested location.  The timestamp is an integer value representing the UNIX
+epoch in seconds.
+

Modified: torvm/trunk/build/win32/Makefile
===================================================================
--- torvm/trunk/build/win32/Makefile	2008-10-05 04:55:08 UTC (rev 17041)
+++ torvm/trunk/build/win32/Makefile	2008-10-05 12:17:49 UTC (rev 17042)
@@ -191,13 +191,25 @@
 	if [ -e ../kamikaze/x86-uclibc-vm/bin/openwrt-x86-vmlinuz ]; then \
 		cp ../kamikaze/x86-uclibc-vm/bin/openwrt-x86-vmlinuz $(ISODIR)/add/vmlinuz; \
 	fi; \
+	if [ -e $(BUILD_SCP_IDF) ]; then \
+		mkdir $(ISODIR)/ssh; \
+		cp "$(BUILD_SCP_IDF)" $(ISODIR)/ssh/; \
+		echo "$(BUILD_SCP_USER)" > $(ISODIR)/ssh/user; \
+		echo "$(BUILD_SCP_HOST)" > $(ISODIR)/ssh/host; \
+		echo "$(BUILD_SCP_DIR)" > $(ISODIR)/ssh/dest; \
+	fi; \
+	if [[ "$(AUTO_SHUTDOWN)" != "" ]]; then \
+		echo "export AUTO_SHUTDOWN=$(AUTO_SHUTDOWN)" >> $(ISODIR)/bldopts; \
+	fi; \
+	if [[ "$(DEBUG_NO_STRIP)" != "" ]]; then \
+		echo "export DEBUG_NO_STRIP=$(DEBUG_NO_STRIP)" >> $(ISODIR)/bldopts; \
+	fi; \
 	cp files/autorun.inf files/install.bat $(ISODIR)/; \
 	cp files/hdd.img.gz $(ISODIR)/add/; \
 	gzip -d $(ISODIR)/add/hdd.img.gz; \
 	cp files/fstab $(ISODIR)/bin/; \
 	cp files/buildall.sh $(ISODIR)/dl/src; \
 	cp patches/* $(ISODIR)/dl/src; \
-	cp files/*.tgz $(ISODIR)/dl/src; \
 	unzip $(WDLDIR)/$(ZLIB_F) -d $(ISODIR)/ bin/zlib1.dll; \
 	unzip $(WDLDIR)/$(GZIP_F) -d $(ISODIR)/ bin/gzip.exe; \
 	unzip $(WDLDIR)/$(BZIP2_F) -d $(ISODIR)/ bin/bzip2.exe bin/bzip2.dll; \
@@ -223,7 +235,13 @@
 		mkisofs -hide-rr-moved -pad -l -o $$ODIR/w32build.iso -r -J .; \
 	); if (( $$? != 0 )); then exit 1; fi
 
+ifeq (,$(W32AUTO_BUILD_CMD))
+  W32BLD=echo "Win32 build ISO image ready.  Please load the ISO into a Windows systems to start the build."
+else
+  W32BLD=$(W32AUTO_BUILD_CMD);true
+endif
+
 runinstall: buildiso
-	@echo "NOTICE: This feature is not yet automated.  Please load the ISO into a Windows systems to start the build."
+	@$(W32BLD)
 
 .PHONY: downloads extract buildiso runinstall

Modified: torvm/trunk/build/win32/files/buildall.sh
===================================================================
--- torvm/trunk/build/win32/files/buildall.sh	2008-10-05 04:55:08 UTC (rev 17041)
+++ torvm/trunk/build/win32/files/buildall.sh	2008-10-05 12:17:49 UTC (rev 17042)
@@ -12,6 +12,14 @@
   /usr/src/buildall.sh dobuild 2>&1 | tee build.log
 else
 
+if [ -f ~/.ssh/user ]; then
+  export BUILD_SCP_USER=`cat ~/.ssh/user`
+  export BUILD_SCP_HOST=`cat ~/.ssh/host`
+  export BUILD_SCP_DIR=`cat ~/.ssh/dest`
+  chmod 700 ~/.ssh >/dev/null 2>&1
+  chmod 600 ~/.ssh/id* >/dev/null 2>&1
+fi
+
 export WPCAP_DIR=/usr/src/WpcapSrc_4_1_beta4
 export WPCAP_INCLUDE="-I${WPCAP_DIR}/wpcap/libpcap -I${WPCAP_DIR}/wpcap/libpcap/Win32/Include"
 export WPCAP_LDFLAGS="-L${WPCAP_DIR}/wpcap/PRJ -L${WPCAP_DIR}/packetNtx/Dll/Project"
@@ -266,10 +274,28 @@
 cp torvm.exe $ddir/
 
 
-# last but not least, include the virtual disk and other parts
-cp /usr/src/add/* $libdir/
-cp /usr/src/add/hdd.img $statedir/
+# don't forget the kernel and virtual disk
+cp /usr/src/add/vmlinuz $libdir/
+cp /usr/src/add/hdd.img $libdir/
 
+if [[ "$DEBUG_NO_STRIP" == "" ]]; then
+  strip $libdir/*.dll
+  strip $bindir/*.exe
+  strip $ddir/*.exe
+fi
+
+if [[ "$BUILD_SCP_USER" != "" ]]; then
+  echo "Transferring build to destination ${BUILD_SCP_HOST}:${BUILD_SCP_DIR} ..."
+  udate=`date +%s`
+  scp -o BatchMode=yes -o CheckHostIP=no -o StrictHostKeyChecking=no \
+      -r /c/Tor_VM "${BUILD_SCP_USER}@${BUILD_SCP_HOST}:${BUILD_SCP_DIR}/Tor_VM_${udate}"
+fi
+
+if [[ "$AUTO_SHUTDOWN" == "TRUE" ]]; then
+  echo "Invoking automated shutdown ..."
+  shutdown.exe -f -s -t 1
+fi
+
 echo "DONE."
 exit 0
 

Modified: torvm/trunk/build/win32/files/install.bat
===================================================================
--- torvm/trunk/build/win32/files/install.bat	2008-10-05 04:55:08 UTC (rev 17041)
+++ torvm/trunk/build/win32/files/install.bat	2008-10-05 12:17:49 UTC (rev 17042)
@@ -58,6 +58,16 @@
 set MSYSROOT=C:\\msys\\1.0
 md etc\profile.d
 ECHO export MSYSROOT="%MSYSROOT%" > etc\profile.d\defpaths.sh
+IF EXIST %ISODRV%\ssh (
+  md "home\%USERNAME%"
+  md "home\%USERNAME%\.ssh"
+  cd /d %ISODRV%
+  cd ssh
+  copy *.* %DDRV%%MDIR%\%MVER%\home\%USERNAME%\.ssh\
+)
+IF EXIST %ISODRV%\bldopts (
+  print %ISODRV%\bldopts >> etc\profile.d\bldopts.sh
+)
 set WD=C:\msys\1.0\bin\
 set PATH=%WD%;%PATH%
 



More information about the tor-commits mailing list