-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_script.sh
executable file
·52 lines (37 loc) · 1.46 KB
/
build_script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Script generated by ChatGPT
# Output directory
output_dir="out"
# Operating system
os="linux"
# List of architectures
architectures=("386" "amd64" "arm64" "armv6" "armv7")
# Checksums file name
checksums_file="$output_dir/checksums.txt"
# Remove the output directory if it already exists
rm -rf "$output_dir"
# Create the output directory
mkdir -p "$output_dir"
# Loop over architectures
for arch in "${architectures[@]}"; do
# Binary name
binary_name="power-linux-$arch"
# Full path of the binary
binary_path="$output_dir/$binary_name"
# Use go build to generate the binary
if [ "$arch" == "armv6" ] || [ "$arch" == "armv7" ]; then
GOOS=$os GOARCH=arm GOARM=$(if [ "$arch" == "armv6" ]; then echo 6; else echo 7; fi) go build -o "$binary_path"
else
GOOS=$os GOARCH=$arch go build -o "$binary_path"
fi
# Display a message indicating that the binary is built
echo "Binary $binary_name built successfully."
# Calculate the SHA256 checksum
checksum=$(sha256sum "$binary_path" | cut -d ' ' -f 1)
# Add the checksum to the checksums.txt file
echo "$checksum *$binary_name" >> "$checksums_file"
# Save the original output of sha256sum to a .sha256 file
(cd "$output_dir" && sha256sum "$binary_name" > "$binary_name.sha256")
done
# Display a message indicating that the process is complete
echo "Binaries, checksum files, and checksums.txt successfully generated in the $output_dir directory."