Build Rust components and ship in optional mercurial-rust package
Original patch has been tweaked by Mads Kiilerich.
This commit is contained in:
parent
d5e33e9ca9
commit
095581b5d6
65
mercurial-rust-metadata.patch
Normal file
65
mercurial-rust-metadata.patch
Normal file
@ -0,0 +1,65 @@
|
||||
# HG changeset patch
|
||||
# Parent 5bd6bcd31dd1ebb63b8914b00064f96297267af7
|
||||
Patch cargo metadata for Fedora build
|
||||
|
||||
Backport upstream 6.2 changes to 6.1:
|
||||
- update memmap2 to 0.5.3 (upstream ec8d9b5a5e7c)
|
||||
- update micro-timer to 0.4.0 (upstream 8848c3453661, ec8d9b5a5e7c)
|
||||
|
||||
Update zstd to 0.10.0 (upstream is stuck on 0.5 because MSRV)
|
||||
- adapt for breaking changes in zstd 0.10.0
|
||||
|
||||
Downgrade ouroboros to 0.13.0 (Fedora packaging needs update - rhbz#2027028)
|
||||
|
||||
diff --git a/rust/hg-core/Cargo.toml b/rust/hg-core/Cargo.toml
|
||||
--- a/rust/hg-core/Cargo.toml
|
||||
+++ b/rust/hg-core/Cargo.toml
|
||||
@@ -18,7 +18,7 @@ im-rc = "15.0.*"
|
||||
itertools = "0.9"
|
||||
lazy_static = "1.4.0"
|
||||
libc = "0.2"
|
||||
-ouroboros = "0.15.0"
|
||||
+ouroboros = ">= 0.13.0, < 0.16.0"
|
||||
rand = "0.8.4"
|
||||
rand_pcg = "0.3.1"
|
||||
rand_distr = "0.4.2"
|
||||
@@ -29,10 +29,10 @@ twox-hash = "1.5.0"
|
||||
same-file = "1.0.6"
|
||||
tempfile = "3.1.0"
|
||||
crossbeam-channel = "0.4"
|
||||
-micro-timer = "0.3.0"
|
||||
+micro-timer = "0.4.0"
|
||||
log = "0.4.8"
|
||||
-memmap2 = {version = "0.4", features = ["stable_deref_trait"]}
|
||||
-zstd = "0.5.3"
|
||||
+memmap2 = {version = "0.5.3", features = ["stable_deref_trait"]}
|
||||
+zstd = "0.10"
|
||||
format-bytes = "0.3.0"
|
||||
|
||||
# We don't use the `miniz-oxide` backend to not change rhg benchmarks and until
|
||||
|
||||
diff --git a/rust/hg-core/src/revlog/revlog.rs b/rust/hg-core/src/revlog/revlog.rs
|
||||
--- a/rust/hg-core/src/revlog/revlog.rs
|
||||
+++ b/rust/hg-core/src/revlog/revlog.rs
|
||||
@@ -431,7 +431,7 @@ impl<'a> RevlogEntry<'a> {
|
||||
} else {
|
||||
let cap = self.uncompressed_len.max(0) as usize;
|
||||
let mut buf = vec![0; cap];
|
||||
- let len = zstd::block::decompress_to_buffer(self.bytes, &mut buf)
|
||||
+ let len = zstd::bulk::decompress_to_buffer(self.bytes, &mut buf)
|
||||
.map_err(|_| corrupted())?;
|
||||
if len != self.uncompressed_len as usize {
|
||||
Err(corrupted())
|
||||
|
||||
diff --git a/rust/rhg/Cargo.toml b/rust/rhg/Cargo.toml
|
||||
--- a/rust/rhg/Cargo.toml
|
||||
+++ b/rust/rhg/Cargo.toml
|
||||
@@ -16,7 +16,7 @@ derive_more = "0.99"
|
||||
home = "0.5.3"
|
||||
lazy_static = "1.4.0"
|
||||
log = "0.4.11"
|
||||
-micro-timer = "0.3.1"
|
||||
+micro-timer = "0.4.0"
|
||||
regex = "1.3.9"
|
||||
env_logger = "0.7.1"
|
||||
format-bytes = "0.3.0"
|
@ -1,7 +1,14 @@
|
||||
# build Rust binary and extensions
|
||||
%ifarch %{rust_arches}
|
||||
%bcond_without rust
|
||||
%else
|
||||
%bcond_with rust
|
||||
%endif
|
||||
|
||||
Summary: Mercurial -- a distributed SCM
|
||||
Name: mercurial
|
||||
Version: 6.1.1
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
|
||||
# Release: 1.rc1%%{?dist}
|
||||
|
||||
@ -12,6 +19,8 @@ License: GPLv2+
|
||||
URL: https://mercurial-scm.org/
|
||||
Source0: https://www.mercurial-scm.org/release/%{name}-%{upstreamversion}.tar.gz
|
||||
Source1: mercurial-site-start.el
|
||||
# Patch cargo metadata for dependency versions available in Fedora
|
||||
Patch0: mercurial-rust-metadata.patch
|
||||
BuildRequires: make
|
||||
BuildRequires: bash-completion
|
||||
BuildRequires: emacs-el
|
||||
@ -22,6 +31,9 @@ BuildRequires: pkgconfig
|
||||
BuildRequires: python3-devel
|
||||
BuildRequires: python3-setuptools
|
||||
BuildRequires: python3-docutils
|
||||
%if %{with rust}
|
||||
BuildRequires: rust-packaging
|
||||
%endif
|
||||
|
||||
Provides: hg = %{version}-%{release}
|
||||
Requires: python3
|
||||
@ -66,9 +78,54 @@ With chg, a Mercurial command server background process is created that runs
|
||||
Mercurial. When you type chg, a C program connects to that background process
|
||||
and executes Mercurial commands.
|
||||
|
||||
%if %{with rust}
|
||||
%package rust
|
||||
Summary: Mercurial Rust binaries and extensions
|
||||
# Effective license for the rust binaries, computed from statically linked dependencies:
|
||||
# BSD
|
||||
# GPLv2+
|
||||
# MIT
|
||||
# MIT or ASL 2.0
|
||||
# MPLv2.0
|
||||
# Python
|
||||
# Unlicense or MIT
|
||||
# zlib or ASL 2.0 or MIT
|
||||
License: GPLv2+
|
||||
Requires: hg = %{version}-%{release}
|
||||
|
||||
%description rust
|
||||
This subpackage provides following Mercurial components implemented in Rust:
|
||||
|
||||
The `rustext` extension speeds up some functionality of Mercurial, e.g.
|
||||
ancestry computations in revision graphs, status or discovery of differences
|
||||
between repositories.
|
||||
|
||||
The experimental `rhg` executable implements a subset of the functionality of `hg` using
|
||||
only Rust, to avoid the startup cost of a Python interpreter. This subset is
|
||||
initially small but grows over time as `rhg` is improved. When fallback to the
|
||||
Python implementation is configured, `rhg` aims to be a drop-in replacement
|
||||
for `hg` that should behave the same, except that some commands run faster.
|
||||
%endif
|
||||
|
||||
%prep
|
||||
%setup -q -n %{name}-%{upstreamversion}
|
||||
%autosetup -p1 -n %{name}-%{upstreamversion}
|
||||
|
||||
%if %{with rust}
|
||||
pushd rust
|
||||
%cargo_prep
|
||||
popd
|
||||
|
||||
%generate_buildrequires
|
||||
for crate in rust/hg-core rust/hg-cpython rust/rhg; do
|
||||
cd $crate
|
||||
# Temporarily remove hg-core = { path = "../hg-core"} dependencies while generating buildrequires.
|
||||
sed -i.br -r -e '/=\s*\{[^}]+path\s*=/d' Cargo.toml
|
||||
%cargo_generate_buildrequires
|
||||
mv -f Cargo.toml{.br,}
|
||||
cd - >/dev/null
|
||||
done
|
||||
%endif
|
||||
# /with rust
|
||||
|
||||
%build
|
||||
PYTHON=%{python3} make all
|
||||
@ -78,10 +135,27 @@ pushd contrib/chg
|
||||
make
|
||||
popd
|
||||
|
||||
%if %{with rust}
|
||||
# Mercurial build system hardcodes too much. Instead, just build with Fedora macro.
|
||||
pushd rust
|
||||
%cargo_build
|
||||
popd
|
||||
%endif
|
||||
|
||||
%install
|
||||
%{python3} setup.py install -O1 --root %{buildroot} --prefix %{_prefix} --record=%{name}.files
|
||||
make install-doc DESTDIR=%{buildroot} MANDIR=%{_mandir}
|
||||
|
||||
# Overrule setup.py policy "c" for module usage: always allow rust extension (if available)
|
||||
echo 'modulepolicy = b"rust+c-allow"' > %{buildroot}%{python3_sitearch}/mercurial/__modulepolicy__.py
|
||||
|
||||
%if %{with rust}
|
||||
# We are not using the Mercurial build system to build rust, and must thus manually install relevant parts.
|
||||
install -D -m 755 -pv rust/target/release/rhg %{buildroot}%{_bindir}
|
||||
install -D -m 755 -pv rust/target/release/librusthg.so \
|
||||
%{buildroot}%{python3_sitearch}/mercurial/rustext%{python3_ext_suffix}
|
||||
%endif
|
||||
|
||||
grep -v -e 'hgk.py*' \
|
||||
-e "%{python3_sitearch}/mercurial/" \
|
||||
-e "%{python3_sitearch}/hgext/" \
|
||||
@ -157,6 +231,7 @@ pathfix.py -pni "%{python3}" %{buildroot}%{_bindir}/hg-ssh
|
||||
%dir %{_sysconfdir}/mercurial/hgrc.d
|
||||
%{_datadir}/bash-completion/
|
||||
%{_datadir}/zsh/site-functions/_mercurial
|
||||
%exclude %{python3_sitearch}/mercurial/rustext%{python3_ext_suffix}
|
||||
%{python3_sitearch}/mercurial/
|
||||
%{python3_sitearch}/hgext/
|
||||
%{python3_sitearch}/hgext3rd/
|
||||
@ -176,6 +251,12 @@ pathfix.py -pni "%{python3}" %{buildroot}%{_bindir}/hg-ssh
|
||||
%{_bindir}/chg
|
||||
%doc %attr(644,root,root) %{_mandir}/man?/chg.*.gz
|
||||
|
||||
%if %{with rust}
|
||||
%files rust
|
||||
%{_bindir}/rhg
|
||||
%{python3_sitearch}/mercurial/rustext%{python3_ext_suffix}
|
||||
%endif
|
||||
|
||||
|
||||
#%%check
|
||||
# This will now fail everytime. Mercurial is not ported properly for Python3
|
||||
@ -185,6 +266,9 @@ pathfix.py -pni "%{python3}" %{buildroot}%{_bindir}/hg-ssh
|
||||
|
||||
|
||||
%changelog
|
||||
* Thu Apr 14 2022 Aleksei Bavshin <alebastr@fedoraproject.org> - 6.1.1-3
|
||||
- Build Rust components
|
||||
|
||||
* Wed Apr 06 2022 Mads Kiilerich <mads@kiilerich.com> - 6.1.1-2
|
||||
- Undo accicental commit
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user