containerd/script/setup/install-runhcs-shim
Danny Canter 15b13fb3ea Windows: Supply windows shim version via file
Somewhat similar to how we supply the version of runc to grab for testing via
a file in script/, this change supplies the Windows shim version to build off
of via a file in the same directory. This seems like a decent home given it now
lives next to the script that pulls and builds the shim to include in our build
artifacts/locally.

The motivation behind this change is:

Cut down on unneccessary hcsshim vendorings if no library code for containerd
changed. It was some what clunky how the Windows builds work today. The Windows
shim is developed out of tree at github.com/microsoft/hcsshim. To let containerd know
what tag to build the shim off of we'd vendor hcsshim into containerd, and then
parse the version string from go.mod, fetch this tag, and then build the shim and
include it in our artifacts. As mentioned, often times the vendoring would bring in
no actual changes that would affect containerd's usage of hcsshim as a library, and
would just serve as a means to bump the version of the containerd shim we should build.

Now this process can be a one line change and we can avoid the possible headaches that come
with bumping go.mod (bumping other unrelated deps etc.)

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-08-28 11:55:55 -07:00

46 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright The containerd Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
scripts_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
: ${RUNHCS_VERSION:="$(cat $scripts_path/runhcs-version)"}
: ${RUNHCS_REPO:="https://github.com/Microsoft/hcsshim.git"}
: ${HCSSHIM_SRC:=''}
: ${DESTDIR:=''}
: ${GOOS:="windows"}
tmpdir="$(mktemp -d)"
cleanup() {
rm -rf "$tmpdir"
}
trap 'cleanup' EXIT
export GOOS
if [ "$HCSSHIM_SRC" == "" ]
then
set -e -x
cd "$tmpdir"
git init .
git remote add origin "$RUNHCS_REPO"
git fetch --tags --depth=1 origin ${RUNHCS_VERSION}
else
cd "${HCSSHIM_SRC}"
fi
git checkout "refs/tags/${RUNHCS_VERSION}" || git checkout "refs/heads/${RUNHCS_VERSION}" || git checkout "${RUNHCS_VERSION}"
GO111MODULE=on go build -mod=vendor -o "${DESTDIR}/containerd-shim-runhcs-v1.exe" ./cmd/containerd-shim-runhcs-v1