blob: 7be11073ee03fdaf8b10c87594f30ed9e0aa580f [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"
24)
25
26var (
27 flagShelfPath string
28 flagRepositoresBzlPath string
29)
30
31func main() {
32 flag.StringVar(&flagShelfPath, "shelf_path", "", "Path to shelf (cache/lockfile)")
33 flag.StringVar(&flagRepositoresBzlPath, "repositories_bzl", "", "Path to output repositories.bzl file")
34 flag.Parse()
35
36 if flagShelfPath == "" {
37 log.Fatalf("shelf_path must be set")
38 }
39 if flagRepositoresBzlPath == "" {
40 log.Fatalf("repositories_bzl must be set")
41 }
42
43 shelf, err := shelfLoad(flagShelfPath)
44 if err != nil {
45 log.Fatalf("could not load shelf: %v", err)
46 }
47
48 p := &planner{
49 available: make(map[string]*dependency),
50 enabled: make(map[string]bool),
51 seen: make(map[string]string),
52
53 shelf: shelf,
54 }
55
56 // gRPC/proto deps (https://github.com/bazelbuild/rules_go/blob/master/go/workspace.rst#id8)
57 // bump down from 1.28.1 to 1.26.0 because https://github.com/etcd-io/etcd/issues/11563
58 p.collect(
59 "google.golang.org/grpc", "v1.26.0",
60 ).use(
61 "golang.org/x/net",
62 "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
Serge Bazanskid9ed6562021-01-07 16:06:44 +010085 // Used by //metropolis/build/mkimage
Serge Bazanskif369cfa2020-05-22 18:36:42 +020086 p.collect("github.com/diskfs/go-diskfs", "v1.0.0").use(
87 "gopkg.in/djherbis/times.v1",
88 )
Lorenz Brun878f5f92020-05-12 16:15:39 +020089
Serge Bazanskid9ed6562021-01-07 16:06:44 +010090 // Used by //metropolis/build/genosrelease
91 p.collect("github.com/joho/godotenv", "v1.3.0")
92
Serge Bazanskif369cfa2020-05-22 18:36:42 +020093 // used by //build/bindata
94 p.collect("github.com/kevinburke/go-bindata", "v3.16.0")
95
Leopold Schabel3058b7a2020-06-03 17:51:07 +020096 // for interactive debugging during development (//:dlv alias)
97 depsDelve(p)
98
Serge Bazanskid9ed6562021-01-07 16:06:44 +010099 // Used by //metropolis/test/nanoswitch
Lorenz Brun52f7f292020-06-24 16:42:02 +0200100 p.collect("github.com/google/nftables", "7127d9d22474b437f0e8136ddb21855df29790bf").use(
101 "github.com/koneu/natend",
Lorenz Brunf042e6f2020-06-24 16:46:09 +0200102 )
103
Serge Bazanskid9ed6562021-01-07 16:06:44 +0100104 // Used by //metropolis/node/core/network/dhcp4c
105 p.collect("github.com/google/gopacket", "v1.1.17")
106
Lorenz Brunf042e6f2020-06-24 16:46:09 +0200107 // used by //core//kubernetes/clusternet
108 p.collect("golang.zx2c4.com/wireguard/wgctrl", "ec7f26be9d9e47a32a2789f8c346031978485cbf").use(
Lorenz Brun52f7f292020-06-24 16:42:02 +0200109 "github.com/mdlayher/netlink",
Lorenz Brunf042e6f2020-06-24 16:46:09 +0200110 "github.com/mdlayher/genetlink",
Lorenz Brun52f7f292020-06-24 16:42:02 +0200111 )
112
Lorenz Brunb682ba52020-07-08 14:51:36 +0200113 p.collect(
114 "github.com/sbezverk/nfproxy", "7fac5f39824e7f34228b08ba8b7640770ca6a9f4",
115 patches("nfproxy.patch"),
116 ).use(
117 "github.com/sbezverk/nftableslib",
118 )
119
Lorenz Brunb29e0b02020-07-28 17:26:12 +0200120 p.collect("github.com/coredns/coredns", "v1.7.0",
121 prePatches("coredns-remove-unused-plugins.patch"),
122 ).use(
123 "github.com/caddyserver/caddy",
124 "github.com/dnstap/golang-dnstap",
125 "github.com/farsightsec/golang-framestream",
Lorenz Brunb29e0b02020-07-28 17:26:12 +0200126 "github.com/flynn/go-shlex",
Serge Bazanskid9ed6562021-01-07 16:06:44 +0100127 "github.com/grpc-ecosystem/grpc-opentracing",
128 "github.com/infobloxopen/go-trees",
129 "github.com/miekg/dns",
130 "github.com/opentracing/opentracing-go",
Lorenz Brunb29e0b02020-07-28 17:26:12 +0200131 )
132
Leopold Schabel26d41992020-12-15 19:27:58 +0100133 // goimports
134 p.collectOverride("golang.org/x/tools", "v0.0.0-20201215171152-6307297f4651")
135
Serge Bazanskif369cfa2020-05-22 18:36:42 +0200136 // First generate the repositories starlark rule into memory. This is because rendering will lock all unlocked
137 // dependencies, which might take a while. If a use were to interrupt it now, they would end up with an incomplete
138 // repositories.bzl and would have to restore from git.
139 buf := bytes.NewBuffer(nil)
140 err = p.render(buf)
141 if err != nil {
142 log.Fatalf("could not render deps: %v", err)
143 }
144
145 err = ioutil.WriteFile(flagRepositoresBzlPath, buf.Bytes(), 0666)
146 if err != nil {
147 log.Fatalf("could not write deps: %v", err)
148 }
149}