Blob Blame History Raw
%if 0%{?fedora} || 0%{?rhel} == 6
%global with_devel 1
%global with_bundled 0
%global with_debug 0
%global with_check 1
%global with_unit_test 1
%else
%global with_devel 0
%global with_bundled 0
%global with_debug 0
%global with_check 0
%global with_unit_test 0
%endif

%if 0%{?with_debug}
%global _dwz_low_mem_die_limit 0
%else
%global debug_package   %{nil}
%endif

%global provider        github
%global provider_tld    com
%global project         coreos
%global repo            go-systemd
# https://github.com/coreos/go-systemd
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path     %{provider_prefix}
%global commit          b4a58d95188dd092ae20072bac14cece0e67c388
%global shortcommit     %(c=%{commit}; echo ${c:0:7})

Name:           golang-%{provider}-%{project}-%{repo}
Version:        4
Release:        1%{?dist}
Summary:        Go bindings to systemd socket activation, journal and D-BUS APIs
License:        ASL 2.0
URL:            https://%{provider_prefix}
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz

# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm}}
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}

%description
%{summary}

%if 0%{?with_devel}
%package devel
Summary:       %{summary}
BuildArch:     noarch

%if 0%{?with_check}
BuildRequires: golang(github.com/godbus/dbus)
%endif

Requires:      golang(github.com/godbus/dbus)

Provides:      golang(%{import_path}/activation) = %{version}-%{release}
Provides:      golang(%{import_path}/daemon) = %{version}-%{release}
Provides:      golang(%{import_path}/dbus) = %{version}-%{release}
Provides:      golang(%{import_path}/journal) = %{version}-%{release}
Provides:      golang(%{import_path}/login1) = %{version}-%{release}
Provides:      golang(%{import_path}/machine1) = %{version}-%{release}
Provides:      golang(%{import_path}/sdjournal) = %{version}-%{release}
Provides:      golang(%{import_path}/unit) = %{version}-%{release}
Provides:      golang(%{import_path}/util) = %{version}-%{release}

%description devel
%{summary}

This package contains library source intended for
building other packages which use import path with
%{import_path} prefix.
%endif

%if 0%{?with_unit_test} && 0%{?with_devel}
%package unit-test
Summary:         Unit tests for %{name} package
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}

%if 0%{?with_check}
#Here comes all BuildRequires: PACKAGE the unit tests
#in %%check section need for running
%endif

# test subpackage tests code from devel subpackage
Requires:        %{name}-devel = %{version}-%{release}

%description unit-test
%{summary}

This package contains unit tests for project
providing packages with %{import_path} prefix.
%endif

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

%build

%install
# source codes for building projects
%if 0%{?with_devel}
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
# find all *.go but no *_test.go files and generate devel.file-list
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
done
%endif

# testing files for this project
%if 0%{?with_unit_test} && 0%{?with_devel}
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
# find all *_test.go files and generate unit-test.file-list
for file in $(find . -iname "*_test.go"); do
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
done
%endif

%if 0%{?with_devel}
sort -u -o devel.file-list devel.file-list
%endif

%check
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
%if ! 0%{?with_bundled}
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
%else
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath}
%endif

%if ! 0%{?gotest:1}
%global gotest go test
%endif

# needs port binding
#%gotest %{import_path}/activation
# need /var/run/dbus/system_bus_socket
#%gotest %{import_path}/dbus
# need /var/run/dbus/system_bus_socket
#%gotest %{import_path}/login1
# dbus_test.go:28: dial unix /var/run/dbus/system_bus_socket: connect: no such file or directory
#%gotest %{import_path}/machine1
# FAIL: TestSerialize, incorrent output
#%gotest %{import_path}/unit
%endif

#define license tag if not already defined
%{!?_licensedir:%global license %doc}

%if 0%{?with_devel}
%files devel -f devel.file-list
%license LICENSE
%doc README.md
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
%endif

%if 0%{?with_unit_test} && 0%{?with_devel}
%files unit-test -f unit-test.file-list
%license LICENSE
%doc README.md
%endif

%changelog
* Thu Nov 26 2015 jchaloup <jchaloup@redhat.com> - 4-1
- Bump to upstream b4a58d95188dd092ae20072bac14cece0e67c388
  related: #1248722

* Sat Sep 12 2015 jchaloup <jchaloup@redhat.com> - 3-3
- Update to spec-2.1
  related: #1248722

* Fri Sep 11 2015 jchaloup <jchaloup@redhat.com> - 3-2
- Bump to upstream cea488b4e6855fee89b6c22a811e3c5baca861b6
  related: #1248722

* Thu Aug 20 2015 jchaloup <jchaloup@redhat.com> - 3-1
- Bump to upstream be94bc700879ae8217780e9d141789a2defa302b
  related: #1248722

* Thu Jul 30 2015 jchaloup <jchaloup@redhat.com> - 2-8
- Update spec file to spec-2.0
  resolves: #1248722

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Tue Mar 31 2015 jchaloup <jchaloup@redhat.com> - 2-6
- Bump to upstream 7a81740665de3d730bf98811f6b2ae5746e42a32
  The last commit containing unchanged StartTransientUnit method (libcontainer)
  and still providing daemon package (fleet).
  related: #1165690

* Tue Mar 31 2015 jchaloup <jchaloup@redhat.com> - 2-5
- Bump to upstream fe2137a286b607d0023a8356cdc22a38098246b8
  related: #1165690

* Mon Mar 30 2015 jchaloup <jchaloup@redhat.com> - 2-4
- Bump to upstream 2d21675230a81a503f4363f4aa3490af06d52bb8
  related: #1165690

* Mon Jan 19 2015 jchaloup <jchaloup@redhat.com> - 2-3
- Adding missing Provides and removing superfluous Provides
  related: #1165690

* Wed Nov 19 2014 jchaloup <jchaloup@redhat.com> - 2-2
- Update to a606a1e936df81b70d85448221c7b1c6d8a74ef1 commit
  resolves: #1165688
- remove gopath and add golang >= 1.2.1-3
- add Requires on github.com/godbus/dbus

* Mon Jun 09 2014 Lokesh Mandvekar <lsm5@fedoraproject.org> - 2-1
- upstream version bump to v2
- change in NVR format since numbered versions are available

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0-0.5.git8514b9f
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Thu Apr 10 2014 Bobby Powers <bobbypowers@gmail.com> 0-0.4.git8514b9f
- update to latest upstream

* Fri Oct 18 2013 Lokesh Mandvekar <lsm5@redhat.com> 0-0.3.git68bc612
- double quotes removed from provides

* Mon Oct 14 2013 Lokesh Mandvekar <lsm5@redhat.com> 0-0.2.git68bc612
- provides golang("github.com/coreos/go-systemd")
- defattr removed

* Sat Oct 12 2013 Lokesh Mandvekar <lsm5@redhat.com> 0-0.1.git68bc612
- Initial fedora package