Optimize containerd/nerdctl upgrader script
- Dominant language
- Go
- Stars
- 21.9k
- Forks
- 957
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 53
Description
https://github.com/lima-vm/lima/blob/ee32d35b22117763fa859e8902bf8607f83f13df/pkg/cidata/cidata.TEMPLATE.d/boot/40-install-containerd.sh#L11-L34
- - -
> Idea for optimization:
>
> ```console
> root@lima-default:/mnt/lima-cidata# gunzip -c nerdctl-full.tgz | head -c 512 | tar tv | awk '/ bin\/$/ {print $4}'
> 2022-03-03
> root@lima-default:/mnt/lima-cidata# date -r /usr/local/bin/nerdctl "+%F"
> 2022-03-03
> ```
> Then do simple string comparison on the dates.
>
> This relies on a tar header block being 512 bytes (so `tar` will not throw an error), and `bin/` being the first entry in the tarball. I think these are reasonable assumptions, but am not totally sure. If the first line doesn't return a non-empty string, fall back on the expensive check by extracting the tarball.
_Originally posted by @jandubois in https://github.com/lima-vm/lima/pull/694#discussion_r820375597_
Contributor guide
Assessment
This issue has not been assessed yet.