File syncthing.spec of Package syncthing

# spec file for package syncthing
# Copyright (c) 2016 SUSE LINUX 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

Name:           syncthing
Version:        0.14.0
Release:        0
Summary:        FOSS Continuous File Synchronisation
License:        MPL-2.0
Group:          Productivity/Networking/File-Sharing
Source2:        %{name}.keyring
Source3:        %{name}.firewall
BuildRequires:  go >= 1.3
BuildRequires:  systemd
BuildRequires:  systemd-rpm-macros

Syncthing replaces proprietary sync and cloud services with
something open, trustworthy and decentralised. Your data is your
data alone and you deserve to choose where it is stored, if it is
shared with some third party and how it's transmitted over the

%setup -q -n %{name}
cp -f %{SOURCE3} %{name}.firewall
%if !(0%{?suse_version} > 1320 || 0%{?sle_version} >= 120200)
# Remove an entry that only exists since systemd 215.
sed -i '/^RestartForceExitStatus=/d;s/^\(SuccessExitStatus=\).*$/\12/' \

mkdir -p build/src/ build/vendor/
export GOPATH="$PWD/build:$PWD/build/vendor"

mkdir -p build/src/{name}/%{name}
ls | sed '/^build$/d' | xargs cp -at build/src/{name}/%{name}
cp -a vendor build/vendor/src

pushd build/src/{name}/%{name}/
go run build.go install all \
  -version v%{version} -no-upgrade

install -Dm 0755 build/src/{name}/%{name}/bin/%{name} \
install -Dm 0644 etc/linux-systemd/system/%{name}@.service        \
install -Dm 0644 etc/linux-systemd/system/%{name}-resume.service  \
%if 0%{?suse_version} > 1320 || 0%{?sle_version} >= 120200
install -Dm 0644 etc/linux-systemd/user/%{name}.service           \
install -Dm 0644 %{name}.firewall                                 \

%service_add_pre %{name}-resume.service

%service_add_post %{name}-resume.service
%if 0%{?suse_version} > 1320 || 0%{?sle_version} >= 120200
%systemd_user_post %{name}.service

%service_del_preun %{name}@.service %{name}-resume.service
%if 0%{?suse_version} > 1320 || 0%{?sle_version} >= 120200
%systemd_user_preun %{name}.service

%service_del_postun %{name}-resume.service
%if 0%{?suse_version} > 1320 || 0%{?sle_version} >= 120200
%systemd_user_postun %{name}.service

%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}
%if 0%{?suse_version} > 1320 || 0%{?sle_version} >= 120200