File obs-service-cargo_vendor.spec of Package obs-service-cargo_vendor

#
# spec file for package obs-service-cargo_vendor
#
# Copyright (c) 2019 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 https://bugs.opensuse.org/
#

# Macros from obs-service_tar_scm
%if 0%{?suse_version} >= 1315 || 0%{?fedora_version} >= 29
%bcond_without python3
%else
%bcond_with    python3
%endif

# This list probably needs to be extended
# logic seems to be if python < 2.7 ; then needs_external_argparse ; fi
%if (0%{?centos_version} == 6) || (0%{?suse_version} && 0%{?suse_version} < 1315) || (0%{?fedora_version} && 0%{?fedora_version} < 26)
%bcond_without needs_external_argparse
%else
%bcond_with    needs_external_argparse
%endif

%if %{with python3}
%define use_python python3
%define use_test   test3
%else
%define use_python python
%define use_test   test
%endif

%define service cargo_vendor

Name:           obs-service-%{service}
Summary:        OBS Source Service to vendor all dependencies for a Rust project
License:        GPL-2.0-or-later
Group:          Development/Tools/Building
Url:            https://github.com/openSUSE/obs-service-%{service}
Version:        0.2.0
Release:        0
Source:         %{name}-%{version}.tar.xz
%if %{with needs_external_argparse}
BuildRequires:  %{use_python}-argparse
%endif
%if %{with python3}
BuildRequires:  %{use_python}
# Fix missing Requires in python3-pbr in Leap42.3
BuildRequires:  %{use_python}-setuptools
%endif
BuildRequires:  go-md2man
Requires:       cargo >= 1.35.0
Requires:       gzip
Requires:       tar
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
This service extracts a Rust application source,
searches for a Rust application containing a Cargo.toml file,
download all crates.io and dependecies,
and creates a vendor.tar[.<tar compression>] to be committed allowing fully offline
builds of Rust applications.

%prep
%setup -q

%build

%install
mkdir -p %{buildroot}%{_prefix}/lib/obs/service
mkdir -p %{buildroot}%{_prefix}/lib/obs/service
install -m 0755 cargo_vendor %{buildroot}%{_prefix}/lib/obs/service
install -m 0644 cargo_vendor.service %{buildroot}%{_prefix}/lib/obs/service

# Build the man page from markdown documentation.
go-md2man -in README.md -out %{name}.1

# Install the man page.
install -D -m 0644 %{name}.1 "%{buildroot}/%{_mandir}/man1/%{name}.1"
rm %{name}.1

%files
%defattr(-,root,root)
%doc README.md
%license LICENSE
%dir %{_prefix}/lib/obs
%{_prefix}/lib/obs/service
%{_mandir}/man1/%{name}.1%{?ext_man}

%changelog
openSUSE Build Service is sponsored by