Blob Blame History Raw
%if 0%{fedora}
# https://bugzilla.redhat.com/show_bug.cgi?id=995136#c12
%global _dwz_low_mem_die_limit 0
%else
%global debug_package   %{nil}
%endif
%global provider        github
%global provider_tld    com
%global project         skynetservices
%global repo            skydns
%global import_path     %{provider}.%{provider_tld}/%{project}/%{repo}
%global commit          6c94cbe92349cf550e64752a7cb72c98bcc44325
%global shortcommit     %(c=%{commit}; echo ${c:0:7})

Name:           golang-%{provider}-%{project}-%{repo}
Version:        0
Release:        0.4.git%{shortcommit}%{?dist}
Summary:        DNS service discovery for etcd 
License:        MIT
URL:            https://%{import_path}
Source0:        https://%{import_path}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
Source1:        %{repo}.service
Source2:        %{repo}.conf
ExclusiveArch:  %{ix86} x86_64 %{arm}

%description
%{summary}

%package -n %{repo}
Summary:        %{summary}
ExclusiveArch:  %{ix86} x86_64 %{arm}
BuildRequires: systemd
BuildRequires: golang >= 1.2.1-3
BuildRequires: golang(github.com/coreos/go-etcd/etcd)
BuildRequires: golang(github.com/coreos/go-systemd/activation)
BuildRequires: golang(github.com/miekg/dns)
BuildRequires: golang(github.com/prometheus/client_golang/prometheus)
BuildRequires: golang(github.com/rcrowley/go-metrics)
BuildRequires: golang(github.com/rcrowley/go-metrics/stathat)

Requires: etcd
Requires(pre):  shadow-utils
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd

Provides: %{repo} = %{version}-%{release}

%description -n %{repo}
%{summary}

%if 0%{?fedora}
%package devel
%if 0%{?fedora} >= 19
BuildArch:      noarch
%else
ExclusiveArch:  %{ix86} x86_64 %{arm}
%endif
BuildRequires: golang >= 1.2.1-3
BuildRequires: golang(github.com/coreos/go-etcd/etcd)
BuildRequires: golang(github.com/coreos/go-systemd/activation)
BuildRequires: golang(github.com/miekg/dns)
BuildRequires: golang(github.com/prometheus/client_golang/prometheus)
BuildRequires: golang(github.com/rcrowley/go-metrics)
BuildRequires: golang(github.com/rcrowley/go-metrics/stathat)
Requires: golang >= 1.2.1-3
Requires: golang(github.com/coreos/go-etcd/etcd)
Requires: golang(github.com/coreos/go-systemd/activation)
Requires: golang(github.com/miekg/dns)
Requires: golang(github.com/prometheus/client_golang/prometheus)
Requires: golang(github.com/rcrowley/go-metrics)
Requires: golang(github.com/rcrowley/go-metrics/stathat)
Summary: %{summary}
Provides: golang(%{import_path}/backends/etcd) = %{version}-%{release}
Provides: golang(%{import_path}/cache) = %{version}-%{release}
Provides: golang(%{import_path}/msg) = %{version}-%{release}
Provides: golang(%{import_path}/server) = %{version}-%{release}
Provides: golang(%{import_path}/stats) = %{version}-%{release}

%description devel
%{summary}

This package contains library source intended for 
building other packages which use %{project}/%{repo}.
%endif

%prep
%setup -q -n %{repo}-%{commit}

%build
%if 0%{?fedora}
# Make link for skydns itself
mkdir -p src/github.com/skynetservices
ln -s ../../../ src/github.com/skynetservices/skydns

export GOPATH=$(pwd):%{gopath}:$GOPATH
function gobuild { go build -a -ldflags "-B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')" -v -x "$@"; }
gobuild -o %{repo} %{import_path}
%else

%endif


%install
install -D -p -m 0755 %{repo} %{buildroot}%{_bindir}/%{repo}
install -D -p -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{repo}.service
install -d -m 0755 %{buildroot}%{_sysconfdir}/%{repo}
install -m 644 -t %{buildroot}%{_sysconfdir}/%{repo} %{SOURCE2}

# And create /var/lib/skydns, even if not used at the moment
install -d -m 0755 %{buildroot}%{_sharedstatedir}/%{repo}

%if 0%{?fedora}
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
cp -pav *.go %{buildroot}/%{gopath}/src/%{import_path}/
cp -rpav backends %{buildroot}/%{gopath}/src/%{import_path}/
cp -rpav cache %{buildroot}/%{gopath}/src/%{import_path}/
cp -rpav msg %{buildroot}/%{gopath}/src/%{import_path}/
cp -rpav server %{buildroot}/%{gopath}/src/%{import_path}/
cp -rpav stats %{buildroot}/%{gopath}/src/%{import_path}/
%endif

%check
%if 0%{?fedora}
GOPATH=%{buildroot}/%{gopath}:%{gopath} go test %{import_path}/msg
# server test takes more them 4 minutes, skipping
%endif

%pre
getent group %{repo} >/dev/null || groupadd -r %{repo}
getent passwd %{repo} >/dev/null || useradd -r -g %{repo} -d %{_sharedstatedir}/%{repo} \
        -s /sbin/nologin -c "etcd user" %{repo}

%post
%systemd_post %{repo}.service

%preun
%systemd_preun %{repo}.service

%postun
%systemd_postun %{repo}.service

%files -n %{repo}
%if 0%{?fedora}
%license LICENSE
%else
%doc LICENSE
%endif
%doc README.md CONTRIBUTORS AUTHORS
%{_bindir}/%{repo}
%dir %attr(-,%{repo},%{repo}) %{_sharedstatedir}/%{repo}
%{_unitdir}/%{repo}.service
%config(noreplace) %{_sysconfdir}/%{repo}

%if 0%{?fedora}
%files devel
%if 0%{?fedora}
%license LICENSE
%else
%doc LICENSE
%endif
%doc README.md CONTRIBUTORS AUTHORS
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
%{gopath}/src/%{import_path}
%endif

%changelog
* Wed Jun 03 2015 jchaloup <jchaloup@redhat.com> - 0-0.4.git6c94cbe
- Bump to upstream 6c94cbe92349cf550e64752a7cb72c98bcc44325
- Add skydns subpackage with skydns binary
- Add debuginfo
- Move LICENSE under license macro
- Add skydns.service and skydns.conf files
  related: #1181197

* Mon Jan 19 2015 jchaloup <jchaloup@redhat.com> - 0-0.3.git245a121
- Requires on kubernetes makes building of kubernetes failing.
  related: #1181197

* Sun Jan 18 2015 jchaloup <jchaloup@redhat.com> - 0-0.2.git245a121
- Fix Requires on kubernetes
  related: #1181197

* Mon Jan 12 2015 jchaloup <jchaloup@redhat.com> - 0-0.1.git245a121
- First package for Fedora
  resolves: #1181197