etcd/etcd.spec

172 lines
5.0 KiB
RPMSpec
Raw Normal View History

2020-08-18 10:22:31 +08:00
# Generated by go2rpm
%bcond_without check
2021-01-27 15:16:21 +08:00
%bcond_with bootstrap
%define debug_package %{nil}
2020-08-11 09:30:02 +08:00
2020-08-18 10:22:31 +08:00
# https://github.com/etcd-io/etcd
%global goipath go.etcd.io/etcd
%global forgeurl https://github.com/etcd-io/etcd
2021-01-27 15:16:21 +08:00
Version: 3.4.14
2020-08-11 09:30:02 +08:00
2021-01-27 15:16:21 +08:00
%global goipaths0 go.etcd.io/etcd
%global goipathsex0 go.etcd.io/etcd/etcdserver/api/v3rpc/
%if %{without bootstrap}
%global goipaths1 go.etcd.io/etcd/etcdserver/api/v3rpc/
%endif
2020-08-18 10:22:31 +08:00
2021-01-27 15:16:21 +08:00
%global goaltipaths github.com/coreos/etcd go.etcd.io/etcd/v3
%global man_version 3.4.14
2020-08-11 09:30:02 +08:00
2020-08-18 10:22:31 +08:00
%global common_description %{expand:
Distributed reliable key-value store for the most critical data of a distributed
system.}
2020-08-11 09:30:02 +08:00
2020-08-18 10:22:31 +08:00
%global golicenses LICENSE NOTICE
%global godocs CONTRIBUTING.md README.md Documentation\\\
README-*.md READMEv2-etcdctl.md
2020-08-11 09:30:02 +08:00
2020-08-18 10:22:31 +08:00
%global gosupfiles integration/fixtures/* etcdserver/api/v2http/testdata/*
2020-08-11 09:30:02 +08:00
2020-08-18 10:22:31 +08:00
Name: etcd
Release: 5
2020-08-18 10:22:31 +08:00
Summary: Distributed reliable key-value store for the most critical data of a distributed system
# Upstream license specification: Apache-2.0
2021-01-27 15:16:21 +08:00
License: ASL 2.0 and MIT
URL: https://github.com/etcd-io/etcd
Source0: etcd-%{version}.tar.gz
2020-08-18 10:22:31 +08:00
Source1: %{name}.service
Source2: %{name}.conf
Source3: man-%{man_version}.tar.gz
# sh genmanpages.sh path_to_built_source
Source10: genmanpages.sh
2021-01-27 15:16:21 +08:00
# update grpc-go version to v1.32.0
Patch1: 0001-Convert-int-to-string-using-strconv.Itoa.patch
Patch2: 0002-Etcd-on-unsupported-platform-without-ETCD_UNSUPPORTED_ARCH=arm64-set.patch
Patch3: 0003-etcd-Add-sw64-architecture.patch
2020-08-18 10:22:31 +08:00
BuildRequires: golang
2020-08-18 10:22:31 +08:00
BuildRequires: python3-devel
%{?systemd_requires}
BuildRequires: systemd
Requires(pre): shadow-utils
2020-08-11 09:30:02 +08:00
%description
2020-08-18 10:22:31 +08:00
%{common_description}
2020-08-11 09:30:02 +08:00
2020-08-18 10:22:31 +08:00
%gopkg
2020-08-11 09:30:02 +08:00
%prep
%setup -q -n man-%{man_version} -T -b 3
2020-08-18 10:22:31 +08:00
%forgesetup
2021-01-27 15:16:21 +08:00
%patch1 -p1
%patch2 -p1
%ifarch sw_64
%patch3 -p1
%endif
2020-08-18 10:22:31 +08:00
# For compatibility
cp -aR etcdserver/api/snap snap
cp -aR etcdserver/api/membership etcdserver/membership
cp -aR etcdserver/api/v2store store
for d in client clientv3 contrib etcdctl functional hack; do
mv $d/README.md README-$d.md
done
mv etcdctl/READMEv2.md READMEv2-etcdctl.md
2020-08-11 09:30:02 +08:00
mkdir -p man/man1
cp ../man-%{man_version}/*.1 man/man1/.
2021-01-27 15:16:21 +08:00
%if %{without bootstrap}
2020-08-11 09:30:02 +08:00
%build
CGO_CFLAGS="-fstack-protector-strong -fPIE -D_FORTIFY_SOURCE=2 -O2" \
CGO_LDFLAGS_ALLOW="-Wl,-z,relro,-z,now" \
CGO_LDFLAGS="-Wl,-z,relro,-z,now -Wl,-z,noexecstack" \
GO111MODULE=on GOFLAGS=-mod=vendor \
go build -buildmode=pie -ldflags "-linkmode=external -w -s" \
-o %{gobuilddir}/bin/etcd %{goipath}
2020-08-18 10:22:31 +08:00
for cmd in etcdctl; do
CGO_CFLAGS="-fstack-protector-strong -fPIE -D_FORTIFY_SOURCE=2 -O2" \
CGO_LDFLAGS_ALLOW="-Wl,-z,relro,-z,now" \
CGO_LDFLAGS="-Wl,-z,relro,-z,now -Wl,-z,noexecstack" \
GO111MODULE=on GOFLAGS=-mod=vendor \
go build -buildmode=pie -ldflags "-linkmode=external -w -s" \
-o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd
2020-08-18 10:22:31 +08:00
done
2021-01-27 15:16:21 +08:00
%endif
2020-08-11 09:30:02 +08:00
2020-08-18 10:22:31 +08:00
# make -C docs help
# make -C docs html
2020-08-11 09:30:02 +08:00
%install
2021-01-27 15:16:21 +08:00
%if %{without bootstrap}
2020-08-18 10:22:31 +08:00
install -m 0755 -vd %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
install -Dpm 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
install -dm 0755 %{buildroot}%{_sysconfdir}/%{name}
install -pm 644 -t %{buildroot}%{_sysconfdir}/%{name} %{SOURCE2}
2020-08-11 09:30:02 +08:00
# install manpages
install -d %{buildroot}%{_mandir}/man1
2020-08-18 10:22:31 +08:00
install -pm 644 man/man1/* %{buildroot}%{_mandir}/man1
2020-08-11 09:30:02 +08:00
# And create /var/lib/etcd
2020-08-18 10:22:31 +08:00
install -dm 0755 %{buildroot}%{_sharedstatedir}/%{name}
2021-01-27 15:16:21 +08:00
%endif
2020-08-18 10:22:31 +08:00
2021-01-27 15:16:21 +08:00
%if %{without bootstrap}
%if %{with check}
%check
GO111MODULE=on GOFLAGS=-mod=vendor go test $( GO111MODULE=on GOFLAGS=-mod=vendor go list ./... | grep -v -E "tlsutil|expect|tester|integration|e2e|backend|auth|ordering|snapshot|etcdserver|mvcc")
%endif
%endif
2020-08-11 09:30:02 +08:00
2021-01-27 15:16:21 +08:00
%if %{without bootstrap}
2020-08-11 09:30:02 +08:00
%pre
2020-08-18 10:22:31 +08:00
getent group %{name} >/dev/null || groupadd -r %{name}
getent passwd %{name} >/dev/null || useradd -r -g %{name} -d %{_sharedstatedir}/%{name} \
-s /sbin/nologin -c "etcd user" %{name}
2020-08-11 09:30:02 +08:00
%post
2020-08-18 10:22:31 +08:00
%systemd_post %{name}.service
2020-08-11 09:30:02 +08:00
%preun
2020-08-18 10:22:31 +08:00
%systemd_preun %{name}.service
2020-08-11 09:30:02 +08:00
%postun
2020-08-18 10:22:31 +08:00
%systemd_postun %{name}.service
2020-08-11 09:30:02 +08:00
%files
2020-08-18 10:22:31 +08:00
%license LICENSE NOTICE
%doc CONTRIBUTING.md README.md
%doc Documentation README-*.md READMEv2-etcdctl.md
%{_bindir}/*
%config(noreplace) %{_sysconfdir}/%{name}
%dir %attr(-,%{name},%{name}) %{_sharedstatedir}/%{name}
%{_unitdir}/%{name}.service
2020-08-11 09:30:02 +08:00
%{_mandir}/man1/*.1*
2021-01-27 15:16:21 +08:00
%endif
2020-08-18 10:22:31 +08:00
2020-08-11 09:30:02 +08:00
%changelog
* Wed Oct 19 2022 wuzx<wuzx1226@qq.com> - 3.4.14-5
- add sw64 patch
* Wed Sep 2021 jikui <jikui2@huawei.com> - 3.4.14-4
- modify build flags for secure compilation options
* Wed Jun 2021 jiangxinyu <jiangxinyu@kylinos.cn> - 3.4.14-3
- Solve the problem of etcd on unsupported platform without ETCD_UNSUPPORTED_ARCH=arm64 set
* Thu Mar 04 2021 jiangxinyu <jiangxinyu@kylinos.cn> - 3.4.14-2
- Remove the BuildRequires: go-compilers package
2021-01-27 15:16:21 +08:00
* Thu Jan 21 2021 jiangxinyu <jiangxinyu@kylinos.cn> - 3.4.14-1
- Update to 3.4.14
2020-08-18 10:22:31 +08:00
* Thu Aug 13 2020 jiangxinyu <jiangxinyu@kylinos.cn> - 3.4.7-1
2020-08-11 09:37:01 +08:00
- Init etcd project