/[packages]/cauldron/cargo/current/SPECS/cargo.spec
ViewVC logotype

Contents of /cauldron/cargo/current/SPECS/cargo.spec

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1108108 - (show annotations) (download)
Wed Jun 21 09:39:42 2017 UTC (6 years, 10 months ago) by akien
File size: 6073 byte(s)
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
1 # (akien) This package is (for now) synced with Fedora / Josh Stone's spec.
2 # The aim is to work with them on a rust packaging policy we could share,
3 # so that we can ensure a good packaging and share the workload.
4
5
6 # Only x86_64 and i686 are Tier 1 platforms at this time.
7 # https://forge.rust-lang.org/platform-support.html
8 %global rust_arches x86_64 %ix86 armv7hl aarch64 ppc64 ppc64le s390x
9
10 # Only the specified arches will use bootstrap binaries.
11 #global bootstrap_arches %%{rust_arches}
12
13 %if 0%{?rhel} && !0%{?epel}
14 %bcond_without bundled_libgit2
15 %else
16 %bcond_with bundled_libgit2
17 %endif
18
19 Name: cargo
20 Version: 0.19.0
21 Release: %mkrel 2
22 Summary: Rust's package manager and build tool
23 %if 0%{?mageia}
24 Group: Development/Other
25 %endif
26 License: ASL 2.0 or MIT
27 URL: https://crates.io/
28 ExclusiveArch: %{rust_arches}
29
30 %global cargo_version %{version}
31 %global cargo_bootstrap 0.18.0
32
33 Source0: https://github.com/rust-lang/%{name}/archive/%{cargo_version}/%{name}-%{cargo_version}.tar.gz
34
35 # submodule, bundled for local installation only, not distributed
36 %global rust_installer 4f994850808a572e2cc8d43f968893c8e942e9bf
37 Source1: https://github.com/rust-lang/rust-installer/archive/%{rust_installer}/rust-installer-%{rust_installer}.tar.gz
38
39 # Get the Rust triple for any arch.
40 %{lua: function rust_triple(arch)
41 local abi = "gnu"
42 if arch == "armv7hl" then
43 arch = "armv7"
44 abi = "gnueabihf"
45 elseif arch == "ppc64" then
46 arch = "powerpc64"
47 elseif arch == "ppc64le" then
48 arch = "powerpc64le"
49 elseif arch == "i586" then
50 arch = "i686"
51 end
52 return arch.."-unknown-linux-"..abi
53 end}
54
55 %global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))}
56
57 %if %defined bootstrap_arches
58 # For each bootstrap arch, add an additional binary Source.
59 # Also define bootstrap_source just for the current target.
60 %{lua: do
61 local bootstrap_arches = {}
62 for arch in string.gmatch(rpm.expand("%{bootstrap_arches}"), "%S+") do
63 table.insert(bootstrap_arches, arch)
64 end
65 local base = rpm.expand("https://static.rust-lang.org/dist/cargo-%{cargo_bootstrap}")
66 local target_arch = rpm.expand("%{_target_cpu}")
67 for i, arch in ipairs(bootstrap_arches) do
68 i = i + 10
69 print(string.format("Source%d: %s-%s.tar.gz\n",
70 i, base, rust_triple(arch)))
71 if arch == target_arch then
72 rpm.define("bootstrap_source "..i)
73 end
74 end
75 end}
76 %endif
77
78 # Use vendored crate dependencies so we can build offline.
79 # Created using https://github.com/alexcrichton/cargo-vendor/ 0.1.7
80 # It's so big because some of the -sys crates include the C library source they
81 # want to link to. With our -devel buildreqs in place, they'll be used instead.
82 # FIXME: These should all eventually be packaged on their own!
83 Source100: %{name}-%{version}-vendor.tar.xz
84
85 BuildRequires: rust
86 BuildRequires: make
87 BuildRequires: cmake
88 BuildRequires: gcc
89
90 %ifarch %{bootstrap_arches}
91 %global bootstrap_root cargo-%{cargo_bootstrap}-%{rust_triple}
92 %global local_cargo %{_builddir}/%{bootstrap_root}/cargo/bin/cargo
93 %else
94 BuildRequires: %{name} >= 0.13.0
95 %global local_cargo %{_bindir}/%{name}
96 %endif
97
98 # Indirect dependencies for vendored -sys crates above
99 BuildRequires: libcurl-devel
100 BuildRequires: libssh2-devel
101 BuildRequires: openssl-devel
102 BuildRequires: zlib-devel
103 BuildRequires: pkgconfig
104
105 %if %with bundled_libgit2
106 Provides: bundled(libgit2) = 0.25.0
107 %else
108 BuildRequires: libgit2-devel >= 0.24
109 %endif
110
111 # Cargo is not much use without Rust
112 Requires: rust
113
114 %description
115 Cargo is a tool that allows Rust projects to declare their various dependencies
116 and ensure that you'll always get a repeatable build.
117
118
119 %prep
120
121 %ifarch %{bootstrap_arches}
122 %setup -q -n %{bootstrap_root} -T -b %{bootstrap_source}
123 test -f '%{local_cargo}'
124 %endif
125
126 # vendored crates
127 %setup -q -n %{name}-%{version}-vendor -T -b 100
128
129 # cargo sources
130 %setup -q -n %{name}-%{cargo_version}
131
132 # rust-installer
133 %setup -q -n %{name}-%{cargo_version} -T -D -a 1
134 rmdir src/rust-installer
135 mv rust-installer-%{rust_installer} src/rust-installer
136
137 # define the offline registry
138 %global cargo_home $PWD/.cargo
139 mkdir -p %{cargo_home}
140 cat >.cargo/config <<EOF
141 [source.crates-io]
142 registry = 'https://github.com/rust-lang/crates.io-index'
143 replace-with = 'vendored-sources'
144
145 [source.vendored-sources]
146 directory = '$PWD/../%{name}-%{version}-vendor'
147 EOF
148
149 # This should eventually migrate to distro policy
150 # Enable optimization, debuginfo, and link hardening.
151 %global rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now
152
153
154 %build
155
156 %if %without bundled_libgit2
157 # convince libgit2-sys to use the distro libgit2
158 export LIBGIT2_SYS_USE_PKG_CONFIG=1
159 %endif
160
161 # use our offline registry and custom rustc flags
162 export CARGO_HOME="%{cargo_home}"
163 export RUSTFLAGS="%{rustflags}"
164
165 %configure --disable-option-checking \
166 --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
167 --rustc=%{_bindir}/rustc --rustdoc=%{_bindir}/rustdoc \
168 --cargo=%{local_cargo} \
169 --release-channel=stable \
170 --disable-cross-tests \
171 %{nil}
172
173 make %{_smp_mflags}
174
175
176 %install
177 export CARGO_HOME="%{cargo_home}"
178 export RUSTFLAGS="%{rustflags}"
179
180 %make_install
181
182 # Remove installer artifacts (manifests, uninstall scripts, etc.)
183 rm -rv %{buildroot}%{_prefix}/lib/
184
185 # Fix the etc/ location
186 mv -v %{buildroot}%{_prefix}%{_sysconfdir} %{buildroot}%{_sysconfdir}
187
188 # Remove unwanted documentation files (we already package them)
189 rm -rf %{buildroot}%{_docdir}/%{name}/
190
191 # Create the path for crate-devel packages
192 mkdir -p %{buildroot}%{_datadir}/cargo/registry
193
194
195 %check
196 export CARGO_HOME="%{cargo_home}"
197 export RUSTFLAGS="%{rustflags}"
198
199 # the testsuite run in parallel itself
200 # some tests are known to fail exact output due to libgit2 differences
201 make test || :
202
203
204 %files
205 %license LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY
206 %doc README.md
207 %{_bindir}/cargo
208 %{_mandir}/man1/cargo*.1*
209 %{_sysconfdir}/bash_completion.d/cargo
210 %{_datadir}/zsh/site-functions/_cargo
211 %dir %{_datadir}/cargo
212 %dir %{_datadir}/cargo/registry

  ViewVC Help
Powered by ViewVC 1.1.30