!42 [sync] PR-41: Avoid using C ldflags with Go compiler

From: @openeuler-sync-bot 
Reviewed-by: @duguhaotian 
Signed-off-by: @duguhaotian
This commit is contained in:
openeuler-ci-bot 2024-04-10 10:23:24 +00:00 committed by Gitee
commit 74c582f646
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -16,7 +16,7 @@
Name: %{project}-%{repo}
Version: 1.2.0
Release: 2
Release: 3
Summary: Libraries for use by writing CNI plugin
License: ASL 2.0
URL: https://github.com/containernetworking/plugins
@ -119,7 +119,7 @@ for d in $PLUGINS; do
if [ -d "$d" ]; then
plugin="$(basename "$d")"
echo " $plugin"
go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -s -w -linkmode=external -extldflags '%__global_ldflags %{?__golang_extldflags} -Wl,-z,now ' " -a -v -x -o "${PWD}/bin/$plugin" "$@" github.com/containernetworking/plugins/$d
go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags " -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -s -w -linkmode=external -extldflags '%__global_ldflags %{?__golang_extldflags} -Wl,-z,now ' " -a -v -x -o "${PWD}/bin/$plugin" "$@" github.com/containernetworking/plugins/$d
fi
done
@ -192,7 +192,7 @@ VERSIONFLAGS="
"
TAGS="apparmor seccomp netcgo osusergo providerless"
STATIC="-extldflags '-static -lm -ldl -lz -lpthread'"
GO111MODULE=off CGO_ENABLED=0 GOPATH=$TMPDIR go build -tags "$TAGS" -buildmode=pie -ldflags "$VERSIONFLAGS $LDFLAGS $STATIC -s -w -linkmode=external -extldflags '-Wl,-z,relro -Wl,-z,now ' " -o %{_builddir}/cni
GO111MODULE=off CGO_ENABLED=0 GOPATH=$TMPDIR go build -tags "$TAGS" -buildmode=pie -ldflags "$VERSIONFLAGS $STATIC -s -w -linkmode=external -extldflags '-Wl,-z,relro -Wl,-z,now ' " -o %{_builddir}/cni
%install
install -d -p %{buildroot}%{_libexecdir}/cni/
@ -313,6 +313,9 @@ export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath}
%changelog
* Fri Mar 1 2024 luofeng <luofeng13@huawei.com> - 1.2.0-3
- Avoid using C ldflags with Go compiler
* Thu Dec 28 2023 yaoxin <yao_xin001@hoperun.com> - 1.2.0-2
- Rebuild for golang cves: CVE-2023-24534,CVE-2023-24536,CVE-2023-24537 and CVE-2023-24538