From 2f055a0e21efcfe6f2ac23cf5100d8a8bc265a80 Mon Sep 17 00:00:00 2001 From: MSVSphere Packaging Team Date: Fri, 20 Dec 2024 16:14:14 +0300 Subject: [PATCH] import rust-libz-sys-1.1.20-1.el10 --- .gitignore | 1 + .rust-libz-sys.metadata | 1 + ...use-pkg-config-to-link-with-system-z.patch | 265 ++++++++++++++++++ SOURCES/libz-sys-fix-metadata.diff | 32 +++ SOURCES/rust2rpm.toml | 16 ++ SPECS/rust-libz-sys.spec | 242 ++++++++++++++++ 6 files changed, 557 insertions(+) create mode 100644 .gitignore create mode 100644 .rust-libz-sys.metadata create mode 100644 SOURCES/0001-unconditionally-use-pkg-config-to-link-with-system-z.patch create mode 100644 SOURCES/libz-sys-fix-metadata.diff create mode 100644 SOURCES/rust2rpm.toml create mode 100644 SPECS/rust-libz-sys.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0580e43 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/libz-sys-1.1.20.crate diff --git a/.rust-libz-sys.metadata b/.rust-libz-sys.metadata new file mode 100644 index 0000000..e23432d --- /dev/null +++ b/.rust-libz-sys.metadata @@ -0,0 +1 @@ +254603a064265c3f9a9e31f99295f1a4c6afd16b SOURCES/libz-sys-1.1.20.crate diff --git a/SOURCES/0001-unconditionally-use-pkg-config-to-link-with-system-z.patch b/SOURCES/0001-unconditionally-use-pkg-config-to-link-with-system-z.patch new file mode 100644 index 0000000..5ad31e8 --- /dev/null +++ b/SOURCES/0001-unconditionally-use-pkg-config-to-link-with-system-z.patch @@ -0,0 +1,265 @@ +From 3660391791ccadf584bcbfd0b9238fca13e52522 Mon Sep 17 00:00:00 2001 +From: Fabio Valentini +Date: Wed, 25 Sep 2024 17:10:14 +0200 +Subject: [PATCH] unconditionally use pkg-config to link with system zlib + +--- + build.rs | 243 +------------------------------------------------------ + 1 file changed, 4 insertions(+), 239 deletions(-) + +diff --git a/build.rs b/build.rs +index cab160a..8d1acf7 100644 +--- a/build.rs ++++ b/build.rs +@@ -1,244 +1,9 @@ +-use std::env; +-use std::fs; +-use std::path::PathBuf; +- + fn main() { +- println!("cargo:rerun-if-env-changed=LIBZ_SYS_STATIC"); + println!("cargo:rerun-if-changed=build.rs"); +- println!("cargo:rerun-if-changed=zng/cmake.rs"); +- println!("cargo:rerun-if-changed=zng/cc.rs"); +- +- let host = env::var("HOST").unwrap(); +- let target = env::var("TARGET").unwrap(); +- +- let host_and_target_contain = |s| host.contains(s) && target.contains(s); +- +- let want_ng = cfg!(any( +- feature = "zlib-ng", +- feature = "zlib-ng-no-cmake-experimental-community-maintained" +- )) && !cfg!(feature = "stock-zlib"); +- +- if want_ng && target != "wasm32-unknown-unknown" { +- return build_zlib_ng(&target, true); +- } +- +- // All android compilers should come with libz by default, so let's just use +- // the one already there. Likewise, Haiku always ships with libz, so we can +- // link to it even when cross-compiling. +- if target.contains("android") || target.contains("haiku") { +- println!("cargo:rustc-link-lib=z"); +- return; +- } +- +- // Don't run pkg-config if we're linking statically (we'll build below) and +- // also don't run pkg-config on FreeBSD/DragonFly. That'll end up printing +- // `-L /usr/lib` which wreaks havoc with linking to an OpenSSL in /usr/local/lib +- // (Ports, etc.) +- let want_static = +- cfg!(feature = "static") || env::var("LIBZ_SYS_STATIC").unwrap_or(String::new()) == "1"; +- if !want_static && +- !target.contains("msvc") && // pkg-config just never works here +- !(host_and_target_contain("freebsd") || +- host_and_target_contain("dragonfly")) +- { +- // Don't print system lib dirs to cargo since this interferes with other +- // packages adding non-system search paths to link against libraries +- // that are also found in a system-wide lib dir. +- let zlib = pkg_config::Config::new() +- .cargo_metadata(true) +- .print_system_libs(false) +- .probe("zlib"); +- match zlib { +- Ok(zlib) => { +- if !zlib.include_paths.is_empty() { +- let paths = zlib +- .include_paths +- .iter() +- .map(|s| s.display().to_string()) +- .collect::>(); +- println!("cargo:include={}", paths.join(",")); +- } +- } +- Err(e) => { +- println!("cargo-warning={}", e.to_string()) +- } +- } +- } +- +- if target.contains("windows") { +- if try_vcpkg() { +- return; +- } +- } +- +- let mut cfg = cc::Build::new(); +- +- // Situations where we build unconditionally. +- // +- // MSVC basically never has it preinstalled, MinGW picks up a bunch of weird +- // paths we don't like, `want_static` may force us, and cross compiling almost +- // never has a prebuilt version. +- // +- // Apple platforms have libz.1.dylib, and it's usually available even when +- // cross compiling (via fat binary or in the target's Xcode SDK) +- let cross_compiling = target != host; +- if target.contains("msvc") +- || target.contains("pc-windows-gnu") +- || want_static +- || (cross_compiling && !target.contains("-apple-")) +- { +- return build_zlib(&mut cfg, &target); +- } +- +- // If we've gotten this far we're probably a pretty standard platform. +- // Almost all platforms here ship libz by default, but some don't have +- // pkg-config files that we would find above. +- // +- // In any case test if zlib is actually installed and if so we link to it, +- // otherwise continue below to build things. +- if zlib_installed(&mut cfg) { +- println!("cargo:rustc-link-lib=z"); +- return; +- } +- +- build_zlib(&mut cfg, &target) +-} +- +-fn build_zlib(cfg: &mut cc::Build, target: &str) { +- let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); +- let lib = dst.join("lib"); +- +- cfg.warnings(false).out_dir(&lib).include("src/zlib"); +- +- cfg.file("src/zlib/adler32.c") +- .file("src/zlib/compress.c") +- .file("src/zlib/crc32.c") +- .file("src/zlib/deflate.c") +- .file("src/zlib/infback.c") +- .file("src/zlib/inffast.c") +- .file("src/zlib/inflate.c") +- .file("src/zlib/inftrees.c") +- .file("src/zlib/trees.c") +- .file("src/zlib/uncompr.c") +- .file("src/zlib/zutil.c"); + +- if !cfg!(feature = "libc") || target.starts_with("wasm32") { +- cfg.define("Z_SOLO", None); +- } else { +- cfg.file("src/zlib/gzclose.c") +- .file("src/zlib/gzlib.c") +- .file("src/zlib/gzread.c") +- .file("src/zlib/gzwrite.c"); +- } +- +- if !target.contains("windows") { +- cfg.define("STDC", None); +- cfg.define("_LARGEFILE64_SOURCE", None); +- cfg.define("_POSIX_SOURCE", None); +- cfg.flag("-fvisibility=hidden"); +- } +- if target.contains("apple") { +- cfg.define("_C99_SOURCE", None); +- } +- if target.contains("solaris") { +- cfg.define("_XOPEN_SOURCE", "700"); +- } +- +- cfg.compile("z"); +- +- fs::create_dir_all(dst.join("include")).unwrap(); +- fs::copy("src/zlib/zlib.h", dst.join("include/zlib.h")).unwrap(); +- fs::copy("src/zlib/zconf.h", dst.join("include/zconf.h")).unwrap(); +- +- fs::create_dir_all(lib.join("pkgconfig")).unwrap(); +- let zlib_h = fs::read_to_string(dst.join("include/zlib.h")).unwrap(); +- let version = zlib_h +- .lines() +- .find(|l| l.contains("ZLIB_VERSION")) +- .unwrap() +- .split("\"") +- .nth(1) ++ pkg_config::Config::new() ++ .cargo_metadata(true) ++ .print_system_libs(false) ++ .probe("zlib") + .unwrap(); +- fs::write( +- lib.join("pkgconfig/zlib.pc"), +- fs::read_to_string("src/zlib/zlib.pc.in") +- .unwrap() +- .replace("@prefix@", dst.to_str().unwrap()) +- .replace("@includedir@", "${prefix}/include") +- .replace("@libdir@", "${prefix}/lib") +- .replace("@VERSION@", version), +- ) +- .unwrap(); +- +- println!("cargo:root={}", dst.to_str().unwrap()); +- println!("cargo:rustc-link-search=native={}", lib.to_str().unwrap()); +- println!("cargo:include={}/include", dst.to_str().unwrap()); +-} +- +-#[cfg(any( +- feature = "zlib-ng", +- feature = "zlib-ng-no-cmake-experimental-community-maintained" +-))] +-mod zng { +- #[cfg_attr(feature = "zlib-ng", path = "cmake.rs")] +- #[cfg_attr( +- all( +- feature = "zlib-ng-no-cmake-experimental-community-maintained", +- not(feature = "zlib-ng") +- ), +- path = "cc.rs" +- )] +- mod build_zng; +- +- pub(super) use build_zng::build_zlib_ng; +-} +- +-fn build_zlib_ng(_target: &str, _compat: bool) { +- #[cfg(any( +- feature = "zlib-ng", +- feature = "zlib-ng-no-cmake-experimental-community-maintained" +- ))] +- zng::build_zlib_ng(_target, _compat); +-} +- +-fn try_vcpkg() -> bool { +- // see if there is a vcpkg tree with zlib installed +- match vcpkg::Config::new() +- .emit_includes(true) +- .find_package("zlib") +- { +- Ok(zlib) => { +- if !zlib.include_paths.is_empty() { +- let paths = zlib +- .include_paths +- .iter() +- .map(|s| s.display().to_string()) +- .collect::>(); +- println!("cargo:include={}", paths.join(",")); +- } +- true +- } +- Err(e) => { +- println!("note, vcpkg did not find zlib: {}", e); +- false +- } +- } +-} +- +-fn zlib_installed(cfg: &mut cc::Build) -> bool { +- let mut cmd = cfg.get_compiler().to_command(); +- cmd.arg("src/smoke.c") +- .arg("-g0") +- .arg("-o") +- .arg("/dev/null") +- .arg("-lz"); +- +- println!("running {:?}", cmd); +- if let Ok(status) = cmd.status() { +- if status.success() { +- return true; +- } +- } +- +- false + } +-- +2.46.2 + diff --git a/SOURCES/libz-sys-fix-metadata.diff b/SOURCES/libz-sys-fix-metadata.diff new file mode 100644 index 0000000..63d57c6 --- /dev/null +++ b/SOURCES/libz-sys-fix-metadata.diff @@ -0,0 +1,32 @@ +--- libz-sys-1.1.20/Cargo.toml 1970-01-01T00:00:01+00:00 ++++ libz-sys-1.1.20/Cargo.toml 2024-09-25T15:05:48.025207+00:00 +@@ -72,29 +72,15 @@ + [build-dependencies.cc] + version = "1.0.98" + +-[build-dependencies.cmake] +-version = "0.1.50" +-optional = true +- + [build-dependencies.pkg-config] + version = "0.3.9" + +-[build-dependencies.vcpkg] +-version = "0.2.11" +- + [features] +-asm = [] + default = [ + "libc", + "stock-zlib", + ] +-static = [] + stock-zlib = [] +-zlib-ng = [ +- "libc", +- "cmake", +-] +-zlib-ng-no-cmake-experimental-community-maintained = ["libc"] + + [lints.rust.unexpected_cfgs] + level = "warn" diff --git a/SOURCES/rust2rpm.toml b/SOURCES/rust2rpm.toml new file mode 100644 index 0000000..7daa6b3 --- /dev/null +++ b/SOURCES/rust2rpm.toml @@ -0,0 +1,16 @@ +[package] +cargo-toml-patch-comments = [ + "drop features for zlib-ng support and statically linking libz", +] + +[requires] +build = ["pkgconfig(zlib)"] +lib = ["pkgconfig(zlib)"] + +[scripts] +prep.post = [ + "# remove bundled zlib and zlib-ng sources", + "rm -r src/zlib/", + "rm -r src/zlib-ng/", +] + diff --git a/SPECS/rust-libz-sys.spec b/SPECS/rust-libz-sys.spec new file mode 100644 index 0000000..a1560da --- /dev/null +++ b/SPECS/rust-libz-sys.spec @@ -0,0 +1,242 @@ +## START: Set by rpmautospec +## (rpmautospec version 0.7.2) +## RPMAUTOSPEC: autorelease, autochangelog +%define autorelease(e:s:pb:n) %{?-p:0.}%{lua: + release_number = 1; + base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); + print(release_number + base_release_number - 1); +}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} +## END: Set by rpmautospec + +# Generated by rust2rpm 26 +%bcond_without check +%global debug_package %{nil} + +%global crate libz-sys + +Name: rust-libz-sys +Version: 1.1.20 +Release: %autorelease +Summary: Low-level bindings to the system libz library (also known as zlib) + +License: MIT OR Apache-2.0 +URL: https://crates.io/crates/libz-sys +Source: %{crates_source} +# Manually created patch for downstream crate metadata changes +# * drop features for zlib-ng support and statically linking libz +Patch: libz-sys-fix-metadata.diff +# * remove code related to building vendored zlib / zlib-ng sources +# * unconditionally use pkg-config to link with system libz +Patch: 0001-unconditionally-use-pkg-config-to-link-with-system-z.patch + +BuildRequires: cargo-rpm-macros >= 24 +BuildRequires: pkgconfig(zlib) + +%global _description %{expand: +Low-level bindings to the system libz library (also known as zlib).} + +%description %{_description} + +%package devel +Summary: %{summary} +BuildArch: noarch +Requires: pkgconfig(zlib) + +%description devel %{_description} + +This package contains library source intended for building other packages which +use the "%{crate}" crate. + +%files devel +%license %{crate_instdir}/LICENSE-APACHE +%license %{crate_instdir}/LICENSE-MIT +%doc %{crate_instdir}/README.md +%{crate_instdir}/ + +%package -n %{name}+default-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+default-devel %{_description} + +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 %{crate_instdir}/Cargo.toml + +%package -n %{name}+libc-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+libc-devel %{_description} + +This package contains library source intended for building other packages which +use the "libc" feature of the "%{crate}" crate. + +%files -n %{name}+libc-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+stock-zlib-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+stock-zlib-devel %{_description} + +This package contains library source intended for building other packages which +use the "stock-zlib" feature of the "%{crate}" crate. + +%files -n %{name}+stock-zlib-devel +%ghost %{crate_instdir}/Cargo.toml + +%prep +%autosetup -n %{crate}-%{version} -p1 +%cargo_prep +# remove bundled zlib and zlib-ng sources +rm -r src/zlib/ +rm -r src/zlib-ng/ + +%generate_buildrequires +%cargo_generate_buildrequires + +%build +%cargo_build + +%install +%cargo_install + +%if %{with check} +%check +%cargo_test +%endif + +%changelog +* Fri Dec 20 2024 MSVSphere Packaging Team - 1.1.20-1 +- Rebuilt for MSVSphere 10 + +## START: Generated by rpmautospec +* Wed Sep 25 2024 Fabio Valentini - 1.1.20-1 +- Update to version 1.1.20; Fixes RHBZ#2283120 + +* Sat Jul 20 2024 Fedora Release Engineering - 1.1.16-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Fri May 17 2024 Fabio Valentini - 1.1.16-1 +- Update to version 1.1.16; Fixes RHBZ#2260523 + +* Fri Jan 26 2024 Fedora Release Engineering - 1.1.14-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Wed Jan 10 2024 Fabio Valentini - 1.1.14-1 +- Update to version 1.1.14; Fixes RHBZ#2257247 + +* Sat Jul 29 2023 Fabio Valentini - 1.1.12-1 +- Update to version 1.1.12; Fixes RHBZ#2224862 + +* Fri Jul 21 2023 Fedora Release Engineering - 1.1.9-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Mon May 01 2023 Fabio Valentini - 1.1.9-1 +- Update to version 1.1.9; Fixes RHBZ#2190481 + +* Fri Jan 20 2023 Fedora Release Engineering - 1.1.8-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Sat Jul 23 2022 Fedora Release Engineering - 1.1.8-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Mon May 30 2022 Fabio Valentini - 1.1.8-1 +- Update to version 1.1.8; Fixes RHBZ#2091230 + +* Thu May 12 2022 Fabio Valentini - 1.1.6-1 +- Update to version 1.1.6; Fixes RHBZ#2079190 + +* Thu Mar 31 2022 Fabio Valentini - 1.1.5-1 +- Update to version 1.1.5; Fixes RHBZ#2061218 + +* Fri Jan 21 2022 Fedora Release Engineering - 1.1.3-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Fri Jul 23 2021 Fedora Release Engineering - 1.1.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Fri Apr 30 2021 Fabio Valentini - 1.1.3-1 +- Update to version 1.1.3. +- Fixes RHBZ#1955368 + +* Wed Jan 27 2021 Fedora Release Engineering - 1.1.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Fri Sep 18 2020 Fabio Valentini - 1.1.2-1 +- Update to version 1.1.2. + +* Wed Aug 19 2020 Josh Stone - 1.1.0-1 +- Update to 1.1.0 + +* Wed Jul 29 2020 Fedora Release Engineering - 1.0.25-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Thu Jan 30 2020 Fedora Release Engineering - 1.0.25-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Fri Jul 26 2019 Fedora Release Engineering - 1.0.25-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Thu Jun 20 12:34:11 CEST 2019 Igor Gnatenko - 1.0.25-5 +- Regenerate + +* Sat Feb 02 2019 Fedora Release Engineering - 1.0.25-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Thu Dec 20 2018 Igor Gnatenko - 1.0.25-3 +- Run tests in infrastructure + +* Sun Nov 04 2018 Igor Gnatenko - 1.0.25-2 +- Adapt to new packaging + +* Thu Oct 25 2018 Josh Stone - 1.0.25-1 +- Update to 1.0.25 + +* Fri Oct 12 2018 Josh Stone - 1.0.24-1 +- Update to 1.0.24 + +* Fri Sep 28 2018 Josh Stone - 1.0.23-1 +- Update to 1.0.23 + +* Mon Sep 17 2018 Josh Stone - 1.0.22-1 +- Update to 1.0.22 + +* Tue Aug 07 2018 Josh Stone - 1.0.20-1 +- Update to 1.0.20 + +* Sat Jul 14 2018 Fedora Release Engineering - 1.0.18-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Fri Feb 09 2018 Fedora Release Engineering - 1.0.18-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Mon Jan 08 2018 Igor Gnatenko - 1.0.18-3 +- Rebuild for rust-packaging v5 + +* Sun Dec 03 2017 Igor Gnatenko - 1.0.18-2 +- Remove bundled zlib + +* Thu Nov 16 2017 Igor Gnatenko - 1.0.18-1 +- Update to 1.0.18 + +* Mon Jun 26 2017 Igor Gnatenko - 1.0.16-1 +- Update to 1.0.16 + +* Thu Jun 15 2017 Igor Gnatenko - 1.0.14-1 +- Update to 1.0.14 + +* Wed Jun 14 2017 Igor Gnatenko - 1.0.13-3 +- Port to use rust-packaging + +* Sun Feb 26 2017 Igor Gnatenko - 1.0.13-2 +- Rebuild + +* Sun Feb 26 2017 Igor Gnatenko - 1.0.13-1 +- Initial package + +## END: Generated by rpmautospec