commit 99c51d270bf63b988e882bb2746b59cf26676445 Author: MSVSphere Packaging Team Date: Fri Dec 20 14:37:42 2024 +0300 import rust-adblock-0.9.3-1.el10 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..35813bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/adblock-0.9.3.crate diff --git a/.rust-adblock.metadata b/.rust-adblock.metadata new file mode 100644 index 0000000..0dda954 --- /dev/null +++ b/.rust-adblock.metadata @@ -0,0 +1 @@ +985af600e8f771a541edc3af35bd99e754c1ac15 SOURCES/adblock-0.9.3.crate diff --git a/SOURCES/0001-drop-tests-that-require-unshipped-support-code.patch b/SOURCES/0001-drop-tests-that-require-unshipped-support-code.patch new file mode 100644 index 0000000..a8cdf31 --- /dev/null +++ b/SOURCES/0001-drop-tests-that-require-unshipped-support-code.patch @@ -0,0 +1,245 @@ +From f7342120f0a7c2e4955fc4601794f31f46da8140 Mon Sep 17 00:00:00 2001 +From: Fabio Valentini +Date: Wed, 28 Feb 2024 16:55:26 +0100 +Subject: [PATCH] drop tests that require unshipped support code + +--- + src/blocker.rs | 172 ----------------------------------------- + src/filters/network.rs | 28 ------- + src/lib.rs | 4 - + 3 files changed, 204 deletions(-) + +diff --git a/src/blocker.rs b/src/blocker.rs +index 78d7edd..cc1435f 100644 +--- a/src/blocker.rs ++++ b/src/blocker.rs +@@ -2135,175 +2135,3 @@ mod placeholder_string_tests { + assert_eq!(block.filter, Some("NetworkFilter".to_string())); + } + } +- +-#[cfg(test)] +-mod legacy_rule_parsing_tests { +- use crate::test_utils::rules_from_lists; +- use crate::lists::{parse_filters, FilterFormat, ParseOptions}; +- use crate::blocker::{Blocker, BlockerOptions}; +- use crate::blocker::vec_hashmap_len; +- +- struct ListCounts { +- pub filters: usize, +- pub cosmetic_filters: usize, +- pub exceptions: usize, +- pub duplicates: usize, +- } +- +- impl std::ops::Add for ListCounts { +- type Output = ListCounts; +- +- fn add(self, other: ListCounts) -> Self::Output { +- ListCounts { +- filters: self.filters + other.filters, +- cosmetic_filters: self.cosmetic_filters + other.cosmetic_filters, +- exceptions: self.exceptions + other.exceptions, +- duplicates: 0, // Don't bother trying to calculate - lists could have cross-duplicated entries +- } +- } +- } +- +- // number of expected EasyList cosmetic rules from old engine is 31144, but is incorrect as it skips a few particularly long rules that are nevertheless valid +- // easyList = { 24478, 31144, 0, 5589 }; +- // not handling (and not including) filters with the following options: +- // - $popup +- // - $elemhide +- // difference from original counts caused by not handling document/subdocument options and possibly miscounting on the blocker side. +- // Printing all non-cosmetic, non-html, non-comment/-empty rules and ones with no unsupported options yields 29142 items +- // This engine also handles 3 rules that old one does not +- const EASY_LIST: ListCounts = ListCounts { filters: 24064, cosmetic_filters: 31163, exceptions: 5796, duplicates: 0 }; +- // easyPrivacy = { 11817, 0, 0, 1020 }; +- // differences in counts explained by hashset size underreporting as detailed in the next two cases +- const EASY_PRIVACY: ListCounts = ListCounts { filters: 11889, cosmetic_filters: 0, exceptions: 1021, duplicates: 2 }; +- // ublockUnbreak = { 4, 8, 0, 94 }; +- // differences in counts explained by client.hostAnchoredExceptionHashSet->GetSize() underreporting when compared to client.numHostAnchoredExceptionFilters +- const UBLOCK_UNBREAK: ListCounts = ListCounts { filters: 4, cosmetic_filters: 8, exceptions: 98, duplicates: 0 }; +- // braveUnbreak = { 31, 0, 0, 4 }; +- // differences in counts explained by client.hostAnchoredHashSet->GetSize() underreporting when compared to client.numHostAnchoredFilters +- const BRAVE_UNBREAK: ListCounts = ListCounts { filters: 32, cosmetic_filters: 0, exceptions: 4, duplicates: 0 }; +- // disconnectSimpleMalware = { 2450, 0, 0, 0 }; +- const DISCONNECT_SIMPLE_MALWARE: ListCounts = ListCounts { filters: 2450, cosmetic_filters: 0, exceptions: 0, duplicates: 0 }; +- // spam404MainBlacklist = { 5629, 166, 0, 0 }; +- const SPAM_404_MAIN_BLACKLIST: ListCounts = ListCounts { filters: 5629, cosmetic_filters: 166, exceptions: 0, duplicates: 0 }; +- const MALWARE_DOMAIN_LIST: ListCounts = ListCounts { filters: 1104, cosmetic_filters: 0, exceptions: 0, duplicates: 3 }; +- const MALWARE_DOMAINS: ListCounts = ListCounts { filters: 26853, cosmetic_filters: 0, exceptions: 0, duplicates: 48 }; +- +- fn check_list_counts(rule_lists: impl IntoIterator>, format: FilterFormat, expectation: ListCounts) { +- let rules = rules_from_lists(rule_lists); +- +- let (network_filters, cosmetic_filters) = parse_filters(rules, true, ParseOptions { format, ..Default::default() }); +- +- assert_eq!( +- (network_filters.len(), +- network_filters.iter().filter(|f| f.is_exception()).count(), +- cosmetic_filters.len()), +- (expectation.filters + expectation.exceptions, +- expectation.exceptions, +- expectation.cosmetic_filters), +- "Number of collected filters does not match expectation"); +- +- let blocker_options = BlockerOptions { +- enable_optimizations: false, // optimizations will reduce number of rules +- }; +- +- let blocker = Blocker::new(network_filters, &blocker_options); +- +- // Some filters in the filter_map are pointed at by multiple tokens, increasing the total number of items +- assert!(vec_hashmap_len(&blocker.exceptions.filter_map) + vec_hashmap_len(&blocker.generic_hide.filter_map) +- >= expectation.exceptions, "Number of collected exceptions does not match expectation"); +- +- assert!(vec_hashmap_len(&blocker.filters.filter_map) + +- vec_hashmap_len(&blocker.importants.filter_map) + +- vec_hashmap_len(&blocker.redirects.filter_map) + +- vec_hashmap_len(&blocker.redirects.filter_map) + +- vec_hashmap_len(&blocker.csp.filter_map) >= +- expectation.filters - expectation.duplicates, "Number of collected network filters does not match expectation"); +- } +- +- #[test] +- fn parse_easylist() { +- check_list_counts(["./data/test/easylist.txt"], FilterFormat::Standard, EASY_LIST); +- } +- +- #[test] +- fn parse_easyprivacy() { +- check_list_counts(["./data/test/easyprivacy.txt"], FilterFormat::Standard, EASY_PRIVACY); +- } +- +- #[test] +- fn parse_ublock_unbreak() { +- check_list_counts(["./data/test/ublock-unbreak.txt"], FilterFormat::Standard, UBLOCK_UNBREAK); +- } +- +- #[test] +- fn parse_brave_unbreak() { +- check_list_counts(["./data/test/brave-unbreak.txt"], FilterFormat::Standard, BRAVE_UNBREAK); +- } +- +- #[test] +- fn parse_brave_disconnect_simple_malware() { +- check_list_counts(["./data/test/disconnect-simple-malware.txt"], FilterFormat::Standard, DISCONNECT_SIMPLE_MALWARE); +- } +- +- #[test] +- fn parse_spam404_main_blacklist() { +- check_list_counts(["./data/test/spam404-main-blacklist.txt"], FilterFormat::Standard, SPAM_404_MAIN_BLACKLIST); +- } +- +- #[test] +- fn parse_malware_domain_list() { +- check_list_counts(["./data/test/malwaredomainlist.txt"], FilterFormat::Hosts, MALWARE_DOMAIN_LIST); +- } +- +- #[test] +- fn parse_malware_domain_list_just_hosts() { +- check_list_counts(["./data/test/malwaredomainlist_justhosts.txt"], FilterFormat::Hosts, MALWARE_DOMAIN_LIST); +- } +- +- #[test] +- fn parse_malware_domains() { +- check_list_counts(["./data/test/malwaredomains.txt"], FilterFormat::Hosts, MALWARE_DOMAINS); +- } +- +- #[test] +- fn parse_multilist() { +- let expectation = EASY_LIST + EASY_PRIVACY + UBLOCK_UNBREAK + BRAVE_UNBREAK; +- check_list_counts( +- [ +- "./data/test/easylist.txt", +- "./data/test/easyprivacy.txt", +- "./data/test/ublock-unbreak.txt", +- "./data/test/brave-unbreak.txt", +- ], +- FilterFormat::Standard, +- expectation, +- ) +- } +- +- #[test] +- fn parse_malware_multilist() { +- let expectation = SPAM_404_MAIN_BLACKLIST + DISCONNECT_SIMPLE_MALWARE; +- check_list_counts( +- [ +- "./data/test/spam404-main-blacklist.txt", +- "./data/test/disconnect-simple-malware.txt", +- ], +- FilterFormat::Standard, +- expectation, +- ) +- } +- +- #[test] +- fn parse_hosts_formats() { +- let mut expectation = MALWARE_DOMAIN_LIST + MALWARE_DOMAINS; +- expectation.duplicates = 69; +- check_list_counts( +- [ +- "./data/test/malwaredomainlist.txt", +- "./data/test/malwaredomains.txt", +- ], +- FilterFormat::Hosts, +- expectation, +- ) +- } +-} +diff --git a/src/filters/network.rs b/src/filters/network.rs +index 093b0e6..69f10d0 100644 +--- a/src/filters/network.rs ++++ b/src/filters/network.rs +@@ -3386,31 +3386,3 @@ mod match_tests { + assert_eq!(get_url_after_hostname("https://www.youtube.com/?aclksa=l&ai=DChcSEwioqMfq5", "google.com"), ""); + } + } +- +-#[cfg(test)] +-mod hash_collision_tests { +- use super::*; +- +- use crate::test_utils; +- use crate::lists::parse_filters; +- use std::collections::HashMap; +- +- #[test] +- fn check_rule_ids_no_collisions() { +- let rules = test_utils::rules_from_lists([ +- "data/easylist.to/easylist/easylist.txt", +- "data/easylist.to/easylist/easyprivacy.txt", +- ]); +- let (network_filters, _) = parse_filters(rules, true, Default::default()); +- +- let mut filter_ids: HashMap = HashMap::new(); +- +- for filter in network_filters { +- let id = filter.get_id(); +- let rule = *filter.raw_line.unwrap_or_default(); +- let existing_rule = filter_ids.get(&id); +- assert!(existing_rule.is_none() || existing_rule.unwrap() == &rule, "ID {} for {} already present from {}", id, rule, existing_rule.unwrap()); +- filter_ids.insert(id, rule); +- } +- } +-} +diff --git a/src/lib.rs b/src/lib.rs +index 956f082..5db786a 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -37,10 +37,6 @@ pub use engine::Engine; + #[doc(inline)] + pub use lists::FilterSet; + +-#[cfg(test)] +-#[path = "../tests/test_utils.rs"] +-mod test_utils; +- + #[cfg(test)] + mod sync_tests { + #[allow(unused)] +-- +2.44.0 + diff --git a/SOURCES/adblock-fix-metadata.diff b/SOURCES/adblock-fix-metadata.diff new file mode 100644 index 0000000..404bf7f --- /dev/null +++ b/SOURCES/adblock-fix-metadata.diff @@ -0,0 +1,117 @@ +--- adblock-0.9.3/Cargo.toml 1970-01-01T00:00:01+00:00 ++++ adblock-0.9.3/Cargo.toml 2024-12-05T21:46:44.598116+00:00 +@@ -44,35 +44,6 @@ + path = "src/lib.rs" + bench = false + +-[[bench]] +-name = "bench_cosmetic_matching" +-path = "benches/bench_cosmetic_matching.rs" +- +-[[bench]] +-name = "bench_matching" +-path = "benches/bench_matching.rs" +-harness = false +- +-[[bench]] +-name = "bench_redirect_performance" +-path = "benches/bench_redirect_performance.rs" +-harness = false +- +-[[bench]] +-name = "bench_regex" +-path = "benches/bench_regex.rs" +-harness = false +- +-[[bench]] +-name = "bench_rules" +-path = "benches/bench_rules.rs" +-harness = false +- +-[[bench]] +-name = "bench_url" +-path = "benches/bench_url.rs" +-harness = false +- + [dependencies.addr] + version = "0.15" + features = ["psl"] +@@ -80,20 +51,16 @@ + default-features = false + + [dependencies.base64] +-version = "0.13" ++version = "0.22" + + [dependencies.bitflags] + version = "1.3" + +-[dependencies.cssparser] +-version = "0.28" +-optional = true +- + [dependencies.idna] +-version = "0.2" ++version = "0.5" + + [dependencies.itertools] +-version = "0.10" ++version = "0.13" + + [dependencies.lifeguard] + version = "^ 0.6.1" +@@ -112,14 +79,10 @@ + version = "1.5" + + [dependencies.rmp-serde] +-version = "0.15" ++version = "1" + + [dependencies.seahash] + version = "3" +- +-[dependencies.selectors] +-version = "0.23" +-optional = true + + [dependencies.serde] + version = "1.0" +@@ -137,9 +100,6 @@ + [dependencies.url] + version = "2.2" + +-[dev-dependencies.criterion] +-version = "0.5" +- + [dev-dependencies.csv] + version = "1" + +@@ -147,15 +107,10 @@ + version = "0.3" + + [dev-dependencies.mock_instant] +-version = "0.5" +- +-[dev-dependencies.reqwest] +-version = "0.11" +-features = ["rustls-tls"] +-default-features = false ++version = ">=0.3,<0.6" + + [dev-dependencies.sha2] +-version = "0.9" ++version = "0.10" + + [dev-dependencies.tokio] + version = "1.24" +@@ -163,10 +118,6 @@ + + [features] + content-blocking = [] +-css-validation = [ +- "cssparser", +- "selectors", +-] + default = [ + "embedded-domain-resolver", + "full-regex-handling", diff --git a/SOURCES/rust2rpm.toml b/SOURCES/rust2rpm.toml new file mode 100644 index 0000000..0ab8666 --- /dev/null +++ b/SOURCES/rust2rpm.toml @@ -0,0 +1,13 @@ +[package] +cargo-toml-patch-comments = [ + "bump base64 dependency from 0.13 to 0.22", + "bump idna dependency from 0.2 to 0.5", + "bump itertools dependency from 0.10 to 0.13", + "bump rmp-serde dependency from 0.15 to 1", + "relax mock_instant dev-dependency", + "bump sha2 dev-dependency from 0.9 to 0.10", + "drop unused, benchmark-only criterion dev-dependency", + "drop unused, benchmark-only reqwest dev-dependency", + "drop unused css-validation feature with outdated dependencies", +] + diff --git a/SPECS/rust-adblock.spec b/SPECS/rust-adblock.spec new file mode 100644 index 0000000..52ddb0f --- /dev/null +++ b/SPECS/rust-adblock.spec @@ -0,0 +1,216 @@ +## START: Set by rpmautospec +## (rpmautospec version 0.7.3) +## 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 27 +# * temporarily disable tests until mock_instant ^0.5 is available +%bcond check 0 +%global debug_package %{nil} + +%global crate adblock + +Name: rust-adblock +Version: 0.9.3 +Release: %autorelease +Summary: Native Rust module for Adblock Plus syntax + +License: MPL-2.0 +URL: https://crates.io/crates/adblock +Source: %{crates_source} +# Manually created patch for downstream crate metadata changes +# * bump base64 dependency from 0.13 to 0.22 +# * bump idna dependency from 0.2 to 0.5 +# * bump itertools dependency from 0.10 to 0.13 +# * bump rmp-serde dependency from 0.15 to 1 +# * relax mock_instant dev-dependency +# * bump sha2 dev-dependency from 0.9 to 0.10 +# * drop unused, benchmark-only criterion dev-dependency +# * drop unused, benchmark-only reqwest dev-dependency +# * drop unused css-validation feature with outdated dependencies +Patch: adblock-fix-metadata.diff +# * drop tests that require unshipped support code +Patch: 0001-drop-tests-that-require-unshipped-support-code.patch + +BuildRequires: cargo-rpm-macros >= 24 + +%global _description %{expand: +Native Rust module for Adblock Plus syntax (e.g. EasyList, EasyPrivacy) +filter parsing and matching.} + +%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 +%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}+addr-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+addr-devel %{_description} + +This package contains library source intended for building other packages which +use the "addr" feature of the "%{crate}" crate. + +%files -n %{name}+addr-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+content-blocking-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+content-blocking-devel %{_description} + +This package contains library source intended for building other packages which +use the "content-blocking" feature of the "%{crate}" crate. + +%files -n %{name}+content-blocking-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+embedded-domain-resolver-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+embedded-domain-resolver-devel %{_description} + +This package contains library source intended for building other packages which +use the "embedded-domain-resolver" feature of the "%{crate}" crate. + +%files -n %{name}+embedded-domain-resolver-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+full-regex-handling-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+full-regex-handling-devel %{_description} + +This package contains library source intended for building other packages which +use the "full-regex-handling" feature of the "%{crate}" crate. + +%files -n %{name}+full-regex-handling-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+lifeguard-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+lifeguard-devel %{_description} + +This package contains library source intended for building other packages which +use the "lifeguard" feature of the "%{crate}" crate. + +%files -n %{name}+lifeguard-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+object-pooling-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+object-pooling-devel %{_description} + +This package contains library source intended for building other packages which +use the "object-pooling" feature of the "%{crate}" crate. + +%files -n %{name}+object-pooling-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+regex-debug-info-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+regex-debug-info-devel %{_description} + +This package contains library source intended for building other packages which +use the "regex-debug-info" feature of the "%{crate}" crate. + +%files -n %{name}+regex-debug-info-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+resource-assembler-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+resource-assembler-devel %{_description} + +This package contains library source intended for building other packages which +use the "resource-assembler" feature of the "%{crate}" crate. + +%files -n %{name}+resource-assembler-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+unsync-regex-caching-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+unsync-regex-caching-devel %{_description} + +This package contains library source intended for building other packages which +use the "unsync-regex-caching" feature of the "%{crate}" crate. + +%files -n %{name}+unsync-regex-caching-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.9.3-1 +- Rebuilt for MSVSphere 10 + +## START: Generated by rpmautospec +* Thu Dec 05 2024 Fabio Valentini - 0.9.3-1 +- Update to version 0.9.3; Fixes RHBZ#2277901 + +* Sat Oct 05 2024 Fabio Valentini - 0.8.8-3 +- Bump more dependencies to the latest version + +* Fri Jul 19 2024 Fedora Release Engineering - 0.8.8-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Tue Mar 26 2024 Fabio Valentini - 0.8.8-1 +- Initial import (#2266634) +## END: Generated by rpmautospec