Skip to content

Commit dbc2b5a

Browse files
committed
build Buildkit from source so we can use forks
1 parent ff6f6ce commit dbc2b5a

File tree

7 files changed

+65
-44
lines changed

7 files changed

+65
-44
lines changed

bass/buildkit.bass

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
(def *buildkit-repository* "moby/buildkit")
22

33
; bumped by hack/bump-buildkit
4-
(def *buildkit-tag* "master")
4+
(def *buildkit-pkg* "github.com/sipsma/buildkit")
5+
(def *buildkit-commit* "9b0bdb600641f3dd1d96f54ac2d86581ab6433b2")
56

67
(def *cni-version* "v1.1.1")
78

89
(provide [image bass-config test-config]
910
(use (.git (linux/alpine/git)))
1011

1112
(defn image [os arch config-dir]
12-
(from (resolve {:platform {:os os} ; TODO: :arch arch}
13-
:repository *buildkit-repository*
14-
:tag *buildkit-tag*})
13+
(from (docker-build
14+
(git:checkout (str "https://" *buildkit-pkg*) *buildkit-commit*)
15+
{:os "linux"})
1516
($ apk add --no-cache dumb-init iptables ip6tables dnsmasq) ; TODO: nix?
1617
($ mkdir -p /opt/cni/bin/ /etc/buildkit/)
1718
($ cp $dnsname /opt/cni/bin/dnsname)

bass/bump-buildkit

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,63 @@
33
(use (.strings)
44
(.git (linux/alpine/git)))
55

6+
(def *canonical-pkg*
7+
"github.com/moby/buildkit")
8+
69
(defn main []
7-
(def {:src src :tag tag}
10+
(def {:src src
11+
(:pkg *canonical-pkg*) pkg
12+
(:ref "master") ref
13+
(:sha null) sha}
814
(next *stdin*))
915

10-
(let [bumped-go (bump-go src tag)]
16+
(def version
17+
(or sha (git:ls-remote (str "https://" pkg) ref)))
18+
19+
(let [bumped-go (bump-go src pkg version)]
1120
(write bumped-go/go.mod src/go.mod)
1221
(write bumped-go/go.sum src/go.sum))
1322

1423
(write
15-
(bump-bass src/bass/buildkit.bass tag)
24+
(bump-bass src/bass/buildkit.bass pkg version)
1625
src/bass/buildkit.bass))
1726

18-
(defn bump-go [src tag]
19-
(def buildkit
20-
(git:github/moby/buildkit/ref/ tag))
21-
22-
(def bumped-replaces
23-
(sync-replaces src/go.mod "buildkit" buildkit))
27+
(defn bump-go [src pkg commit]
28+
(let [buildkit (git:checkout (str "https://" pkg) commit)
29+
bumped-replaces (update-replaces src/go.mod "buildkit"
30+
pkg commit
31+
(find-replaces buildkit))]
32+
(from (linux/golang)
33+
(cd src
34+
($ cp $bumped-replaces ./go.mod)
35+
(if (= pkg *canonical-pkg*)
36+
(cache-go ($ go get (str pkg "@" commit)))
37+
($ echo using fork $pkg at $commit))
38+
(cache-go ($ go mod tidy))))))
2439

25-
(from (linux/golang)
26-
(cd src
27-
($ cp $bumped-replaces ./go.mod)
28-
(cache-go ($ go get (str "github.com/moby/buildkit@" tag)))
29-
(cache-go ($ go mod tidy)))))
30-
31-
(defn bump-bass [buildkit.bass tag]
40+
(defn bump-bass [buildkit.bass pkg commit]
3241
(from (linux/alpine)
33-
($ sed -e
42+
($ sed
43+
-e
44+
(str "s"
45+
"|(def \\*buildkit-pkg\\* \".*\")"
46+
"|"[:def :*buildkit-pkg* pkg] ; feelin cute, might refactor later
47+
"|")
48+
-e
3449
(str "s"
35-
"/(def \\*buildkit-tag\\* \".*\")"
36-
"/"[:def :*buildkit-tag* tag] ; feelin cute, might refactor later
50+
"/(def \\*buildkit-commit\\* \".*\")"
51+
"/"[:def :*buildkit-commit* commit] ; feelin cute, might refactor later
3752
"/")
3853
$buildkit.bass)))
3954

40-
(defn sync-replaces [gomod label replace-src]
41-
(update-replaces gomod label (find-replaces replace-src)))
42-
4355
(defn find-replaces [replace-src]
4456
(-> ($ sh -c "grep '^replace' $0 || true" replace-src/go.mod)
4557
(with-image (linux/alpine))
4658
(read :raw)
4759
next
4860
trim))
4961

50-
(defn escape-linebreaks [lines]
51-
(strings:join "\\\n" (strings:split lines "\n")))
52-
53-
(defn update-replaces [gomod label val]
62+
(defn update-replaces [gomod label pkg version replaces]
5463
(subpath
5564
(from (linux/alpine)
5665
($ cp $gomod ./go.mod)
@@ -61,13 +70,21 @@
6170
"c\\"
6271
; new content
6372
"// BEGIN SYNC " label "\\\n"
64-
(escape-linebreaks val) "\\\n"
73+
; replace canonical package with fork
74+
(if (= pkg *canonical-pkg*)
75+
""
76+
(str "replace " *canonical-pkg* " => " pkg " " version "\\\n"))
77+
; inline replace rules (if any) from upstream
78+
(escape-linebreaks replaces) "\\\n"
6579
; autofmt adds this blank line so be consistent
6680
"\\\n"
6781
"// END SYNC")
6882
./go.mod))
6983
./go.mod))
7084

85+
(defn escape-linebreaks [lines]
86+
(strings:join "\\\n" (strings:split lines "\n")))
87+
7188
(defn cache-go [thunk]
7289
(-> thunk
7390
(with-mount (cache-dir "bass go mod") /go/pkg/mod/)

bass/bump-image

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
(def {:src src
66
(:os "linux") os
77
(:arch "amd64") arch
8-
(:tag "dev") tag}
8+
(:tag buildkit:*buildkit-commit*) tag}
99
(next *stdin*))
1010

1111
(let [image (buildkit:image os arch buildkit:bass-config)
@@ -18,4 +18,5 @@
1818
($ sed -e (str "s/const Version = .*/const Version = \"" tag "\"/")
1919
$buildkitd.go))
2020
buildkitd.go)
21-
(log "bumped buildkitd.go"))
21+
22+
(log "bumped buildkitd.go" :tag tag))

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ require (
6565
github.com/charmbracelet/lipgloss v0.5.0 // indirect
6666
github.com/containerd/console v1.0.3 // indirect
6767
github.com/containerd/continuity v0.3.0 // indirect
68-
github.com/containerd/go-runc v1.0.0 // indirect
68+
github.com/containerd/go-runc v1.0.1-0.20230316182144-f5d58d02d6c8 // indirect
6969
github.com/containerd/typeurl/v2 v2.1.0 // indirect
7070
github.com/creack/pty v1.1.11 // indirect
7171
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect
7272
github.com/dlclark/regexp2 v1.4.0 // indirect
7373
github.com/docker/docker-credential-helpers v0.7.0 // indirect
74+
github.com/docker/go-units v0.5.0 // indirect
7475
github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776 // indirect
7576
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
7677
github.com/go-logr/logr v1.2.3 // indirect
@@ -130,5 +131,6 @@ require (
130131
)
131132

132133
// BEGIN SYNC buildkit
134+
replace github.com/moby/buildkit => github.com/sipsma/buildkit v0.6.1-0.20230401023155-9b0bdb600641
133135

134136
// END SYNC

go.sum

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,15 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH
110110
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
111111
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
112112
github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM=
113-
github.com/containerd/console v1.0.1/go.mod h1:XUsP6YE/mKtz6bxc+I8UiKKTP04qjQL4qcS3XoQ5xkw=
114113
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
115114
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
116115
github.com/containerd/containerd v1.7.0 h1:G/ZQr3gMZs6ZT0qPUZ15znx5QSdQdASW11nXTLTM2Pg=
117116
github.com/containerd/containerd v1.7.0/go.mod h1:QfR7Efgb/6X2BDpTPJRvPTYDE9rsF0FsXX9J8sIs/sc=
118117
github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg=
119118
github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM=
120119
github.com/containerd/fifo v1.1.0 h1:4I2mbh5stb1u6ycIABlBw9zgtlK8viPI9QkQNRQEEmY=
121-
github.com/containerd/go-runc v1.0.0 h1:oU+lLv1ULm5taqgV/CJivypVODI4SUz1znWjv3nNYS0=
122-
github.com/containerd/go-runc v1.0.0/go.mod h1:cNU0ZbCgCQVZK4lgG3P+9tn9/PaJNmoDXPpoJhDR+Ok=
120+
github.com/containerd/go-runc v1.0.1-0.20230316182144-f5d58d02d6c8 h1:PCkiJcIQIOyhwsVjN2AGZaItt+mKpw3sWsJB3eKmyyI=
121+
github.com/containerd/go-runc v1.0.1-0.20230316182144-f5d58d02d6c8/go.mod h1:3nyIw00YvKyqQHpVTwj21SepIlzVs2cYLEwJZdqQjwY=
123122
github.com/containerd/nydus-snapshotter v0.3.1 h1:b8WahTrPkt3XsabjG2o/leN4fw3HWZYr+qxo/Z8Mfzk=
124123
github.com/containerd/stargz-snapshotter v0.14.1 h1:M58AiJ+Kj50cabqYP1TpBPgUczKgn8zipmteC5FyjVs=
125124
github.com/containerd/stargz-snapshotter/estargz v0.14.1 h1:n9M2GDSWM96pyipFTA0DaU+zdtzi3Iwsnj/rIHr1yFM=
@@ -153,6 +152,7 @@ github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNk
153152
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
154153
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8=
155154
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
155+
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
156156
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
157157
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
158158
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
@@ -338,8 +338,6 @@ github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx
338338
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
339339
github.com/mna/pigeon v1.0.1-0.20200224192238-18953b277063 h1:V7s6vhIrNeOqocziAmRoVJh6gnPPx83ovlpT7Hf5shI=
340340
github.com/mna/pigeon v1.0.1-0.20200224192238-18953b277063/go.mod h1:rkFeDZ0gc+YbnrXPw0q2RlI0QRuKBBPu67fgYIyGRNg=
341-
github.com/moby/buildkit v0.11.0-rc3.0.20230331212110-3187d2d056de h1:qpJKlqT+l6opCfwRbuZXb/rsV3SAQykAMCldXrTkUxI=
342-
github.com/moby/buildkit v0.11.0-rc3.0.20230331212110-3187d2d056de/go.mod h1:GwK84qTEVfkyvAhd6aET84FRzND+lrQZC0pTesljST0=
343341
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
344342
github.com/moby/patternmatcher v0.5.0 h1:YCZgJOeULcxLw1Q+sVR636pmS7sPEn1Qo2iAN6M7DBo=
345343
github.com/moby/patternmatcher v0.5.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
@@ -383,7 +381,6 @@ github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3I
383381
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b h1:YWuSjZCQAPM8UUBLkYUk1e+rZcvWHJmFb6i6rM44Xs8=
384382
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ=
385383
github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs=
386-
github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
387384
github.com/opencontainers/runtime-spec v1.1.0-rc.1 h1:wHa9jroFfKGQqFHj0I1fMRKLl0pfj+ynAqBxo3v6u9w=
388385
github.com/opencontainers/runtime-spec v1.1.0-rc.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
389386
github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaLpt7tQ7oU=
@@ -424,6 +421,8 @@ github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX
424421
github.com/shibumi/go-pathspec v1.3.0 h1:QUyMZhFo0Md5B8zV8x2tesohbb5kfbpTi9rBnKh5dkI=
425422
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
426423
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
424+
github.com/sipsma/buildkit v0.6.1-0.20230401023155-9b0bdb600641 h1:UUFIpbN4aIZAMPwnQ5aHkWPJ4+759twFKgAH0qfxTro=
425+
github.com/sipsma/buildkit v0.6.1-0.20230401023155-9b0bdb600641/go.mod h1:kBeTvY8P9RlrJa8EJRglnsSVPtj19LTfoPlgBrdDnq0=
427426
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
428427
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
429428
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
@@ -663,7 +662,6 @@ golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7w
663662
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
664663
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
665664
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
666-
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
667665
golang.org/x/sys v0.0.0-20200918174421-af09f7315aff/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
668666
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
669667
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

hack/local-buildkit-image

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -e -u -x
44

55
tag=${1:-dev}
66

7-
./bass/buildkit-image -i os=linux -i arch=amd64 | bass --export > /tmp/buildkit-image.tar
7+
cd $(dirname $0)/..
88

9-
skopeo --insecure-policy copy oci-archive:/tmp/buildkit-image.tar docker-daemon:basslang/buildkit:$tag
9+
./bass/bump-image -i src=./ -i tag=$tag
10+
11+
docker pull basslang/buildkit:$tag

pkg/runtimes/util/buildkitd/buildkitd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
const DevTag = "dev"
2828

2929
// bumped *manually*
30-
const Version = "dev"
30+
const Version = "9b0bdb600641f3dd1d96f54ac2d86581ab6433b2"
3131

3232
const (
3333
// Long timeout to allow for slow image pulls of

0 commit comments

Comments
 (0)