Skip to content

Commit fca4a0d

Browse files
committed
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 <github@gone.nl> Signed-off-by: Phil Estes <estesp@amazon.com> (cherry picked from commit 1645738) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 0dea191 commit fca4a0d

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

script/setup/install-cni

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +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-
go get -d github.com/containernetworking/plugins/...
28+
git clone https://github.com/containernetworking/plugins.git "$GOPATH"/src/github.com/containernetworking/plugins
2929
cd "$GOPATH"/src/github.com/containernetworking/plugins
3030
git checkout $CNI_COMMIT
3131
./build_linux.sh

script/setup/install-cni-windows

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

24-
go get -d "${WINCNI_PKG}/..."
24+
git clone "https://${WINCNI_PKG}.git" "${GOPATH}/src/${WINCNI_PKG}"
2525
cd "${GOPATH}/src/${WINCNI_PKG}"
2626
git checkout "${WINCNI_VERSION}"
2727
make all

script/setup/install-critools

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ set -eu -o pipefail
2222

2323
go get -u github.com/onsi/ginkgo/ginkgo
2424
CRITEST_COMMIT=2bf7674922a424337d7580a08166d666c6802818 # v1.18.0-100-g2bf7674
25-
go get -d github.com/kubernetes-sigs/cri-tools/...
25+
git clone https://github.com/kubernetes-sigs/cri-tools.git "$GOPATH"/src/github.com/kubernetes-sigs/cri-tools
2626
cd "$GOPATH"/src/github.com/kubernetes-sigs/cri-tools
27-
git checkout $CRITEST_COMMIT
27+
git checkout "$CRITEST_COMMIT"
2828
make
2929
sudo make install -e BINDIR=${DESTDIR:=''}/usr/local/bin
3030
cat << EOF | sudo tee ${DESTDIR}/etc/crictl.yaml

script/setup/install-runc

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

26-
go get -d github.com/opencontainers/runc
27-
cd "$GOPATH"/src/github.com/opencontainers/runc
28-
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}"
2930
make BUILDTAGS='apparmor seccomp selinux' runc
3031

3132
USESUDO=${USESUDO:-false}
@@ -35,6 +36,8 @@ function install_runc() {
3536
SUDO=''
3637
fi
3738
${SUDO} make install
39+
popd
40+
rm -fR "${TMPROOT}"
3841
}
3942

4043
function install_crun() {
@@ -43,7 +46,7 @@ function install_crun() {
4346
chmod +x /usr/local/sbin/runc
4447
}
4548

46-
: ${RUNC_FLAVOR:=runc}
49+
: "${RUNC_FLAVOR:=runc}"
4750
case ${RUNC_FLAVOR} in
4851
runc) install_runc ;;
4952
crun) install_crun ;;

0 commit comments

Comments
 (0)