devtools/jiri-test: fix issues in release automation.

- In release production, add a step to build necessary tools.
- Fix some typos and output.

I tested this locally on jenkins-release-1 slave. Tomorrow
after a new snapshot is cut and tested, we could add another
Jenkins job (release-production maybe) that the oncall person
can manually start to automate the production release process.

Change-Id: I83a5809de1af3cfb9b097d35da00a84e4417a1d0
diff --git a/jiri-test/internal/test/release.go b/jiri-test/internal/test/release.go
index afddb1d..375b9cc 100644
--- a/jiri-test/internal/test/release.go
+++ b/jiri-test/internal/test/release.go
@@ -7,7 +7,6 @@
 import (
 	"bytes"
 	"fmt"
-	"io"
 	"os"
 	"path/filepath"
 	"regexp"
@@ -44,6 +43,14 @@
 	defaultReleaseTestTimeout = time.Minute * 5
 	manifestRE                = regexp.MustCompile(`^devmgr/.*<manifest snapshotpath="manifest/(.*)">`)
 
+	toolsPackages = []string{
+		"v.io/x/ref/services/agent/gcreds/",
+		"v.io/x/ref/services/agent/vbecome/",
+		"v.io/x/ref/services/debug/debug/",
+		"v.io/x/ref/services/device/device/",
+		"v.io/x/devtools/vbinary/",
+	}
+
 	serviceBinaries = []string{
 		"applicationd",
 		"binaryd",
@@ -85,16 +92,16 @@
 	}
 }
 
-// buildVanadiumBinaries builds all vanadium binaries.
-func (u *updater) buildVanadiumBinaries() error {
+// buildBinaries builds binaries for the given package pattern.
+func (u *updater) buildBinaries(pkgs ...string) error {
 	s := u.jirix.NewSeq()
 	args := []string{
 		"jiri",
 		"go",
 		"install",
 		"-tags=leveldb",
-		"v.io/...",
 	}
+	args = append(args, pkgs...)
 	u.outputCmd(args)
 	return s.Last(args[0], args[1:]...)
 }
@@ -138,11 +145,13 @@
 func (u *updater) downloadReleaseBinaries(binDir string) error {
 	s := u.jirix.NewSeq()
 	args := []string{
+		u.bin("vbinary"),
 		"--release",
 		"download",
 		"--output-dir=" + binDir,
 	}
-	return s.Last(u.bin("vbinary"), args...)
+	u.outputCmd(args)
+	return s.Last(args[0], args[1:]...)
 }
 
 // checkReleaseCandidateStatus checks whether the "latest" file in
@@ -153,11 +162,10 @@
 	s := u.jirix.NewSeq()
 	args := []string{
 		"cat",
-		fmt.Sprintf("%s/latest"),
+		fmt.Sprintf("%s/latest", bucket),
 	}
 	var out bytes.Buffer
-	stdout := io.MultiWriter(u.jirix.Stdout(), &out)
-	if err := s.Capture(stdout, nil).Last("gsutil", args...); err != nil {
+	if err := s.Capture(&out, nil).Last("gsutil", args...); err != nil {
 		return "", err
 	}
 	t, err := time.Parse(rcTimeFormat, out.String())
@@ -168,6 +176,7 @@
 	if t.Year() != now.Year() || t.Month() != now.Month() || t.Day() != now.Day() {
 		return "", fmt.Errorf("Release candidate (%v) not done for today", t)
 	}
+	fmt.Fprintf(u.jirix.Stdout(), "Snapshot timestamp: %s\n", out.String())
 	return out.String(), nil
 }
 
@@ -383,7 +392,7 @@
 		step{
 			msg: "Prepare binaries",
 			fn: func() error {
-				if err := u.buildVanadiumBinaries(); err != nil {
+				if err := u.buildBinaries("v.io/..."); err != nil {
 					return err
 				}
 				return u.uploadVanadiumBinaries(rcTimestamp)
@@ -421,13 +430,20 @@
 	defer u.jirix.NewSeq().RemoveAll(binDir)
 
 	// Make sure we got a release candidate today.
-	rcTimestamp, err := u.checkReleaseCandidateStatus()
-	if err != nil {
-		return nil, newInternalError(err, "Check release candidate")
+	rcTimestamp := ""
+	if result, err := invoker(jirix, "Check release candidate status", func() error {
+		rcTimestamp, err = u.checkReleaseCandidateStatus()
+		return err
+	}); result != nil || err != nil {
+		return result, err
 	}
 
 	steps := []step{
 		step{
+			msg: "Prepare tools",
+			fn:  func() error { return u.buildBinaries(toolsPackages...) },
+		},
+		step{
 			msg: "Download release binaries",
 			fn:  func() error { return u.downloadReleaseBinaries(binDir) },
 		},