Skip to content

Commit ee32d35

Browse files
authored
Merge pull request #694 from AkihiroSuda/auto-upgrade-nerdctl
cidata: automatically upgrade existing containerd/nerdctl ; nerdctl: update to v0.17.1
2 parents be578f2 + 35ebd33 commit ee32d35

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

pkg/cidata/cidata.TEMPLATE.d/boot/40-install-containerd.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
set -eux
33

44
if [ "${LIMA_CIDATA_CONTAINERD_SYSTEM}" != 1 ] && [ "${LIMA_CIDATA_CONTAINERD_USER}" != 1 ]; then
@@ -8,14 +8,31 @@ fi
88
# This script does not work unless systemd is available
99
command -v systemctl >/dev/null 2>&1 || exit 0
1010

11-
if [ ! -x /usr/local/bin/nerdctl ]; then
11+
# Extract bin/nerdctl and compare whether it is newer than the current /usr/local/bin/nerdctl (if already exists).
12+
# Takes 4-5 seconds. (FIXME: optimize)
13+
tmp_extract_nerdctl="$(mktemp -d)"
14+
tar Cxzf "${tmp_extract_nerdctl}" "${LIMA_CIDATA_MNT}"/nerdctl-full.tgz bin/nerdctl
15+
16+
if [ ! -f /usr/local/bin/nerdctl ] || [[ "${tmp_extract_nerdctl}"/bin/nerdctl -nt /usr/local/bin/nerdctl ]]; then
17+
if [ -f /usr/local/bin/nerdctl ]; then
18+
(
19+
set +e
20+
echo "Upgrading existing nerdctl"
21+
echo "- Old: $(/usr/local/bin/nerdctl --version)"
22+
echo "- New: $("${tmp_extract_nerdctl}"/bin/nerdctl --version)"
23+
systemctl disable --now containerd buildkit stargz-snapshotter
24+
sudo -iu "${LIMA_CIDATA_USER}" "XDG_RUNTIME_DIR=/run/user/${LIMA_CIDATA_UID}" "PATH=${PATH}" containerd-rootless-setuptool.sh uninstall
25+
)
26+
fi
1227
tar Cxzf /usr/local "${LIMA_CIDATA_MNT}"/nerdctl-full.tgz
1328

1429
mkdir -p /etc/bash_completion.d
1530
nerdctl completion bash >/etc/bash_completion.d/nerdctl
1631
# TODO: enable zsh completion too
1732
fi
1833

34+
rm -rf "${tmp_extract_nerdctl}"
35+
1936
if [ "${LIMA_CIDATA_CONTAINERD_SYSTEM}" = 1 ]; then
2037
mkdir -p /etc/containerd
2138
cat >"/etc/containerd/config.toml" <<EOF

pkg/limayaml/defaults.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ import (
2222
)
2323

2424
func defaultContainerdArchives() []File {
25-
const nerdctlVersion = "0.17.0"
25+
const nerdctlVersion = "0.17.1"
2626
location := func(goarch string) string {
2727
return "https://github.com/containerd/nerdctl/releases/download/v" + nerdctlVersion + "/nerdctl-full-" + nerdctlVersion + "-linux-" + goarch + ".tar.gz"
2828
}
2929
return []File{
3030
{
3131
Location: location("amd64"),
3232
Arch: X8664,
33-
Digest: "sha256:5eef74d5031b2f014a7f594e1f2ff319161a29f9309a56bee1a44fb90430a28d",
33+
Digest: "sha256:046ac1c3d007b9b64880cb15a78ea1e0be345d31f51ff282be783a9c203f299d",
3434
},
3535
{
3636
Location: location("arm64"),
3737
Arch: AARCH64,
38-
Digest: "sha256:b0ae2fc89d362afa18afcc35798d4da613096613d06cae07181b777cd66002e8",
38+
Digest: "sha256:b773a0db178af9d0963b7c84df88ee434e0c1986fe7491dc1de3231e071e3921",
3939
},
4040
}
4141
}

0 commit comments

Comments
 (0)