Skip to content

Commit 5b0919a

Browse files
authored
Merge pull request #3087 from afbjorklund/nerdctl-archive
Refactor the containerd archive compression
2 parents f765918 + 96ca88a commit 5b0919a

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ command -v systemctl >/dev/null 2>&1 || exit 0
1414
# Extract bin/nerdctl and compare whether it is newer than the current /usr/local/bin/nerdctl (if already exists).
1515
# Takes 4-5 seconds. (FIXME: optimize)
1616
tmp_extract_nerdctl="$(mktemp -d)"
17-
tar Cxzf "${tmp_extract_nerdctl}" "${LIMA_CIDATA_MNT}"/nerdctl-full.tgz bin/nerdctl
17+
tar Cxaf "${tmp_extract_nerdctl}" "${LIMA_CIDATA_MNT}"/"${LIMA_CIDATA_CONTAINERD_ARCHIVE}" bin/nerdctl
1818

1919
if [ ! -f "${LIMA_CIDATA_GUEST_INSTALL_PREFIX}"/bin/nerdctl ] || [[ "${tmp_extract_nerdctl}"/bin/nerdctl -nt "${LIMA_CIDATA_GUEST_INSTALL_PREFIX}"/bin/nerdctl ]]; then
2020
if [ -f "${LIMA_CIDATA_GUEST_INSTALL_PREFIX}"/bin/nerdctl ]; then
@@ -28,7 +28,7 @@ if [ ! -f "${LIMA_CIDATA_GUEST_INSTALL_PREFIX}"/bin/nerdctl ] || [[ "${tmp_extra
2828
sudo -iu "${LIMA_CIDATA_USER}" "XDG_RUNTIME_DIR=/run/user/${LIMA_CIDATA_UID}" "PATH=${PATH}" containerd-rootless-setuptool.sh uninstall
2929
)
3030
fi
31-
tar Cxzf "${LIMA_CIDATA_GUEST_INSTALL_PREFIX}" "${LIMA_CIDATA_MNT}"/nerdctl-full.tgz
31+
tar Cxaf "${LIMA_CIDATA_GUEST_INSTALL_PREFIX}" "${LIMA_CIDATA_MNT}"/"${LIMA_CIDATA_CONTAINERD_ARCHIVE}"
3232

3333
mkdir -p /etc/bash_completion.d
3434
nerdctl completion bash >/etc/bash_completion.d/nerdctl

pkg/cidata/cidata.TEMPLATE.d/lima.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ LIMA_CIDATA_CONTAINERD_SYSTEM=1
2929
{{- else}}
3030
LIMA_CIDATA_CONTAINERD_SYSTEM=
3131
{{- end}}
32+
{{- if or .Containerd.User .Containerd.System}}
33+
LIMA_CIDATA_CONTAINERD_ARCHIVE={{.Containerd.Archive}}
34+
{{- end}}
3235
LIMA_CIDATA_SLIRP_DNS={{.SlirpDNS}}
3336
LIMA_CIDATA_SLIRP_GATEWAY={{.SlirpGateway}}
3437
LIMA_CIDATA_SLIRP_IP_ADDRESS={{.SlirpIPAddress}}

pkg/cidata/cidata.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func templateArgs(bootScripts bool, instDir, name string, instConfig *limayaml.L
116116
if err := limayaml.Validate(instConfig, false); err != nil {
117117
return nil, err
118118
}
119+
archive := "nerdctl-full.tgz"
119120
args := TemplateArgs{
120121
Debug: debugutil.Debug,
121122
BootScripts: bootScripts,
@@ -127,7 +128,7 @@ func templateArgs(bootScripts bool, instDir, name string, instConfig *limayaml.L
127128
UID: *instConfig.User.UID,
128129
GuestInstallPrefix: *instConfig.GuestInstallPrefix,
129130
UpgradePackages: *instConfig.UpgradePackages,
130-
Containerd: Containerd{System: *instConfig.Containerd.System, User: *instConfig.Containerd.User},
131+
Containerd: Containerd{System: *instConfig.Containerd.System, User: *instConfig.Containerd.User, Archive: archive},
131132
SlirpNICName: networks.SlirpNICName,
132133

133134
RosettaEnabled: *instConfig.Rosetta.Enabled,
@@ -407,14 +408,15 @@ func GenerateISO9660(instDir, name string, instConfig *limayaml.LimaYAML, udpDNS
407408
})
408409

409410
if nerdctlArchive != "" {
411+
nftgz := args.Containerd.Archive
410412
nftgzR, err := os.Open(nerdctlArchive)
411413
if err != nil {
412414
return err
413415
}
414416
defer nftgzR.Close()
415417
layout = append(layout, iso9660util.Entry{
416418
// ISO9660 requires len(Path) <= 30
417-
Path: "nerdctl-full.tgz",
419+
Path: nftgz,
418420
Reader: nftgzR,
419421
})
420422
}

pkg/cidata/template.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ type Cert struct {
2929
}
3030

3131
type Containerd struct {
32-
System bool
33-
User bool
32+
System bool
33+
User bool
34+
Archive string
3435
}
3536
type Network struct {
3637
MACAddress string

website/content/en/docs/dev/internals.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ The volume label is "cidata", as defined by [cloud-init NoCloud](https://docs.cl
187187
- `LIMA_CIDATA_MOUNTTYPE`: the type of the Lima mounts ("reverse-sshfs", "9p", ...)
188188
- `LIMA_CIDATA_CONTAINERD_USER`: set to "1" if rootless containerd to be set up
189189
- `LIMA_CIDATA_CONTAINERD_SYSTEM`: set to "1" if system-wide containerd to be set up
190+
- `LIMA_CIDATA_CONTAINERD_ARCHIVE`: the name of the containerd archive. `nerdctl-full.tgz`
190191
- `LIMA_CIDATA_SLIRP_GATEWAY`: set to the IP address of the host on the SLIRP network. `192.168.5.2`.
191192
- `LIMA_CIDATA_SLIRP_DNS`: set to the IP address of the DNS on the SLIRP network. `192.168.5.3`.
192193
- `LIMA_CIDATA_SLIRP_IP_ADDRESS`: set to the IP address of the guest on the SLIRP network. `192.168.5.15`.

0 commit comments

Comments
 (0)