update dev-* scripts to use misc/devlib.pl and install binaries in gopath/bin/OS_ARCH

Change-Id: Iec928f786e7763a104d10f7e2a34a1bc6d948919
This commit is contained in:
Brad Fitzpatrick 2012-03-27 10:37:21 -07:00
parent aecc8fbfa7
commit 0fa34e75b0
6 changed files with 46 additions and 24 deletions

View File

@ -3,6 +3,7 @@
use strict; use strict;
use FindBin qw($Bin); use FindBin qw($Bin);
use Getopt::Long; use Getopt::Long;
require "$Bin/misc/devlib.pl";
unless ($ENV{GOPATH}) { unless ($ENV{GOPATH}) {
$ENV{GOPATH} = "$Bin/gopath" $ENV{GOPATH} = "$Bin/gopath"
@ -19,6 +20,8 @@ Getopt::Long::Configure("pass_through");
GetOptions("tls" => \$opt_tls) GetOptions("tls" => \$opt_tls)
or usage(); or usage();
my $camget = build_bin("./cmd/camget");
# Respected by camli/osutil: # Respected by camli/osutil:
$ENV{"CAMLI_CONFIG_DIR"} = "$Bin/config/dev-client-dir"; $ENV{"CAMLI_CONFIG_DIR"} = "$Bin/config/dev-client-dir";
@ -32,7 +35,7 @@ if ($opt_tls) {
$blobserver =~ s/^http/https/; $blobserver =~ s/^http/https/;
} }
exec("$ENV{GOPATH}/bin/camget", exec("$camget",
"--verbose", "--verbose",
"--blobserver=$blobserver", "--blobserver=$blobserver",
@ARGV); @ARGV);

View File

@ -1,20 +1,30 @@
#!/bin/sh #!/usr/bin/perl
set -x use strict;
set -e use FindBin qw($Bin);
use Getopt::Long;
require "$Bin/misc/devlib.pl";
DIR=/tmp/cammount-dir my $blobref = shift;
mkdir -p $DIR unless ($blobref && $blobref =~ /^\w+-[0-9a-f]{10,}$/) {
die "Usage: dev-cammount [blobref]\n";
}
my $cammount = build_bin("./cmd/cammount");
go install ./cmd/cammount/ my $dir = "/tmp/cammount-dir";
mkdir $dir, 0700 unless -d $dir;
(fusermount -u $DIR) || umount $DIR || umount -f $DIR || true try_unmount();
print "Mounting on $dir ...\n";
cammount --blobserver=localhost:3179/bs $@ $DIR & system("$cammount", "--blobserver=localhost:3179/bs", $blobref, $dir)
sleep 1 and warn "cammount failure: $!\n";
cd $DIR warn "Failed to unmount\n" unless try_unmount();
bash
cd /
fusermount -u $DIR || umount $DIR || umount -f $DIR || true
sub try_unmount {
if ($^O eq "linux" && system("fusermount", "-u", $dir) == 0) {
return 1;
}
return 1 if system("umount", $dir) == 0;
return 1 if system("umount", "-f", $dir) == 0;
return 0;
}

View File

@ -3,6 +3,7 @@
use strict; use strict;
use FindBin qw($Bin); use FindBin qw($Bin);
use Getopt::Long; use Getopt::Long;
require "$Bin/misc/devlib.pl";
unless ($ENV{GOPATH}) { unless ($ENV{GOPATH}) {
$ENV{GOPATH} = "$Bin/gopath" $ENV{GOPATH} = "$Bin/gopath"
@ -19,6 +20,8 @@ Getopt::Long::Configure("pass_through");
GetOptions("tls" => \$opt_tls) GetOptions("tls" => \$opt_tls)
or usage(); or usage();
my $camput = build_bin("./cmd/camput");
# Respected by camli/osutil: # Respected by camli/osutil:
$ENV{"CAMLI_CONFIG_DIR"} = "$Bin/config/dev-client-dir"; $ENV{"CAMLI_CONFIG_DIR"} = "$Bin/config/dev-client-dir";
@ -32,7 +35,7 @@ if ($opt_tls) {
$blobserver =~ s/^http/https/; $blobserver =~ s/^http/https/;
} }
exec("$ENV{GOPATH}/bin/camput", exec("$camput",
"--verbose", "--verbose",
"--blobserver=$blobserver", "--blobserver=$blobserver",
@ARGV); @ARGV);

View File

@ -1,4 +1,11 @@
#!/bin/sh #!/usr/bin/perl
use strict;
use FindBin qw($Bin);
use Getopt::Long;
require "$Bin/misc/devlib.pl";
my $camsync = build_bin("./cmd/camsync");
exec($camsync, "--verbose", "--src=http://localhost:3179/bs", "--srcpassword=pass3179", @ARGV);
die "Failed to exec camsync.";
./build.pl camsync && \
clients/go/camsync/camsync --verbose --src=http://localhost:3179/bs --srcpassword=pass3179 $@

3
dev-db
View File

@ -1,4 +1,3 @@
#!/bin/sh #!/bin/sh
mysql -uroot -proot devcamli$USER exec mysql -uroot -proot devcamli$USER

View File

@ -15,8 +15,8 @@ sub build_bin {
sub find_bin { sub find_bin {
my $target = shift; my $target = shift;
$target =~ s!.+/!!; $target =~ s!.+/!!;
my $gp = find_arch_gopath(); my $bin = find_gobin();
return "$gp/bin/$target"; return "$bin/$target";
} }
sub find_gobin { sub find_gobin {