LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File consul.spec of Package consul (Project home:matya:branches:Virtualization:containers)

#
# spec file for package consul
#
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%if 0%{?suse_version} > 1230
%bcond_without systemd
%else
%bcond_with systemd
%endif

%define home_dir %{_localstatedir}/lib/%{name}
%define go_arches %ix86 x86_64 ppc64le aarch64

%ifarch %go_arches
%define go_tool go
%else
%define go_tool go-5
%endif

Name:           consul
Version:        0.8.3
Release:        0
Summary:        A tool for service discovery, monitoring and configuration
License:        Apache-2.0
Group:          System/Management
Url:            https://github.com/hashicorp/consul

Source0:        v%{version}.tar.gz
Source1:        %{name}-rpmlintrc
Source2:        %{name}.service
Source10:       %{name}.sysconfig
Source11:       %{name}.json

%if 0%{?suse_version} >= 1210
BuildRequires: systemd-rpm-macros
%endif
%{?systemd_requires}
BuildRequires:  golang-packaging
BuildRequires:  xz
%ifarch %go_arches
BuildRequires:  go >= 1.6
%else
BuildRequires:  gcc5-go >= 5.0
%endif

%if %{with systemd}
BuildRequires:  pkgconfig(systemd)
%{?systemd_requires}
%endif

%if 0%{?suse_version} > 1110
Requires(pre):  pwdutils
%else
Requires(pre):  shadow-utils
%endif

Requires(pre):  %{fillup_prereq}

%go_provides

BuildRoot:      %{_tmppath}/%{name}-%{version}-build


%description
A tool for service discovery and configuration, it is distributed, highly
available, and extremely scalable.


%prep
%setup -q -n %{name}-%{version}

%build
export GOPATH=$PWD/go
mkdir -p $GOPATH/src/github.com/hashicorp

# Copy the vendor directory into the GOPATH.
cp -r $PWD/vendor/* $GOPATH/src
ln -s $PWD $GOPATH/src/github.com/hashicorp/%{name}

%go_tool build -x -o %{name}-%{version}

%install
install -d -m 0755 %{buildroot}%{_bindir}
install -D -m 0755 %{name}-%{version} %{buildroot}%{_bindir}/%{name}

%if %{with systemd}
install -d -m 0755 %{buildroot}%{_unitdir}
install -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service

install -d -m 0755 %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%endif

install -d -m 0755 %{buildroot}%{_localstatedir}/adm/fillup-templates
install -m 0644 %{SOURCE10} %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}

install -d -m 0755 %{buildroot}%{_sysconfdir}/%{name}
install -D -m 0644 %{SOURCE11} %{buildroot}%{_sysconfdir}/%{name}/%{name}.json

install -d -m 750 %{buildroot}%{_localstatedir}/lib/%{name}


%pre
getent group %{name} >/dev/null || %{_sbindir}/groupadd -r %{name}
getent passwd %{name} >/dev/null || %{_sbindir}/useradd -r -g %{name} -d %{home_dir} -s /bin/false -c "Consul daemon" %{name}

%if %{with systemd}
%service_add_pre %{name}.service
%endif


%post
%if %{with systemd}
%{fillup_only -n %{name} %{name}}
%service_add_post %{name}.service
%endif


%preun
%if %{with systemd}
%service_del_preun %{name}.service
%endif


%postun
%if %{with systemd}
%service_del_postun %{name}.service
%endif


%files
%defattr(-,root,root,-)
%{_bindir}/consul

%if %{with systemd}
%attr(0644,root,root) %{_unitdir}/%{name}.service
%endif

%{_sbindir}/rc%{name}
%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}

%dir %attr(0750,%{name},root) %{_localstatedir}/lib/%{name}
%dir %config(noreplace) %attr(0750,root,%{name}) %{_sysconfdir}/%{name}
%config(noreplace) %attr(0640,root,%{name}) %{_sysconfdir}/%{name}/%{name}.json

%changelog