lima icon indicating copy to clipboard operation
lima copied to clipboard

Optimize containerd/nerdctl upgrader script

Open AkihiroSuda opened this issue 3 years ago • 0 comments

https://github.com/lima-vm/lima/blob/ee32d35b22117763fa859e8902bf8607f83f13df/pkg/cidata/cidata.TEMPLATE.d/boot/40-install-containerd.sh#L11-L34


Idea for optimization:

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

AkihiroSuda avatar Mar 07 '22 05:03 AkihiroSuda