Merged changes from trunk@4:8.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README Thu Dec 25 07:33:20 2008 +0000
@@ -0,0 +1,19 @@
+= jparallel
+
+jparallel is a "parallel jail shell" written in Ruby.
+
+This is shell that can be used to interact with multiple FreeBSD jail instances
+simultaneously. It includes a Ruby binding to the FreeBSD jail(2) functions.
+
+It's still under development, but in the meantime, you can check out the
+current development source with Subversion from the following URL:
+
+ svn://deveiate.org/jparallel/trunk
+
+The project page is also likely to have more details:
+
+ http://deveiate.org/projects/Jparallel/
+
+== License
+
+See the LICENSE file in the same directory for licensing details.
--- a/Rakefile Tue Oct 14 16:11:19 2008 +0000
+++ b/Rakefile Thu Dec 25 07:33:20 2008 +0000
@@ -21,9 +21,10 @@
$LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
}
+require 'rubygems'
+gem 'rake', '>= 0.8.3'
require 'rbconfig'
-require 'rubygems'
require 'rake'
require 'rake/rdoctask'
require 'rake/testtask'
@@ -34,26 +35,43 @@
### Config constants
BASEDIR = Pathname.new( __FILE__ ).dirname.relative_path_from( Pathname.getwd )
+BINDIR = BASEDIR + 'bin'
LIBDIR = BASEDIR + 'lib'
EXTDIR = BASEDIR + 'ext'
DOCSDIR = BASEDIR + 'docs'
PKGDIR = BASEDIR + 'pkg'
+DATADIR = BASEDIR + 'data'
-PKG_NAME = 'jparallel'
+PROJECT_NAME = 'jparallel'
+PKG_NAME = PROJECT_NAME.downcase
PKG_SUMMARY = 'A "parallel jail shell" written in Ruby'
+
VERSION_FILE = LIBDIR + 'jparallel.rb'
-PKG_VERSION = VERSION_FILE.read[ /VERSION = '(\d+\.\d+\.\d+)'/, 1 ]
+if VERSION_FILE.exist? && buildrev = ENV['CC_BUILD_LABEL']
+ PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ] + '.' + buildrev
+elsif VERSION_FILE.exist?
+ PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ]
+else
+ PKG_VERSION = '0.0.0'
+end
+
PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}"
GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem"
+EXTCONF = EXTDIR + 'extconf.rb'
+
ARTIFACTS_DIR = Pathname.new( ENV['CC_BUILD_ARTIFACTS'] || 'artifacts' )
TEXT_FILES = %w( Rakefile ChangeLog README LICENSE ).collect {|filename| BASEDIR + filename }
+BIN_FILES = Pathname.glob( BINDIR + '*' ).delete_if {|item| item =~ /\.svn/ }
LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ }
EXT_FILES = Pathname.glob( EXTDIR + '**/*.{c,h,rb}' ).delete_if {|item| item =~ /\.svn/ }
+DATA_FILES = Pathname.glob( DATADIR + '**/*' ).delete_if {|item| item =~ /\.svn/ }
SPECDIR = BASEDIR + 'spec'
-SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' ).delete_if {|item| item =~ /\.svn/ }
+SPECLIBDIR = SPECDIR + 'lib'
+SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' ).delete_if {|item| item =~ /\.svn/ } +
+ Pathname.glob( SPECLIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ }
TESTDIR = BASEDIR + 'tests'
TEST_FILES = Pathname.glob( TESTDIR + '**/*.tests.rb' ).delete_if {|item| item =~ /\.svn/ }
@@ -64,14 +82,16 @@
LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local'
EXTRA_PKGFILES = []
-EXTRA_PKGFILES += Pathname.glob( BASEDIR + 'examples/*.{c,rb}' ).delete_if {|item| item =~ /\.svn/ }
+EXTRA_PKGFILES.concat Pathname.glob( BASEDIR + 'examples/*.{c,rb}' ).delete_if {|item| item =~ /\.svn/ }
EXTRA_PKGFILES.concat Pathname.glob( BASEDIR + 'misc/monkeypatches.rb' ).delete_if {|item| item =~ /\.svn/ }
RELEASE_FILES = TEXT_FILES +
SPEC_FILES +
TEST_FILES +
+ BIN_FILES +
LIB_FILES +
EXT_FILES +
+ DATA_FILES +
RAKE_TASKLIBS +
EXTRA_PKGFILES
@@ -109,12 +129,13 @@
SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem"
# Documentation constants
+RDOCDIR = DOCSDIR + 'api'
RDOC_OPTIONS = [
'-w', '4',
'-SHN',
'-i', '.',
'-m', 'README',
- '-W', 'http://deveiate.org/projects/Jparallel//browser/trunk/'
+ '-W', 'http://deveiate.org/projects/jParallel//browser/trunk/'
]
# Release constants
@@ -125,7 +146,8 @@
PROJECT_HOST = 'deveiate.org'
PROJECT_PUBDIR = "/usr/local/www/public/code"
PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}"
-PROJECT_SCPURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
+PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}"
+PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
# Rubyforge stuff
RUBYFORGE_GROUP = 'deveiate'
@@ -135,9 +157,25 @@
DEPENDENCIES = {
}
+# Developer Gem dependencies: gemname => version
+DEVELOPMENT_DEPENDENCIES = {
+ 'amatch' => '>= 0.2.3',
+ 'rake' => '>= 0.8.1',
+ 'rcodetools' => '>= 0.7.0.0',
+ 'rcov' => '>= 0',
+ 'RedCloth' => '>= 4.0.3',
+ 'rspec' => '>= 0',
+ 'rubyforge' => '>= 0',
+ 'termios' => '>= 0',
+ 'text-format' => '>= 1.0.0',
+ 'tmail' => '>= 1.2.3.1',
+ 'ultraviolet' => '>= 0.10.2',
+ 'libxml-ruby' => '>= 0.8.3',
+}
+
# Non-gem requirements: packagename => version
REQUIREMENTS = {
- 'FreeBSD' => '>= 7.0',
+ 'FreeBSD' => '>= 5.0',
}
# RubyGem specification
@@ -148,18 +186,23 @@
gem.summary = PKG_SUMMARY
gem.description = <<-EOD
This is shell that can be used to interact with multiple FreeBSD jail instances
-
simultaneously. It includes a Ruby binding to the FreeBSD jail(2) functions.
EOD
gem.authors = 'Michael Granger and Mahlon Smith'
gem.email = 'ged@FaerieMUD.org, mahlon@martini.nu'
- gem.homepage = 'http://deveiate.org/projects/Jparallel/'
+ gem.homepage = 'http://deveiate.org/projects/jParallel/'
gem.rubyforge_project = RUBYFORGE_PROJECT
gem.has_rdoc = true
gem.rdoc_options = RDOC_OPTIONS
+ gem.bindir = BINDIR.relative_path_from(BASEDIR).to_s
+
+ if EXTCONF.exist?
+ gem.extensions << EXTCONF.relative_path_from( BASEDIR ).to_s
+ end
+
gem.files = RELEASE_FILES.
collect {|f| f.relative_path_from(BASEDIR).to_s }
gem.test_files = SPEC_FILES.
@@ -167,7 +210,15 @@
DEPENDENCIES.each do |name, version|
version = '>= 0' if version.length.zero?
- gem.add_dependency( name, version )
+ gem.add_runtime_dependency( name, version )
+ end
+
+ # Developmental dependencies don't work as of RubyGems 1.2.0
+ unless Gem::Version.new( Gem::RubyGemsVersion ) <= Gem::Version.new( "1.2.0" )
+ DEVELOPMENT_DEPENDENCIES.each do |name, version|
+ version = '>= 0' if version.length.zero?
+ gem.add_development_dependency( name, version )
+ end
end
REQUIREMENTS.each do |name, version|
@@ -175,6 +226,9 @@
end
end
+# Manual-generation config
+MANUALDIR = DOCSDIR + 'manual'
+
$trace = Rake.application.options.trace ? true : false
$dryrun = Rake.application.options.dryrun ? true : false
@@ -204,7 +258,10 @@
#####################################################################
### Default task
-task :default => [:clean, :spec, :rdoc, :package]
+task :default => [:clean, :local, :spec, :rdoc, :package]
+
+### Task the local Rakefile can append to -- no-op by default
+task :local
### Task: clean
@@ -227,13 +284,16 @@
### Task: cruise (Cruisecontrol task)
desc "Cruisecontrol build"
-task :cruise => [:clean, :spec, :package] do |task|
+task :cruise => [:clean, 'spec:quiet', :package] do |task|
raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
- artifact_dir = ARTIFACTS_DIR.cleanpath
+ artifact_dir = ARTIFACTS_DIR.cleanpath + ENV['CC_BUILD_LABEL']
artifact_dir.mkpath
- $stderr.puts "Copying coverage stats..."
- FileUtils.cp_r( 'coverage', artifact_dir )
+ coverage = BASEDIR + 'coverage'
+ if coverage.exist? && coverage.directory?
+ $stderr.puts "Copying coverage stats..."
+ FileUtils.cp_r( 'coverage', artifact_dir )
+ end
$stderr.puts "Copying packages..."
FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir )
--- a/Rakefile.local Tue Oct 14 16:11:19 2008 +0000
+++ b/Rakefile.local Thu Dec 25 07:33:20 2008 +0000
@@ -1,89 +1,62 @@
+#!rake
+
#!rake
-begin
- require 'mkrf'
-rescue LoadError => err
- unless Object.const_defined?( :Gem )
- require 'rubygems'
- retry
- end
-
- fail "You need to have the mkrf library installed to build this."
-end
-
-
# C extension constants
-EXT_RAKEFILE = EXTDIR + 'Rakefile'
-EXT_SO = EXTDIR + "redleaf_ext.#{CONFIG['DLEXT']}"
-
-ADDITIONAL_INCLUDE_DIRS = %w[
- /usr/local/include
- /opt/include
- /opt/local/include
-]
-
-# Additional (auto-generated) spec constants
-SPEC_RAKEFILE = SPECDIR + 'Rakefile'
+EXT_MAKEFILE = EXTDIR + 'Makefile'
+EXT_SOURCES = FileList[ EXTDIR + '*.c' ]
+EXT_SO = EXTDIR + "bsdjail.#{CONFIG['DLEXT']}"
#####################################################################
### T A S K S
#####################################################################
-# task :local => [ :build, :build_specs ]
-task :local => [ :build ]
-task :spec => [ :build ]
+# Make both the default task and the spec task depend on building the extension
+task :local => :build
+task :spec => :build
+namespace :spec do
+ task :doc => [ :build ]
+ task :quiet => [ :build ]
+ task :html => [ :build ]
+ task :text => [ :build ]
+end
-desc "Make the Rakefile for the C extension"
-file EXT_RAKEFILE.to_s => FileList[ 'Rakefile', EXTDIR + '*.c' ] do
- require 'misc/monkeypatches' # Fix Mkrf's output
-
+desc "Make the Makefile for the C extension"
+file EXT_MAKEFILE.to_s => EXT_SOURCES do
log "Configuring bsdjail C extension"
- Dir.chdir( EXTDIR ) do
- Mkrf::Generator.new( 'bsdjail', FileList['*.c'] ) do |gen|
- trace "Setting CFLAGS"
- gen.cflags << ' -Wall'
- gen.cflags << ' -DDEBUG'
-
- # Make sure we have the ODE library and header available
- trace "checking for sys/param.h"
- gen.include_header( "sys/param.h" ) or
- fail "Can't find the sys/param.h header."
-
- trace "checking for sys/jail.h"
- gen.include_header( "sys/jail.h" ) or
- fail "Can't find the sys/jail.h header."
-
- gen.include_library( "c", "jail_attach" ) or
- fail "Can't find jail_attach in the stdlib."
- end
+ in_subdirectory( EXTDIR ) do
+ ruby 'extconf.rb'
end
end
-CLOBBER.include( EXTDIR + 'mkrf.log' )
-
+CLOBBER.include( EXTDIR + 'mkmf.log', EXT_SO )
desc "Build the C extension"
-task :build => EXT_RAKEFILE.to_s do
- Dir.chdir( EXTDIR ) do
- sh 'rake'
+task :build => [ EXT_MAKEFILE.to_s, *EXT_SOURCES ] do
+ in_subdirectory( EXTDIR ) do
+ sh 'make'
end
end
+desc "Rebuild the C extension"
+task :rebuild => [ :clean, :build ]
+
+
task :clean do
- if EXT_RAKEFILE.exist?
- Dir.chdir( EXTDIR ) do
- sh 'rake', 'clean'
+ if EXT_MAKEFILE.exist?
+ in_subdirectory( EXTDIR ) do
+ sh 'make clean'
end
end
end
task :clobber do
- if EXT_RAKEFILE.exist?
- Dir.chdir( EXTDIR ) do
- sh 'rake', 'clobber'
+ if EXT_MAKEFILE.exist?
+ in_subdirectory( EXTDIR ) do
+ sh 'make distclean'
end
end
end
-CLOBBER.include( EXT_RAKEFILE )
+CLOBBER.include( EXT_MAKEFILE )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ext/bsdjail.h Thu Dec 25 07:33:20 2008 +0000
@@ -0,0 +1,74 @@
+/*
+ * bsdjail.h - Header for the bsdjail extension
+ * $Id$
+ *
+ * Authors:
+ * * Michael Granger <ged@FaerieMUD.org>
+ * * Mahlon E. Smith <mahlon@martini.nu>
+ *
+ * Copyright (c) 2008, Michael Granger and Mahlon Smith
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the author/s, nor the names of the project's
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef _BSDJAIL_H_
+#define _BSDJAIL_H_
+
+
+#include <stdio.h>
+#include <sys/param.h>
+#include <sys/jail.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <ruby.h>
+#include <intern.h> /* For rb_dbl2big() */
+
+
+/* Debugging functions/macros */
+#ifdef HAVE_STDARG_PROTOTYPES
+#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+extern void rbjail_debug(const char *fmt, ...);
+#else
+#include <varargs.h>
+#define va_init_list(a,b) va_start(a)
+extern void rbjail_debug(fmt, va_alist);
+#endif
+
+
+/* Debugging macro */
+#if DEBUG
+# define debugMsg(f) rbjail_debug f
+#else /* ! DEBUG */
+# define debugMsg(f)
+#endif /* DEBUG */
+
+
+#endif /* _BSDJAIL_H_ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ext/extconf.rb Thu Dec 25 07:33:20 2008 +0000
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+
+require 'mkmf'
+require 'fileutils'
+
+ADDITIONAL_LIBRARY_DIRS = %w[
+ /usr/local/lib
+ /opt/lib
+ /opt/local/lib
+]
+ADDITIONAL_INCLUDE_DIRS = %w[
+ /usr/local/include
+ /opt/include
+ /opt/local/include
+]
+
+$CFLAGS << ' -Wall' << ' -ggdb' << ' -DDEBUG'
+
+def fail( *messages )
+ $stderr.puts( *messages )
+ exit( 1 )
+end
+
+
+dir_config( 'bsdjail' )
+
+have_header( 'stdio.h' ) or fail "Can't find the stdio.h header."
+have_header( 'sys/param.h' ) or fail "Can't find the sys/param.h header."
+have_header( 'sys/jail.h' ) or fail "Can't find the sys/jail.h header."
+have_header( 'sys/types.h' ) or fail "Can't find the sys/types.h header."
+have_header( 'unistd.h' ) or fail "Can't find the unistd.h header."
+
+have_func( "jail_attach" ) or fail "Can't find jail_attach in the stdlib."
+
+create_makefile( 'bsdjail' )
+
--- a/misc/monkeypatches.rb Tue Oct 14 16:11:19 2008 +0000
+++ b/misc/monkeypatches.rb Thu Dec 25 07:33:20 2008 +0000
@@ -42,12 +42,14 @@
task :default => EXT
rule '.#{objext}' => '.#{@source_extension}' do |t|
- sh "\#{CC} \#{CFLAGS} \#{INCLUDES} -c \#{t.source}"
+ $stderr.puts " building \#{t.name} from \#{t.source}"
+ sh "\#{CC} \#{CFLAGS} \#{INCLUDES} -c \#{t.source}"
end
desc "Build this extension"
file EXT => OBJ do
- sh "\#{LDSHARED} \#{LIBPATH} #{@available.ld_outfile(@extension_name)} \#{OBJ} \#{ADDITIONAL_OBJECTS} \#{LIBS} \#{LIBRUBYARG_SHARED}"
+ $stderr.puts " linking \#{OBJ.join(', ')} into \#{EXT}"
+ sh "\#{LDSHARED} \#{LIBPATH} #{@available.ld_outfile(@extension_name)} \#{OBJ} \#{ADDITIONAL_OBJECTS} \#{LIBS} \#{LIBRUBYARG_SHARED}"
end
@@ -55,7 +57,7 @@
desc "Install this extension"
task :install => [EXT, RUBYARCHDIR] do
- install EXT, RUBYARCHDIR, :verbose => true
+ install EXT, RUBYARCHDIR, :verbose => true
end
#{additional_code}
--- a/project.yml Tue Oct 14 16:11:19 2008 +0000
+++ b/project.yml Thu Dec 25 07:33:20 2008 +0000
@@ -7,11 +7,14 @@
simultaneously. It includes a Ruby binding to the FreeBSD jail(2) functions.
rubyforge_group: deveiate
author_name: Michael Granger and Mahlon Smith
-project_homepage: http://deveiate.org/projects/Jparallel/
+project_homepage: http://deveiate.org/projects/jParallel/
project_dependencies: {}
project_summary: A "parallel jail shell" written in Ruby
project_name: jparallel
+version_file: "jparallel.rb"
additional_pkgfiles:
- examples/*.{c,rb}
+dev_dependencies: {}
+
author_email: ged@FaerieMUD.org, mahlon@martini.nu