commit 88956bece2ffb59d574c596ff75de398a910a9c8 Author: MSVSphere Packaging Team Date: Fri Dec 20 15:09:48 2024 +0300 import rust-const-random-macro-0.1.16-4.el10 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a8de91e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/const-random-macro-0.1.16.crate diff --git a/.rust-const-random-macro.metadata b/.rust-const-random-macro.metadata new file mode 100644 index 0000000..1a86530 --- /dev/null +++ b/.rust-const-random-macro.metadata @@ -0,0 +1 @@ +c4a3ce1b86fb4fcc2d7e94fb2eea60defa492774 SOURCES/const-random-macro-0.1.16.crate diff --git a/SOURCES/backport-compilation-fix-with-rust-1.77+.patch b/SOURCES/backport-compilation-fix-with-rust-1.77+.patch new file mode 100644 index 0000000..248c434 --- /dev/null +++ b/SOURCES/backport-compilation-fix-with-rust-1.77+.patch @@ -0,0 +1,168 @@ +diff --git a/src/lib.rs b/src/lib.rs +index f656956..7320283 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -1,11 +1,9 @@ +-#[allow(unused_extern_crates)] + extern crate proc_macro; + + use proc_macro::*; + use std::iter::once; + mod span; +-use crate::span::{gen_random_bytes, gen_random}; +- ++use crate::span::{gen_random, gen_random_bytes}; + + /// Create a TokenStream of an identifier out of a string + fn ident(ident: &str) -> TokenStream { +@@ -14,44 +12,89 @@ fn ident(ident: &str) -> TokenStream { + + #[proc_macro] + pub fn const_random(input: TokenStream) -> TokenStream { +- match &input.to_string()[..] { +- "u8" => TokenTree::from(Literal::u8_suffixed(gen_random())).into(), +- "u16" => TokenTree::from(Literal::u16_suffixed(gen_random())).into(), +- "u32" => TokenTree::from(Literal::u32_suffixed(gen_random())).into(), +- "u64" => TokenTree::from(Literal::u64_suffixed(gen_random())).into(), +- "u128" => TokenTree::from(Literal::u128_suffixed(gen_random())).into(), +- "i8" => TokenTree::from(Literal::i8_suffixed(gen_random())).into(), +- "i16" => TokenTree::from(Literal::i16_suffixed(gen_random())).into(), +- "i32" => TokenTree::from(Literal::i32_suffixed(gen_random())).into(), +- "i64" => TokenTree::from(Literal::i64_suffixed(gen_random())).into(), +- "i128" => TokenTree::from(Literal::i128_suffixed(gen_random())).into(), +- "usize" => { +- let value: TokenStream = TokenTree::from(Literal::u128_suffixed(gen_random())).into(); +- let type_cast: TokenStream = [value, ident("as"), ident("usize")] +- .iter() +- .cloned() +- .collect(); +- TokenTree::from(Group::new(Delimiter::Parenthesis, type_cast)).into() ++ let mut iter = input.into_iter(); ++ let Some(tt) = iter.next() else { ++ panic!("missing type arg"); ++ }; ++ ++ let result = match &tt { ++ TokenTree::Ident(id) => { ++ let s = id.to_string(); ++ match s.as_str() { ++ "u8" => TokenTree::from(Literal::u8_suffixed(gen_random())).into(), ++ "u16" => TokenTree::from(Literal::u16_suffixed(gen_random())).into(), ++ "u32" => TokenTree::from(Literal::u32_suffixed(gen_random())).into(), ++ "u64" => TokenTree::from(Literal::u64_suffixed(gen_random())).into(), ++ "u128" => TokenTree::from(Literal::u128_suffixed(gen_random())).into(), ++ "i8" => TokenTree::from(Literal::i8_suffixed(gen_random())).into(), ++ "i16" => TokenTree::from(Literal::i16_suffixed(gen_random())).into(), ++ "i32" => TokenTree::from(Literal::i32_suffixed(gen_random())).into(), ++ "i64" => TokenTree::from(Literal::i64_suffixed(gen_random())).into(), ++ "i128" => TokenTree::from(Literal::i128_suffixed(gen_random())).into(), ++ "usize" => { ++ // Note: usize does not implement `Random` and follow the pattern above. If it ++ // did, when cross-compiling from a 32-bit host to a 64-bit target, ++ // `usize::random()` would produce a 32-bit random usize which would then be ++ // turned into a suffixed literal (e.g. `0x1234_5678usize`). On the 64-bit ++ // target that literal would always have the upper 32 bits as zero, which would ++ // be bad. Instead we produce code that will generate a 128-bit integer literal ++ // (on the host) and then truncate it to usize (on the target). ++ let value: TokenStream = ++ TokenTree::from(Literal::u128_suffixed(gen_random())).into(); ++ let type_cast: TokenStream = [value, ident("as"), ident("usize")] ++ .iter() ++ .cloned() ++ .collect(); ++ TokenTree::from(Group::new(Delimiter::Parenthesis, type_cast)).into() ++ } ++ "isize" => { ++ // The same reasoning as `usize` applies for `isize`. ++ let value: TokenStream = ++ TokenTree::from(Literal::i128_suffixed(gen_random())).into(); ++ let type_cast: TokenStream = [value, ident("as"), ident("isize")] ++ .iter() ++ .cloned() ++ .collect(); ++ TokenTree::from(Group::new(Delimiter::Parenthesis, type_cast)).into() ++ } ++ _ => panic!("invalid integer type arg: `{}`", s), ++ } + } +- "isize" => { +- let value: TokenStream = TokenTree::from(Literal::i128_suffixed(gen_random())).into(); +- let type_cast: TokenStream = [value, ident("as"), ident("isize")] +- .iter() +- .cloned() +- .collect(); +- TokenTree::from(Group::new(Delimiter::Parenthesis, type_cast)).into() ++ TokenTree::Group(group) if group.delimiter() == Delimiter::Bracket => { ++ let mut iter = group.stream().into_iter(); ++ match (&iter.next(), &iter.next(), &iter.next(), &iter.next()) { ++ ( ++ Some(TokenTree::Ident(ident)), ++ Some(TokenTree::Punct(punct)), ++ Some(TokenTree::Literal(literal)), ++ None, ++ ) if ident.to_string().as_str() == "u8" && punct.as_char() == ';' => { ++ let Ok(len) = literal.to_string().parse() else { ++ panic!("invalid array length: `{}`", literal); ++ }; ++ let mut random_bytes = vec![0; len]; ++ gen_random_bytes(&mut random_bytes); ++ let array_parts: TokenStream = random_bytes ++ .into_iter() ++ .flat_map(|byte| { ++ let val = TokenTree::from(Literal::u8_suffixed(byte)); ++ let comma = TokenTree::from(Punct::new(',', Spacing::Alone)); ++ once(val).chain(once(comma)) ++ }) ++ .collect(); ++ TokenTree::from(Group::new(Delimiter::Bracket, array_parts)).into() ++ } ++ _ => panic!("invalid array type arg: `{}`", tt), ++ } + } +- byte_array if byte_array.starts_with("[u8 ; ") && byte_array.ends_with(']')=> { +- let len = byte_array[6..byte_array.len()-1].parse().unwrap(); +- let mut random_bytes = vec![0; len]; +- gen_random_bytes(&mut random_bytes); +- let array_parts: TokenStream = random_bytes.into_iter().flat_map(|byte| { +- let val = TokenTree::from(Literal::u8_suffixed(byte)); +- let comma = TokenTree::from(Punct::new(',', Spacing::Alone)); +- once(val).chain(once(comma)) +- }).collect(); +- TokenTree::from(Group::new(Delimiter::Bracket, array_parts)).into() ++ _ => { ++ panic!("invalid type arg: `{}`", tt); + } +- _ => panic!("Invalid type"), +- } ++ }; ++ ++ if let Some(tt) = iter.next() { ++ panic!("invalid trailing token tree: `{}`", tt); ++ }; ++ ++ result + } +diff --git a/src/span.rs b/src/span.rs +index ab72bb0..e9bda8d 100644 +--- a/src/span.rs ++++ b/src/span.rs +@@ -2,16 +2,15 @@ use proc_macro::Span; + use std::option_env; + + use once_cell::race::OnceBox; +-use tiny_keccak::{Xof, Hasher, Shake}; +- ++use tiny_keccak::{Hasher, Shake, Xof}; + + static SEED: OnceBox> = OnceBox::new(); + + fn get_seed() -> &'static [u8] { + &SEED.get_or_init(|| { + if let Some(value) = option_env!("CONST_RANDOM_SEED") { +- Box::new(value.as_bytes().to_vec()) +- } else { ++ Box::new(value.as_bytes().to_vec()) ++ } else { + let mut value = [0u8; 32]; + getrandom::getrandom(&mut value).unwrap(); + Box::new(value.to_vec()) diff --git a/SPECS/rust-const-random-macro.spec b/SPECS/rust-const-random-macro.spec new file mode 100644 index 0000000..6af9861 --- /dev/null +++ b/SPECS/rust-const-random-macro.spec @@ -0,0 +1,144 @@ +## START: Set by rpmautospec +## (rpmautospec version 0.7.1) +## RPMAUTOSPEC: autorelease, autochangelog +%define autorelease(e:s:pb:n) %{?-p:0.}%{lua: + release_number = 4; + 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 25 +%bcond_without check +%global debug_package %{nil} + +%global crate const-random-macro + +Name: rust-const-random-macro +Version: 0.1.16 +Release: %autorelease +Summary: Procedural macro used by const-random + +License: MIT OR Apache-2.0 +URL: https://crates.io/crates/const-random-macro +Source: %{crates_source} + +# * backported upstream patch to fix compiler errors with Rust 1.77+: +# https://github.com/tkaitchuck/constrandom/pull/33 +Patch: backport-compilation-fix-with-rust-1.77+.patch + +BuildRequires: cargo-rpm-macros >= 24 + +%global _description %{expand: +Provides the procedural macro used by const-random.} + +%description %{_description} + +%package devel +Summary: %{summary} +BuildArch: noarch + +%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 +%{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 + +%prep +%autosetup -n %{crate}-%{version} -p1 +%cargo_prep + +%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 - 0.1.16-4 +- Rebuilt for MSVSphere 10 + +## START: Generated by rpmautospec +* Fri Jul 19 2024 Fedora Release Engineering - 0.1.16-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Tue Jun 25 2024 Fabio Valentini - 0.1.16-3 +- Backport upstream patch to fix compiler errors with Rust 1.77+ + +* Fri Jan 26 2024 Fedora Release Engineering - 0.1.16-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Thu Jan 04 2024 Fabio Valentini - 0.1.16-1 +- Update to version 0.1.16; Fixes RHBZ#2245738 + +* Fri Jul 21 2023 Fedora Release Engineering - 0.1.15-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Fri Feb 03 2023 Fabio Valentini - 0.1.15-1 +- Update to version 0.1.15; Fixes RHBZ#2137490 + +* Fri Jan 20 2023 Fedora Release Engineering - 0.1.13-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Sat Jul 23 2022 Fedora Release Engineering - 0.1.13-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Fri Jan 21 2022 Fedora Release Engineering - 0.1.13-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Sun Nov 28 2021 Igor Raits - 0.1.13-4 +- Regenerate + +* Fri Jul 23 2021 Fedora Release Engineering - 0.1.13-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Thu Mar 25 2021 Fabio Valentini - 0.1.13-1 +- Update to version 0.1.13. + +* Wed Jan 27 2021 Fedora Release Engineering - 0.1.11-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Fri Nov 06 2020 Fabio Valentini - 0.1.11-1 +- Update to version 0.1.11. +- Fixes RHBZ#1886088 + +* Wed Oct 07 2020 Fabio Valentini - 0.1.10-1 +- Update to version 0.1.10. + +* Wed Jul 29 2020 Fedora Release Engineering - 0.1.8-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Thu Jan 30 2020 Fedora Release Engineering - 0.1.8-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Jan 23 2020 Josh Stone - 0.1.8-1 +- Update to 0.1.8 + +* Fri Dec 20 19:57:24 CET 2019 Igor Gnatenko - 0.1.6-1 +- Initial package + +## END: Generated by rpmautospec