File syncthing.spec of Package syncthing

#
# spec file for package 
#
# Copyright (c) 2014 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/
#

Name:           syncthing
Version:        0.14.44
Release:        0
License:        MIT
Summary:        Open Source Continuous Replication / Cluster Synchronization Thing
Url:            http://discourse.syncthing.net/
Group:          Productivity/Networking/Other
Source0:        https://github.com/syncthing/syncthing/archive/v%{version}.tar.gz
Source1:        %{name}@.service
BuildRequires:  go >= 1.5
BuildRequires:  go-devel
BuildRequires:  systemd
#Provides:
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
This is the syncthing project. The following are the project goals:

Define a protocol for synchronization of a file repository between a number of collaborating nodes. The protocol should be well defined, unambigous, easily understood, free to use, efficient, secure and languange neutral. This is the Block Exchange Protocol.

Provide the reference implementation to demonstrate the usability of said protocol. This is the syncthing utility. It is the hope that alternative, compatible implementations of the protocol will come to exist.

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

%build
%define gopath %{_builddir}/go

#% goprep github.com/syncthing/syncthing
%{__mkdir_p} %{gopath}/src/github.com/syncthing/syncthing
cp -R ./* %{gopath}/src/github.com/syncthing/syncthing
pushd %{gopath}/src/github.com/syncthing/syncthing
GOPATH=%{gopath}
GOPATH="$(pwd)/Godeps/_workspace:$GOPATH" go build -ldflags "-w -X main.Version v%{version} \
  -X main.BuildStamp %(date +"%FT%T") -X main.BuildUser %(whoami) \
  -X main.BuildHost %(hostname) -X main.BuildEnv %{_host}" \
  -tags noupgrade ./cmd/syncthing
popd

%install
%{__mkdir_p} %{buildroot}%{_bindir}
%{__install} -m755 %{gopath}/src/github.com/syncthing/syncthing/syncthing %{buildroot}%{_bindir}/syncthing

%{__mkdir_p} %{buildroot}%{_sbindir}
ln -s service %{buildroot}%{_sbindir}/rcsyncthing
install -D -m644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}@.service

%pre
%service_add_pre %{name}@.service

%post
%service_add_post %{name}@.service

%preun
%service_del_preun %{name}@.service

%postun
%service_del_postun %{name}@.service

%files
%defattr(-,root,root)
%doc LICENSE CONTRIBUTING.md AUTHORS README.md
%{_bindir}/syncthing
%{_sbindir}/rcsyncthing
%{_unitdir}/%{name}@.service

%changelog

openSUSE Build Service is sponsored by