Skip to content

Commit 1645738

Browse files
thaJeztahestesp
authored andcommitted
script/setup: use git clone instead of go get -d
`go get -d` uses go modules by default in Go 1.16 and up, which results in modules being fetched for the "latest" module version, after which we tried to "git checkout" to `<VERSION>`. For runc, this means that (possibly incorrectly), `go get` will download runc `v0.1.1` (most recent non-"pre-release", which caused failures (e.g the old `Sirupsen/logrus` being downloaded). In addition, some of the dependencies we're installing use vendoring, and thus would not require the modules to be downloaded (and vendored files will be ignored when using `go get` with modules). This patch switches several uses `go get -d` to use a regular git clone, after which the desired version is checked out, and the binaries are built. Signed-off-by: Sebastiaan van Stijn <[email protected]> Signed-off-by: Phil Estes <[email protected]>
1 parent 5f2d02a commit 1645738

4 files changed

Lines changed: 13 additions & 12 deletions

File tree

script/setup/install-cni

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ CNI_COMMIT=$(grep containernetworking/plugins "$GOPATH"/src/github.com/container
2525
CNI_DIR=${DESTDIR:=''}/opt/cni
2626
CNI_CONFIG_DIR=${DESTDIR}/etc/cni/net.d
2727

28-
cd "$GOPATH"
29-
go get -d github.com/containernetworking/plugins/...
28+
git clone https://github.com/containernetworking/plugins.git "$GOPATH"/src/github.com/containernetworking/plugins
3029
cd "$GOPATH"/src/github.com/containernetworking/plugins
3130
git checkout $CNI_COMMIT
3231
./build_linux.sh

script/setup/install-cni-windows

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ WINCNI_BIN_DIR="${DESTDIR}/cni"
2121
WINCNI_PKG=github.com/Microsoft/windows-container-networking
2222
WINCNI_VERSION=aa10a0b31e9f72937063436454def1760b858ee2
2323

24-
cd "$GOPATH"
25-
go get -d "${WINCNI_PKG}/..."
24+
git clone "https://${WINCNI_PKG}.git" "${GOPATH}/src/${WINCNI_PKG}"
2625
cd "${GOPATH}/src/${WINCNI_PKG}"
2726
git checkout "${WINCNI_VERSION}"
2827
make all

script/setup/install-critools

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ set -eu -o pipefail
2323
cd "$GOPATH"
2424
go get -u github.com/onsi/ginkgo/ginkgo
2525
CRITEST_COMMIT=0f5f734a7e1da0979915c6e7d5b6641bd9dc2627
26-
go get -d github.com/kubernetes-sigs/cri-tools/...
26+
27+
git clone https://github.com/kubernetes-sigs/cri-tools.git "$GOPATH"/src/github.com/kubernetes-sigs/cri-tools
2728
cd "$GOPATH"/src/github.com/kubernetes-sigs/cri-tools
28-
git checkout $CRITEST_COMMIT
29+
git checkout "$CRITEST_COMMIT"
2930
make
3031
make install -e BINDIR=${DESTDIR:=''}/usr/local/bin
3132
cat << EOF | tee ${DESTDIR}/etc/crictl.yaml

script/setup/install-runc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,23 @@ set -eu -o pipefail
2323
function install_runc() {
2424
RUNC_COMMIT=$(grep opencontainers/runc "$GOPATH"/src/github.com/containerd/containerd/go.mod | awk '{print $2}')
2525

26-
cd "$GOPATH"
27-
go get -d github.com/opencontainers/runc
28-
cd "$GOPATH"/src/github.com/opencontainers/runc
29-
git checkout $RUNC_COMMIT
26+
TMPROOT=$(mktemp -d)
27+
git clone https://github.com/opencontainers/runc.git "${TMPROOT}"/runc
28+
pushd "${TMPROOT}"/runc
29+
git checkout "${RUNC_COMMIT}"
3030
make BUILDTAGS='apparmor seccomp selinux' runc
3131
make install
32+
popd
33+
rm -fR "${TMPROOT}"
3234
}
3335

3436
function install_crun() {
3537
CRUN_VERSION=0.17
36-
curl -o /usr/local/sbin/runc -L https://github.com/containers/crun/releases/download/${CRUN_VERSION}/crun-${CRUN_VERSION}-linux-$(go env GOARCH)
38+
curl -o /usr/local/sbin/runc -L https://github.com/containers/crun/releases/download/"${CRUN_VERSION}"/crun-"${CRUN_VERSION}"-linux-"$(go env GOARCH)"
3739
chmod +x /usr/local/sbin/runc
3840
}
3941

40-
: ${RUNC_FLAVOR:=runc}
42+
: "${RUNC_FLAVOR:=runc}"
4143
case ${RUNC_FLAVOR} in
4244
runc) install_runc ;;
4345
crun) install_crun ;;

0 commit comments

Comments
 (0)