rust/rust.spec

245 lines
7.9 KiB
RPMSpec

#
# spec file for package rust
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2017 Luke Jones, luke.nukem.jones@gmail.com
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%global prev_rust 1.15.1
%global prev_cargo 0.16.0
%global abi gnu
%ifarch s390x
%global _arch s390x
%endif
%ifarch armv7hl
%global _arch armv7
%global abi gnueabihf
%endif
%ifarch ppc64
%global _arch powerpc64
%endif
%ifarch ppc64le
%global _arch powerpc64le
%endif
%ifarch x86_64
%global _arch x86_64
%endif
%ifarch %{ix86}
%global _arch i586
%endif
%global rust_triple %{_arch}-unknown-linux-%{abi}
%bcond_with rust_bootstrap
Name: rust-%{version}
Version: 1.16.0
Release: 0
Summary: A systems programming language
License: MIT or Apache-2.0
Group: Development/Languages/Other
Url: http://www.rust-lang.org
Source0: https://static.rust-lang.org/dist/rustc-%{version}-src.tar.gz
Source1: config.toml
Source100: %{name}-rpmlintrc
# PATCH-FIX-OPENSUSE: Set DT_SONAME when building dylibs
Patch1: add-soname.patch
BuildRequires: ccache
BuildRequires: chrpath
BuildRequires: cmake
BuildRequires: curl
BuildRequires: gcc-c++
BuildRequires: llvm-devel
BuildRequires: ninja
BuildRequires: procps
BuildRequires: python
Recommends: cargo
Recommends: %{name}-doc
Recommends: %{name}-std
Provides: rust = %{version}
Conflicts: rust <= %{version}
Conflicts: rust >= %{version}
Conflicts: rustc-bootstrap <= %{version}
Conflicts: rustc-bootstrap >= %{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# Restrict the architectures as building rust relies on being initially
# bootstrapped before we can build the n+1 release
ExclusiveArch: %{ix86} x86_64 %{arm} aarch64 ppc64 ppc64le s390x
%if 0%{?suse_version}
BuildRequires: fdupes
%endif
# There are no successful builds for less than TW or Leap 42.2, so bootstrap
# until such time that there is.
%if %{with rust_bootstrap} || (0%{?suse_version} < 1330 && 0%{?sle_version} <= 120100)
BuildRequires: cargo-bootstrap >= %{prev_cargo}
BuildRequires: rust-std-bootstrap == %{prev_rust}
BuildRequires: rustc-bootstrap == %{prev_rust}
%else
# Require exact versions to help prevent OBS build loops
BuildRequires: cargo == %{prev_cargo}
BuildRequires: rust == %{prev_rust}
BuildRequires: rust-std == %{prev_rust}
%endif
%description
Rust is a systems programming language focused on three goals:
safety, speed, and concurrency. It maintains these goals without
having a garbage collector, making it a useful language for a
number of use cases other languages are not good at: embedding
in other languages, programs with specific space and time
requirements, and writing low-level code, like device drivers
and operating systems. It improves on current languages targeting
this space by having a number of compile-time safety checks
that produce no runtime overhead, while eliminating all
data races. Rust also aims to achieve "zero-cost abstractions",
even though some of these abstractions feel like those of a
high-level language. Even then, Rust still allows precise
control like a low-level language would.
%package -n rust-std-%{version}
Summary: Standard library for Rust
Group: Development/Languages/Other
Provides: rust-std = %{version}
Conflicts: rust-std <= %{version}
Conflicts: rust-std >= %{version}
%description rust-std-%{version}
This package includes the standard libraries for building
applications written in Rust.
%package -n rust-doc-%{version}
Summary: Rust documentation
Group: Development/Languages/Other
Provides: rust-doc = %{version}
Conflicts: rust <= %{version}
Conflicts: rust >= %{version}
%description rust-doc-%{version}
Documentation for the Rust language.
%package -n rust-gdb-%{version}
Summary: Gdb integration for rust binaries
Group: Development/Languages/Other
Supplements: packageand(%{name}:gdb)
Provides: rustc:%{_bindir}/rust-gdb
%description rust-gdb-%{version}
This subpackage provides pretty printers and a wrapper script for
invoking gdb on rust binaries.
%prep
%setup -q -n rustc-%{version}-src
%patch1 -p1
sed -e 's:<rust-triple>:%{rust_triple}:g' \
-e 's:<prefix>:%{_prefix}:g' \
-e 's:<libdir>:%{_prefix}/lib:g' \
-e 's:<mandir>:%{_mandir}:g' \
-e 's:<docdir>:%{_docdir}/%{name}:g' \
%{SOURCE1} > config.toml
%build
export CPPFLAGS="%{optflags}" # eliminate complain from RPMlint
./x.py build -v
./x.py doc -v
%install
sed -e 's:<rust-triple>:%{rust_triple}:g' \
-e 's:<prefix>:%{buildroot}%{_prefix}:g' \
-e 's:<libdir>:%{buildroot}%{_prefix}/lib:g' \
-e 's:<mandir>:%{buildroot}%{_mandir}:g' \
-e 's:<docdir>:%{buildroot}%{_docdir}/%{name}:g' \
%{SOURCE1} > config.toml
./x.py dist --install
# Fix any rpaths if needed
chrpath -d %{buildroot}%{_prefix}/lib/lib*.so
# Remove executable permission from HTML documentation
# to prevent RPMLINT errors.
chmod -R -x+X %{buildroot}%{_docdir}/%{name}/html
# Remove surplus files
rm %{buildroot}%{_prefix}/lib/rustlib/components
rm %{buildroot}%{_prefix}/lib/rustlib/manifest-rust*
rm %{buildroot}%{_prefix}/lib/rustlib/install.log
rm %{buildroot}%{_prefix}/lib/rustlib/uninstall.sh
rm %{buildroot}%{_prefix}/lib/rustlib/rust-installer-version
# Remove lockfile to avoid errors.
rm %{buildroot}%{_docdir}/%{name}/html/.lock
# The remaining shared libraries should be executable for debuginfo extraction.
find %{buildroot}/%{_prefix}/lib/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
# extract bundled licenses for packaging - From fedora spec
cp src/rt/hoedown/LICENSE src/rt/hoedown/LICENSE-hoedown
sed -e '/*\//q' src/libbacktrace/backtrace.h \
>src/libbacktrace/LICENSE-libbacktrace
# Remvove the license files from _docdir: make install put duplicates there
rm %{buildroot}%{_defaultdocdir}/%{name}/{COPYRIGHT,LICENSE-APACHE,LICENSE-MIT}
%if 0%{?suse_version}
%fdupes %{buildroot}%{_prefix}
%endif
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root,-)
%license COPYRIGHT LICENSE-APACHE LICENSE-MIT
%license src/libbacktrace/LICENSE-libbacktrace
%license src/rt/hoedown/LICENSE-hoedown
%doc README.md
%{_bindir}/rustc
%{_bindir}/rustdoc
%{_bindir}/rust-lldb
%{_mandir}/man1/rustc.1*
%{_mandir}/man1/rustdoc.1*
%{_prefix}/lib/lib*.so
%exclude %{_docdir}/%{name}/html
%files rust-std-%{version}
%defattr(-,root,root)
%dir %{_prefix}/lib/rustlib
%dir %{_prefix}/lib/rustlib/%{rust_triple}
%dir %{_prefix}/lib/rustlib/%{rust_triple}/lib
%{_prefix}/lib/rustlib/%{rust_triple}/lib/*.rlib
%{_prefix}/lib/rustlib/%{rust_triple}/lib/*.so
%files rust-gdb-%{version}
%defattr(-,root,root,-)
%{_bindir}/rust-gdb
%dir %{_prefix}/lib/rustlib
%dir %{_prefix}/lib/rustlib/etc
%{_prefix}/lib/rustlib/etc/debugger_pretty_printers_common.py
%{_prefix}/lib/rustlib/etc/gdb_load_rust_pretty_printers.py
%{_prefix}/lib/rustlib/etc/gdb_rust_pretty_printing.py
%{_prefix}/lib/rustlib/etc/lldb_rust_formatters.py
%files rust-doc-%{version}
%defattr(-,root,root)
%license %{_docdir}/%{name}/html/FiraSans-LICENSE.txt
%license %{_docdir}/%{name}/html/Heuristica-LICENSE.txt
%license %{_docdir}/%{name}/html/LICENSE-APACHE.txt
%license %{_docdir}/%{name}/html/LICENSE-MIT.txt
%license %{_docdir}/%{name}/html/SourceCodePro-LICENSE.txt
%license %{_docdir}/%{name}/html/SourceSerifPro-LICENSE.txt
%dir %{_docdir}/%{name}
%dir %{_docdir}/%{name}/html
%doc %{_docdir}/%{name}/html/*
%changelog