Update vendor_build.sh

This commit is contained in:
2026-05-20 18:59:27 +00:00
parent 1649aaa293
commit d859b3215d

View File

@@ -7,7 +7,7 @@
# You may obtain a copy of the License at # You may obtain a copy of the License at
# https://opensource.org/licenses/CDDL-1.0 # https://opensource.org/licenses/CDDL-1.0
# #
# Скрипт сборки futriis с использованием vendoring зависимостей # Скрипт сборки futriix с использованием vendoring зависимостей
# Поддерживает Linux и Illumos (OpenIndiana) # Поддерживает Linux и Illumos (OpenIndiana)
# НЕ ТРЕБУЕТ GCC - использует CGO_ENABLED=0 для всех платформ # НЕ ТРЕБУЕТ GCC - использует CGO_ENABLED=0 для всех платформ
@@ -18,16 +18,16 @@ if [ -t 1 ]; then
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
CYAN='\033[1;36m' # Жирный-голубой (cyan) LIGHT_CYAN='\033[0;36m'
NC='\033[0m' NC='\033[0m'
else else
RED=''; GREEN=''; YELLOW=''; CYAN=''; NC='' RED=''; GREEN=''; YELLOW=''; LIGHT_CYAN=''; NC=''
fi fi
# Функции # Функции
error_msg() { echo -e "${RED}$1${NC}"; } error_msg() { echo -e "${RED}$1${NC}"; }
success_msg() { echo -e "${GREEN}$1${NC}"; } success_msg() { echo -e "${GREEN}$1${NC}"; }
info_msg() { echo -e "${CYAN}📋 $1${NC}"; } info_msg() { echo -e "${LIGHT_CYAN}📋 $1${NC}"; }
warning_msg() { echo -e "${YELLOW}⚠️ $1${NC}"; } warning_msg() { echo -e "${YELLOW}⚠️ $1${NC}"; }
print_separator() { echo "================================================"; } print_separator() { echo "================================================"; }
@@ -42,7 +42,6 @@ check_go() {
GO_VERSION=$(go version | awk '{print $3}') GO_VERSION=$(go version | awk '{print $3}')
success_msg "Go found: $GO_VERSION" success_msg "Go found: $GO_VERSION"
# Настраиваем Go proxy
go env -w GOPROXY=https://proxy.golang.org,direct 2>/dev/null || true go env -w GOPROXY=https://proxy.golang.org,direct 2>/dev/null || true
info_msg "Go proxy: $(go env GOPROXY)" info_msg "Go proxy: $(go env GOPROXY)"
} }
@@ -51,7 +50,6 @@ check_go() {
setup_vendor() { setup_vendor() {
info_msg "Checking vendor directory..." info_msg "Checking vendor directory..."
# Проверяем, нужно ли обновить vendor
NEED_VENDOR=false NEED_VENDOR=false
if [ ! -d "vendor" ] || [ ! -f "vendor/modules.txt" ]; then if [ ! -d "vendor" ] || [ ! -f "vendor/modules.txt" ]; then
@@ -87,7 +85,7 @@ create_bin_dir() {
build_static() { build_static() {
local target_os=$1 local target_os=$1
local target_arch="amd64" local target_arch="amd64"
local output_name="futriis-${target_os}-vendor" local output_name="futriix-${target_os}-vendor"
info_msg "Building for ${target_os} (static, no CGO)..." info_msg "Building for ${target_os} (static, no CGO)..."
@@ -98,9 +96,9 @@ build_static() {
local build_tags="" local build_tags=""
if [ "${target_os}" = "illumos" ] || [ "${target_os}" = "solaris" ]; then if [ "${target_os}" = "illumos" ] || [ "${target_os}" = "solaris" ]; then
build_tags="-tags=illumos" build_tags="-tags=illumos"
output_name="futriis-illumos-vendor" output_name="futriix-illumos-vendor"
elif [ "${target_os}" = "linux" ]; then elif [ "${target_os}" = "linux" ]; then
output_name="futriis-linux-vendor" output_name="futriix-linux-vendor"
fi fi
local output_path="bin/${output_name}" local output_path="bin/${output_name}"
@@ -129,15 +127,15 @@ build_current() {
export CGO_ENABLED=0 export CGO_ENABLED=0
local output_path="bin/futriis-current-vendor" local output_path="bin/futriix-current-vendor"
if go build -mod=vendor \ if go build -mod=vendor \
-ldflags="-s -w -X main.buildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ -ldflags="-s -w -X main.buildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o "${output_path}" ./cmd/futriis; then -o "${output_path}" ./cmd/futriis; then
success_msg "Current OS build successful: ${output_path}" success_msg "Current OS build successful: ${output_path}"
cp "${output_path}" ./futriis-current-vendor 2>/dev/null || true cp "${output_path}" ./futriix-current-vendor 2>/dev/null || true
info_msg "Binary copied to: ./futriis-current-vendor" info_msg "Binary copied to: ./futriix-current-vendor"
SIZE=$(ls -lh "${output_path}" | awk '{print $5}') SIZE=$(ls -lh "${output_path}" | awk '{print $5}')
info_msg "Binary size: $SIZE" info_msg "Binary size: $SIZE"
@@ -151,8 +149,8 @@ build_current() {
# Очистка # Очистка
clean() { clean() {
info_msg "Cleaning binary files..." info_msg "Cleaning binary files..."
rm -f bin/futriis-*-vendor rm -f bin/futriix-*-vendor
rm -f ./futriis-*-vendor rm -f ./futriix-*-vendor
success_msg "Clean completed" success_msg "Clean completed"
} }
@@ -209,7 +207,7 @@ show_help() {
# Основная функция # Основная функция
main() { main() {
print_separator print_separator
echo -e "${GREEN}🔨 Building futriis database with vendoring (no GCC required)${NC}" echo -e "${GREEN}🔨 Building futriix database with vendoring (no GCC required)${NC}"
print_separator print_separator
local os=$(uname -s | tr '[:upper:]' '[:lower:]') local os=$(uname -s | tr '[:upper:]' '[:lower:]')
@@ -258,11 +256,11 @@ main() {
success_msg "All builds completed successfully!" success_msg "All builds completed successfully!"
echo "" echo ""
info_msg "Generated binaries:" info_msg "Generated binaries:"
ls -lh bin/futriis-*-vendor 2>/dev/null || echo " No binaries in bin/" ls -lh bin/futriix-*-vendor 2>/dev/null || echo " No binaries in bin/"
echo "" echo ""
info_msg "To run the database:" info_msg "To run the database:"
echo " ./futriis-linux-vendor # On Linux" echo " ./futriix-linux-vendor # On Linux"
echo " ./futriis-illumos-vendor # On Illumos/OpenIndiana" echo " ./futriix-illumos-vendor # On Illumos/OpenIndiana"
echo "" echo ""
info_msg "Note: All binaries are statically linked and do not require GCC" info_msg "Note: All binaries are statically linked and do not require GCC"
else else
@@ -271,4 +269,4 @@ main() {
fi fi
} }
main "$@" main "$@"