]> git.pld-linux.org Git - packages/cargo.git/blob - cargo.spec
80bbaf2e87cb23d0185261cb35612f45ef676495
[packages/cargo.git] / cargo.spec
1 # Only x86_64 and i686 are Tier 1 platforms at this time.
2 # https://forge.rust-lang.org/platform-support.html
3 %define rust_arches x86_64 i686 armv7hl aarch64 ppc64 ppc64le s390x
4
5 # Only the specified arches will use bootstrap binaries.
6 #define bootstrap_arches %%{rust_arches}
7
8 %define cargo_version %{version}
9 %define cargo_bootstrap 0.18.0
10
11 Summary:        Rust's package manager and build tool
12 Name:           cargo
13 Version:        0.19.0
14 Release:        0.1
15 License:        ASL 2.0 or MIT
16 Source0:        https://github.com/rust-lang/cargo/archive/%{cargo_version}/%{name}-%{cargo_version}.tar.gz
17 # submodule, bundled for local installation only, not distributed
18 %define rust_installer 4f994850808a572e2cc8d43f968893c8e942e9bf
19 Source1:        https://github.com/rust-lang/rust-installer/archive/%{rust_installer}/rust-installer-%{rust_installer}.tar.gz
20
21 # Use vendored crate dependencies so we can build offline.
22 # Created using https://github.com/alexcrichton/cargo-vendor/ 0.1.7
23 # It's so big because some of the -sys crates include the C library source they
24 # want to link to.  With our -devel buildreqs in place, they'll be used instead.
25 # FIXME: These should all eventually be packaged on their own!
26 Source100:      %{name}-%{version}-vendor.tar.xz
27
28 URL:            https://crates.io/
29 %ifarch %{bootstrap_arches}
30 %define bootstrap_root cargo-%{cargo_bootstrap}-%{rust_triple}
31 %define local_cargo %{_builddir}/%{bootstrap_root}/cargo/bin/cargo
32 %else
33 BuildRequires:  %{name} >= 0.13.0
34 %define local_cargo %{_bindir}/%{name}
35 %endif
36
37 BuildRequires:  cmake
38 BuildRequires:  gcc
39 BuildRequires:  rust
40 # Indirect dependencies for vendored -sys crates above
41 BuildRequires:  curl-devel
42 BuildRequires:  libgit2-devel >= 0.24
43 BuildRequires:  libssh2-devel
44 BuildRequires:  openssl-devel
45 BuildRequires:  pkgconfig
46 BuildRequires:  zlib-devel
47 Requires:       rust
48 ExclusiveArch:  %{rust_arches}
49
50 %define rust_triple %{_target_cpu}-unknown-linux-gnu
51
52 %description
53 Cargo is a tool that allows Rust projects to declare their various
54 dependencies and ensure that you'll always get a repeatable build.
55
56 %prep
57 %ifarch %{bootstrap_arches}
58 %setup -q -n %{bootstrap_root} -T -b %{bootstrap_source}
59 test -f '%{local_cargo}'
60 %endif
61
62 # vendored crates
63 %setup -q -n %{name}-%{version}-vendor -T -b 100
64
65 # cargo sources
66 %setup -q -n %{name}-%{cargo_version}
67
68 # rust-installer
69 %setup -q -n %{name}-%{cargo_version} -T -D -a 1
70 rmdir src/rust-installer
71 mv rust-installer-%{rust_installer} src/rust-installer
72
73 # define the offline registry
74 %define cargo_home $PWD/.cargo
75 mkdir -p %{cargo_home}
76 cat >.cargo/config <<EOF
77 [source.crates-io]
78 registry = 'https://github.com/rust-lang/crates.io-index'
79 replace-with = 'vendored-sources'
80
81 [source.vendored-sources]
82 directory = '$PWD/../%{name}-%{version}-vendor'
83 EOF
84
85 # This should eventually migrate to distro policy
86 # Enable optimization, debuginfo, and link hardening.
87 %define rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now
88
89 %build
90 # convince libgit2-sys to use the distro libgit2
91 export LIBGIT2_SYS_USE_PKG_CONFIG=1
92
93 # use our offline registry and custom rustc flags
94 export CARGO_HOME="%{cargo_home}"
95 export RUSTFLAGS="%{rustflags}"
96
97 %configure \
98         --disable-option-checking \
99         --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
100         --rustc=%{_bindir}/rustc --rustdoc=%{_bindir}/rustdoc \
101         --cargo=%{local_cargo} \
102         --release-channel=stable \
103         --disable-cross-tests
104
105 %{__make}
106
107 %install
108 rm -rf $RPM_BUILD_ROOT
109 export CARGO_HOME="%{cargo_home}"
110 export RUSTFLAGS="%{rustflags}"
111
112 %{__make} install \
113         DESTDIR=$RPM_BUILD_ROOT
114
115 # Remove installer artifacts (manifests, uninstall scripts, etc.)
116 rm -rv $RPM_BUILD_ROOT%{_prefix}/lib/
117
118 # Fix the etc/ location
119 mv -v $RPM_BUILD_ROOT%{_prefix}/%{_sysconfdir} $RPM_BUILD_ROOT%{_sysconfdir}
120
121 # Remove unwanted documentation files (we already package them)
122 rm -rf $RPM_BUILD_ROOT%{_docdir}/%{name}/
123
124 # Create the path for crate-devel packages
125 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
126
127 %clean
128 rm -rf $RPM_BUILD_ROOT
129
130 %files
131 %defattr(644,root,root,755)
132 %doc LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY
133 %doc README.md
134 %attr(755,root,root) %{_bindir}/cargo
135 %{_mandir}/man1/cargo*.1*
136 %{_sysconfdir}/bash_completion.d/cargo
137 %{zsh_compdir}/_cargo
138 %dir %{_datadir}/cargo
139 %dir %{_datadir}/cargo/registry
This page took 0.106418 seconds and 2 git commands to generate.