Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lima-vm
GitHub Repository: lima-vm/lima
Path: blob/master/hack/validate-artifact.sh
1637 views
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
61
62