Skip to content

Commit 12bbe36

Browse files
authored
Merge pull request #3503 from AkihiroSuda/fix-3321
Makefile: split lima-additional-guestagents-*.tar.gz from lima-*.tar.gz
2 parents f20084e + 69815ea commit 12bbe36

File tree

5 files changed

+92
-7
lines changed

5 files changed

+92
-7
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ jobs:
8080
run: make artifacts-linux
8181
- name: "Make misc artifacts"
8282
run: make artifacts-misc
83+
- name: "Validate artifactts"
84+
run: ./hack/validate-artifact.sh ./_artifacts/*.tar.gz
8385
- name: "SHA256SUMS"
8486
run: |
8587
( cd _artifacts; sha256sum *.tar.gz ) | tee /tmp/SHA256SUMS

Makefile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ exe: _output/bin/limactl$(exe)
140140

141141
.PHONY: minimal native
142142
minimal: clean limactl native-guestagent default_template
143-
native: clean limactl helpers native-guestagent templates
143+
native: clean limactl helpers native-guestagent templates template_experimentals
144144

145145
################################################################################
146146
# Kconfig
@@ -291,7 +291,7 @@ ALL_GUESTAGENTS = $(addsuffix $(gz),$(ALL_GUESTAGENTS_NOT_COMPRESSED))
291291
guestagent_path = $(foreach arch,$(2),$($(1)_GUESTAGENT_PATH_COMMON)$(arch)$(gz))
292292

293293
ifeq ($(CONFIG_GUESTAGENT_OS_LINUX),y)
294-
NATIVE_GUESTAGENT_ARCH = $(shell uname -m | sed -e s/arm64/aarch64/)
294+
NATIVE_GUESTAGENT_ARCH = $(shell echo $(GOARCH) | sed -e s/arm64/aarch64/ -e s/arm/armv7l/ -e s/amd64/x86_64/)
295295
NATIVE_GUESTAGENT = $(call guestagent_path,LINUX,$(NATIVE_GUESTAGENT_ARCH))
296296
ADDITIONAL_GUESTAGENT_ARCHS = $(filter-out $(NATIVE_GUESTAGENT_ARCH),$(LINUX_GUESTAGENT_ARCHS))
297297
ADDITIONAL_GUESTAGENTS = $(call guestagent_path,LINUX,$(ADDITIONAL_GUESTAGENT_ARCHS))
@@ -510,6 +510,7 @@ generate:
510510

511511
################################################################################
512512
# _artifacts/lima-$(VERSION_TRIMMED)-$(ARTIFACT_OS)-$(ARTIFACT_UNAME_M)
513+
# _artifacts/lima-additional-guestagents-$(VERSION_TRIMMED)-$(ARTIFACT_OS)-$(ARTIFACT_UNAME_M)
513514
.PHONY: artifact
514515

515516
# returns the capitalized string of $(1).
@@ -535,11 +536,13 @@ endif
535536
ARTIFACT_OS = $(call capitalize,$(GOOS))
536537
ARTIFACT_UNAME_M = $(call to_uname_m,$(GOARCH))
537538
ARTIFACT_PATH_COMMON = _artifacts/lima-$(VERSION_TRIMMED)-$(ARTIFACT_OS)-$(ARTIFACT_UNAME_M)
539+
ARTIFACT_ADDITIONAL_GUESTAGENTS_PATH_COMMON = _artifacts/lima-additional-guestagents-$(VERSION_TRIMMED)-$(ARTIFACT_OS)-$(ARTIFACT_UNAME_M)
538540

539-
artifact: $(addprefix $(ARTIFACT_PATH_COMMON),$(ARTIFACT_FILE_EXTENSIONS))
541+
artifact: $(addprefix $(ARTIFACT_PATH_COMMON),$(ARTIFACT_FILE_EXTENSIONS)) \
542+
$(addprefix $(ARTIFACT_ADDITIONAL_GUESTAGENTS_PATH_COMMON),$(ARTIFACT_FILE_EXTENSIONS))
540543

541544
ARTIFACT_DES = _output/bin/limactl$(exe) $(LIMA_DEPS) $(HELPERS_DEPS) \
542-
$(ALL_GUESTAGENTS) \
545+
$(NATIVE_GUESTAGENT) \
543546
$(TEMPLATES) $(TEMPLATE_EXPERIMENTALS) \
544547
$(DOCUMENTATION) _output/share/doc/lima/templates \
545548
_output/share/man/man1/limactl.1
@@ -548,9 +551,18 @@ ARTIFACT_DES = _output/bin/limactl$(exe) $(LIMA_DEPS) $(HELPERS_DEPS) \
548551
$(ARTIFACT_PATH_COMMON).tar.gz: $(ARTIFACT_DES) | _artifacts
549552
$(TAR) -C _output/ --no-xattrs -czvf $@ ./
550553

554+
$(ARTIFACT_ADDITIONAL_GUESTAGENTS_PATH_COMMON).tar.gz:
555+
# FIXME: do not exec make from make
556+
make clean additional-guestagents
557+
$(TAR) -C _output/ --no-xattrs -czvf $@ ./
558+
551559
$(ARTIFACT_PATH_COMMON).zip: $(ARTIFACT_DES) | _artifacts
552560
cd _output && $(ZIP) -r ../$@ *
553561

562+
$(ARTIFACT_ADDITIONAL_GUESTAGENTS_PATH_COMMON).zip:
563+
make clean additional-guestagents
564+
cd _output && $(ZIP) -r ../$@ *
565+
554566
# generate manpages using native limactl.
555567
manpages-using-native-limactl: GOOS = $(GOHOSTOS)
556568
manpages-using-native-limactl: GOARCH = $(GOHOSTARCH)
@@ -582,7 +594,7 @@ artifact-%-arm64 artifact-%-aarch64 artifact-arm64 artifact-aarch64: GOARCH = ar
582594

583595
# build cross arch binaries.
584596
artifact-%: $$(call generate_manpages_if_needed)
585-
make artifact GOOS=$(GOOS) GOARCH=$(GOARCH)
597+
make clean artifact GOOS=$(GOOS) GOARCH=$(GOARCH)
586598

587599
.PHONY: artifacts-misc
588600
artifacts-misc: | _artifacts

hack/validate-artifact.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
# SPDX-FileCopyrightText: Copyright The Lima Authors
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# This script validates that lima-<VERSION>-Darwin-arm64.tar.gz
7+
# contains lima-guestagent.Linux-aarch64
8+
# but does not contain share/lima/lima-guestagent.Linux-x86_64
9+
10+
set -eu -o pipefail
11+
12+
must_contain() {
13+
tmp="$(mktemp)"
14+
tar tzf "$1" >"$tmp"
15+
if ! grep -q "$2" "$tmp"; then
16+
echo >&2 "ERROR: $1 must contain $2"
17+
cat "$tmp"
18+
rm -f "$tmp"
19+
exit 1
20+
fi
21+
rm -f "$tmp"
22+
}
23+
24+
must_not_contain() {
25+
tmp="$(mktemp)"
26+
tar tzf "$1" >"$tmp"
27+
if grep -q "$2" "$tmp"; then
28+
echo >&2 "ERROR: $1 must not contain $2"
29+
cat "$tmp"
30+
rm -f "$tmp"
31+
exit 1
32+
fi
33+
rm -f "$tmp"
34+
}
35+
36+
validate_artifact() {
37+
FILE="$1"
38+
MYARCH="x86_64"
39+
OTHERARCH="aarch64"
40+
if [[ $FILE == *"aarch64"* || $FILE == *"arm64"* ]]; then
41+
MYARCH="aarch64"
42+
OTHERARCH="x86_64"
43+
fi
44+
if [[ $FILE == *"go-mod-vendor.tar.gz" ]]; then
45+
: NOP
46+
elif [[ $FILE == *"lima-additional-guestagents"*".tar.gz" ]]; then
47+
must_not_contain "$FILE" "lima-guestagent.Linux-$MYARCH"
48+
must_contain "$FILE" "lima-guestagent.Linux-$OTHERARCH"
49+
elif [[ $FILE == *"lima-"*".tar.gz" ]]; then
50+
must_not_contain "$FILE" "lima-guestagent.Linux-$OTHERARCH"
51+
must_contain "$FILE" "lima-guestagent.Linux-$MYARCH"
52+
else
53+
echo >&2 "ERROR: Unexpected file: $FILE"
54+
exit 1
55+
fi
56+
}
57+
58+
for FILE in "$@"; do
59+
validate_artifact "$FILE"
60+
done

website/content/en/docs/installation/_index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ and extract it under `/usr/local` (or somewhere else).
4646
```bash
4747
VERSION=$(curl -fsSL https://api.github.com/repos/lima-vm/lima/releases/latest | jq -r .tag_name)
4848
curl -fsSL "https://github.com/lima-vm/lima/releases/download/${VERSION}/lima-${VERSION:1}-$(uname -s)-$(uname -m).tar.gz" | tar Cxzvm /usr/local
49+
50+
# For Lima v1.1 onward
51+
curl -fsSL "https://github.com/lima-vm/lima/releases/download/${VERSION}/lima-additional-guestagents-${VERSION:1}-$(uname -s)-$(uname -m).tar.gz" | tar Cxzvm /usr/local
4952
```
5053
{{% /tab %}}
5154
{{< /tabpane >}}

website/content/en/docs/installation/source.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,21 @@ export PATH=$HOME/.local/bin:$PATH
3636
## Packaging Lima for Distribution
3737
After building Lima from source, you may want to package it for installation on other machines:
3838

39+
1. The package for the core component and the native guest agent:
3940
```bash
41+
make clean native
4042
cd _output
41-
# Create a compressed archive
4243
tar czf lima-package.tar.gz *
4344
```
4445

45-
This package can then be transferred and installed on the target system.
46+
2. The package for the additional guest agents:
47+
```
48+
make clean additional-guestagents
49+
cd _output
50+
tar czf lima-additional-guestagents-package.tar.gz *
51+
```
52+
53+
These packages can then be transferred and installed on the target system.
4654

4755
## Advanced Configuration with Kconfig Tools
4856
(This step is not needed for most users)

0 commit comments

Comments
 (0)