blob: b51187314f9f63e38e86db5dc8213da3fe39f9ce [file] [log] [blame]
Serge Bazanskif369cfa2020-05-22 18:36:42 +02001// Copyright 2020 The Monogon Project Authors.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17package main
18
19import (
20 "bytes"
21 "flag"
22 "io/ioutil"
23 "log"
Serge Bazanski116c4a62021-09-24 14:22:27 +020024 "os"
25 "path"
Serge Bazanskif369cfa2020-05-22 18:36:42 +020026
Serge Bazanski116c4a62021-09-24 14:22:27 +020027 "source.monogon.dev/build/toolbase"
28 "source.monogon.dev/build/toolbase/gotoolchain"
Serge Bazanskif369cfa2020-05-22 18:36:42 +020029)
30
31func main() {
Serge Bazanskif369cfa2020-05-22 18:36:42 +020032 flag.Parse()
33
Serge Bazanski116c4a62021-09-24 14:22:27 +020034 // TODO(q3k): factor out fietsje as a library, make it independent from
35 // monogon workspace assumptions.
36 wd, err := toolbase.WorkspaceDirectory()
37 if err != nil {
38 log.Fatalf("%v", err)
Serge Bazanskif369cfa2020-05-22 18:36:42 +020039 }
Serge Bazanski116c4a62021-09-24 14:22:27 +020040 shelfPath := path.Join(wd, "third_party/go/shelf.pb.text")
41 repositoriesBzlPath := path.Join(wd, "third_party/go/repositories.bzl")
42 os.Setenv("GOROOT", gotoolchain.Root)
Serge Bazanskif369cfa2020-05-22 18:36:42 +020043
Serge Bazanski116c4a62021-09-24 14:22:27 +020044 shelf, err := shelfLoad(shelfPath)
Serge Bazanskif369cfa2020-05-22 18:36:42 +020045 if err != nil {
46 log.Fatalf("could not load shelf: %v", err)
47 }
48
49 p := &planner{
50 available: make(map[string]*dependency),
51 enabled: make(map[string]bool),
52 seen: make(map[string]string),
53
54 shelf: shelf,
55 }
56
Serge Bazanski216fe7b2021-05-21 18:36:16 +020057 // Currently can't bump past v1.30.0, as that removes the old balancer.Picker API
58 // that go-etcd depends upon. See https://github.com/etcd-io/etcd/pull/12398 .
Serge Bazanskif369cfa2020-05-22 18:36:42 +020059 p.collect(
Serge Bazanskif12bedf2021-01-15 16:58:50 +010060 "google.golang.org/grpc", "v1.29.1",
Serge Bazanskif369cfa2020-05-22 18:36:42 +020061 ).use(
Serge Bazanskif369cfa2020-05-22 18:36:42 +020062 "golang.org/x/text",
63 )
64
65 depsKubernetes(p)
66 depsContainerd(p)
67 depsGVisor(p)
Serge Bazanskif369cfa2020-05-22 18:36:42 +020068
69 // our own deps, common
70 p.collectOverride("go.uber.org/zap", "v1.15.0")
71 p.collectOverride("golang.org/x/mod", "v0.3.0")
72 p.collect("github.com/cenkalti/backoff/v4", "v4.0.2")
73
74 p.collect("github.com/google/go-tpm", "ae6dd98980d4")
75 p.collect("github.com/google/go-tpm-tools", "f8c04ff88181")
Lorenz Bruna50e8452020-09-09 17:09:27 +020076 p.collect("github.com/google/certificate-transparency-go", "v1.1.0")
Lorenz Brun56a7ae62020-10-29 11:03:30 +010077 p.collect("github.com/insomniacslk/dhcp", "67c425063dcad32c5d14ce9a520c8865240dc945").use(
78 "github.com/mdlayher/ethernet",
Serge Bazanskif369cfa2020-05-22 18:36:42 +020079 "github.com/mdlayher/raw",
Lorenz Brun56a7ae62020-10-29 11:03:30 +010080 "github.com/u-root/u-root",
Serge Bazanskif369cfa2020-05-22 18:36:42 +020081 )
82 p.collect("github.com/rekby/gpt", "a930afbc6edcc89c83d39b79e52025698156178d")
83 p.collect("github.com/yalue/native_endian", "51013b03be4fd97b0aabf29a6923e60359294186")
84
Lorenz Brunb60d9cb2021-02-18 17:34:00 +010085 // Used by //build/bazel_cc_fix, override to make sure we use the latest version
86 p.collectOverride("github.com/mattn/go-shellwords", "v1.0.11")
87
Serge Bazanskid9ed6562021-01-07 16:06:44 +010088 // Used by //metropolis/build/mkimage
Serge Bazanskif369cfa2020-05-22 18:36:42 +020089 p.collect("github.com/diskfs/go-diskfs", "v1.0.0").use(
90 "gopkg.in/djherbis/times.v1",
91 )
Lorenz Brun878f5f92020-05-12 16:15:39 +020092
Serge Bazanskid9ed6562021-01-07 16:06:44 +010093 // Used by //metropolis/build/genosrelease
94 p.collect("github.com/joho/godotenv", "v1.3.0")
95
Serge Bazanskif369cfa2020-05-22 18:36:42 +020096 // used by //build/bindata
97 p.collect("github.com/kevinburke/go-bindata", "v3.16.0")
98
Leopold Schabel3058b7a2020-06-03 17:51:07 +020099 // for interactive debugging during development (//:dlv alias)
100 depsDelve(p)
101
Serge Bazanskid9ed6562021-01-07 16:06:44 +0100102 // Used by //metropolis/test/nanoswitch
Lorenz Brun52f7f292020-06-24 16:42:02 +0200103 p.collect("github.com/google/nftables", "7127d9d22474b437f0e8136ddb21855df29790bf").use(
104 "github.com/koneu/natend",
Lorenz Brunf042e6f2020-06-24 16:46:09 +0200105 )
106
Serge Bazanskid9ed6562021-01-07 16:06:44 +0100107 // Used by //metropolis/node/core/network/dhcp4c
108 p.collect("github.com/google/gopacket", "v1.1.17")
109
Lorenz Brunf042e6f2020-06-24 16:46:09 +0200110 // used by //core//kubernetes/clusternet
111 p.collect("golang.zx2c4.com/wireguard/wgctrl", "ec7f26be9d9e47a32a2789f8c346031978485cbf").use(
Lorenz Brun52f7f292020-06-24 16:42:02 +0200112 "github.com/mdlayher/netlink",
Lorenz Brunf042e6f2020-06-24 16:46:09 +0200113 "github.com/mdlayher/genetlink",
Lorenz Brun52f7f292020-06-24 16:42:02 +0200114 )
115
Lorenz Brunb682ba52020-07-08 14:51:36 +0200116 p.collect(
117 "github.com/sbezverk/nfproxy", "7fac5f39824e7f34228b08ba8b7640770ca6a9f4",
118 patches("nfproxy.patch"),
119 ).use(
120 "github.com/sbezverk/nftableslib",
121 )
122
Lorenz Brunb29e0b02020-07-28 17:26:12 +0200123 p.collect("github.com/coredns/coredns", "v1.7.0",
124 prePatches("coredns-remove-unused-plugins.patch"),
125 ).use(
126 "github.com/caddyserver/caddy",
127 "github.com/dnstap/golang-dnstap",
128 "github.com/farsightsec/golang-framestream",
Lorenz Brunb29e0b02020-07-28 17:26:12 +0200129 "github.com/flynn/go-shlex",
Serge Bazanskid9ed6562021-01-07 16:06:44 +0100130 "github.com/grpc-ecosystem/grpc-opentracing",
131 "github.com/infobloxopen/go-trees",
132 "github.com/miekg/dns",
133 "github.com/opentracing/opentracing-go",
Lorenz Brunb29e0b02020-07-28 17:26:12 +0200134 )
135
Leopold Schabel26d41992020-12-15 19:27:58 +0100136 // goimports
137 p.collectOverride("golang.org/x/tools", "v0.0.0-20201215171152-6307297f4651")
138
Serge Bazanski6ebdc412021-05-21 16:25:55 +0200139 // commentwrap is used as a nogo analyzer to stick to a maximum line
140 // length for comments.
141 // We have to patch both it and its only direct dependency to add generated
142 // go_tool_library targets. This is needed as Gazelle doesn't generate them,
143 // because they're a temporary solution to a problem that shouldn't exist soon:
144 // https://github.com/bazelbuild/rules_go/issues/2374
145 p.collect("github.com/corverroos/commentwrap", "2926638be44ce0c6c0ee2471e9b5ad9473c984cd",
146 patches("commentwrap-tool-library.patch"),
147 ).with(patches("reflow-tool-library.patch")).use(
148 "github.com/muesli/reflow",
149 )
150
Serge Bazanski216fe7b2021-05-21 18:36:16 +0200151 // First generate the repositories starlark rule into memory. This is because
152 // rendering will lock all unlocked dependencies, which might take a while. If a
153 // use were to interrupt it now, they would end up with an incomplete
Serge Bazanskif369cfa2020-05-22 18:36:42 +0200154 // repositories.bzl and would have to restore from git.
155 buf := bytes.NewBuffer(nil)
156 err = p.render(buf)
157 if err != nil {
158 log.Fatalf("could not render deps: %v", err)
159 }
160
Serge Bazanski116c4a62021-09-24 14:22:27 +0200161 err = ioutil.WriteFile(repositoriesBzlPath, buf.Bytes(), 0666)
Serge Bazanskif369cfa2020-05-22 18:36:42 +0200162 if err != nil {
163 log.Fatalf("could not write deps: %v", err)
164 }
165}