eggo static compile

Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
This commit is contained in:
zhangxiaoyu 2021-09-07 16:56:33 +08:00
parent c7bb39dde0
commit ffd5b7662b
2 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,52 @@
From 2471b2b91c1e0581c386cf63a8db7e95a039ba8b Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Tue, 7 Sep 2021 16:36:44 +0800
Subject: [PATCH] eggo static compile
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
Makefile | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index e1cb535..9722c0c 100644
--- a/Makefile
+++ b/Makefile
@@ -9,26 +9,30 @@ LDFLAGS := -X isula.org/eggo/cmd.Version=$(VERSION) \
-X isula.org/eggo/cmd.BuildTime=$(SOURCE_DATE_EPOCH) \
-X isula.org/eggo/cmd.Arch=$(ARCH) \
$(EXTRALDFLAGS)
+STATIC_LDFLAGS := -extldflags=-static -linkmode=external
SAFEBUILDFLAGS := -buildmode=pie -extldflags=-ftrapv -extldflags=-zrelro -extldflags=-znow -tmpdir=/tmp/xxeggo $(LDFLAGS)
+GO := go
+GO_BUILD := CGO_ENABLED=0 $(GO)
+
.PHONY: eggo
eggo:
@echo "build eggo starting..."
- @go build -ldflags '$(LDFLAGS)' -o bin/eggo .
+ @$(GO_BUILD) build -ldflags '$(LDFLAGS) $(STATIC_LDFLAGS)' -o bin/eggo .
@echo "build eggo done!"
local:
@echo "build eggo use vendor starting..."
- @go build -ldflags '$(LDFLAGS)' -mod vendor -o bin/eggo .
+ @$(GO_BUILD) build -ldflags '$(LDFLAGS) $(STATIC_LDFLAGS)' -mod vendor -o bin/eggo .
@echo "build eggo use vendor done!"
test:
@echo "Unit tests starting..."
- @go test -race -cover -count=1 -timeout=300s ./...
+ @$(GO) test -race -cover -count=1 -timeout=300s ./...
@echo "Units test done!"
.PHONY: safe
safe:
@echo "build safe eggo starting..."
- go build -ldflags '$(SAFEBUILDFLAGS)' -o bin/eggo .
+ $(GO_BUILD) build -ldflags '$(SAFEBUILDFLAGS) $(STATIC_LDFLAGS)' -o bin/eggo .
@echo "build safe eggo done!"
images: image-eggo
--
2.25.1

View File

@ -1,6 +1,6 @@
Name: eggo
Version: 0.9.3
Release: 2
Release: 3
Summary: Eggo is a tool built to provide standard multi-ways for creating Kubernetes clusters.
License: Mulan PSL V2
URL: https://gitee.com/openeuler/eggo
@ -8,6 +8,7 @@ Source0: https://gitee.com/openeuler/eggo/repository/archive/v%{version}.tar.gz
Patch0001: 0001-remove-residual-objects.patch
Patch0002: 0002-remove-residual-in-infrastruce.patch
Patch0003: 0003-eggo-static-compile.patch
BuildRequires: make
BuildRequires: git
@ -48,6 +49,12 @@ rm -rf src
%attr(551,root,root) %{_bindir}/eggo
%changelog
* Tue Sep 07 2021 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 0.9.3-3
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:eggo static compile
* Tue Sep 07 2021 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 0.9.3-2
- Type:upgrade
- CVE:NA