cargo-vl.spec 9.4 KB

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