Blame cargo.spec

353e7c7
# Only x86_64 and i686 are Tier 1 platforms at this time.
353e7c7
# https://forge.rust-lang.org/platform-support.html
c4ff9ee
%global rust_arches x86_64 i686 armv7hl aarch64 ppc64 ppc64le s390x
353e7c7
353e7c7
# Only the specified arches will use bootstrap binaries.
Igor Gnatenko c36ab45
#global bootstrap_arches %%{rust_arches}
353e7c7
9ceb3a3
%if 0%{?rhel} && !0%{?epel}
99b1d91
%bcond_without bundled_libgit2
99b1d91
%else
99b1d91
%bcond_with bundled_libgit2
99b1d91
%endif
99b1d91
b61f619
Name:           cargo
7a003e1
Version:        0.25.0
7a003e1
Release:        1%{?dist}
b61f619
Summary:        Rust's package manager and build tool
b61f619
License:        ASL 2.0 or MIT
b61f619
URL:            https://crates.io/
353e7c7
ExclusiveArch:  %{rust_arches}
b61f619
39386fb
%global cargo_version %{version}
7a003e1
%global cargo_bootstrap 0.24.0
39386fb
39386fb
Source0:        https://github.com/rust-lang/%{name}/archive/%{cargo_version}/%{name}-%{cargo_version}.tar.gz
39386fb
4401bff
Patch1:         cargo-0.23.0-disable-mdbook.patch
7a003e1
Patch2:         0001-Remove-test-that-requires-Emscripten.patch
4401bff
353e7c7
# Get the Rust triple for any arch.
353e7c7
%{lua: function rust_triple(arch)
353e7c7
  local abi = "gnu"
353e7c7
  if arch == "armv7hl" then
353e7c7
    arch = "armv7"
353e7c7
    abi = "gnueabihf"
353e7c7
  elseif arch == "ppc64" then
353e7c7
    arch = "powerpc64"
353e7c7
  elseif arch == "ppc64le" then
353e7c7
    arch = "powerpc64le"
353e7c7
  end
353e7c7
  return arch.."-unknown-linux-"..abi
353e7c7
end}
353e7c7
353e7c7
%global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))}
353e7c7
353e7c7
%if %defined bootstrap_arches
353e7c7
# For each bootstrap arch, add an additional binary Source.
353e7c7
# Also define bootstrap_source just for the current target.
353e7c7
%{lua: do
353e7c7
  local bootstrap_arches = {}
353e7c7
  for arch in string.gmatch(rpm.expand("%{bootstrap_arches}"), "%S+") do
353e7c7
    table.insert(bootstrap_arches, arch)
353e7c7
  end
39386fb
  local base = rpm.expand("https://static.rust-lang.org/dist/cargo-%{cargo_bootstrap}")
353e7c7
  local target_arch = rpm.expand("%{_target_cpu}")
353e7c7
  for i, arch in ipairs(bootstrap_arches) do
353e7c7
    i = i + 10
e9823e1
    print(string.format("Source%d: %s-%s.tar.xz\n",
353e7c7
                        i, base, rust_triple(arch)))
353e7c7
    if arch == target_arch then
353e7c7
      rpm.define("bootstrap_source "..i)
353e7c7
    end
353e7c7
  end
353e7c7
end}
b61f619
%endif
b61f619
b61f619
# Use vendored crate dependencies so we can build offline.
4401bff
# Created using https://github.com/alexcrichton/cargo-vendor/ 0.1.13
b61f619
# It's so big because some of the -sys crates include the C library source they
b61f619
# want to link to.  With our -devel buildreqs in place, they'll be used instead.
b61f619
# FIXME: These should all eventually be packaged on their own!
4dbf2d3
Source100:      %{name}-%{version}-vendor.tar.xz
b61f619
b61f619
BuildRequires:  rust
b61f619
BuildRequires:  make
b61f619
BuildRequires:  cmake
b61f619
BuildRequires:  gcc
7a003e1
BuildRequires:  git
b61f619
353e7c7
%ifarch %{bootstrap_arches}
87e3528
%global bootstrap_root cargo-%{cargo_bootstrap}-%{rust_triple}
353e7c7
%global local_cargo %{_builddir}/%{bootstrap_root}/cargo/bin/cargo
cd86ae4
Provides:       bundled(%{name}-bootstrap) = %{cargo_bootstrap}
353e7c7
%else
0596771
BuildRequires:  %{name} >= 0.13.0
4dbf2d3
%global local_cargo %{_bindir}/%{name}
b61f619
%endif
b61f619
b61f619
# Indirect dependencies for vendored -sys crates above
b61f619
BuildRequires:  libcurl-devel
b61f619
BuildRequires:  libssh2-devel
353e7c7
BuildRequires:  openssl-devel
b61f619
BuildRequires:  zlib-devel
b61f619
BuildRequires:  pkgconfig
b61f619
99b1d91
%if %with bundled_libgit2
7a003e1
Provides:       bundled(libgit2) = 0.26.0
99b1d91
%else
99b1d91
BuildRequires:  libgit2-devel >= 0.24
99b1d91
%endif
99b1d91
RĂ©mi Verschelde a34dfd8
# Cargo is not much use without Rust
29db706
Requires:       rust
29db706
b61f619
%description
b61f619
Cargo is a tool that allows Rust projects to declare their various dependencies
b61f619
and ensure that you'll always get a repeatable build.
b61f619
b61f619
cd86ae4
%package doc
cd86ae4
Summary:        Documentation for Cargo
cd86ae4
BuildArch:      noarch
cd86ae4
cd86ae4
%description doc
cd86ae4
This package includes HTML documentation for Cargo.
cd86ae4
cd86ae4
b61f619
%prep
b61f619
353e7c7
%ifarch %{bootstrap_arches}
353e7c7
%setup -q -n %{bootstrap_root} -T -b %{bootstrap_source}
353e7c7
test -f '%{local_cargo}'
353e7c7
%endif
353e7c7
353e7c7
# cargo sources
39386fb
%setup -q -n %{name}-%{cargo_version}
7c3637b
cd86ae4
# vendored crates
a8cedf1
%setup -q -n %{name}-%{cargo_version} -T -D -a 100
847e2b5
3392761
%patch1 -p1 -b .mdbook
7a003e1
%patch2 -p1 -b .emscripten
4401bff
6ad6151
# fixed upstream in commit 64828ba9cab7 -> cargo ~0.26
6ad6151
chmod -x src/cargo/lib.rs
6ad6151
cfca530
# define the offline registry
cfca530
%global cargo_home $PWD/.cargo
cfca530
mkdir -p %{cargo_home}
0596771
cat >.cargo/config <
0596771
[source.crates-io]
0596771
registry = 'https://github.com/rust-lang/crates.io-index'
0596771
replace-with = 'vendored-sources'
0596771
0596771
[source.vendored-sources]
cd86ae4
directory = '$PWD/vendor'
0596771
EOF
b61f619
cfca530
# This should eventually migrate to distro policy
cfca530
# Enable optimization, debuginfo, and link hardening.
cfca530
%global rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now
b61f619
b61f619
%build
b61f619
99b1d91
%if %without bundled_libgit2
b61f619
# convince libgit2-sys to use the distro libgit2
b61f619
export LIBGIT2_SYS_USE_PKG_CONFIG=1
99b1d91
%endif
b61f619
cfca530
# use our offline registry and custom rustc flags
cfca530
export CARGO_HOME="%{cargo_home}"
cfca530
export RUSTFLAGS="%{rustflags}"
b61f619
cd86ae4
# cargo no longer uses a configure script, but we still want to use
cd86ae4
# CFLAGS in case of the odd C file in vendored dependencies.
cd86ae4
%{?__global_cflags:export CFLAGS="%{__global_cflags}"}
cd86ae4
%{!?__global_cflags:%{?optflags:export CFLAGS="%{optflags}"}}
cd86ae4
%{?__global_ldflags:export LDFLAGS="%{__global_ldflags}"}
b61f619
cd86ae4
%{local_cargo} build --release
cd86ae4
sh src/ci/dox.sh
b61f619
b61f619
b61f619
%install
cfca530
export CARGO_HOME="%{cargo_home}"
cfca530
export RUSTFLAGS="%{rustflags}"
cfca530
cd86ae4
%{local_cargo} install --root %{buildroot}%{_prefix}
cd86ae4
rm %{buildroot}%{_prefix}/.crates.toml
b61f619
c13a43e
mkdir -p %{buildroot}%{_mandir}/man1
cd86ae4
%{__install} -p -m644 src/etc/man/cargo*.1 \
c13a43e
  -t %{buildroot}%{_mandir}/man1
b61f619
cd86ae4
%{__install} -p -m644 src/etc/cargo.bashcomp.sh \
cd86ae4
  -D %{buildroot}%{_sysconfdir}/bash_completion.d/cargo
b61f619
cd86ae4
%{__install} -p -m644 src/etc/_cargo \
cd86ae4
  -D %{buildroot}%{_datadir}/zsh/site-functions/_cargo
0999073
0999073
# Create the path for crate-devel packages
0999073
mkdir -p %{buildroot}%{_datadir}/cargo/registry
b61f619
cd86ae4
mkdir -p %{buildroot}%{_docdir}/cargo
cd86ae4
cp -a target/doc %{buildroot}%{_docdir}/cargo/html
cd86ae4
b61f619
b61f619
%check
cfca530
export CARGO_HOME="%{cargo_home}"
cfca530
export RUSTFLAGS="%{rustflags}"
cfca530
cfca530
# some tests are known to fail exact output due to libgit2 differences
cd86ae4
CFG_DISABLE_CROSS_TESTS=1 %{local_cargo} test --no-fail-fast || :
b61f619
b61f619
b61f619
%files
b61f619
%license LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY
b61f619
%doc README.md
b61f619
%{_bindir}/cargo
b61f619
%{_mandir}/man1/cargo*.1*
b61f619
%{_sysconfdir}/bash_completion.d/cargo
b61f619
%{_datadir}/zsh/site-functions/_cargo
0999073
%dir %{_datadir}/cargo
0999073
%dir %{_datadir}/cargo/registry
b61f619
cd86ae4
%files doc
cd86ae4
%{_docdir}/cargo/html
cd86ae4
b61f619
b61f619
%changelog
7a003e1
* Wed Feb 21 2018 Josh Stone <jistone@redhat.com> - 0.25.0-1
7a003e1
- Update to 0.25.0.
7a003e1
6ad6151
* Wed Feb 07 2018 Josh Stone <jistone@redhat.com> - 0.24.0-3
6ad6151
- FTBFS: fix a misidentified shebang
6ad6151
310912d
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.24.0-2
310912d
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
310912d
3392761
* Mon Jan 08 2018 Josh Stone <jistone@redhat.com> - 0.24.0-1
3392761
- Update to 0.24.0.
3392761
4401bff
* Wed Nov 29 2017 Josh Stone <jistone@redhat.com> - 0.23.0-1
4401bff
- Update to 0.23.0.
4401bff
a8cedf1
* Mon Oct 16 2017 Josh Stone <jistone@redhat.com> - 0.22.0-1
4401bff
- Update to 0.22.0.
a8cedf1
938b26d
* Mon Sep 11 2017 Josh Stone <jistone@redhat.com> - 0.21.1-1
938b26d
- Update to 0.21.1.
938b26d
e9823e1
* Thu Aug 31 2017 Josh Stone <jistone@redhat.com> - 0.21.0-1
e9823e1
- Update to 0.21.0.
e9823e1
8ad9523
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.20.0-3
8ad9523
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
8ad9523
cc825ea
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.20.0-2
cc825ea
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
cc825ea
cd86ae4
* Fri Jul 21 2017 Josh Stone <jistone@redhat.com> - 0.20.0-1
cd86ae4
- Update to 0.20.0.
cd86ae4
- Add a cargo-doc subpackage.
cd86ae4
Igor Gnatenko c36ab45
* Sat Jul 08 2017 Igor Gnatenko <ignatenko@redhat.com> - 0.19.0-4
Igor Gnatenko c36ab45
- Disable bootstrap
Igor Gnatenko c36ab45
Igor Gnatenko fb99d33
* Sat Jul 08 2017 Igor Gnatenko <ignatenko@redhat.com> - 0.19.0-3
Igor Gnatenko fb99d33
- Rebuild for libgit2 0.26.x
Igor Gnatenko fb99d33
0999073
* Tue Jun 20 2017 Josh Stone <jistone@redhat.com> - 0.19.0-2
0999073
- Create /usr/share/cargo/registry for crate-devel packages
0999073
87e3528
* Fri Jun 09 2017 Josh Stone <jistone@redhat.com> - 0.19.0-1
87e3528
- Update to 0.19.0.
87e3528
073e413
* Thu Apr 27 2017 Josh Stone <jistone@redhat.com> - 0.18.0-1
073e413
- Update to 0.18.0.
073e413
39386fb
* Thu Mar 16 2017 Josh Stone <jistone@redhat.com> - 0.17.0-1
e30022a
- Update to 0.17.0.
39386fb
aa1160a
* Tue Feb 14 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.16.0-2
aa1160a
- Backport patch to expose description in cargo metadata
aa1160a
99b1d91
* Thu Feb 09 2017 Josh Stone <jistone@redhat.com> - 0.16.0-1
99b1d91
- Update to 0.16.0.
99b1d91
- Start using the current upstream release for bootstrap.
99b1d91
- Merge and clean up conditionals for epel7.
99b1d91
Igor Gnatenko 58ad158
* Tue Feb 07 2017 Igor Gnatenko <ignatenko@redhat.com> - 0.15.0-4
Igor Gnatenko 58ad158
- Disable bootstrap
Igor Gnatenko 58ad158
Igor Gnatenko 52508ae
* Tue Feb 07 2017 Igor Gnatenko <ignatenko@redhat.com> - 0.15.0-3
Igor Gnatenko 52508ae
- Rebuild for libgit2-0.25.x
Igor Gnatenko 52508ae
902aff3
* Tue Jan 03 2017 Josh Stone <jistone@redhat.com> - 0.15.0-2
902aff3
- Rebuild without bootstrap binaries.
902aff3
353e7c7
* Tue Jan 03 2017 Josh Stone <jistone@redhat.com> - 0.15.0-1
353e7c7
- Update to 0.15.0.
353e7c7
- Rewrite bootstrap logic to target specific arches.
353e7c7
- Bootstrap ppc64, ppc64le, s390x.
353e7c7
7c3637b
* Sun Nov 13 2016 Josh Stone <jistone@redhat.com> - 0.14.0-2
7c3637b
- Fix CFG_RELEASE_NUM
7c3637b
0596771
* Thu Nov 10 2016 Josh Stone <jistone@redhat.com> - 0.14.0-1
0596771
- Update to 0.14.0.
0596771
- Use hardening flags for linking.
0596771
34e4323
* Thu Oct 20 2016 Josh Stone <jistone@redhat.com> - 0.13.0-4
34e4323
- Rebuild with Rust 1.12.1 and enabled MIR.
34e4323
ffd2ba3
* Fri Oct 07 2016 Josh Stone <jistone@redhat.com> - 0.13.0-3
ffd2ba3
- Rebuild without bootstrap binaries.
ffd2ba3
b6081af
* Thu Oct 06 2016 Josh Stone <jistone@redhat.com> - 0.13.0-2
b6081af
- Bootstrap aarch64.
b6081af
- Use jemalloc's MALLOC_CONF to work around #36944.
b6081af
4dbf2d3
* Fri Sep 30 2016 Josh Stone <jistone@redhat.com> - 0.13.0-1
4dbf2d3
- Update to 0.13.0.
4dbf2d3
- Always use --local-cargo, even for bootstrap binaries.
47d1014
- Disable MIR until rust#36774 is resolved.
4dbf2d3
2420837
* Sat Sep 03 2016 Josh Stone <jistone@redhat.com> - 0.12.0-3
2420837
- Rebuild without bootstrap binaries.
2420837
32cf806
* Fri Sep 02 2016 Josh Stone <jistone@redhat.com> - 0.12.0-2
32cf806
- Bootstrap armv7hl.
3c1eadf
- Patch dl-snapshot.py to ignore hashes on unknown archs.
32cf806
9959bad
* Wed Aug 24 2016 Josh Stone <jistone@redhat.com> - 0.12.0-1
9959bad
- Update to 0.12.0.
9959bad
29db706
* Mon Aug 22 2016 Josh Stone <jistone@redhat.com> 0.11.0-3
29db706
- Rebuild without bootstrap binaries.
29db706
- Add a runtime requirement on rust.
29db706
b61f619
* Mon Aug 22 2016 Josh Stone <jistone@redhat.com> - 0.11.0-2
b61f619
- Initial import into Fedora (#1357749), bootstrapped
b61f619
b61f619
* Sun Jul 17 2016 Josh Stone <jistone@fedoraproject.org> - 0.11.0-1
b61f619
- Initial package, bootstrapped