You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.0 KiB

Name: etcd
Version: 3.5.4
Release: 1%{?dist}
Summary: Distributed reliable key-value store for the most critical data of a distributed system
License: ASL 2.0
URL: https://github.com/etcd-io/etcd
#Source0: https://github.com/etcd-io/etcd/archive/v%{version}.tar.gz
Source1: %{name}.service
Source2: %{name}.conf
%{?systemd_requires}
BuildRequires: systemd
Requires(pre): shadow-utils
%description
Distributed reliable key-value store for the most critical data of a distributed
system.
%prep
%setup -q -T -c %{name}-%{version}
%build
export GOPATH="`pwd`"
export CGO_ENABLED=0
export GO111MODULE=on
#mkdir -p go/src/go.etcd.io/
#cd go/src/go.etcd.io/
mkdir -p go/src/github.com/
cd go/src/github.com/
git clone https://github.com/etcd-io/etcd
cd etcd
git checkout v%{version}
go mod vendor
go build -v -installsuffix cgo -ldflags "-extldflags -s -w -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -X go.etcd.io/etc/version.Version=%{version} -X go.etcd.io/etc/version.GitSHA=%{gitversion}" -o etcd
cd etcdctl
go build -v -installsuffix cgo -ldflags "-extldflags -s -w -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -X go.etcd.io/etc/version.Version=%{version} -X go.etcd.io/etc/version.GitSHA=%{gitversion}" -o etcdctl
%install
install -pDm755 go/src/github.com/etcd/etcd %{buildroot}%{_sbindir}/etcd
install -pDm755 go/src/github.com/etcd/etcdctl/etcdctl %{buildroot}%{_bindir}/etcdctl
install -pDm644 %{SOURCE1} %{buildroot}%{_unitdir}/etcd.service
install -pDm640 %{SOURCE2} %{buildroot}%{_sysconfdir}/%{name}/etcd.conf
mkdir -p %{buildroot}%{_sharedstatedir}/%{name}
%pre
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}
%post
%systemd_post %{name}.service
%preun
%systemd_preun %{name}.service
%postun
%systemd_postun %{name}.service
%files
%{_sbindir}/etcd
%{_bindir}/etcdctl
%config(noreplace) %{_sysconfdir}/%{name}
%dir %attr(-,%{name},%{name}) %{_sharedstatedir}/%{name}
%{_unitdir}/%{name}.service
%changelog