File cargo.spec of Package cargo

# spec file for package cargo
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2016 Michal Vyskocil,
# Copyright (c) 2016 Kristoffer Gronlund,
# Copyright (c) 2017 Luke Jones,
# 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

%global bootstrap_version 0.26.0
%global bootstrap_rustc_version 1.25.0
%global current_rustc_version 1.25.0
%global rust_arch %{_arch}
%global abi gnu
%ifarch armv7hl
%global rust_arch armv7
%global abi gnueabihf
%ifarch armv6hl
%global rust_arch arm
%global abi gnueabihf
%ifarch ppc64
%global rust_arch powerpc64
%ifarch ppc64le
%global rust_arch powerpc64le
# Must restrict the x86 build to i686 since i586 is currently unsupported
%ifarch %ix86
%global rust_arch i686
%global rust_triple %{rust_arch}-unknown-linux-%{abi}
%bcond_with cargo_bootstrap
Name:           cargo
Version:        0.26.0
Release:        0
Summary:        The Rust package manager
License:        MIT OR Apache-2.0
Group:          Development/Languages/Other
Source0:        cargo-%{version}.tar.gz
Source1:        vendor.tar.xz
Patch0:         update-config-guess.patch
BuildRequires:  cmake
BuildRequires:  curl
BuildRequires:  git
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(libcrypto)
BuildRequires:  pkgconfig(libcurl)
BuildRequires:  pkgconfig(libgit2) >= 0.23
BuildRequires:  pkgconfig(libssh)
BuildRequires:  pkgconfig(libssh_threads)
BuildRequires:  pkgconfig(libssl)
BuildRequires:  pkgconfig(openssl)
BuildRequires:  pkgconfig(zlib)
Requires:       rust
Conflicts:      cargo
Conflicts:      cargo-bootstrap
ExclusiveArch:  x86_64 %{arm} aarch64 ppc64 ppc64le s390x
%ifarch %ix86
BuildArch:      i686
ExclusiveArch:  i586 i686
# There are no successful builds for less than TW or Leap 42.2, so bootstrap
# until such time that there is.
%if %{with cargo_bootstrap}
BuildRequires:  cargo-bootstrap = %{bootstrap_version}
BuildRequires:  rust-std-bootstrap = %{bootstrap_rustc_version}
BuildRequires:  rustc-bootstrap = %{bootstrap_rustc_version}
BuildRequires:  cargo <= %{version}
BuildRequires:  rust <= %{current_rustc_version}
BuildRequires:  rust-std <= %{current_rustc_version}

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

%setup -q -n cargo-%{version}
%setup -q -D -T -a 1 -n cargo-%{version}
#patch0 -p1
mkdir cargo-home
cat >cargo-home/config <<EOF
registry = ''
replace-with = 'vendored-sources'
directory = './vendor'

# This should eventually migrate to distro policy
# Enable optimization, debuginfo, and link hardening.
export RUSTFLAGS="-Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now"

export CARGO_HOME=`pwd`/cargo-home/
cargo build --target=%{rust_triple} --release %{?_smp_mflags}

mkdir build
export CARGO_HOME=`pwd`/cargo-home/

cargo install --root %{buildroot}%{_prefix}
rm %{buildroot}%{_prefix}/.crates.toml

mkdir -p %{buildroot}%{_mandir}/man1
install -Dm0644 src%{_sysconfdir}/man/cargo*.1 %{buildroot}%{_mandir}/man1/
install -Dm0644 src%{_sysconfdir}/ %{buildroot}%{_sysconfdir}/bash_completion.d/
install -Dm0644 src%{_sysconfdir}/_cargo %{buildroot}%{_sysconfdir}/zsh/site-functions/_cargo

%config %{_sysconfdir}/bash_completion.d/
%dir %{_sysconfdir}/zsh
%dir %{_sysconfdir}/zsh/site-functions
%config %{_sysconfdir}/zsh/site-functions/_cargo

openSUSE Build Service is sponsored by