diff --git a/scripts/build b/scripts/build index 26b72060a2..bb0bc07b03 100755 --- a/scripts/build +++ b/scripts/build @@ -8,13 +8,17 @@ PKG="github.com/rancher/k3s" PKG_CONTAINERD="github.com/containerd/containerd" PKG_RANCHER_CONTAINERD="github.com/rancher/containerd" PKG_CRICTL="github.com/kubernetes-sigs/cri-tools" +VENDOR_PREFIX= +if [ -z "$(go mod why 2>/dev/null)" ]; then + VENDOR_PREFIX="${PKG}/vendor/" +fi VERSIONFLAGS=" - -X $PKG/pkg/version.Version=$VERSION - -X $PKG/pkg/version.GitCommit=${COMMIT:0:8} - -X $PKG_CONTAINERD/version.Version=$VERSION_CONTAINERD - -X $PKG_CONTAINERD/version.Package=$PKG_RANCHER_CONTAINERD - -X $PKG_CRICTL/pkg/version.Version=$VERSION_CRICTL" + -X ${PKG}/pkg/version.Version=${VERSION} + -X ${PKG}/pkg/version.GitCommit=${COMMIT:0:8} + -X ${VENDOR_PREFIX}${PKG_CONTAINERD}/version.Version=${VERSION_CONTAINERD} + -X ${VENDOR_PREFIX}${PKG_CONTAINERD}/version.Package=${PKG_RANCHER_CONTAINERD} + -X ${VENDOR_PREFIX}${PKG_CRICTL}/pkg/version.Version=${VERSION_CRICTL}" LDFLAGS=" -w -s" STATIC="