From e54acae3789e79eb43436f086276e6c9a2a8e25e Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Sat, 16 Jul 2022 14:36:03 +0200 Subject: [PATCH] Update to version 0.1.19; Fixes RHBZ#2094053 --- .gitignore | 1 + ...tionally-link-against-system-liblzma.patch | 123 ++++++++++++++++++ lzma-sys-fix-metadata.diff | 9 ++ rust-lzma-sys.spec | 45 +++---- sources | 2 +- 5 files changed, 152 insertions(+), 28 deletions(-) create mode 100644 0001-build-unconditionally-link-against-system-liblzma.patch create mode 100644 lzma-sys-fix-metadata.diff diff --git a/.gitignore b/.gitignore index d3d80f3..88e67bb 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ /lzma-sys-0.1.15.crate /lzma-sys-0.1.16.crate /lzma-sys-0.1.17.crate +/lzma-sys-0.1.19.crate diff --git a/0001-build-unconditionally-link-against-system-liblzma.patch b/0001-build-unconditionally-link-against-system-liblzma.patch new file mode 100644 index 0000000..98443a0 --- /dev/null +++ b/0001-build-unconditionally-link-against-system-liblzma.patch @@ -0,0 +1,123 @@ +From 5f427b0df0bebef259b1ab39e5b06eda38022b8b Mon Sep 17 00:00:00 2001 +From: Fabio Valentini +Date: Sat, 16 Jul 2022 14:26:41 +0200 +Subject: [PATCH] build: unconditionally link against system liblzma + +--- + build.rs | 103 ++----------------------------------------------------- + 1 file changed, 2 insertions(+), 101 deletions(-) + +diff --git a/build.rs b/build.rs +index 7d4c939..22ab405 100644 +--- a/build.rs ++++ b/build.rs +@@ -1,104 +1,5 @@ +-use std::env; +-use std::fs; +-use std::path::PathBuf; +- +-const SKIP_FILENAMES: &[&str] = &["crc32_small", "crc64_small"]; +- + fn main() { +- let target = env::var("TARGET").unwrap(); +- + println!("cargo:rerun-if-changed=build.rs"); +- println!("cargo:rerun-if-env-changed=LZMA_API_STATIC"); +- let want_static = cfg!(feature = "static") || env::var("LZMA_API_STATIC").is_ok(); +- let msvc = target.contains("msvc"); +- +- // If a static link is desired, we compile from source. +- // If we're compiling for MSVC, pkg-config runs a risk of picking up MinGW +- // libraries by accident, so disable it. +- // +- // Otherwise check the system to see if it has an lzma library already +- // installed that we can use. +- if !want_static && !msvc && pkg_config::probe_library("liblzma").is_ok() { +- return; +- } +- +- let out_dir = env::var("OUT_DIR").unwrap(); +- println!("cargo:root={}", out_dir); +- let include_dir = env::current_dir().unwrap().join("xz-5.2/src/liblzma/api"); +- println!("cargo:include={}", include_dir.display()); +- +- let src_files = [ +- "xz-5.2/src/liblzma/common", +- "xz-5.2/src/liblzma/lzma", +- "xz-5.2/src/liblzma/lz", +- "xz-5.2/src/liblzma/check", +- "xz-5.2/src/liblzma/delta", +- "xz-5.2/src/liblzma/rangecoder", +- "xz-5.2/src/liblzma/simple", +- ] +- .iter() +- .flat_map(|dir| read_dir_files(dir)) +- .chain(vec![ +- "xz-5.2/src/common/tuklib_cpucores.c".into(), +- "xz-5.2/src/common/tuklib_physmem.c".into(), +- ]); +- +- let mut build = cc::Build::new(); +- +- build +- .files(src_files) +- // all C preproc defines are in `./config.h` +- .define("HAVE_CONFIG_H", "1") +- .include("xz-5.2/src/liblzma/api") +- .include("xz-5.2/src/liblzma/lzma") +- .include("xz-5.2/src/liblzma/lz") +- .include("xz-5.2/src/liblzma/check") +- .include("xz-5.2/src/liblzma/simple") +- .include("xz-5.2/src/liblzma/delta") +- .include("xz-5.2/src/liblzma/common") +- .include("xz-5.2/src/liblzma/rangecoder") +- .include("xz-5.2/src/common") +- .include(env::current_dir().unwrap()); +- +- if !target.ends_with("msvc") { +- build.flag("-std=c99").flag("-pthread"); +- } +- +- if let Ok(s) = env::var("CARGO_CFG_TARGET_ENDIAN") { +- if s == "big" { +- build.define("WORDS_BIGENDIAN", None); +- } +- } +- +- build.compile("liblzma.a"); +-} +- +-fn read_dir_files(dir: &str) -> impl Iterator { +- fs::read_dir(dir) +- .expect(&format!("failed to read dir {}", dir)) +- .filter_map(|ent| { +- let ent = ent.expect("failed to read entry"); +- +- if ent.file_type().unwrap().is_dir() { +- return None; +- } +- +- let path = ent.path(); +- +- if path.extension().unwrap() != "c" { +- return None; +- } +- +- { +- let file_stem = path.file_stem().unwrap().to_str().unwrap(); +- if SKIP_FILENAMES.contains(&file_stem) { +- return None; +- } +- if file_stem.ends_with("tablegen") { +- return None; +- } +- } +- +- Some(path) +- }) ++ pkg_config::probe_library("liblzma").unwrap(); ++ return; + } +-- +2.37.1 + diff --git a/lzma-sys-fix-metadata.diff b/lzma-sys-fix-metadata.diff new file mode 100644 index 0000000..d532b90 --- /dev/null +++ b/lzma-sys-fix-metadata.diff @@ -0,0 +1,9 @@ +--- lzma-sys-0.1.19/Cargo.toml 1970-01-01T00:00:01+00:00 ++++ lzma-sys-0.1.19/Cargo.toml 2022-07-16T12:20:45.015978+00:00 +@@ -36,6 +36,3 @@ + + [build-dependencies.pkg-config] + version = "0.3.14" +- +-[features] +-static = [] diff --git a/rust-lzma-sys.spec b/rust-lzma-sys.spec index 8c9125e..adbb8a0 100644 --- a/rust-lzma-sys.spec +++ b/rust-lzma-sys.spec @@ -1,11 +1,11 @@ -# Generated by rust2rpm 15 +# Generated by rust2rpm 21 %bcond_without check %global debug_package %{nil} %global crate lzma-sys Name: rust-%{crate} -Version: 0.1.17 +Version: 0.1.19 Release: %autorelease Summary: Raw bindings to liblzma @@ -13,13 +13,14 @@ Summary: Raw bindings to liblzma License: MIT or ASL 2.0 URL: https://crates.io/crates/lzma-sys Source: %{crates_source} +# Initial patched metadata +# * drop feature for statically linking against the bundled version of liblzma +Patch0: lzma-sys-fix-metadata.diff +Patch1: 0001-build-unconditionally-link-against-system-liblzma.patch ExclusiveArch: %{rust_arches} -%if %{__cargo_skip_build} -BuildArch: noarch -%endif -BuildRequires: rust-packaging +BuildRequires: rust-packaging >= 21 %global _description %{expand: Raw bindings to liblzma which contains an implementation of LZMA and xz stream @@ -35,12 +36,13 @@ Requires: (pkgconfig(liblzma) >= 5.2.4 with pkgconfig(liblzma) < 6.0.0) %description devel %{_description} -This package contains library source intended for building other packages -which use "%{crate}" crate. +This package contains library source intended for building other packages which +use the "%{crate}" crate. %files devel -%license LICENSE-MIT LICENSE-APACHE -%{cargo_registry}/%{crate}-%{version_no_tilde}/ +%license %{crate_instdir}/LICENSE-APACHE +%license %{crate_instdir}/LICENSE-MIT +%{crate_instdir}/ %package -n %{name}+default-devel Summary: %{summary} @@ -48,28 +50,17 @@ BuildArch: noarch %description -n %{name}+default-devel %{_description} -This package contains library source intended for building other packages -which use "default" feature of "%{crate}" crate. +This package contains library source intended for building other packages which +use the "default" feature of the "%{crate}" crate. %files -n %{name}+default-devel -%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml - -%package -n %{name}+static-devel -Summary: %{summary} -BuildArch: noarch - -%description -n %{name}+static-devel %{_description} - -This package contains library source intended for building other packages -which use "static" feature of "%{crate}" crate. - -%files -n %{name}+static-devel -%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml +%ghost %{crate_instdir}/Cargo.toml %prep %autosetup -n %{crate}-%{version_no_tilde} -p1 -# No bundled libs -rm -vrf xz-* config.h +# remove bundled dependencies +rm -r xz-* +rm config.h %cargo_prep %generate_buildrequires diff --git a/sources b/sources index c375ee9..417ec7a 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (lzma-sys-0.1.17.crate) = 1801602b11b479c71552e67b1e0384535b7b6ffbfeb3abee122c2a965db0f07e98452d046b1036143047d4675f3749507eb144591eda083573175b392af2e0af +SHA512 (lzma-sys-0.1.19.crate) = 2a6cf7566987f9383b24d3880c28f47752f48b33badb0bf50f770354dccb4aaa2c934251912a3795bbe5d89f5c1485d66d772be9fa6defefcdbfaa053ac1aecd