Serge Bazanski | f369cfa | 2020-05-22 18:36:42 +0200 | [diff] [blame] | 1 | // 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 | |
| 17 | package main |
| 18 | |
| 19 | import ( |
| 20 | "bytes" |
| 21 | "flag" |
| 22 | "io/ioutil" |
| 23 | "log" |
| 24 | ) |
| 25 | |
| 26 | var ( |
| 27 | flagShelfPath string |
| 28 | flagRepositoresBzlPath string |
| 29 | ) |
| 30 | |
| 31 | func 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 Bazanski | 14cf750 | 2020-05-28 14:29:56 +0200 | [diff] [blame] | 68 | depsCilium(p) |
Serge Bazanski | f369cfa | 2020-05-22 18:36:42 +0200 | [diff] [blame] | 69 | depsSQLBoiler(p) |
| 70 | |
| 71 | // our own deps, common |
| 72 | p.collectOverride("go.uber.org/zap", "v1.15.0") |
| 73 | p.collectOverride("golang.org/x/mod", "v0.3.0") |
| 74 | p.collect("github.com/cenkalti/backoff/v4", "v4.0.2") |
| 75 | |
| 76 | p.collect("github.com/google/go-tpm", "ae6dd98980d4") |
| 77 | p.collect("github.com/google/go-tpm-tools", "f8c04ff88181") |
| 78 | p.collect("github.com/insomniacslk/dhcp", "5dd7202f19711228cb4a51aa8b3415421c2edefe") |
| 79 | p.collect("github.com/mdlayher/ethernet", "0394541c37b7f86a10e0b49492f6d4f605c34163").use( |
| 80 | "github.com/mdlayher/raw", |
| 81 | ) |
| 82 | p.collect("github.com/rekby/gpt", "a930afbc6edcc89c83d39b79e52025698156178d") |
| 83 | p.collect("github.com/yalue/native_endian", "51013b03be4fd97b0aabf29a6923e60359294186") |
| 84 | |
| 85 | // used by insomniacslk/dhcp for pkg/uio |
| 86 | p.collect("github.com/u-root/u-root", "v6.0.0") |
| 87 | |
| 88 | // used by //core/cmd/mkimage |
| 89 | p.collect("github.com/diskfs/go-diskfs", "v1.0.0").use( |
| 90 | "gopkg.in/djherbis/times.v1", |
| 91 | ) |
Lorenz Brun | 878f5f9 | 2020-05-12 16:15:39 +0200 | [diff] [blame] | 92 | |
Serge Bazanski | f369cfa | 2020-05-22 18:36:42 +0200 | [diff] [blame] | 93 | // used by //build/bindata |
| 94 | p.collect("github.com/kevinburke/go-bindata", "v3.16.0") |
| 95 | |
| 96 | // used by deltagen |
Serge Bazanski | 14cf750 | 2020-05-28 14:29:56 +0200 | [diff] [blame] | 97 | p.collectOverride("github.com/lyft/protoc-gen-star", "v0.4.14") |
Serge Bazanski | f369cfa | 2020-05-22 18:36:42 +0200 | [diff] [blame] | 98 | |
Leopold Schabel | 3058b7a | 2020-06-03 17:51:07 +0200 | [diff] [blame] | 99 | // for interactive debugging during development (//:dlv alias) |
| 100 | depsDelve(p) |
| 101 | |
Lorenz Brun | 52f7f29 | 2020-06-24 16:42:02 +0200 | [diff] [blame] | 102 | // Used by //core/cmd/nanoswitch |
| 103 | p.collect("github.com/google/nftables", "7127d9d22474b437f0e8136ddb21855df29790bf").use( |
| 104 | "github.com/koneu/natend", |
Lorenz Brun | f042e6f | 2020-06-24 16:46:09 +0200 | [diff] [blame] | 105 | ) |
| 106 | |
| 107 | // used by //core//kubernetes/clusternet |
| 108 | p.collect("golang.zx2c4.com/wireguard/wgctrl", "ec7f26be9d9e47a32a2789f8c346031978485cbf").use( |
Lorenz Brun | 52f7f29 | 2020-06-24 16:42:02 +0200 | [diff] [blame] | 109 | "github.com/mdlayher/netlink", |
Lorenz Brun | f042e6f | 2020-06-24 16:46:09 +0200 | [diff] [blame] | 110 | "github.com/mdlayher/genetlink", |
Lorenz Brun | 52f7f29 | 2020-06-24 16:42:02 +0200 | [diff] [blame] | 111 | ) |
| 112 | |
Serge Bazanski | f369cfa | 2020-05-22 18:36:42 +0200 | [diff] [blame] | 113 | // First generate the repositories starlark rule into memory. This is because rendering will lock all unlocked |
| 114 | // dependencies, which might take a while. If a use were to interrupt it now, they would end up with an incomplete |
| 115 | // repositories.bzl and would have to restore from git. |
| 116 | buf := bytes.NewBuffer(nil) |
| 117 | err = p.render(buf) |
| 118 | if err != nil { |
| 119 | log.Fatalf("could not render deps: %v", err) |
| 120 | } |
| 121 | |
| 122 | err = ioutil.WriteFile(flagRepositoresBzlPath, buf.Bytes(), 0666) |
| 123 | if err != nil { |
| 124 | log.Fatalf("could not write deps: %v", err) |
| 125 | } |
| 126 | } |