# (akien) This package is (for now) synced with Fedora / Josh Stone's spec. # The aim is to work with them on a rust packaging policy we could share, # so that we can ensure a good packaging and share the workload. # Only x86_64 and i686 are Tier 1 platforms at this time. # https://forge.rust-lang.org/platform-support.html %global rust_arches x86_64 %ix86 armv7hl aarch64 ppc64 ppc64le s390x # Only the specified arches will use bootstrap binaries. #global bootstrap_arches %%{rust_arches} %if 0%{?rhel} && !0%{?epel} %bcond_without bundled_libgit2 %else %bcond_with bundled_libgit2 %endif Name: cargo Version: 0.26.0 Release: %mkrel 1 Summary: Rust's package manager and build tool %if 0%{?mageia} Group: Development/Other %endif License: ASL 2.0 or MIT URL: https://crates.io/ ExclusiveArch: %{rust_arches} %global cargo_version %{version} %global cargo_bootstrap 0.25.0 Source0: https://github.com/rust-lang/%{name}/archive/%{cargo_version}/%{name}-%{cargo_version}.tar.gz # Get the Rust triple for any arch. %{lua: function rust_triple(arch) local abi = "gnu" if arch == "armv7hl" then arch = "armv7" abi = "gnueabihf" elseif arch == "ppc64" then arch = "powerpc64" elseif arch == "ppc64le" then arch = "powerpc64le" elseif arch == "i586" then arch = "i686" end return arch.."-unknown-linux-"..abi end} %global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))} %if %defined bootstrap_arches # For each bootstrap arch, add an additional binary Source. # Also define bootstrap_source just for the current target. %{lua: do local bootstrap_arches = {} for arch in string.gmatch(rpm.expand("%{bootstrap_arches}"), "%S+") do table.insert(bootstrap_arches, arch) end local base = rpm.expand("https://static.rust-lang.org/dist/cargo-%{cargo_bootstrap}") local target_arch = rpm.expand("%{_target_cpu}") for i, arch in ipairs(bootstrap_arches) do i = i + 10 print(string.format("Source%d: %s-%s.tar.xz\n", i, base, rust_triple(arch))) if arch == target_arch then rpm.define("bootstrap_source "..i) end end end} %endif # Use vendored crate dependencies so we can build offline. # Created using https://github.com/alexcrichton/cargo-vendor/ 0.1.12 # It's so big because some of the -sys crates include the C library source they # want to link to. With our -devel buildreqs in place, they'll be used instead. # FIXME: These should all eventually be packaged on their own! Source100: %{name}-%{version}-vendor.tar.xz BuildRequires: rust BuildRequires: make BuildRequires: cmake BuildRequires: gcc BuildRequires: git %ifarch %{bootstrap_arches} %global bootstrap_root cargo-%{cargo_bootstrap}-%{rust_triple} %global local_cargo %{_builddir}/%{bootstrap_root}/cargo/bin/cargo Provides: bundled(%{name}-bootstrap) = %{cargo_bootstrap} %else BuildRequires: %{name} >= 0.13.0 %global local_cargo %{_bindir}/%{name} %endif # Indirect dependencies for vendored -sys crates above BuildRequires: libcurl-devel BuildRequires: libssh2-devel BuildRequires: openssl-devel BuildRequires: zlib-devel BuildRequires: pkgconfig %if %with bundled_libgit2 Provides: bundled(libgit2) = 0.26.0 %else BuildRequires: libgit2-devel >= 0.24 %endif # Cargo is not much use without Rust Requires: rust %description Cargo is a tool that allows Rust projects to declare their various dependencies and ensure that you'll always get a repeatable build. %package doc Summary: Documentation for Cargo BuildArch: noarch # Cargo no longer builds its own documentation # https://github.com/rust-lang/cargo/pull/4904 Requires: rust-doc %description doc This package includes HTML documentation for Cargo. %prep %ifarch %{bootstrap_arches} %setup -q -n %{bootstrap_root} -T -b %{bootstrap_source} test -f '%{local_cargo}' %endif # cargo sources %setup -q -n %{name}-%{cargo_version} # vendored crates %setup -q -n %{name}-%{cargo_version} -T -D -a 100 # define the offline registry %global cargo_home $PWD/.cargo mkdir -p %{cargo_home} cat >.cargo/config <<EOF [source.crates-io] registry = 'https://github.com/rust-lang/crates.io-index' replace-with = 'vendored-sources' [source.vendored-sources] directory = '$PWD/vendor' EOF # This should eventually migrate to distro policy # Enable optimization, debuginfo, and link hardening. %global rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now %build %if %without bundled_libgit2 # convince libgit2-sys to use the distro libgit2 export LIBGIT2_SYS_USE_PKG_CONFIG=1 %endif # use our offline registry and custom rustc flags export CARGO_HOME="%{cargo_home}" export RUSTFLAGS="%{rustflags}" # cargo no longer uses a configure script, but we still want to use # CFLAGS in case of the odd C file in vendored dependencies. %{?__global_cflags:export CFLAGS="%{__global_cflags}"} %{!?__global_cflags:%{?optflags:export CFLAGS="%{optflags}"}} %{?__global_ldflags:export LDFLAGS="%{__global_ldflags}"} %{local_cargo} build --release %install export CARGO_HOME="%{cargo_home}" export RUSTFLAGS="%{rustflags}" %{local_cargo} install --root %{buildroot}%{_prefix} rm %{buildroot}%{_prefix}/.crates.toml mkdir -p %{buildroot}%{_mandir}/man1 %{__install} -p -m644 src/etc/man/cargo*.1 \ -t %{buildroot}%{_mandir}/man1 %{__install} -p -m644 src/etc/cargo.bashcomp.sh \ -D %{buildroot}%{_sysconfdir}/bash_completion.d/cargo %{__install} -p -m644 src/etc/_cargo \ -D %{buildroot}%{_datadir}/zsh/site-functions/_cargo # Create the path for crate-devel packages mkdir -p %{buildroot}%{_datadir}/cargo/registry # Cargo no longer builds its own documentation # https://github.com/rust-lang/cargo/pull/4904 mkdir -p %{buildroot}%{_docdir}/cargo/html cat <<EOF > %{buildroot}%{_docdir}/cargo/html/index.html <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta http-equiv="refresh" content="0; url=../../rust/html/cargo/index.html"> <script type="text/javascript"> window.location.href = "../../rust/html/cargo/index.html" </script> <title>cargo-doc redirection</title> </head> <body> Cargo documentation has been moved to the rust-doc package. If you are not redirected automatically, please follow this <a href="../../rust/html/cargo/index.html">link</a>. </body> </html> EOF %check export CARGO_HOME="%{cargo_home}" export RUSTFLAGS="%{rustflags}" # some tests are known to fail exact output due to libgit2 differences CFG_DISABLE_CROSS_TESTS=1 %{local_cargo} test --no-fail-fast || : %files %license LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY %doc README.md %{_bindir}/cargo %{_mandir}/man1/cargo*.1* %{_sysconfdir}/bash_completion.d/cargo %{_datadir}/zsh/site-functions/_cargo %dir %{_datadir}/cargo %dir %{_datadir}/cargo/registry %files doc %{_docdir}/cargo/html %changelog * Sat Apr 07 2018 akien <akien> 0.26.0-1.mga6 (not released yet) + Revision: 1216026 - Sync with Fedora: Mon Apr 02 2018 Josh Stone <jistone@redhat.com> - 0.26.0-2 o Update to 0.26.0. o Use an HTML redirect for docs instead of the dir-symlink replacement. - Sync with Fedora: Wed Feb 21 2018 Josh Stone <jistone@redhat.com> - 0.25.0-1 o Update to 0.25.0. o FTBFS: fix a misidentified shebang - Sync with Fedora: Mon Jan 08 2018 Josh Stone <jistone@redhat.com> - 0.24.0-1 o Update to 0.24.0. - Sync with Fedora: Wed Nov 29 2017 Josh Stone <jistone@redhat.com> - 0.23.0-1 o Update to 0.23.0. - Sync with Fedora: Mon Oct 16 2017 Josh Stone <jistone@redhat.com> - 0.22.0-1 o Update to 0.22.0 - Rebuild against fixed rust for armv7hl - Sync with Fedora: Thu Aug 31 2017 Josh Stone <jistone@redhat.com> - 0.21.0-1 o Update to 0.21.0. - Sync with Fedora: Fri Jul 21 2017 Josh Stone <jistone@redhat.com> - 0.20.0-1 o Update to 0.20.0. o Add a cargo-doc subpackage. * Wed Jun 21 2017 akien <akien> 0.19.0-2.mga6 + Revision: 1108108 - Sync with Fedora: Tue Jun 20 2017 Josh Stone <jistone@redhat.com> - 0.19.0-2 o Create /usr/share/cargo/registry for crate-devel packages * Sat Jun 10 2017 akien <akien> 0.19.0-1.mga6 + Revision: 1107521 - Sync with Fedora: Fri Jun 09 2017 Josh Stone <jistone@redhat.com> - 0.19.0-1 o Update to 0.19.0. o Enable non-gating tests. * Tue May 02 2017 akien <akien> 0.18.0-1.mga6 + Revision: 1098717 - Sync with Fedora: Thu Apr 27 2017 Josh Stone <jistone@redhat.com> - 0.18.0-1 o Update to 0.18.0. * Wed Mar 29 2017 akien <akien> 0.17.0-2.mga6 + Revision: 1095244 - Rebuild for libgit2 0.25.0 * Sun Mar 19 2017 akien <akien> 0.17.0-1.mga6 + Revision: 1093565 - Sync with Fedora: Thu Mar 16 2017 Josh Stone <jistone@redhat.com> - 0.17.0-1 o Update to 0.17.0. - Sync with Fedora: Tue Feb 14 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.16.0-2 o Backport patch to expose description in cargo metadata * Fri Feb 10 2017 akien <akien> 0.16.0-1.mga6 + Revision: 1085563 - Sync with Fedora: Thu Feb 09 2017 Josh Stone <jistone@redhat.com> - 0.16.0-1 o Update to 0.16.0. o Start using the current upstream release for bootstrap. * Thu Jan 05 2017 akien <akien> 0.15.0-1.mga6 + Revision: 1080184 - Sync with Fedora: * Tue Jan 03 2017 Josh Stone <jistone@redhat.com> - 0.15.0-1 o Update to 0.15.0. o Rewrite bootstrap logic to target specific arches. * Mon Nov 14 2016 akien <akien> 0.14.0-2.mga6 + Revision: 1067149 - Sync with Fedora: Sun Nov 13 2016 Josh Stone <jistone@redhat.com> - 0.14.0-2 o Fix CFG_RELEASE_NUM * Sat Nov 12 2016 akien <akien> 0.14.0-1.mga6 + Revision: 1066913 - Sync with Fedora: Thu Nov 10 2016 Josh Stone <jistone@redhat.com> - 0.14.0-1 o Update to 0.14.0. o Use hardening flags for linking. o Re-enable MIR with fixed Rust 1.12.1+. - Sync with Fedora: Thu Oct 06 2016 Josh Stone <jistone@redhat.com> - 0.13.0-2 o Bootstrap aarch64. (Not used on Mageia but added to reduce diff) o Use jemalloc's MALLOC_CONF to work around #36944. * Wed Oct 05 2016 akien <akien> 0.13.0-4.mga6 + Revision: 1058873 - Rebuild with system cargo on all arches * Wed Oct 05 2016 pterjan <pterjan> 0.13.0-3.mga6 + Revision: 1058843 - Fix bootstrap - Really bootstrap * Wed Oct 05 2016 pterjan <pterjan> 0.13.0-2.mga6 + Revision: 1058832 - Bootstrap for armv7hl, using last night armv6 tarball * Tue Oct 04 2016 akien <akien> 0.13.0-1.mga6 + Revision: 1058721 - Sync with Fedora: Tue Oct 04 2016 Josh Stone <jistone@redhat.com> - 0.13.0-1 o Disable MIR until rust#36774 is resolved. - Sync with Fedora: Fri Sep 30 2016 Josh Stone <jistone@redhat.com> - 0.13.0-1 o Update to 0.13.0. o Always use --local-cargo, even for bootstrap binaries. * Thu Sep 29 2016 akien <akien> 0.12.0-2.mga6 + Revision: 1057624 - Rebuild without bootstrap - Temporarily disable armv7hl build, as we miss rust there * Thu Sep 29 2016 akien <akien> 0.12.0-1.mga6 + Revision: 1057560 - Add missing RPM group - Initial bootstrap - Adjust spec file for Mageia compatibility o x86 32-bit arch on Mageia is i586, use %%ix86 and adjust rust triple accordingly o Use pkgconfig for BRs (necessary here as there is no virtual provides for libgit2-devel) o Drop ldconfig calls handled by our filetriggers o Use %%autopatch and %%mkrel - Use shorter GitHub archive URLs for the sources (own patch cherry-picked from Fedora) - Import cargo from Fedora, packaging by Josh Stone (0.12.0-2.fc26)