From 5645570ca98a9a0666a3f656caf372e030741853 Mon Sep 17 00:00:00 2001 From: mpl Date: Mon, 22 Jul 2013 22:29:44 +0200 Subject: [PATCH] dev-server: use updatelibrary.go to update closure lib This change also removes misc/get_closure.pl and updates the Makefile accordingly. http://camlistore.org/issue/140 Change-Id: I508271cee24eb20d8391cb3d84e1201ce3ef567e --- Makefile | 3 -- dev-server | 8 ++--- dev/update_closure_compiler.go | 6 ++-- misc/get_closure.pl | 65 ---------------------------------- 4 files changed, 7 insertions(+), 75 deletions(-) delete mode 100644 misc/get_closure.pl diff --git a/Makefile b/Makefile index b5dbd22f3..ed34d0246 100644 --- a/Makefile +++ b/Makefile @@ -22,9 +22,6 @@ presubmit: embeds: go install ./pkg/fileembed/genfileembed/ && genfileembed ./server/camlistored/ui && genfileembed ./pkg/server -getclosure: - perl -e 'require "misc/get_closure.pl"; get_closure_lib(); get_closure_compiler();' - UIDIR = server/camlistored/ui NEWUIDIR = server/camlistored/newui diff --git a/dev-server b/dev-server index b296c1244..246ee98aa 100755 --- a/dev-server +++ b/dev-server @@ -185,10 +185,10 @@ if ($opt_fullclosure) { if (-e "$Bin/tmp/closure-lib/.svn") { system("rm", "-rf", "$Bin/tmp/closure-lib") and die "Failed to remove the svn checkout of the closure-lib.\n"; } - get_closure_lib(); - get_closure_compiler(); - chdir $Bin or die; - $ENV{CAMLI_DEV_CLOSURE_DIR} = "$Bin/tmp/closure-lib/closure"; + print STDERR "Updating closure library ...\n"; + system("go", "run", "third_party/closure/updatelibrary.go", "-verbose") + and die "go run third_party/closure/updatelibrary.go failed"; + $ENV{CAMLI_DEV_CLOSURE_DIR} = "third_party/closure/lib/closure"; } print "Starting dev server on $base/ui/ with password \"pass$port\"\n"; diff --git a/dev/update_closure_compiler.go b/dev/update_closure_compiler.go index 8ac60fcc9..847a32307 100644 --- a/dev/update_closure_compiler.go +++ b/dev/update_closure_compiler.go @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -// The updatelibrary command allows to selectively download -// from the closure library git repository (at a chosen revision) -// the resources needed by the Camlistore ui. +// update_closure_compiler downloads a new version +// of the closure compiler if the one in tmp/closure-compiler +// doesn't exist or is older than the requested version. package main import ( diff --git a/misc/get_closure.pl b/misc/get_closure.pl deleted file mode 100644 index eff1c8c9c..000000000 --- a/misc/get_closure.pl +++ /dev/null @@ -1,65 +0,0 @@ -use strict; -use FindBin qw($Bin); -use File::Fetch; -use IO::Uncompress::Unzip qw(unzip $UnzipError) ; - -my $closure_sha = "1389e13"; -my $closure_git = "https://code.google.com/p/closure-library/"; -my $compiler_version = "20121212"; -my $compiler_baseurl = "http://closure-compiler.googlecode.com/files/"; - -sub get_closure_lib { - my $closure_dir = "$Bin/tmp/closure-lib"; - if (-d $closure_dir) { - chdir $closure_dir or die; - my $local_sha = `git rev-parse --short HEAD`; - chomp($local_sha); - if ($local_sha ne $closure_sha) { - system("git", "fetch") - and die "Failed to git fetch the closure library: $!\n"; - system("git", "reset", "--hard", $closure_sha) - and die "Failed to git reset the closure library repo: $!\n"; - } - } else { - system("git", "clone", $closure_git, $closure_dir) - and die "Failed to git clone the closure library: $!\n"; - chdir $closure_dir or die; - system("git", "reset", "--hard", $closure_sha) - and die "Failed to git reset the closure library repo: $!\n"; - } -} - -sub get_closure_compiler { - # first java check is needed, because the actual call - # always has a non zero exit status (because running the - # compiler.jar with --version writes to stderr). - my $version = `java -version 2>/dev/null`; - die "The Java Runtime Environment is needed to run the closure compiler.\n" if $?; - my $closure_compiler_dir = "$Bin/tmp/closure-compiler"; - my $jar = "$closure_compiler_dir/compiler.jar"; - if (-f $jar) { - my $cmd = join "", "java -jar ", $jar, " --version --help 2>&1"; - my $version = `$cmd`; - $version =~ s/.*Version: (.*) \(revision.*/$1/s; - if ($version eq $compiler_version) { - return; - } - unlink $jar or die "Could not unlink $jar: $!"; - } - printf("Getting closure compiler version %s.\n", $compiler_version); - unless (-d $closure_compiler_dir) { - system("mkdir", "-p", $closure_compiler_dir) - and die "Failed to create $closure_compiler_dir.\n"; - } - chdir $closure_compiler_dir or die; - my $compiler_filename = join "", "compiler-", $compiler_version, ".zip"; - my $compiler_url = $compiler_baseurl . $compiler_filename; - my $ff = File::Fetch->new(uri => $compiler_url); - my $where = $ff->fetch() or die $ff->error; - unzip $compiler_filename => "compiler.jar" - or die "unzip failed: $UnzipError\n"; - unlink $compiler_filename or die "Could not unlink $compiler_filename: $!"; - return; -} - -1;