Fetch deterministic protobuf packages (fixes bots)

Context:
Our bots started failing a couple of days ago after proto-gen-go
changes were checked in to github.

This broke many people including us.
https://github.com/golang/protobuf/issues/763

This highlighted a known problem we have with deterministic builds -
we fetch a lot of unversioned packages (straight from their master)
which means that we are not only vulnerable to breaking changes, but
also that those changes can break previously good CELab commits.

We should eventually do that for all of our packages, but I've only
taken care of protobuf here.

Change-Id: I0facc895234f3247bee1202e9647e2dc4355518d
Reviewed-on: https://chromium-review.googlesource.com/c/1356765
Reviewed-by: Fei Ling <feiling@chromium.org>
diff --git a/Gopkg.lock b/Gopkg.lock
index cdd5c19..8946c58 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -2,146 +2,405 @@
 
 
 [[projects]]
+  digest = "1:60c758cdfbacefe1690da44509fce39483fdbc1b844518099a2064919d173916"
   name = "cloud.google.com/go"
-  packages = ["compute/metadata","iam","iam/admin/apiv1","internal","internal/optional","internal/version","logging","logging/apiv2","logging/internal","storage"]
+  packages = [
+    "compute/metadata",
+    "iam",
+    "iam/admin/apiv1",
+    "internal",
+    "internal/optional",
+    "internal/version",
+    "logging",
+    "logging/apiv2",
+    "logging/internal",
+    "storage",
+  ]
+  pruneopts = ""
   revision = "f6de2c509ed9d2af648c3c147207eaaf97149aed"
   version = "v0.14.0"
 
 [[projects]]
+  digest = "1:b13707423743d41665fd23f0c36b2f37bb49c30e94adb813319c44188a51ba22"
   name = "github.com/ghodss/yaml"
   packages = ["."]
+  pruneopts = ""
   revision = "0ca9ea5df5451ffdf184b4428c902747c2c11cd7"
   version = "v1.0.0"
 
 [[projects]]
-  branch = "master"
+  digest = "1:3dd078fda7500c341bc26cfbc6c6a34614f295a2457149fc1045cab767cbcf18"
   name = "github.com/golang/protobuf"
-  packages = ["descriptor","jsonpb","proto","protoc-gen-go/descriptor","ptypes","ptypes/any","ptypes/duration","ptypes/empty","ptypes/struct","ptypes/timestamp"]
-  revision = "9f81198da99b79e14d70ca2c3cc1bbe44c6e69b6"
+  packages = [
+    "descriptor",
+    "jsonpb",
+    "proto",
+    "protoc-gen-go/descriptor",
+    "ptypes",
+    "ptypes/any",
+    "ptypes/duration",
+    "ptypes/empty",
+    "ptypes/struct",
+    "ptypes/timestamp",
+  ]
+  pruneopts = ""
+  revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5"
+  version = "v1.2.0"
 
 [[projects]]
+  digest = "1:e097a364f4e8d8d91b9b9eeafb992d3796a41fde3eb548c1a87eb9d9f60725cf"
   name = "github.com/googleapis/gax-go"
   packages = ["."]
+  pruneopts = ""
   revision = "317e0006254c44a0ac427cc52a0e083ff0b9622f"
   version = "v2.0.0"
 
 [[projects]]
+  digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be"
   name = "github.com/inconshreveable/mousetrap"
   packages = ["."]
+  pruneopts = ""
   revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75"
   version = "v1.0"
 
 [[projects]]
+  digest = "1:1bea35e6d6ea2712107d20a9770cf331b5c18e17ba02d28011939d9bc7c67534"
   name = "github.com/kr/fs"
   packages = ["."]
+  pruneopts = ""
   revision = "1455def202f6e05b95cc7bfc7e8ae67ae5141eba"
   version = "v0.1.0"
 
 [[projects]]
+  digest = "1:9c032d03b1641ccdff4c200f05c06876d37d96ac536673af9e4d8cbac55ebec8"
   name = "github.com/mjibson/esc"
-  packages = [".","embed"]
+  packages = [
+    ".",
+    "embed",
+  ]
+  pruneopts = ""
   revision = "58d9cde84f237ecdd89bd7f61c2de2853f4c5c6e"
   version = "v0.1.0"
 
 [[projects]]
+  digest = "1:7365acd48986e205ccb8652cc746f09c8b7876030d53710ea6ef7d0bd0dcd7ca"
   name = "github.com/pkg/errors"
   packages = ["."]
+  pruneopts = ""
   revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
   version = "v0.8.0"
 
 [[projects]]
+  digest = "1:be514ceacb578d4e548d9cc4e62e36bebe97606e223c27edd55909a2e30bbf98"
   name = "github.com/pkg/sftp"
   packages = ["."]
+  pruneopts = ""
   revision = "6b9fa10dea25176501bd80eb8a45a46d2afc97ad"
   version = "v1.8.1"
 
 [[projects]]
+  digest = "1:a1403cc8a94b8d7956ee5e9694badef0e7b051af289caad1cf668331e3ffa4f6"
   name = "github.com/spf13/cobra"
   packages = ["."]
+  pruneopts = ""
   revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385"
   version = "v0.0.3"
 
 [[projects]]
+  digest = "1:8e243c568f36b09031ec18dff5f7d2769dcf5ca4d624ea511c8e3197dc3d352d"
   name = "github.com/spf13/pflag"
   packages = ["."]
+  pruneopts = ""
   revision = "583c0c0531f06d5278b7d917446061adc344b5cd"
   version = "v1.0.1"
 
 [[projects]]
+  digest = "1:7ae9ab20a379344cd296d7cd041180d547ba5489b8fd6e8919e0de24a94991b2"
   name = "go.opencensus.io"
-  packages = [".","exporter/stackdriver/propagation","internal","internal/tagencoding","plugin/ocgrpc","plugin/ochttp","plugin/ochttp/propagation/b3","stats","stats/internal","stats/view","tag","trace","trace/internal","trace/propagation"]
+  packages = [
+    ".",
+    "exporter/stackdriver/propagation",
+    "internal",
+    "internal/tagencoding",
+    "plugin/ocgrpc",
+    "plugin/ochttp",
+    "plugin/ochttp/propagation/b3",
+    "stats",
+    "stats/internal",
+    "stats/view",
+    "tag",
+    "trace",
+    "trace/internal",
+    "trace/propagation",
+  ]
+  pruneopts = ""
   revision = "6edeb78af2d9e4f169abb223feaef35da2e45d06"
   version = "v0.13.0"
 
 [[projects]]
   branch = "master"
+  digest = "1:4cae11053a5fc8e7b08228fcc14d161d3e60b64ba508a8b216937da472690991"
   name = "golang.org/x/crypto"
-  packages = ["curve25519","ed25519","ed25519/internal/edwards25519","internal/chacha20","internal/subtle","poly1305","ssh"]
+  packages = [
+    "curve25519",
+    "ed25519",
+    "ed25519/internal/edwards25519",
+    "internal/chacha20",
+    "internal/subtle",
+    "poly1305",
+    "ssh",
+  ]
+  pruneopts = ""
   revision = "de0752318171da717af4ce24d0a2e8626afaeb11"
 
 [[projects]]
   branch = "master"
+  digest = "1:5dc6753986b9eeba4abdf05dedc5ba06bb52dad43cc8aad35ffb42bb7adfa68f"
   name = "golang.org/x/net"
-  packages = ["context","context/ctxhttp","http/httpguts","http2","http2/hpack","idna","internal/timeseries","trace"]
+  packages = [
+    "context",
+    "context/ctxhttp",
+    "http/httpguts",
+    "http2",
+    "http2/hpack",
+    "idna",
+    "internal/timeseries",
+    "trace",
+  ]
+  pruneopts = ""
   revision = "db08ff08e8622530d9ed3a0e8ac279f6d4c02196"
 
 [[projects]]
   branch = "master"
+  digest = "1:4ffb71a9e1ea114fd29c3bdd2b46bcf9b197ca9154c419db50028257ff17783f"
   name = "golang.org/x/oauth2"
-  packages = [".","google","internal","jws","jwt"]
+  packages = [
+    ".",
+    "google",
+    "internal",
+    "jws",
+    "jwt",
+  ]
+  pruneopts = ""
   revision = "088f8e1d436e8d636f13cd83a345b3d6ff2f04ae"
 
 [[projects]]
   branch = "master"
+  digest = "1:b2ea75de0ccb2db2ac79356407f8a4cd8f798fe15d41b381c00abf3ae8e55ed1"
   name = "golang.org/x/sync"
   packages = ["semaphore"]
+  pruneopts = ""
   revision = "1d60e4601c6fd243af51cc01ddf169918a5407ca"
 
 [[projects]]
+  digest = "1:5acd3512b047305d49e8763eef7ba423901e85d5dd2fd1e71778a0ea8de10bd4"
   name = "golang.org/x/text"
-  packages = ["collate","collate/build","internal/colltab","internal/gen","internal/tag","internal/triegen","internal/ucd","language","secure/bidirule","transform","unicode/bidi","unicode/cldr","unicode/norm","unicode/rangetable"]
+  packages = [
+    "collate",
+    "collate/build",
+    "internal/colltab",
+    "internal/gen",
+    "internal/tag",
+    "internal/triegen",
+    "internal/ucd",
+    "language",
+    "secure/bidirule",
+    "transform",
+    "unicode/bidi",
+    "unicode/cldr",
+    "unicode/norm",
+    "unicode/rangetable",
+  ]
+  pruneopts = ""
   revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
   version = "v0.3.0"
 
 [[projects]]
   branch = "master"
+  digest = "1:ad0f86daae7be807bed607de3d7e10ffdd9bfa0ea5970a35f07537b9f7ff5a14"
   name = "gonum.org/v1/gonum"
-  packages = ["blas","blas/blas64","blas/gonum","floats","graph","graph/encoding","graph/encoding/dot","graph/formats/dot","graph/formats/dot/ast","graph/formats/dot/internal/astx","graph/formats/dot/internal/errors","graph/formats/dot/internal/lexer","graph/formats/dot/internal/parser","graph/formats/dot/internal/token","graph/internal/linear","graph/internal/ordered","graph/internal/set","graph/internal/uid","graph/simple","graph/topo","graph/traverse","internal/asm/c128","internal/asm/f32","internal/asm/f64","internal/math32","lapack","lapack/gonum","lapack/lapack64","mat"]
+  packages = [
+    "blas",
+    "blas/blas64",
+    "blas/gonum",
+    "floats",
+    "graph",
+    "graph/encoding",
+    "graph/encoding/dot",
+    "graph/formats/dot",
+    "graph/formats/dot/ast",
+    "graph/formats/dot/internal/astx",
+    "graph/formats/dot/internal/errors",
+    "graph/formats/dot/internal/lexer",
+    "graph/formats/dot/internal/parser",
+    "graph/formats/dot/internal/token",
+    "graph/internal/linear",
+    "graph/internal/ordered",
+    "graph/internal/set",
+    "graph/internal/uid",
+    "graph/simple",
+    "graph/topo",
+    "graph/traverse",
+    "internal/asm/c128",
+    "internal/asm/f32",
+    "internal/asm/f64",
+    "internal/math32",
+    "lapack",
+    "lapack/gonum",
+    "lapack/lapack64",
+    "mat",
+  ]
+  pruneopts = ""
   revision = "8b277688f55484af354d345d25f4c17bcd0e41a7"
 
 [[projects]]
   branch = "master"
+  digest = "1:7d15746ff4df12481c89fd953a28122fa75368fb1fb1bb1fed918a78647b3c3a"
   name = "google.golang.org/api"
-  packages = ["cloudkms/v1","cloudresourcemanager/v1","compute/v1","deploymentmanager/v2beta","gensupport","googleapi","googleapi/internal/uritemplates","googleapi/transport","iam/v1","internal","iterator","option","runtimeconfig/v1beta1","servicemanagement/v1","storage/v1","support/bundler","transport","transport/grpc","transport/http"]
+  packages = [
+    "cloudkms/v1",
+    "cloudresourcemanager/v1",
+    "compute/v1",
+    "deploymentmanager/v2beta",
+    "gensupport",
+    "googleapi",
+    "googleapi/internal/uritemplates",
+    "googleapi/transport",
+    "iam/v1",
+    "internal",
+    "iterator",
+    "option",
+    "runtimeconfig/v1beta1",
+    "servicemanagement/v1",
+    "storage/v1",
+    "support/bundler",
+    "transport",
+    "transport/grpc",
+    "transport/http",
+  ]
+  pruneopts = ""
   revision = "2eea9ba0a3d94f6ab46508083e299a00bbbc65f6"
 
 [[projects]]
+  digest = "1:c1771ca6060335f9768dff6558108bc5ef6c58506821ad43377ee23ff059e472"
   name = "google.golang.org/appengine"
-  packages = [".","internal","internal/app_identity","internal/base","internal/datastore","internal/log","internal/modules","internal/remote_api","internal/socket","internal/urlfetch","socket","urlfetch"]
+  packages = [
+    ".",
+    "internal",
+    "internal/app_identity",
+    "internal/base",
+    "internal/datastore",
+    "internal/log",
+    "internal/modules",
+    "internal/remote_api",
+    "internal/socket",
+    "internal/urlfetch",
+    "socket",
+    "urlfetch",
+  ]
+  pruneopts = ""
   revision = "b1f26356af11148e710935ed1ac8a7f5702c7612"
   version = "v1.1.0"
 
 [[projects]]
   branch = "master"
+  digest = "1:d88c2eb6750028f5707971ed1340a02407d5f0967af85bf6ac70c031533f6c15"
   name = "google.golang.org/genproto"
-  packages = ["googleapis/api/annotations","googleapis/api/distribution","googleapis/api/label","googleapis/api/metric","googleapis/api/monitoredres","googleapis/iam/admin/v1","googleapis/iam/v1","googleapis/logging/type","googleapis/logging/v2","googleapis/rpc/status","protobuf/field_mask"]
+  packages = [
+    "googleapis/api/annotations",
+    "googleapis/api/distribution",
+    "googleapis/api/label",
+    "googleapis/api/metric",
+    "googleapis/api/monitoredres",
+    "googleapis/iam/admin/v1",
+    "googleapis/iam/v1",
+    "googleapis/logging/type",
+    "googleapis/logging/v2",
+    "googleapis/rpc/status",
+    "protobuf/field_mask",
+  ]
+  pruneopts = ""
   revision = "32ee49c4dd805befd833990acba36cb75042378c"
 
 [[projects]]
+  digest = "1:5f31b45ee9da7a87f140bef3ed0a7ca34ea2a6d38eb888123b8e28170e8aa4f2"
   name = "google.golang.org/grpc"
-  packages = [".","balancer","balancer/base","balancer/roundrobin","codes","connectivity","credentials","credentials/oauth","encoding","encoding/proto","grpclog","internal","internal/backoff","internal/channelz","internal/grpcrand","keepalive","metadata","naming","peer","resolver","resolver/dns","resolver/passthrough","stats","status","tap","transport"]
+  packages = [
+    ".",
+    "balancer",
+    "balancer/base",
+    "balancer/roundrobin",
+    "codes",
+    "connectivity",
+    "credentials",
+    "credentials/oauth",
+    "encoding",
+    "encoding/proto",
+    "grpclog",
+    "internal",
+    "internal/backoff",
+    "internal/channelz",
+    "internal/grpcrand",
+    "keepalive",
+    "metadata",
+    "naming",
+    "peer",
+    "resolver",
+    "resolver/dns",
+    "resolver/passthrough",
+    "stats",
+    "status",
+    "tap",
+    "transport",
+  ]
+  pruneopts = ""
   revision = "168a6198bcb0ef175f7dacec0b8691fc141dc9b8"
   version = "v1.13.0"
 
 [[projects]]
+  digest = "1:f0620375dd1f6251d9973b5f2596228cc8042e887cd7f827e4220bc1ce8c30e2"
   name = "gopkg.in/yaml.v2"
   packages = ["."]
+  pruneopts = ""
   revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183"
   version = "v2.2.1"
 
 [solve-meta]
   analyzer-name = "dep"
   analyzer-version = 1
-  inputs-digest = "0428da8a3eb1fc892401c6d838a0bca6053a70c33cd8fd4aca1757f060b21e32"
+  input-imports = [
+    "cloud.google.com/go/compute/metadata",
+    "cloud.google.com/go/iam/admin/apiv1",
+    "cloud.google.com/go/logging",
+    "cloud.google.com/go/storage",
+    "github.com/ghodss/yaml",
+    "github.com/golang/protobuf/descriptor",
+    "github.com/golang/protobuf/jsonpb",
+    "github.com/golang/protobuf/proto",
+    "github.com/golang/protobuf/protoc-gen-go/descriptor",
+    "github.com/golang/protobuf/ptypes/any",
+    "github.com/mjibson/esc",
+    "github.com/pkg/errors",
+    "github.com/pkg/sftp",
+    "github.com/spf13/cobra",
+    "golang.org/x/crypto/ssh",
+    "golang.org/x/oauth2",
+    "golang.org/x/oauth2/google",
+    "gonum.org/v1/gonum/graph",
+    "gonum.org/v1/gonum/graph/encoding/dot",
+    "gonum.org/v1/gonum/graph/simple",
+    "gonum.org/v1/gonum/graph/topo",
+    "gonum.org/v1/gonum/graph/traverse",
+    "google.golang.org/api/cloudkms/v1",
+    "google.golang.org/api/cloudresourcemanager/v1",
+    "google.golang.org/api/compute/v1",
+    "google.golang.org/api/deploymentmanager/v2beta",
+    "google.golang.org/api/googleapi",
+    "google.golang.org/api/iam/v1",
+    "google.golang.org/api/option",
+    "google.golang.org/api/runtimeconfig/v1beta1",
+    "google.golang.org/api/servicemanagement/v1",
+    "google.golang.org/genproto/googleapis/iam/admin/v1",
+  ]
   solver-name = "gps-cdcl"
   solver-version = 1
diff --git a/Gopkg.toml b/Gopkg.toml
index 2c4819f..2bd3de3 100644
--- a/Gopkg.toml
+++ b/Gopkg.toml
@@ -9,8 +9,8 @@
   version = "0.14.0"
 
 [[constraint]]
-  branch = "master"
   name = "github.com/golang/protobuf"
+  version = "1.2.0"
 
 [[constraint]]
   branch = "master"
diff --git a/build.py b/build.py
index 7cfae7f..8bdd6d8 100755
--- a/build.py
+++ b/build.py
@@ -305,10 +305,6 @@
             protoc-gen-go which generates Go code. More information can be found including
             installation instructions at https://github.com/golang/protobuf.
 
-            A quick and portable way to get it is to run the following:
-
-                go get -u github.com/golang/protobuf/protoc-gen-go
-
             Rerun this script as 'build.py deps --install' to install "protoc-gen-go"
             automatically. If you've already done so, it may be that the GOBIN path is not
             in the system.
@@ -319,8 +315,8 @@
     verbose_flag += ["-v"]
 
   _RunCommand(
-      ['go', 'get', '-u'] + verbose_flag +
-      ['github.com/golang/protobuf/protoc-gen-go'],
+      ['go', 'install'] + verbose_flag +
+      ['./vendor/github.com/golang/protobuf/protoc-gen-go'],
       env=_MergeEnv(args, target_host=True),
       cwd=SOURCE_PATH)
 
@@ -396,14 +392,6 @@
 
   with open(os.devnull, 'r+') as f:
     _CheckAndInstall(
-        ['protoc-gen-go'],
-        _InstallGoProtoc,
-        env=_MergeEnv(args, target_host=True),
-        cwd=SOURCE_PATH,
-        stdin=f,
-        stdout=f,
-        stderr=f)
-    _CheckAndInstall(
         ['protoc', '--version'],
         _InstallProtoc,
         env=_MergeEnv(args, target_host=True),
@@ -468,6 +456,16 @@
   if update_deps:
     subprocess.check_call(['dep', 'prune'])
 
+  with open(os.devnull, 'r+') as f:
+    _CheckAndInstall(
+        ['protoc-gen-go'],
+        _InstallGoProtoc,
+        env=_MergeEnv(args, target_host=True),
+        cwd=SOURCE_PATH,
+        stdin=f,
+        stdout=f,
+        stderr=f)
+
   with open(sentinel, 'w') as f:
     pass