Skip to content

Commit c01de73

Browse files
committed
util/dist-check: made the script self-contained by inlining the test nginx.conf. also fixed compatibility on recent versions of Mac OS X (like 10.10).
1 parent 387089c commit c01de73

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

util/dist-check

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use Getopt::Std qw(getopts);
77
use Cwd qw/cwd/;
88

99
sub sh ($);
10+
sub write_config_file ($);
1011

1112
my %opts;
1213
getopts("lf:", \%opts) or die "Usage: $0 [-f] [-l] <cores>\n";
@@ -44,15 +45,34 @@ if ($^O eq 'solaris') {
4445
$cfg_opts .= " --with-cc=gcc";
4546
}
4647

48+
if ($^O eq 'darwin') {
49+
$cfg_opts .= " --with-cc-opt='-I/usr/local/include'"
50+
. " --with-ld-opt='-L/usr/local/lib'";
51+
}
52+
4753
my $prefix;
4854

55+
my $config = do { local $/; <DATA> };
56+
57+
sub write_config_file ($) {
58+
my $outfile = shift;
59+
warn "Writing file $outfile\n";
60+
open my $out, ">$outfile" or
61+
die "Cannot open $outfile for writing: $!\n";
62+
print $out $config;
63+
close $out;
64+
}
65+
66+
write_config_file "/tmp/nginx.conf";
67+
4968
warn "=== Without Gzip ===\n";
5069
$prefix = "/usr/local/openresty-nogzip";
5170
unless ($opts{f}) {
5271
sh "./configure $cfg_opts --without-http_gzip_module --prefix=$prefix -j$jobs > /dev/null";
5372
}
5473
sh "$make -j$jobs > /dev/null";
5574
sh "sudo $make install > /dev/null";
75+
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
5676
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
5777
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--without-http_gzip_module'";
5878
system "sudo killall nginx > /dev/null 2>&1";
@@ -70,6 +90,7 @@ unless ($opts{f}) {
7090
}
7191
sh "$make -j$jobs > /dev/null";
7292
sh "sudo $make install > /dev/null";
93+
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
7394
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
7495
#sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-no-pool-patch'";
7596
system "sudo killall nginx > /dev/null 2>&1";
@@ -88,6 +109,7 @@ unless ($opts{f}) {
88109
}
89110
sh "$make -j$jobs > /dev/null";
90111
sh "sudo $make install > /dev/null";
112+
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
91113
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
92114
system "sudo killall nginx > /dev/null 2>&1";
93115
sh "sudo $prefix/nginx/sbin/nginx";
@@ -108,6 +130,7 @@ unless ($opts{f}) {
108130
}
109131
sh "$make -j$jobs > /dev/null";
110132
sh "sudo $make install > /dev/null";
133+
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
111134
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
112135
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-debug'";
113136
system "sudo killall nginx > /dev/null 2>&1";
@@ -125,6 +148,7 @@ unless ($opts{f}) {
125148
}
126149
sh "$make -j$jobs > /dev/null";
127150
sh "sudo $make install > /dev/null";
151+
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
128152
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
129153
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-dtrace-probes'";
130154
system "sudo killall nginx > /dev/null 2>&1";
@@ -146,3 +170,49 @@ sub sh ($) {
146170
my $cmd = shift;
147171
system($cmd) == 0 or die "Command \"$cmd\" failed";
148172
}
173+
174+
__DATA__
175+
176+
user nobody;
177+
worker_processes 1;
178+
error_log logs/error.log;
179+
pid logs/nginx.pid;
180+
181+
events {
182+
accept_mutex off;
183+
worker_connections 256;
184+
}
185+
186+
http {
187+
include mime.types;
188+
default_type application/octet-stream;
189+
190+
init_by_lua '
191+
if jit then
192+
require "resty.core"
193+
end
194+
';
195+
196+
server {
197+
listen *:80;
198+
server_name localhost;
199+
200+
location = /lua {
201+
content_by_lua '
202+
local upstream = require "ngx.upstream"
203+
if jit then
204+
ngx.say(jit.version)
205+
else
206+
ngx.say(_VERSION)
207+
end
208+
';
209+
}
210+
211+
location = /cjson {
212+
content_by_lua '
213+
local json = require "cjson.safe"
214+
ngx.say("cjson.safe: ", json.encode{foo = 123})
215+
';
216+
}
217+
}
218+
}

0 commit comments

Comments
 (0)