pg 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/ChangeLog +298 -193
- data/README +2 -2
- data/Rakefile +51 -29
- data/Rakefile.local +229 -160
- data/ext/compat.c +2 -2
- data/ext/extconf.rb +94 -73
- data/ext/pg.c +163 -106
- data/lib/pg.rb +3 -0
- data/rake/documentation.rb +123 -0
- data/rake/helpers.rb +375 -308
- data/rake/hg.rb +17 -3
- data/rake/manual.rb +11 -6
- data/rake/packaging.rb +7 -1
- data/rake/publishing.rb +158 -91
- data/rake/testing.rb +52 -88
- data/spec/lib/helpers.rb +30 -10
- data/spec/m17n_spec.rb +36 -24
- data/spec/pgconn_spec.rb +165 -19
- data/spec/pgresult_spec.rb +3 -6
- metadata +61 -20
- metadata.gz.sig +0 -0
- data/rake/rdoc.rb +0 -30
data/README
CHANGED
@@ -5,8 +5,8 @@ library works with PostgreSQL 7.4 and later.
|
|
5
5
|
|
6
6
|
== Requirements
|
7
7
|
|
8
|
-
* Ruby 1.8.
|
9
|
-
* PostgreSQL 7.
|
8
|
+
* Ruby 1.8.7-p174 or later.
|
9
|
+
* PostgreSQL 7.4 or later installed.
|
10
10
|
|
11
11
|
It may work with earlier versions as well, but those are not regularly tested.
|
12
12
|
|
data/Rakefile
CHANGED
@@ -11,12 +11,14 @@
|
|
11
11
|
#
|
12
12
|
|
13
13
|
BEGIN {
|
14
|
+
require 'rbconfig'
|
14
15
|
require 'pathname'
|
15
16
|
basedir = Pathname.new( __FILE__ ).dirname
|
16
17
|
|
17
18
|
libdir = basedir + "lib"
|
18
|
-
extdir =
|
19
|
+
extdir = libdir + Config::CONFIG['sitearch']
|
19
20
|
|
21
|
+
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
20
22
|
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
21
23
|
$LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
|
22
24
|
}
|
@@ -75,7 +77,7 @@ elsif VERSION_FILE.exist?
|
|
75
77
|
PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ]
|
76
78
|
end
|
77
79
|
|
78
|
-
PKG_VERSION
|
80
|
+
PKG_VERSION = '0.0.0' unless defined?( PKG_VERSION ) && !PKG_VERSION.nil?
|
79
81
|
|
80
82
|
PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}"
|
81
83
|
GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem"
|
@@ -90,7 +92,7 @@ EXTCONF = EXTDIR + 'extconf.rb'
|
|
90
92
|
|
91
93
|
ARTIFACTS_DIR = Pathname.new( CC_BUILD_ARTIFACTS )
|
92
94
|
|
93
|
-
TEXT_FILES = Rake::FileList.new( %w[Rakefile ChangeLog README LICENSE] )
|
95
|
+
TEXT_FILES = Rake::FileList.new( %w[Rakefile ChangeLog README* LICENSE] )
|
94
96
|
BIN_FILES = Rake::FileList.new( "#{BINDIR}/*" )
|
95
97
|
LIB_FILES = Rake::FileList.new( "#{LIBDIR}/**/*.rb" )
|
96
98
|
EXT_FILES = Rake::FileList.new( "#{EXTDIR}/**/*.{c,h,rb}" )
|
@@ -167,26 +169,36 @@ if !RAKE_TASKDIR.exist?
|
|
167
169
|
end
|
168
170
|
|
169
171
|
require RAKE_TASKDIR + 'helpers.rb'
|
172
|
+
include RakefileHelpers
|
170
173
|
|
171
174
|
# Set the build ID if the mercurial executable is available
|
172
175
|
if hg = which( 'hg' )
|
173
|
-
id =
|
174
|
-
PKG_BUILD =
|
176
|
+
id = `#{hg} id -n`.chomp
|
177
|
+
PKG_BUILD = (id.chomp[ /^[[:xdigit:]]+/ ] || '1')
|
175
178
|
else
|
176
|
-
PKG_BUILD = '
|
179
|
+
PKG_BUILD = '0'
|
177
180
|
end
|
178
181
|
SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}"
|
179
182
|
SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem"
|
180
183
|
|
181
184
|
# Documentation constants
|
182
|
-
|
185
|
+
API_DOCSDIR = DOCSDIR + 'api'
|
186
|
+
README_FILE = TEXT_FILES.find {|path| path =~ /^README/ } || 'README'
|
183
187
|
RDOC_OPTIONS = [
|
184
|
-
'-
|
185
|
-
'-
|
186
|
-
'
|
187
|
-
|
188
|
-
|
189
|
-
|
188
|
+
'--tab-width=4',
|
189
|
+
'--show-hash',
|
190
|
+
'--include', BASEDIR.to_s,
|
191
|
+
"--main=#{README_FILE}",
|
192
|
+
"--title=#{PKG_NAME}",
|
193
|
+
]
|
194
|
+
YARD_OPTIONS = [
|
195
|
+
'--use-cache',
|
196
|
+
'--protected',
|
197
|
+
'-r', README_FILE,
|
198
|
+
'--exclude', 'extconf\\.rb',
|
199
|
+
'--files', 'ChangeLog,LICENSE',
|
200
|
+
'--output-dir', API_DOCSDIR.to_s,
|
201
|
+
'--title', "#{PKG_NAME} #{PKG_VERSION}",
|
190
202
|
]
|
191
203
|
|
192
204
|
# Release constants
|
@@ -194,28 +206,30 @@ SMTP_HOST = "mail.faeriemud.org"
|
|
194
206
|
SMTP_PORT = 465 # SMTP + SSL
|
195
207
|
|
196
208
|
# Project constants
|
197
|
-
PROJECT_HOST = '
|
198
|
-
PROJECT_PUBDIR = '/
|
209
|
+
PROJECT_HOST = 'deveiate.org'
|
210
|
+
PROJECT_PUBDIR = '/usr/local/www/public/code/'
|
199
211
|
PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}"
|
200
212
|
PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}"
|
201
213
|
PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
|
202
214
|
|
215
|
+
GEM_PUBHOST = 'rubygems.org'
|
216
|
+
|
203
217
|
# Gem dependencies: gemname => version
|
204
218
|
DEPENDENCIES = {
|
205
219
|
}
|
206
220
|
|
207
221
|
# Developer Gem dependencies: gemname => version
|
208
222
|
DEVELOPMENT_DEPENDENCIES = {
|
209
|
-
'rake'
|
210
|
-
'rcodetools'
|
211
|
-
'rcov'
|
212
|
-
'
|
213
|
-
'RedCloth'
|
214
|
-
'rspec'
|
215
|
-
'termios'
|
216
|
-
'text-format'
|
217
|
-
'tmail'
|
218
|
-
'
|
223
|
+
'rake' => '~> 0.8.7',
|
224
|
+
'rcodetools' => '~> 0.7.0.0',
|
225
|
+
'rcov' => '~> 0.8.1.2.0',
|
226
|
+
'yard' => '~> 0.6.1',
|
227
|
+
'RedCloth' => '~> 4.2.3',
|
228
|
+
'rspec' => '~> 2.0.1',
|
229
|
+
'ruby-termios' => '~> 0.9.6',
|
230
|
+
'text-format' => '~> 1.0.0',
|
231
|
+
'tmail' => '~> 1.2.3.1',
|
232
|
+
'rake-compiler' => '~>0.7.0',
|
219
233
|
}
|
220
234
|
|
221
235
|
# Non-gem requirements: packagename => version
|
@@ -234,13 +248,14 @@ GEMSPEC = Gem::Specification.new do |gem|
|
|
234
248
|
"This library works with PostgreSQL 7.4 and later.",
|
235
249
|
].join( "\n" )
|
236
250
|
|
237
|
-
gem.authors = "Michael Granger"
|
238
|
-
gem.email = ["ged@FaerieMUD.org"]
|
251
|
+
gem.authors = ["Jeff Davis", "Michael Granger"]
|
252
|
+
gem.email = ["ruby-pg@j-davis.com", "ged@FaerieMUD.org"]
|
239
253
|
gem.homepage = 'http://bitbucket.org/ged/ruby-pg/'
|
254
|
+
gem.licenses = ["Ruby", "GPL", "BSD"]
|
240
255
|
|
241
256
|
gem.has_rdoc = true
|
242
257
|
gem.rdoc_options = RDOC_OPTIONS
|
243
|
-
gem.extra_rdoc_files =
|
258
|
+
gem.extra_rdoc_files = TEXT_FILES - [ 'Rakefile' ]
|
244
259
|
|
245
260
|
gem.bindir = BINDIR.relative_path_from(BASEDIR).to_s
|
246
261
|
gem.executables = BIN_FILES.select {|pn| File.executable?(pn) }.
|
@@ -254,6 +269,13 @@ GEMSPEC = Gem::Specification.new do |gem|
|
|
254
269
|
gem.files = RELEASE_FILES
|
255
270
|
gem.test_files = SPEC_FILES
|
256
271
|
|
272
|
+
# signing key and certificate chain
|
273
|
+
gem.signing_key = '/Volumes/Keys/ged-private_gem_key.pem'
|
274
|
+
gem.cert_chain = [File.expand_path('~/.gem/ged-public_gem_cert.pem')]
|
275
|
+
|
276
|
+
|
277
|
+
gem.required_ruby_version = '>=1.8.7'
|
278
|
+
|
257
279
|
DEPENDENCIES.each do |name, version|
|
258
280
|
version = '>= 0' if version.length.zero?
|
259
281
|
gem.add_runtime_dependency( name, version )
|
@@ -294,7 +316,7 @@ import LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist?
|
|
294
316
|
#####################################################################
|
295
317
|
|
296
318
|
### Default task
|
297
|
-
task :default => [:clean, :local, :spec, :
|
319
|
+
task :default => [:clean, :local, :spec, :apidocs, :package]
|
298
320
|
|
299
321
|
### Task the local Rakefile can append to -- no-op by default
|
300
322
|
task :local
|
data/Rakefile.local
CHANGED
@@ -1,26 +1,61 @@
|
|
1
1
|
#!rake
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
3
|
+
require 'uri'
|
4
|
+
require 'tempfile'
|
5
5
|
require 'rbconfig'
|
6
6
|
|
7
|
-
|
7
|
+
MISCDIR = BASEDIR + 'misc'
|
8
|
+
|
8
9
|
EXT_MAKEFILE = EXTDIR + 'Makefile'
|
9
10
|
EXT_SOURCES = FileList[ EXTDIR + '*.c' ]
|
10
|
-
EXT_SO = EXTDIR + "
|
11
|
-
|
12
|
-
SITEARCH_DIR = LIBDIR + Config::CONFIG['sitearch']
|
11
|
+
EXT_SO = EXTDIR + "pg_ext.#{CONFIG['DLEXT']}"
|
13
12
|
|
14
13
|
NUM_CPUS = if File.exist?('/proc/cpuinfo')
|
15
14
|
File.read('/proc/cpuinfo').scan('processor').length
|
15
|
+
elsif RUBY_PLATFORM.include?( 'darwin' )
|
16
|
+
`system_profiler SPHardwareDataType | grep 'Cores' | awk '{print $5}'`.chomp
|
16
17
|
else
|
17
18
|
1
|
18
19
|
end
|
19
20
|
|
20
21
|
# Cross-compilation constants
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
OPENSSL_VERSION = ENV['OPENSSL_VERSION'] || '1.0.0a'
|
23
|
+
POSTGRESQL_VERSION = ENV['POSTGRESQL_VERSION'] || '9.0.1'
|
24
|
+
|
25
|
+
COMPILE_HOME = Pathname( "~/.rake-compiler" ).expand_path
|
26
|
+
STATIC_SOURCESDIR = COMPILE_HOME + 'sources'
|
27
|
+
STATIC_BUILDDIR = COMPILE_HOME + 'builds'
|
28
|
+
|
29
|
+
# Static OpenSSL build vars
|
30
|
+
STATIC_OPENSSL_BUILDDIR = STATIC_BUILDDIR + "openssl-#{OPENSSL_VERSION}"
|
31
|
+
|
32
|
+
OPENSSL_SOURCE_URI =
|
33
|
+
URI( "http://www.openssl.org/source/openssl-#{OPENSSL_VERSION}.tar.gz" )
|
34
|
+
OPENSSL_TARBALL = STATIC_SOURCESDIR + File.basename( OPENSSL_SOURCE_URI.path )
|
35
|
+
OPENSSL_MAKEFILE = STATIC_OPENSSL_BUILDDIR + 'Makefile'
|
36
|
+
|
37
|
+
LIBSSLEAY32 = STATIC_OPENSSL_BUILDDIR + 'libssleay32.a'
|
38
|
+
LIBEAY32 = STATIC_OPENSSL_BUILDDIR + 'libeay32.a'
|
39
|
+
|
40
|
+
OPENSSL_PATCHES = Rake::FileList[ MISCDIR + "openssl-#{OPENSSL_VERSION}.*.patch" ]
|
41
|
+
|
42
|
+
# Static PostgreSQL build vars
|
43
|
+
STATIC_POSTGRESQL_BUILDDIR = STATIC_BUILDDIR + "postgresql-#{POSTGRESQL_VERSION}"
|
44
|
+
POSTGRESQL_SOURCE_URI = begin
|
45
|
+
uristring = "http://ftp9.us.postgresql.org/pub/mirrors/postgresql/source/" +
|
46
|
+
"v%s/postgresql-%s.tar.gz" % [ POSTGRESQL_VERSION, POSTGRESQL_VERSION ]
|
47
|
+
URI( uristring )
|
48
|
+
end
|
49
|
+
POSTGRESQL_TARBALL = STATIC_SOURCESDIR + File.basename( POSTGRESQL_SOURCE_URI.path )
|
50
|
+
|
51
|
+
STATIC_POSTGRESQL_SRCDIR = STATIC_POSTGRESQL_BUILDDIR + 'src'
|
52
|
+
STATIC_POSTGRESQL_LIBDIR = STATIC_POSTGRESQL_SRCDIR + 'interfaces/libpq'
|
53
|
+
STATIC_POSTGRESQL_INCDIR = STATIC_POSTGRESQL_SRCDIR + 'include'
|
54
|
+
|
55
|
+
POSTGRESQL_GLOBAL_MAKEFILE = STATIC_POSTGRESQL_SRCDIR + 'Makefile.global'
|
56
|
+
POSTGRESQL_SHLIB_MAKEFILE = STATIC_POSTGRESQL_SRCDIR + 'Makefile.shlib'
|
57
|
+
POSTGRESQL_SHLIB_MF_ORIG = STATIC_POSTGRESQL_SRCDIR + 'Makefile.shlib.orig'
|
58
|
+
POSTGRESQL_LIB = STATIC_POSTGRESQL_LIBDIR + 'libpq.a'
|
24
59
|
|
25
60
|
CROSS_PREFIX = if RUBY_PLATFORM.include?( 'darwin' )
|
26
61
|
'i386-mingw32'
|
@@ -32,6 +67,13 @@ end
|
|
32
67
|
SPEC_DATA = Rake::FileList[ SPECDIR + 'data/*' ]
|
33
68
|
GEMSPEC.test_files += SPEC_DATA.to_a
|
34
69
|
|
70
|
+
# Clean up any testing database directories
|
71
|
+
TESTING_TMPDIRS = Rake::FileList[ "#{BASEDIR}/tmp_test_*" ]
|
72
|
+
CLOBBER.include( STATIC_SOURCESDIR.to_s, *TESTING_TMPDIRS )
|
73
|
+
|
74
|
+
# clean intermediate files and folders
|
75
|
+
CLEAN.include( STATIC_BUILDDIR.to_s )
|
76
|
+
|
35
77
|
|
36
78
|
#####################################################################
|
37
79
|
### T A S K S
|
@@ -47,197 +89,224 @@ namespace :spec do
|
|
47
89
|
task :text => [ :compile ]
|
48
90
|
end
|
49
91
|
|
50
|
-
ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
ext.
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
92
|
+
ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.2'
|
93
|
+
|
94
|
+
begin
|
95
|
+
require 'rake/clean'
|
96
|
+
require 'rake/extensiontask'
|
97
|
+
require 'rake/extensioncompiler'
|
98
|
+
|
99
|
+
Rake::ExtensionTask.new do |ext|
|
100
|
+
ext.name = 'pg_ext'
|
101
|
+
ext.gem_spec = GEMSPEC
|
102
|
+
ext.ext_dir = EXTDIR.to_s
|
103
|
+
ext.lib_dir = LIBDIR.to_s
|
104
|
+
ext.source_pattern = "*.{c,h}"
|
105
|
+
|
106
|
+
# If there's an explicit 'compile' argument, use everything after it as options.
|
107
|
+
if offset = ARGV.index( 'compile' )
|
108
|
+
trace "config options = %p" % [ ARGV[(offset + 1)..-1] ]
|
109
|
+
ext.config_options = ARGV[ (offset + 1)..-1 ]
|
110
|
+
# Otherwise, just grab everything from the first option onward
|
111
|
+
elsif offset = ARGV.index( ARGV.find {|arg| arg =~ /^--/ } )
|
112
|
+
trace "config options = %p" % [ ARGV[offset..-1] ]
|
113
|
+
ext.config_options = ARGV[ offset..-1 ]
|
114
|
+
else
|
115
|
+
trace "No config options (ARGV = %p)" % [ ARGV ]
|
116
|
+
end
|
70
117
|
|
71
|
-
|
72
|
-
|
118
|
+
ext.cross_compile = true
|
119
|
+
ext.cross_platform = %w[i386-mswin32 i386-mingw32]
|
73
120
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
121
|
+
# configure options only for cross compile
|
122
|
+
ext.cross_config_options += [
|
123
|
+
"--with-pg-include=#{STATIC_POSTGRESQL_LIBDIR}",
|
124
|
+
"--with-opt-include=#{STATIC_POSTGRESQL_INCDIR}",
|
125
|
+
"--with-pg-lib=#{STATIC_POSTGRESQL_LIBDIR}",
|
126
|
+
"--with-opt-lib=#{STATIC_OPENSSL_BUILDDIR}",
|
127
|
+
"--enable-static-build",
|
128
|
+
]
|
82
129
|
|
83
|
-
end
|
130
|
+
end
|
84
131
|
|
85
132
|
|
86
|
-
desc "Stop any Postmaster instances that remain after testing."
|
87
|
-
task :cleanup_testing_dbs do
|
88
|
-
require 'spec/lib/helpers'
|
89
|
-
PgTestingHelpers.stop_existing_postmasters()
|
90
|
-
Rake::Task[:clean].invoke
|
91
|
-
end
|
92
133
|
|
134
|
+
#####################################################################
|
135
|
+
### C R O S S - C O M P I L A T I O N - T A S K S
|
136
|
+
#####################################################################
|
93
137
|
|
94
|
-
#####################################################################
|
95
|
-
### C R O S S - C O M P I L A T I O N - T A S K S
|
96
|
-
#####################################################################
|
97
138
|
|
139
|
+
directory STATIC_SOURCESDIR.to_s
|
98
140
|
|
99
|
-
#
|
100
|
-
|
101
|
-
|
141
|
+
#
|
142
|
+
# Static OpenSSL build tasks
|
143
|
+
#
|
144
|
+
directory STATIC_OPENSSL_BUILDDIR.to_s
|
102
145
|
|
103
|
-
#
|
104
|
-
|
105
|
-
|
106
|
-
# openssl source file should be stored there
|
107
|
-
file "#{COMPILE_HOME}/sources/openssl-#{OPENSSL_VERSION}.tar.gz" => ["#{COMPILE_HOME}/sources"] do |t|
|
108
|
-
# download the source file using wget or curl
|
109
|
-
chdir File.dirname(t.name) do
|
110
|
-
#http://www.openssl.org/source/openssl-0.9.8k.tar.gz
|
111
|
-
url = "http://www.openssl.org/source/#{File.basename(t.name)}"
|
112
|
-
sh "wget #{url} || curl -O #{url}"
|
146
|
+
# openssl source file should be stored there
|
147
|
+
file OPENSSL_TARBALL => STATIC_SOURCESDIR do |t|
|
148
|
+
download( OPENSSL_SOURCE_URI, t.name )
|
113
149
|
end
|
114
|
-
end
|
115
150
|
|
116
|
-
# Extract the openssl builds
|
117
|
-
file
|
118
|
-
|
119
|
-
|
151
|
+
# Extract the openssl builds
|
152
|
+
file STATIC_OPENSSL_BUILDDIR => OPENSSL_TARBALL do |t|
|
153
|
+
trace "extracting %s to %s" % [ OPENSSL_TARBALL, STATIC_OPENSSL_BUILDDIR.parent ]
|
154
|
+
STATIC_OPENSSL_BUILDDIR.mkpath
|
155
|
+
run 'tar', '-xzf', OPENSSL_TARBALL.to_s, '-C', STATIC_OPENSSL_BUILDDIR.parent.to_s
|
156
|
+
OPENSSL_MAKEFILE.unlink if OPENSSL_MAKEFILE.exist?
|
157
|
+
|
158
|
+
OPENSSL_PATCHES.each do |patchfile|
|
159
|
+
trace " applying patch #{patchfile}..."
|
160
|
+
run 'patch', '-Np1', '-d', STATIC_OPENSSL_BUILDDIR.to_s,
|
161
|
+
'-i', File.expand_path( patchfile, BASEDIR )
|
162
|
+
end
|
120
163
|
end
|
121
|
-
end
|
122
164
|
|
123
|
-
|
124
|
-
|
125
|
-
|
165
|
+
CMD_PRELUDE = [
|
166
|
+
'env',
|
167
|
+
"CC=#{CROSS_PREFIX}-gcc",
|
168
|
+
"CFLAGS=-DDSO_WIN32",
|
169
|
+
"AR=#{CROSS_PREFIX}-ar",
|
170
|
+
"RANLIB=#{CROSS_PREFIX}-ranlib"
|
171
|
+
]
|
126
172
|
|
127
|
-
|
128
|
-
|
173
|
+
|
174
|
+
# generate the makefile in a clean build location
|
175
|
+
file OPENSSL_MAKEFILE => STATIC_OPENSSL_BUILDDIR do |t|
|
176
|
+
Dir.chdir( STATIC_OPENSSL_BUILDDIR ) do
|
177
|
+
cmd = CMD_PRELUDE.dup
|
178
|
+
cmd << "./Configure" << 'mingw'
|
179
|
+
|
180
|
+
run( *cmd )
|
181
|
+
end
|
129
182
|
end
|
130
|
-
end
|
131
183
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
184
|
+
desc "compile static openssl libraries"
|
185
|
+
task :openssl_libs => [ LIBSSLEAY32, LIBEAY32 ]
|
186
|
+
|
187
|
+
task :compile_static_openssl => OPENSSL_MAKEFILE do |t|
|
188
|
+
Dir.chdir( STATIC_OPENSSL_BUILDDIR ) do
|
189
|
+
cmd = CMD_PRELUDE.dup
|
190
|
+
cmd << 'make' << "-j#{NUM_CPUS}" << 'build_libs'
|
191
|
+
|
192
|
+
run( *cmd )
|
193
|
+
end
|
141
194
|
end
|
142
|
-
end
|
143
195
|
|
144
|
-
|
145
|
-
|
196
|
+
desc "compile static #{LIBEAY32}"
|
197
|
+
file LIBEAY32 => :compile_static_openssl do |t|
|
198
|
+
FileUtils.cp( STATIC_OPENSSL_BUILDDIR + 'libcrypto.a', LIBEAY32.to_s )
|
199
|
+
end
|
146
200
|
|
201
|
+
desc "compile static #{LIBSSLEAY32}"
|
202
|
+
file LIBSSLEAY32 => :compile_static_openssl do |t|
|
203
|
+
FileUtils.cp( STATIC_OPENSSL_BUILDDIR + 'libssl.a', LIBSSLEAY32.to_s )
|
204
|
+
end
|
147
205
|
|
148
|
-
# define a location where sources will be stored
|
149
|
-
directory "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}"
|
150
206
|
|
151
|
-
# clean intermediate files and folders
|
152
|
-
CLEAN.include("#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}")
|
153
207
|
|
208
|
+
#
|
209
|
+
# Static PostgreSQL build tasks
|
210
|
+
#
|
211
|
+
directory STATIC_POSTGRESQL_BUILDDIR.to_s
|
154
212
|
|
155
|
-
# postgresql source file should be stored there
|
156
|
-
file "#{COMPILE_HOME}/sources/postgresql-#{POSTGRESQL_VERSION}.tar.bz2" => ["#{COMPILE_HOME}/sources"] do |t|
|
157
|
-
# download the source file using wget or curl
|
158
|
-
chdir File.dirname(t.name) do
|
159
|
-
#http://wwwmaster.postgresql.org/redir/53/h/source/v8.4.0/postgresql-8.4.0.tar.bz2
|
160
|
-
url = "http://wwwmaster.postgresql.org/redir/53/h/source/v#{POSTGRESQL_VERSION}/#{File.basename(t.name)}"
|
161
|
-
sh "wget #{url} || curl -O #{url}"
|
162
|
-
end
|
163
|
-
end
|
164
213
|
|
165
|
-
#
|
166
|
-
file
|
167
|
-
|
168
|
-
t.prerequisites.each { |f| sh "tar xfj ../sources/#{File.basename(f)}" }
|
214
|
+
# postgresql source file should be stored there
|
215
|
+
file POSTGRESQL_TARBALL => STATIC_SOURCESDIR do |t|
|
216
|
+
download( POSTGRESQL_SOURCE_URI, t.name )
|
169
217
|
end
|
170
|
-
end
|
171
218
|
|
172
|
-
#
|
173
|
-
file
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
"--host=#{Rake::ExtensionCompiler.mingw_host}",
|
180
|
-
'--with-openssl',
|
181
|
-
'--without-zlib',
|
182
|
-
'--disable-shared',
|
183
|
-
]
|
219
|
+
# Extract the postgresql sources
|
220
|
+
file STATIC_POSTGRESQL_BUILDDIR => POSTGRESQL_TARBALL do |t|
|
221
|
+
trace "extracting %s to %s" % [ POSTGRESQL_TARBALL, STATIC_POSTGRESQL_BUILDDIR.parent ]
|
222
|
+
STATIC_POSTGRESQL_BUILDDIR.mkpath
|
223
|
+
run 'tar', '-xzf', POSTGRESQL_TARBALL.to_s, '-C', STATIC_POSTGRESQL_BUILDDIR.parent.to_s
|
224
|
+
mv POSTGRESQL_SHLIB_MAKEFILE, POSTGRESQL_SHLIB_MF_ORIG
|
225
|
+
end
|
184
226
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
227
|
+
# generate the makefile in a clean build location
|
228
|
+
file POSTGRESQL_GLOBAL_MAKEFILE => [ STATIC_POSTGRESQL_BUILDDIR, :openssl_libs ] do |t|
|
229
|
+
options = [
|
230
|
+
'--target=i386-mingw32',
|
231
|
+
"--host=#{Rake::ExtensionCompiler.mingw_host}",
|
232
|
+
'--with-openssl',
|
233
|
+
'--without-zlib',
|
234
|
+
'--disable-shared',
|
235
|
+
]
|
236
|
+
|
237
|
+
Dir.chdir( STATIC_POSTGRESQL_BUILDDIR ) do
|
238
|
+
configure_path = STATIC_POSTGRESQL_BUILDDIR + 'configure'
|
239
|
+
cmd = [ configure_path.to_s, *options ]
|
240
|
+
cmd << "CFLAGS=-L#{STATIC_OPENSSL_BUILDDIR}"
|
241
|
+
cmd << "LDFLAGS=-L#{STATIC_OPENSSL_BUILDDIR}"
|
242
|
+
cmd << "LDFLAGS_SL=-L#{STATIC_OPENSSL_BUILDDIR}"
|
243
|
+
cmd << "LIBS=-lwsock32 -lgdi32"
|
244
|
+
cmd << "CPPFLAGS=-I#{STATIC_OPENSSL_BUILDDIR}/include"
|
245
|
+
|
246
|
+
run( *cmd )
|
247
|
+
end
|
195
248
|
end
|
196
|
-
end
|
197
249
|
|
198
|
-
# backup Makefile.shlib
|
199
|
-
file "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/Makefile.shlib.bak" => ["#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/Makefile.global"] do |t|
|
200
|
-
cp "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/Makefile.shlib", t.name
|
201
|
-
end
|
202
250
|
|
203
|
-
# patch the Makefile.shlib
|
204
|
-
|
205
|
-
|
251
|
+
# patch the Makefile.shlib -- depend on the build dir so it's only
|
252
|
+
# rewritten if the tarball is re-extracted.
|
253
|
+
file POSTGRESQL_SHLIB_MAKEFILE => POSTGRESQL_SHLIB_MF_ORIG do |t|
|
254
|
+
tf = Tempfile.new( POSTGRESQL_SHLIB_MAKEFILE.basename )
|
255
|
+
POSTGRESQL_SHLIB_MF_ORIG.open( File::RDONLY ) do |ifh|
|
256
|
+
ifh.each_line do |line|
|
257
|
+
tf.print( line.sub(/^(\s*haslibarule\s*=\s*yes)/, "# \\1 ") )
|
258
|
+
end
|
259
|
+
end
|
260
|
+
tf.close
|
206
261
|
|
207
|
-
|
262
|
+
FileUtils.mv( tf.path, t.name, :verbose => $trace )
|
263
|
+
end
|
208
264
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
265
|
+
|
266
|
+
# make libpq.a
|
267
|
+
file POSTGRESQL_LIB => [ POSTGRESQL_GLOBAL_MAKEFILE, POSTGRESQL_SHLIB_MAKEFILE ] do |t|
|
268
|
+
Dir.chdir( POSTGRESQL_LIB.dirname ) do
|
269
|
+
sh 'make', "-j#{NUM_CPUS}", POSTGRESQL_LIB.basename.to_s, 'PORTNAME=win32'
|
214
270
|
end
|
215
271
|
end
|
216
272
|
|
217
|
-
when_writing("Patching Makefile.shlib") {
|
218
|
-
File.open(t.name, 'wb') { |f| f.write(out) }
|
219
|
-
}
|
220
|
-
end
|
221
273
|
|
274
|
+
#desc 'compile static libpg.a'
|
275
|
+
task :static_libpq => POSTGRESQL_LIB
|
222
276
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
277
|
+
desc 'cross compile pg for win32'
|
278
|
+
task :cross do
|
279
|
+
ENV['CROSS_COMPILING'] = 'yes'
|
280
|
+
end
|
281
|
+
task :cross => [ :mingw32, :static_libpq ]
|
282
|
+
|
283
|
+
task :mingw32 do
|
284
|
+
# Use Rake::ExtensionCompiler helpers to find the proper host
|
285
|
+
unless Rake::ExtensionCompiler.mingw_host then
|
286
|
+
warn "You need to install mingw32 cross compile functionality to be able to continue."
|
287
|
+
warn "Please refer to your distribution/package manager documentation about installation."
|
288
|
+
fail
|
289
|
+
end
|
227
290
|
end
|
228
|
-
end
|
229
|
-
|
230
|
-
#desc 'compile static libpg.a'
|
231
|
-
task 'postgresql-make' => ['openssl-make', "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/interfaces/libpq/libpq.a"]
|
232
|
-
|
233
|
-
desc 'cross compile pg for win32'
|
234
|
-
task 'cross' => [:mingw32, 'postgresql-make']
|
235
291
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
warn "You need to install mingw32 cross compile functionality to be able to continue."
|
240
|
-
warn "Please refer to your distribution/package manager documentation about installation."
|
292
|
+
rescue LoadError => err
|
293
|
+
task :no_rake_compiler do
|
294
|
+
log "You'll need to install rake-compiler to compile this."
|
241
295
|
fail
|
242
296
|
end
|
297
|
+
|
298
|
+
task :compile => :no_rake_compiler
|
299
|
+
task :cross => :no_rake_compiler
|
300
|
+
task :mingw32 => :no_rake_compiler
|
301
|
+
task :static_libpq => :no_rake_compiler
|
302
|
+
end
|
303
|
+
|
304
|
+
|
305
|
+
desc "Stop any Postmaster instances that remain after testing."
|
306
|
+
task :cleanup_testing_dbs do
|
307
|
+
require 'spec/lib/helpers'
|
308
|
+
PgTestingHelpers.stop_existing_postmasters()
|
309
|
+
Rake::Task[:clean].invoke
|
243
310
|
end
|
311
|
+
|
312
|
+
|