cargo-vl.spec 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. %bcond_with bootstrap
  2. # Only x86_64 and i686 are Tier 1 platforms at this time.
  3. # https://forge.rust-lang.org/platform-support.html
  4. %global rust_arches x86_64 i686
  5. # Only the specified arches will use bootstrap binaries.
  6. %if %{with bootstrap}
  7. %global bootstrap_arches %%{rust_arches}
  8. %endif
  9. %bcond_with bundled_libgit2
  10. Name: cargo
  11. Version: 0.24.0
  12. Release: 1%{?_dist_release}
  13. Summary: Rust's package manager and build tool
  14. License: ASL 2.0 or MIT
  15. URL: https://crates.io/
  16. ExclusiveArch: %{rust_arches}
  17. %global cargo_version %{version}
  18. %global cargo_bootstrap 0.23.0
  19. Source0: https://github.com/rust-lang/%{name}/archive/%{cargo_version}/%{name}-%{cargo_version}.tar.gz
  20. Patch1: cargo-0.23.0-disable-mdbook.patch
  21. # Get the Rust triple for any arch.
  22. %{lua: function rust_triple(arch)
  23. local abi = "gnu"
  24. if arch == "armv7hl" then
  25. arch = "armv7"
  26. abi = "gnueabihf"
  27. elseif arch == "ppc64" then
  28. arch = "powerpc64"
  29. elseif arch == "ppc64le" then
  30. arch = "powerpc64le"
  31. end
  32. return arch.."-unknown-linux-"..abi
  33. end}
  34. %global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))}
  35. %if %defined bootstrap_arches
  36. # For each bootstrap arch, add an additional binary Source.
  37. # Also define bootstrap_source just for the current target.
  38. %{lua: do
  39. local bootstrap_arches = {}
  40. for arch in string.gmatch(rpm.expand("%{bootstrap_arches}"), "%S+") do
  41. table.insert(bootstrap_arches, arch)
  42. end
  43. local base = rpm.expand("https://static.rust-lang.org/dist/cargo-%{cargo_bootstrap}")
  44. local target_arch = rpm.expand("%{_target_cpu}")
  45. for i, arch in ipairs(bootstrap_arches) do
  46. i = i + 10
  47. print(string.format("Source%d: %s-%s.tar.gz\n",
  48. i, base, rust_triple(arch)))
  49. if arch == target_arch then
  50. rpm.define("bootstrap_source "..i)
  51. end
  52. end
  53. end}
  54. %endif
  55. # Use vendored crate dependencies so we can build offline.
  56. # Created using https://github.com/alexcrichton/cargo-vendor/ 0.1.13
  57. # It's so big because some of the -sys crates include the C library source they
  58. # want to link to. With our -devel buildreqs in place, they'll be used instead.
  59. # FIXME: These should all eventually be packaged on their own!
  60. Source100: %{name}-%{version}-vendor.tar.xz
  61. BuildRequires: rust
  62. BuildRequires: make
  63. BuildRequires: cmake
  64. BuildRequires: gcc
  65. %ifarch %{bootstrap_arches}
  66. %global bootstrap_root cargo-%{cargo_bootstrap}-%{rust_triple}
  67. %global local_cargo %{_builddir}/%{bootstrap_root}/cargo/bin/cargo
  68. Provides: bundled(%{name}-bootstrap) = %{cargo_bootstrap}
  69. %else
  70. BuildRequires: %{name} >= 0.13.0
  71. %global local_cargo %{_bindir}/%{name}
  72. %endif
  73. # Indirect dependencies for vendored -sys crates above
  74. BuildRequires: curl-devel
  75. BuildRequires: libssh2-devel
  76. BuildRequires: openssl-devel
  77. BuildRequires: zlib-devel
  78. BuildRequires: pkgconfig
  79. %if %with bundled_libgit2
  80. Provides: bundled(libgit2) = 0.25.0
  81. %else
  82. BuildRequires: libgit2-devel >= 0.24
  83. %endif
  84. # Cargo is not much use without Rust
  85. Requires: rust
  86. %description
  87. Cargo is a tool that allows Rust projects to declare their various dependencies
  88. and ensure that you'll always get a repeatable build.
  89. %package doc
  90. Summary: Documentation for Cargo
  91. BuildArch: noarch
  92. %description doc
  93. This package includes HTML documentation for Cargo.
  94. %prep
  95. %ifarch %{bootstrap_arches}
  96. %setup -q -n %{bootstrap_root} -T -b %{bootstrap_source}
  97. test -f '%{local_cargo}'
  98. %endif
  99. # cargo sources
  100. %setup -q -n %{name}-%{cargo_version}
  101. # vendored crates
  102. %setup -q -n %{name}-%{cargo_version} -T -D -a 100
  103. %autopatch -p1
  104. # define the offline registry
  105. %global cargo_home $PWD/.cargo
  106. mkdir -p %{cargo_home}
  107. cat >.cargo/config <<EOF
  108. [source.crates-io]
  109. registry = 'https://github.com/rust-lang/crates.io-index'
  110. replace-with = 'vendored-sources'
  111. [source.vendored-sources]
  112. directory = '$PWD/vendor'
  113. EOF
  114. # This should eventually migrate to distro policy
  115. # Enable optimization, debuginfo, and link hardening.
  116. %global rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now
  117. %build
  118. %if %without bundled_libgit2
  119. # convince libgit2-sys to use the distro libgit2
  120. export LIBGIT2_SYS_USE_PKG_CONFIG=1
  121. %endif
  122. # use our offline registry and custom rustc flags
  123. export CARGO_HOME="%{cargo_home}"
  124. export RUSTFLAGS="%{rustflags}"
  125. # cargo no longer uses a configure script, but we still want to use
  126. # CFLAGS in case of the odd C file in vendored dependencies.
  127. %{?__global_cflags:export CFLAGS="%{__global_cflags}"}
  128. %{!?__global_cflags:%{?optflags:export CFLAGS="%{optflags}"}}
  129. %{?__global_ldflags:export LDFLAGS="%{__global_ldflags}"}
  130. %{local_cargo} build --release
  131. sh src/ci/dox.sh
  132. %install
  133. export CARGO_HOME="%{cargo_home}"
  134. export RUSTFLAGS="%{rustflags}"
  135. %{local_cargo} install --root %{buildroot}%{_prefix}
  136. rm %{buildroot}%{_prefix}/.crates.toml
  137. mkdir -p %{buildroot}%{_mandir}/man1
  138. %{__install} -p -m644 src/etc/man/cargo*.1 \
  139. -t %{buildroot}%{_mandir}/man1
  140. %{__install} -p -m644 src/etc/cargo.bashcomp.sh \
  141. -D %{buildroot}%{_sysconfdir}/bash_completion.d/cargo
  142. %{__install} -p -m644 src/etc/_cargo \
  143. -D %{buildroot}%{_datadir}/zsh/site-functions/_cargo
  144. # Create the path for crate-devel packages
  145. mkdir -p %{buildroot}%{_datadir}/cargo/registry
  146. mkdir -p %{buildroot}%{_docdir}/cargo
  147. cp -a target/doc %{buildroot}%{_docdir}/cargo/html
  148. %check
  149. export CARGO_HOME="%{cargo_home}"
  150. export RUSTFLAGS="%{rustflags}"
  151. # some tests are known to fail exact output due to libgit2 differences
  152. CFG_DISABLE_CROSS_TESTS=1 %{local_cargo} test --no-fail-fast || :
  153. %files
  154. %license LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY
  155. %doc README.md
  156. %{_bindir}/cargo
  157. %{_mandir}/man1/cargo*.1*
  158. %{_sysconfdir}/bash_completion.d/cargo
  159. %{_datadir}/zsh/site-functions/_cargo
  160. %dir %{_datadir}/cargo
  161. %dir %{_datadir}/cargo/registry
  162. %files doc
  163. %{_docdir}/cargo/html
  164. %changelog
  165. * Fri Jan 05 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 0.24.0-1
  166. - Updated to 0.24.0.
  167. * Tue Jan 02 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 0.23.0-2
  168. - initial build for Vine Linux.
  169. - built a bootstrap rpm.
  170. * Wed Nov 29 2017 Josh Stone <jistone@redhat.com> - 0.23.0-1
  171. - Update to 0.23.0.
  172. * Mon Oct 16 2017 Josh Stone <jistone@redhat.com> - 0.22.0-1
  173. - Update to 0.22.0.
  174. * Mon Sep 11 2017 Josh Stone <jistone@redhat.com> - 0.21.1-1
  175. - Update to 0.21.1.
  176. * Thu Aug 31 2017 Josh Stone <jistone@redhat.com> - 0.21.0-1
  177. - Update to 0.21.0.
  178. * Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.20.0-3
  179. - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
  180. * Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.20.0-2
  181. - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
  182. * Fri Jul 21 2017 Josh Stone <jistone@redhat.com> - 0.20.0-1
  183. - Update to 0.20.0.
  184. - Add a cargo-doc subpackage.
  185. * Sat Jul 08 2017 Igor Gnatenko <ignatenko@redhat.com> - 0.19.0-4
  186. - Disable bootstrap
  187. * Sat Jul 08 2017 Igor Gnatenko <ignatenko@redhat.com> - 0.19.0-3
  188. - Rebuild for libgit2 0.26.x
  189. * Tue Jun 20 2017 Josh Stone <jistone@redhat.com> - 0.19.0-2
  190. - Create /usr/share/cargo/registry for crate-devel packages
  191. * Fri Jun 09 2017 Josh Stone <jistone@redhat.com> - 0.19.0-1
  192. - Update to 0.19.0.
  193. * Thu Apr 27 2017 Josh Stone <jistone@redhat.com> - 0.18.0-1
  194. - Update to 0.18.0.
  195. * Thu Mar 16 2017 Josh Stone <jistone@redhat.com> - 0.17.0-1
  196. - Update to 0.17.0.
  197. * Tue Feb 14 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.16.0-2
  198. - Backport patch to expose description in cargo metadata
  199. * Thu Feb 09 2017 Josh Stone <jistone@redhat.com> - 0.16.0-1
  200. - Update to 0.16.0.
  201. - Start using the current upstream release for bootstrap.
  202. - Merge and clean up conditionals for epel7.
  203. * Tue Feb 07 2017 Igor Gnatenko <ignatenko@redhat.com> - 0.15.0-4
  204. - Disable bootstrap
  205. * Tue Feb 07 2017 Igor Gnatenko <ignatenko@redhat.com> - 0.15.0-3
  206. - Rebuild for libgit2-0.25.x
  207. * Tue Jan 03 2017 Josh Stone <jistone@redhat.com> - 0.15.0-2
  208. - Rebuild without bootstrap binaries.
  209. * Tue Jan 03 2017 Josh Stone <jistone@redhat.com> - 0.15.0-1
  210. - Update to 0.15.0.
  211. - Rewrite bootstrap logic to target specific arches.
  212. - Bootstrap ppc64, ppc64le, s390x.
  213. * Sun Nov 13 2016 Josh Stone <jistone@redhat.com> - 0.14.0-2
  214. - Fix CFG_RELEASE_NUM
  215. * Thu Nov 10 2016 Josh Stone <jistone@redhat.com> - 0.14.0-1
  216. - Update to 0.14.0.
  217. - Use hardening flags for linking.
  218. * Thu Oct 20 2016 Josh Stone <jistone@redhat.com> - 0.13.0-4
  219. - Rebuild with Rust 1.12.1 and enabled MIR.
  220. * Fri Oct 07 2016 Josh Stone <jistone@redhat.com> - 0.13.0-3
  221. - Rebuild without bootstrap binaries.
  222. * Thu Oct 06 2016 Josh Stone <jistone@redhat.com> - 0.13.0-2
  223. - Bootstrap aarch64.
  224. - Use jemalloc's MALLOC_CONF to work around #36944.
  225. * Fri Sep 30 2016 Josh Stone <jistone@redhat.com> - 0.13.0-1
  226. - Update to 0.13.0.
  227. - Always use --local-cargo, even for bootstrap binaries.
  228. - Disable MIR until rust#36774 is resolved.
  229. * Sat Sep 03 2016 Josh Stone <jistone@redhat.com> - 0.12.0-3
  230. - Rebuild without bootstrap binaries.
  231. * Fri Sep 02 2016 Josh Stone <jistone@redhat.com> - 0.12.0-2
  232. - Bootstrap armv7hl.
  233. - Patch dl-snapshot.py to ignore hashes on unknown archs.
  234. * Wed Aug 24 2016 Josh Stone <jistone@redhat.com> - 0.12.0-1
  235. - Update to 0.12.0.
  236. * Mon Aug 22 2016 Josh Stone <jistone@redhat.com> 0.11.0-3
  237. - Rebuild without bootstrap binaries.
  238. - Add a runtime requirement on rust.
  239. * Mon Aug 22 2016 Josh Stone <jistone@redhat.com> - 0.11.0-2
  240. - Initial import into Fedora (#1357749), bootstrapped
  241. * Sun Jul 17 2016 Josh Stone <jistone@fedoraproject.org> - 0.11.0-1
  242. - Initial package, bootstrapped