# https://github.com/restic/restic
%global goipath         github.com/restic/restic
Version:                0.12.1

#The following is here to allow support of building for Copr EPEL until the
#stops rpmbuild from complaining about empty debug files
%global debug_package %{nil}
%global gometa %{nil}

%gometa

%global common_description %{expand:
A backup program that is easy, fast, verifiable, secure, efficient and free.

Backup destinations can be:
*Local
*SFTP
*REST Server
*Amazon S3
*Minio Server
*OpenStack Swift
*Backblaze B2
*Microsoft Azure Blob Storage
*Google Cloud Storage
*Other Services via rclone}

%global golicenses    LICENSE


Name:    restic
Release: 1%{?dist}
Summary: Fast, secure, efficient backup program
URL:     https://restic.net
License: BSD
Source0: https://%{goipath}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz

#Restic does not compile for the following archs
ExcludeArch: s390x

BuildRequires: golang >= 1.13
BuildRequires: git >= 1.13
#COMMON
#Soft dependency for mounting , ie: fusemount
#Requires: fuse


%description
%{common_description}


%prep
%autosetup

%build 
go run build.go --enable-pie

%install
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_mandir}/man1
mkdir -p %{buildroot}%{_datarootdir}/zsh/site-functions
mkdir -p %{buildroot}%{_datarootdir}/bash-completion/completions
install -p -m 644 doc/man/* %{buildroot}%{_mandir}/man1/
#zsh completion
install -p -m 644 doc/zsh-completion.zsh %{buildroot}%{_datarootdir}/zsh/site-functions/_restic
#Bash completion
install -p -m 644 doc/bash-completion.sh %{buildroot}%{_datarootdir}/bash-completion/completions/restic
install -p -m 755 %{name} %{buildroot}%{_bindir}

%check
#Skip tests using fuse due to root requirement
export RESTIC_TEST_FUSE=0

%files
%license LICENSE
%doc GOVERNANCE.md CONTRIBUTING.md CHANGELOG.md README.md
%{_bindir}/%{name}
%dir %{_datadir}/zsh/site-functions
%{_datadir}/zsh/site-functions/_restic
%dir %{_datadir}/bash-completion/
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/restic
%{_mandir}/man1/restic*.*

%changelog
* Wed Jan 25 2022 Steve Miller <copart@gmail.com> - 0.12.1-1
- Bumped restic version
- Increased mininum Go version as stated at
  https://restic.readthedocs.io/en/stable/020_installation.html#from-source

* Sun Apr 18 2021 Michael Best <michael.best@gmail.com> - 0.12.0-1
- Bumped restic version
- removed Fedora compatibility

* Wed Oct 14 2020 Steve Miller <copart@gmail.com> - 0.10.0-1
- Bumped restic version

* Fri Mar 6 2020 Steve Miller <copart@gmail.com> - 0.9.6-1
- Bumped restic version

* Fri Nov 8 2019 Steve Miller <copart@gmail.com> - 0.9.5-3
- Added RHEL 8 support

* Sat Jun 1 2019 Steve Miller <copart@gmail.com> - 0.9.5-2
- Resolved spec issue https://github.com/copart/restic-rpm/issues/1

* Tue Apr 23 2019 Steve Miller <copart@gmail.com> - 0.9.5-1
- Bumped restic version

* Sun Feb 10 2019 Steve Miller <copart@gmail.com> - 0.9.4-1
- External git copr repository for build added, will be used 
  for epel 6 install.
- Bumped restic version

* Sat Nov 3 2018 Steve Miller <copart@gmail.com> - 0.9.3-1
- Bumped restic version

* Thu Aug 9 2018 Steve Miller <copart@gmail.com> - 0.9.2-1
- Bumped restic version

* Wed Jun 13 2018 Steve Miller <copart@gmail.com> - 0.9.1-2
- Added ppc64 to ExcludeArch, no go for this architecture
- First package for Fedora
- Rework using More Go packaging

* Sun Jun 10 2018 Steve Miller <copart@gmail.com> - 0.9.1-1
- Bumped restic version

* Sun May 27 2018 Steve Miller <copart@gmail.com> - 0.9.0-1
- Bumped restic version

* Sun Mar 04 2018 Steve Miller <copart@gmail.com> - 0.8.3-1
- Bumped restic version

* Tue Feb 20 2018 Steve Miller <copart@gmail.com> - 0.8.2-1
- Bumped restic version

* Fri Jan 12 2018 Steve Miller <copart@gmail.com> - 0.8.1-2
- Added man pages
- Added bash completion
- Added zsh completion

* Sun Jan 07 2018 Steve Miller <copart@gmail.com> - 0.8.1-1
- New Version

* Sat Sep 16 2017 Philipp Baum <phil@phib.io> - 0.7.2-1
- New Version

* Sun Aug 27 2017 Philipp Baum <phil@phib.io> - 0.7.1-1
- New Version

* Wed Mar 15 2017 Philipp Baum <phil@phib.io> - 0.5.0-1
- Initial package build