Skip to content

Commit 38753ee

Browse files
authored
feat(libexec): support amd64 (#10)
1 parent a90e285 commit 38753ee

File tree

4 files changed

+147
-67
lines changed

4 files changed

+147
-67
lines changed

.github/workflows/release.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ jobs:
3535
with:
3636
fetch-depth: 1
3737

38-
- name: Set up Goenv
39-
run: |
40-
brew install goenv
38+
- name: Set up Go
39+
uses: actions/setup-go@v5
40+
with:
41+
go-version: '1.22.0'
4142

42-
- name: Exec
43+
- name: Build
4344
run: |
44-
./main.sh
45+
./main.sh arm64 && ./main.sh amd64
4546
env:
4647
CODESIGN_IDENTITY: ${{ secrets.MACOS_CODESIGN_IDENTITY }}
4748
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -62,14 +63,14 @@ jobs:
6263
- name: Gen Release Notes
6364
run: |
6465
echo '```' > ./release_notes.md
65-
cat ./out/sha256.txt >> ./release_notes.md
66+
shasum -a 256 libexec-darwin-*.tar.gz >> ./release_notes.md
6667
echo '```' >> ./release_notes.md
6768
6869
- name: Release
6970
uses: softprops/action-gh-release@v2
7071
with:
7172
files: |
72-
./out/*
73+
./libexec-darwin-*.tar.gz
7374
body_path: ./release_notes.md
7475
draft: false
7576
prerelease: false

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ $RECYCLE.BIN/
99
gvisor-tap-vsock
1010
krunkit
1111
*.tar.gz
12+
*_temp

main.sh

+126-60
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,126 @@
1-
#/bin/sh
2-
3-
set -ex
4-
5-
export WORK=`pwd`
6-
7-
if [ -z "$CODESIGN_IDENTITY" ]; then
8-
export CODESIGN_IDENTITY="-"
9-
fi
10-
11-
rm -rf ./out
12-
mkdir -p ./out
13-
export GOARCH=arm64
14-
export GOOS=darwin
15-
16-
# Gvp
17-
echo "Building gvp..."
18-
rm -rf gvisor-tap-vsock
19-
git clone https://github.com/containers/gvisor-tap-vsock.git
20-
cd gvisor-tap-vsock
21-
git checkout v0.8.1
22-
eval "$(goenv init -)"
23-
goenv install 1.22.0 -s
24-
goenv shell 1.22.0
25-
make gvproxy
26-
mv ./bin/gvproxy $WORK/out/gvproxy
27-
28-
# krun
29-
echo "Dwonloading krun..."
30-
cd $WORK
31-
rm -rf ./krunkit
32-
mkdir -p krunkit
33-
cd krunkit
34-
gh release download v0.1.4 -R containers/krunkit --pattern "krunkit-*" --clobber
35-
tar -zxvf krunkit-*.tgz -C ./
36-
mv bin/krunkit $WORK/out/krunkit
37-
mv lib/* $WORK/out/
38-
39-
cd $WORK
40-
41-
# codesign
42-
echo "Signing gvproxy..."
43-
codesign --force --sign $CODESIGN_IDENTITY --options=runtime --timestamp $WORK/out/gvproxy
44-
45-
echo "Signing krunkit..."
46-
codesign --force --sign $CODESIGN_IDENTITY --options=runtime --timestamp --entitlements krunkit.entitlements $WORK/out/krunkit
47-
48-
find $WORK/out -name "*.dylib" -type f -exec sh -c "echo 'Set {} permission to 755'; chmod 755 {}" ';'
49-
find $WORK/out -name "*.dylib" -type f -exec sh -c "echo 'Signing {}...'; codesign --force --sign $CODESIGN_IDENTITY --options=runtime --timestamp {}" ';'
50-
51-
# pack
52-
echo "Packing..."
53-
cd $WORK/out
54-
tar --no-mac-metadata -czvf ./libexec-$GOOS-$GOARCH.tar.gz .
55-
56-
# generate sha256
57-
cd $WORK/out
58-
echo "Generating sha256..."
59-
shasum -a 256 ./* > sha256.txt
60-
cat ./sha256.txt
1+
#! /usr/bin/env bash
2+
3+
set -e
4+
5+
_get_krunkit() {
6+
cd "$workspace"
7+
mkdir -p "$workspace/krunkit_temp"
8+
cd "$workspace/krunkit_temp"
9+
gh release download v0.1.4 -R containers/krunkit --pattern "krunkit-*" --clobber
10+
tar -zxvf krunkit-*.tgz -C ./
11+
mv bin/* lib/* "$workspace/out"
12+
cd "$workspace"
13+
}
14+
15+
_build_vfkit() {
16+
cd "$workspace"
17+
v_tag="v0.6.0"
18+
rm -rf ./vfkit_temp
19+
git clone https://github.com/crc-org/vfkit vfkit_temp
20+
cd ./vfkit_temp
21+
git checkout $v_tag
22+
make out/vfkit-amd64
23+
mv ./out/vfkit-amd64 "$workspace/out/vfkit"
24+
cd "$workspace"
25+
}
26+
27+
_build_gvproxy() {
28+
cd "$workspace"
29+
rm -rf gvisor-tap-vsock_temp
30+
git clone https://github.com/containers/gvisor-tap-vsock.git ./gvisor-tap-vsock_temp
31+
cd ./gvisor-tap-vsock_temp
32+
git checkout v0.8.1
33+
make gvproxy
34+
mv ./bin/gvproxy "$workspace/out/gvproxy"
35+
cd "$workspace"
36+
}
37+
38+
_pack_output() {
39+
cd "$workspace/out"
40+
tar --no-mac-metadata -zcvf "$workspace/libexec-$GOOS-$GOARCH.tar.gz" .
41+
cd "$workspace"
42+
}
43+
44+
_do_codesign() {
45+
if [[ -z "$CODESIGN_IDENTITY" ]]; then
46+
CODESIGN_IDENTITY="-"
47+
fi
48+
49+
test -f "$workspace/out/gvproxy" && {
50+
echo "Signing gvproxy..."
51+
codesign --force --sign "$CODESIGN_IDENTITY" --options=runtime --timestamp "$workspace/out/gvproxy"
52+
}
53+
54+
test -f "$workspace/out/vfkit" && {
55+
echo "Signing vfkit..."
56+
codesign --force --sign "$CODESIGN_IDENTITY" --options=runtime --timestamp --entitlements "$workspace/vf.entitlements" "$workspace/out/vfkit"
57+
}
58+
59+
test -f "$workspace/out/krunkit" && {
60+
echo "Signing krunkit..."
61+
codesign --force --sign "$CODESIGN_IDENTITY" --options=runtime --timestamp --entitlements "$workspace/krunkit.entitlements" "$workspace/out/krunkit"
62+
}
63+
64+
find "$workspace/out" -name "*.dylib" -type f -exec sh -c "echo 'Set {} permission to 755'; chmod 755 {}" ';'
65+
find "$workspace/out" -name "*.dylib" -type f -exec sh -c "echo 'Signing {}...'; codesign --force --sign $CODESIGN_IDENTITY --options=runtime --timestamp {}" ';'
66+
}
67+
68+
build_darwin_arm64() {
69+
export GOOS=darwin
70+
export GOARCH=arm64
71+
72+
echo "Build gvproxy"
73+
_build_gvproxy
74+
75+
echo "Download krunkit"
76+
_get_krunkit
77+
78+
echo "Do codesign"
79+
_do_codesign
80+
81+
echo "Packup output"
82+
_pack_output
83+
}
84+
85+
build_darwin_amd64() {
86+
export GOOS=darwin
87+
export GOARCH=amd64
88+
89+
echo "Build gvproxy"
90+
_build_gvproxy
91+
92+
echo "Build vfkit"
93+
_build_vfkit
94+
95+
echo "Do codesign"
96+
_do_codesign
97+
98+
echo "Packup output"
99+
_pack_output
100+
}
101+
102+
main() {
103+
target_arch=$1
104+
workspace="$(pwd)"
105+
if [[ -z $target_arch ]]; then
106+
echo "Error: missing target"
107+
exit 2
108+
fi
109+
110+
# Clean out dir first
111+
rm -rf "$workspace/out"
112+
mkdir -p "$workspace/out"
113+
114+
if [[ $target_arch == arm64 ]]; then
115+
echo "Building binaries for darwin arm64"
116+
build_darwin_arm64
117+
elif [[ $target_arch == amd64 ]]; then
118+
echo "Building binaries for darwin amd64"
119+
build_darwin_amd64
120+
else
121+
echo "Not support targer $target_arch"
122+
exit 2
123+
fi
124+
}
125+
126+
main "$@"

vf.entitlements

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.network.server</key>
6+
<true/>
7+
<key>com.apple.security.network.client</key>
8+
<true/>
9+
<key>com.apple.security.virtualization</key>
10+
<true/>
11+
</dict>
12+
</plist>

0 commit comments

Comments
 (0)