代码拉取完成,页面将自动刷新
同步操作将从 周晶/vanilla 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env perl
use 5.006;
use strict;
use warnings;
use File::Spec;
use Data::Dumper;
sub shell ($@);
sub env ($$);
sub cd ($);
sub auto_complete ($);
sub usage ($);
sub trim ($);
our $vanilla_version = '0.1.0.rc7';
our $vanilla_version_dir_str = '0_1_0_rc7';
my (@make_cmds, @make_install_cmds);
my $root_dir = `pwd`;
chomp $root_dir;
my $OS = $^O;
if (-f 'Makefile') {
unlink 'Makefile' or die "ERROR: failed to remove existing Makefile: $!\n";
}
for my $opt (@ARGV) {
if ($opt =~ /^--platform=(.*)/) {
$OS = $1;
undef $opt;
}
}
my ($platform, $on_solaris);
if ($OS =~ /solaris|sunos/i) {
$platform = 'solaris';
$on_solaris = $platform;
} elsif ($OS eq 'linux') {
$platform = $OS;
} elsif ($OS eq 'MSWin32') {
die "MS Windows not supported. Abort.\n";
} elsif ($OS =~ /^(?:MacOS|darwin|rhapsody)$/) {
$platform = 'macosx';
} elsif ($OS eq 'freebsd') {
$platform = $OS;
} elsif ($OS =~ /^(?:openbsd|netbsd|dragonfly)$/) {
$platform = 'bsd';
} else {
$platform = 'posix';
}
my $prefix = '/usr/local/vanilla';
my $openresty_prefix = '/usr/local/openresty';
my $vanilla_bin_path = '/usr/local/bin';
my %resty_opts;
my $cc;
my $vanilla_root = $prefix;
for my $opt (@ARGV) {
next unless defined $opt;
if ($opt =~ /^--prefix=(.*)/) {
$vanilla_root = $1;
} elsif ($opt =~ /^--vanilla-bin-path=(.*)/) {
$vanilla_bin_path = $1;
} elsif ($opt =~ /^--openresty-path=(.*)/) {
$openresty_prefix = $1;
}
# elsif ($opt eq '--with-lua-filesystem') {
# $resty_opts{lua_filesystem} = 1;
# }
elsif ($opt =~ /^--with-openresty-luajit-include-path=(.*)/) {
$resty_opts{or_jit_inc_path} = $1;
} elsif ($opt =~ /^--with-luajit-or-lua-bin=(.*)/) {
$resty_opts{luajit_or_lua_bin} = $1;
}
# elsif ($opt eq '--without-lua-resty-cookie') {
# $resty_opts{no_lua_resty_cookie} = 1;
# } elsif ($opt eq '--without-lua-resty-template') {
# $resty_opts{no_lua_resty_template} = 1;
# } elsif ($opt eq '--without-lua-resty-http') {
# $resty_opts{no_lua_resty_http} = 1;
# } elsif ($opt eq '--without-lua-resty-logger-socket') {
# $resty_opts{no_lua_resty_logger_socket} = 1;
# } elsif ($opt eq '--without-lua-resty-session') {
# $resty_opts{no_lua_resty_session} = 1;
# } elsif ($opt eq '--without-lua-resty-shcache') {
# $resty_opts{no_lua_resty_shcache} = 1;
# }
elsif ($opt eq '--help') {
usage 0;
} else {
die "Invalid option $opt\n";
}
}
$prefix = $vanilla_root . '/' . $vanilla_version_dir_str;
my $luajit_or_lua_bin = glob "$openresty_prefix/luajit/bin/luajit*";
my $ngx_path = "$openresty_prefix/nginx";
if ($resty_opts{luajit_or_lua_bin}) {
$luajit_or_lua_bin = $resty_opts{luajit_or_lua_bin};
}
if (!$luajit_or_lua_bin) {
die "Didn't set luajit or lua bin. Or did't exists:" ,"$openresty_prefix/luajit/bin/luajit*";
}
build_resty_opts(\%resty_opts);
my $vanilla_extra_opts = " DESTDIR=\$(DESTDIR) VANILLA_LIB_DIR=$prefix"
# ." INSTALL=$root_dir/build/install"
." INSTALL=$root_dir/vanilla/install"
." VANILLA_BIN_PATH=$vanilla_bin_path"
." VANILLA_ROOT=$vanilla_root"
." VANILLA_VERSION=$vanilla_version";
push @make_install_cmds, "cd $root_dir/build/vanilla && " .
"\$(MAKE) install$vanilla_extra_opts";
gen_vanilla_bins();
cd '..'; # to the root
#die "pwd: " .. `pwd`;
# env LIBPQ_LIB => $pg_lib;
gen_makefile();
sub env ($$) {
my ($name, $val) = @_;
print "export $name='$val'\n";
$ENV{$name} = $val;
}
sub shell ($@) {
my ($cmd, $dry_run) = @_;
print "$cmd\n";
unless ($dry_run) {
system($cmd) == 0 or
die "ERROR: failed to run command: ", trim($cmd), "\n";
}
}
sub trim ($) {
my $cmd = shift;
$cmd =~ s/\n.*/.../s;
$cmd;
}
sub auto_complete ($) {
my $name = shift;
my @dirs = glob "$name-[0-9]*" or
die "No source directory found for $name\n";
if (@dirs > 1) {
die "More than one hits for $name: @dirs\n";
}
return $dirs[0];
}
sub cd ($) {
my $dir = shift;
print("cd $dir\n");
chdir $dir or die "failed to cd $dir: $!\n";
}
sub build_resty_opts {
my $opts = shift;
my $make;
if (-d 'build') {
system("rm -rf build") == 0 or
die "failed to remove directory build/.\n";
}
if (-e 'build') {
die "file or directory \"build\" already exists. please remove it first.\n";
}
shell "mkdir -p build/vanilla";
shell "cp -rp vanilla/* build/vanilla";
# shell "cp -rp resty/* build";
# shell "cp -rp lualib/* build";
cd 'build';
# my $lualib_prefix = "$prefix/lualib";
# if ($opts->{lua_filesystem}) {
# if (!$opts->{or_jit_inc_path}) {
# die "luafilesystem need add --with-openresty-luajit-include-path option.";
# }
# my $dir = auto_complete 'luafilesystem';
# if (!defined $dir) {
# die "No luafilesystem found";
# }
# my $lua_inc = $opts->{or_jit_inc_path};
# my $lib_option;
# if ($platform eq 'macosx') {
# $lib_option = "-bundle -undefined dynamic_lookup";
# } else {
# $lib_option = "-shared";
# }
# my $extra_opts = " DESTDIR=\$(DESTDIR) LUA_INC=$lua_inc LUA_LIBDIR=$lualib_prefix " .
# "LUA_CMODULE_DIR=$lualib_prefix LUA_MODULE_DIR=$lualib_prefix" .
# " LIB_OPTION='$lib_option'";
# if (defined $cc) {
# $extra_opts .= " CC='$cc'";
# } else {
# $extra_opts .= " CC=cc";
# }
# push @make_cmds, "cd $root_dir/build/$dir && ".
# "\$(MAKE)$extra_opts";
# push @make_install_cmds, "cd $root_dir/build/$dir && " .
# "\$(MAKE) install$extra_opts";
# }
# for my $key (qw(cookie http logger_socket session shcache template))
# {
# unless ($opts->{"no_lua_resty_$key"}) {
# (my $key2 = $key) =~ s/_/-/g;
# my $name = "lua-resty-$key2";
# my $dir = auto_complete $name;
# if (!defined $dir) {
# die "No $name found";
# }
# my $extra_opts = " DESTDIR=\$(DESTDIR) LUA_LIB_DIR=$prefix/vanilla"
# ." INSTALL=$root_dir/build/install";
# push @make_install_cmds, "cd $root_dir/build/$dir && " .
# "\$(MAKE) install$extra_opts";
# }
# }
}
sub usage ($) {
my $retval = shift;
my $msg = <<'_EOC_';
--help this message
--prefix=PATH set the installation prefix (default to /usr/local/vanilla)
--vanilla-bin-path=PATH set vanilla bin path (default to /usr/local/bin)
--platform= set platform(darwin, linux...)
--openresty-path=PATH set openresty install path (default to /usr/local/openresty)
--with-openresty-luajit-include-path=PATH
set openresty luajit include path for install C moudle
(like: /usr/local/openresty/luajit/include/luajit-2.1)
--with-luajit-or-lua-bin=BIN set openresty luajit or standard lua bin for run vanilla vanilla-console
(default to $openresty_path/luajit/bin/luajit*)
_EOC_
# --without-lua-resty-cookie disable the lua-resty-cookie library
# --without-lua-resty-template disable the lua-resty-template library
# --without-lua-resty-http disable the lua-resty-http library
# --without-lua-resty-logger-socket disable the lua-resty-logger-socket library
# --without-lua-resty-session disable the lua-resty-session library
# --without-lua-resty-shcache disable the lua-resty-shcache library
# --with-lua-filesystem enable and build lua-filesystem
# (must need option --with-openresty-luajit-include-path)
warn $msg;
exit $retval;
}
sub gen_vanilla_bins {
for my $bin_name (qw(vanilla v-console)) {
my $rs_bin_name = "$bin_name-$vanilla_version";
open my $out, ">vanilla/$rs_bin_name" or
die "Cannot open $rs_bin_name for writing: $!\n";
my $cmd_str = <<"_EOC_";
#!/bin/sh
exec '$luajit_or_lua_bin' -e 'VANILLA_ROOT="$vanilla_root"; VANILLA_VERSION_DIR_STR="$vanilla_version_dir_str"; VANILLA_VERSION="$vanilla_version"; VANILLA_NGX_PATH="$ngx_path"; VANILLA_JIT_BIN="$luajit_or_lua_bin"; package.path="$prefix/?.lua;$prefix/?/init.lua;/?.lua;/?/init.lua;"; package.cpath="$prefix/?.so"' '$prefix/bin/$bin_name' "\$@"
_EOC_
print $out $cmd_str;
close $out;
chmod 0755, "vanilla/$rs_bin_name";
}
shell "cp -p vanilla/bin/lemplate ./vanilla/lemplate-$vanilla_version";
}
sub gen_makefile {
open my $out, ">Makefile" or
die "Cannot open Makefile for writing: $!\n";
print $out ".PHONY: all install clean\n\n";
print $out "all:\n\t" . join("\n\t", @make_cmds) . "\n\n";
print $out "install: all\n\t" . join("\n\t", @make_install_cmds) . "\n\n";
print $out "clean:\n\trm -rf build\n";
close $out;
}
# check if we can run some command
sub can_run {
my ($cmd) = @_;
#warn "can run: @_\n";
my $_cmd = $cmd;
return $_cmd if -x $_cmd;
return undef if $_cmd =~ m{[\\/]};
# FIXME: this is a hack; MSWin32 is not supported anyway
my $path_sep = ':';
for my $dir ((split /$path_sep/, $ENV{PATH}), '.') {
next if $dir eq '';
my $abs = File::Spec->catfile($dir, $_[0]);
return $abs if -x $abs;
}
return undef;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。