File cargo.spec of Package cargo

#
# spec file for package cargo
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2016 Michal Vyskocil, michal.vyskocil@opensuse.org
# Copyright (c) 2016 Kristoffer Gronlund, kgronlund@suse.com
#
# 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/
#


%global prev_rustc 1.16.0
%global curr_rustc 1.17.0
%global prev_version 0.17.0
%global pkg_version 0_18
%global rel_version 0.18.0

%global abi gnu
%ifarch s390x
%global _arch s390x
%endif
%ifarch armv7hl
%global _arch armv7
%global abi gnueabihf
%endif
%ifarch ppc64
%global _arch powerpc64
%endif
%ifarch ppc64le
%global _arch powerpc64le
%endif
%ifarch x86_64
%global _arch x86_64
%endif
%ifarch %{ix86}
%global _arch i586
%endif
%global rust_triple %{_arch}-unknown-linux-%{abi}

%bcond_with bootstrap
Name:           cargo
Version:        %{rel_version}
Release:        0
Summary:        The Rust package manager
License:        MIT or Apache-2.0
Group:          Development/Languages/Other
Url:            https://github.com/rust-lang/cargo
Source0:        cargo-%{version}.tar.gz
Source1:        vendor.tar.xz

# There are no successful builds for less than TW or Leap 42.2, so bootstrap
# until such time that there is.
%if %{with bootstrap} || (0%{?suse_version} < 1330 && 0%{?sle_version} < 120200)
BuildRequires:  cargo-bootstrap == %{prev_version}
BuildRequires:  rust == %{prev_rustc}
BuildRequires:  rust-std == %{prev_rustc}
%else
BuildRequires:  cargo <= %{version}
BuildRequires:  cargo >= %{prev_version}
BuildRequires:  rust <= %{curr_rustc}
BuildRequires:  rust >= %{prev_rustc}
BuildRequires:  rust-std <= %{curr_rustc}
BuildRequires:  rust-std >= %{prev_rustc}
%endif
BuildRequires:  cmake
BuildRequires:  curl
BuildRequires:  git
BuildRequires:  libcurl-devel
BuildRequires:  libopenssl-devel
BuildRequires:  libssh-devel
BuildRequires:  zlib-devel
ExclusiveArch:  %{ix86} x86_64 %{arm} aarch64 ppc64 ppc64le s390x

Conflicts:      otherproviders(cargo)
Conflicts:      cargo-bootstrap

BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Cargo downloads your Rust project’s dependencies and compiles your project.

%prep
%setup -q -n cargo-%{version}
%setup -q -D -T -a 1 -n cargo-%{version}
mkdir cargo-home
cat >cargo-home/config <<EOF
[source.crates-io]
registry = 'https://github.com/rust-lang/crates.io-index'
replace-with = 'vendored-sources'
[source.vendored-sources]
directory = './vendor'
EOF

%build
export CARGO_HOME=`pwd`/cargo-home/
%configure --disable-option-checking \
    --build=%{rust_triple} \
    --host=%{rust_triple} \
    --target=%{rust_triple} \
    --local-rust-root=%{_prefix} \
    --prefix=%{_prefix} \
    --libdir=%{_libdir}
cargo build --release %{?_smp_mflags}

%install
mkdir build
export CARGO_HOME=`pwd`/cargo-home/
cargo install --root=build
mkdir -p %{buildroot}%{_bindir}
install -Dm0755 build/bin/cargo %{buildroot}%{_bindir}/cargo
mkdir -p %{buildroot}%{_mandir}/man1
install -Dm0644 src/etc/man/cargo*.1 %{buildroot}%{_mandir}/man1/
install -Dm0644 src/etc/cargo.bashcomp.sh %{buildroot}%{_sysconfdir}/bash_completion.d/cargo.sh

%files
%defattr(-,root,root)
%doc LICENSE-APACHE LICENSE-MIT README.md
%{_bindir}/cargo
%doc %{_mandir}/man1/*
%config %{_sysconfdir}/bash_completion.d/cargo.sh

%changelog
openSUSE Build Service is sponsored by