lima
lima copied to clipboard
Optimize containerd/nerdctl upgrader script
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-03Then do simple string comparison on the dates.
This relies on a tar header block being 512 bytes (so
tarwill not throw an error), andbin/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