From 0fa34e75b04b42c3ababa3adfe4ddfe431d1de22 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 27 Mar 2012 10:37:21 -0700 Subject: [PATCH] update dev-* scripts to use misc/devlib.pl and install binaries in gopath/bin/OS_ARCH Change-Id: Iec928f786e7763a104d10f7e2a34a1bc6d948919 --- dev-camget | 5 ++++- dev-cammount | 40 +++++++++++++++++++++++++--------------- dev-camput | 5 ++++- dev-camsync | 13 ++++++++++--- dev-db | 3 +-- misc/devlib.pl | 4 ++-- 6 files changed, 46 insertions(+), 24 deletions(-) diff --git a/dev-camget b/dev-camget index 6b0215363..c953e38b0 100755 --- a/dev-camget +++ b/dev-camget @@ -3,6 +3,7 @@ use strict; use FindBin qw($Bin); use Getopt::Long; +require "$Bin/misc/devlib.pl"; unless ($ENV{GOPATH}) { $ENV{GOPATH} = "$Bin/gopath" @@ -19,6 +20,8 @@ Getopt::Long::Configure("pass_through"); GetOptions("tls" => \$opt_tls) or usage(); +my $camget = build_bin("./cmd/camget"); + # Respected by camli/osutil: $ENV{"CAMLI_CONFIG_DIR"} = "$Bin/config/dev-client-dir"; @@ -32,7 +35,7 @@ if ($opt_tls) { $blobserver =~ s/^http/https/; } -exec("$ENV{GOPATH}/bin/camget", +exec("$camget", "--verbose", "--blobserver=$blobserver", @ARGV); diff --git a/dev-cammount b/dev-cammount index 39a790da5..a2b0f6c67 100755 --- a/dev-cammount +++ b/dev-cammount @@ -1,20 +1,30 @@ -#!/bin/sh +#!/usr/bin/perl -set -x -set -e +use strict; +use FindBin qw($Bin); +use Getopt::Long; +require "$Bin/misc/devlib.pl"; -DIR=/tmp/cammount-dir -mkdir -p $DIR +my $blobref = shift; +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 - -cammount --blobserver=localhost:3179/bs $@ $DIR & -sleep 1 -cd $DIR -bash -cd / - -fusermount -u $DIR || umount $DIR || umount -f $DIR || true +try_unmount(); +print "Mounting on $dir ...\n"; +system("$cammount", "--blobserver=localhost:3179/bs", $blobref, $dir) + and warn "cammount failure: $!\n"; +warn "Failed to unmount\n" unless try_unmount(); +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; +} diff --git a/dev-camput b/dev-camput index a16e3d2bc..25aec9706 100755 --- a/dev-camput +++ b/dev-camput @@ -3,6 +3,7 @@ use strict; use FindBin qw($Bin); use Getopt::Long; +require "$Bin/misc/devlib.pl"; unless ($ENV{GOPATH}) { $ENV{GOPATH} = "$Bin/gopath" @@ -19,6 +20,8 @@ Getopt::Long::Configure("pass_through"); GetOptions("tls" => \$opt_tls) or usage(); +my $camput = build_bin("./cmd/camput"); + # Respected by camli/osutil: $ENV{"CAMLI_CONFIG_DIR"} = "$Bin/config/dev-client-dir"; @@ -32,7 +35,7 @@ if ($opt_tls) { $blobserver =~ s/^http/https/; } -exec("$ENV{GOPATH}/bin/camput", +exec("$camput", "--verbose", "--blobserver=$blobserver", @ARGV); diff --git a/dev-camsync b/dev-camsync index 706bb512e..bbee57def 100755 --- a/dev-camsync +++ b/dev-camsync @@ -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 $@ diff --git a/dev-db b/dev-db index 3148c4733..5598ffe77 100755 --- a/dev-db +++ b/dev-db @@ -1,4 +1,3 @@ #!/bin/sh -mysql -uroot -proot devcamli$USER - +exec mysql -uroot -proot devcamli$USER diff --git a/misc/devlib.pl b/misc/devlib.pl index f427359ce..d639949e9 100644 --- a/misc/devlib.pl +++ b/misc/devlib.pl @@ -15,8 +15,8 @@ sub build_bin { sub find_bin { my $target = shift; $target =~ s!.+/!!; - my $gp = find_arch_gopath(); - return "$gp/bin/$target"; + my $bin = find_gobin(); + return "$bin/$target"; } sub find_gobin {