From 1f95f901a1e51085ddd0e9c03c928f838751c22c Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Fri, 10 Jan 2025 08:40:05 +0000 Subject: automatic import of perl-IPC-SharedCache --- .gitignore | 1 + IPC-SharedCache-1.3-test.patch | 140 +++++++++++++++++++++++++++++++++++++++++ perl-IPC-SharedCache.spec | 74 ++++++++++++++++++++++ sources | 1 + 4 files changed, 216 insertions(+) create mode 100644 IPC-SharedCache-1.3-test.patch create mode 100644 perl-IPC-SharedCache.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore index e69de29..db7c630 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/IPC-SharedCache-1.3.tar.gz diff --git a/IPC-SharedCache-1.3-test.patch b/IPC-SharedCache-1.3-test.patch new file mode 100644 index 0000000..2f9b7e7 --- /dev/null +++ b/IPC-SharedCache-1.3-test.patch @@ -0,0 +1,140 @@ +diff -up IPC-SharedCache-1.3/SharedCache.pm.old IPC-SharedCache-1.3/SharedCache.pm +--- IPC-SharedCache-1.3/SharedCache.pm.old 2000-03-23 09:00:19.000000000 +0100 ++++ IPC-SharedCache-1.3/SharedCache.pm 2010-12-17 13:45:02.309198942 +0100 +@@ -580,11 +580,13 @@ sub STORE { + my $share; + if (exists $root_record->{'map'}{$key}) { + # we've got a key, get the share and cache it +- $share = IPC::ShareLite->new('-key' => $root_record->{'map'}{$key}, ++ $share = eval { ++ IPC::ShareLite->new('-key' => $root_record->{'map'}{$key}, + '-mode' => $options->{ipc_mode}, + '-size' => $options->{ipc_segment_size}, + '-create' => 0, + '-destroy' => 0); ++ }; + confess("IPC::SharedCache: Unable to get shared cache block $root_record->{'map'}{$key} : $!") unless defined $share; + + $root_record->{'size'} -= $root_record->{'length_map'}{$key}; +@@ -596,13 +598,15 @@ sub STORE { + for ( my $end = $obj_ipc_key + 10000 ; + $obj_ipc_key != $end ; + $obj_ipc_key++ ) { +- $share = IPC::ShareLite->new('-key' => $obj_ipc_key, ++ $share = eval { ++ IPC::ShareLite->new('-key' => $obj_ipc_key, + '-mode' => $options->{ipc_mode}, + '-size' => $options->{ipc_segment_size}, + '-create' => 1, + '-exclusive' => 1, + '-destroy' => 0, + ); ++ }; + last if defined $share; + } + croak("IPC::SharedCache : searched through 10,000 consecutive locations for a free shared memory segment, giving up : $!") +@@ -625,11 +629,13 @@ sub STORE { + my $delete_key = shift @{$root_record->{'queue'}}; + # delete the segment for this object + { +- my $share = IPC::ShareLite->new('-key' => $root_record->{map}{$delete_key}, ++ my $share = eval { ++ IPC::ShareLite->new('-key' => $root_record->{map}{$delete_key}, + '-mode' => $options->{ipc_mode}, + '-size' => $options->{ipc_segment_size}, + '-create' => 0, + '-destroy' => 1); ++ }; + confess("IPC::SharedCache: Unable to get shared cache block $root_record->{'map'}{$key} : $!") unless defined $share; + # share is now deleted since destroy == 1 and $share goes out of scope + } +@@ -684,11 +690,13 @@ sub DELETE { + + # delete the segment for this object + { +- my $share = IPC::ShareLite->new('-key' => $obj_ipc_key, ++ my $share = eval { ++ IPC::ShareLite->new('-key' => $obj_ipc_key, + '-mode' => $options->{ipc_mode}, + '-size' => $options->{ipc_segment_size}, + '-create' => 0, + '-destroy' => 1); ++ }; + confess("IPC::SharedCache: Unable to get shared cache block $root_record->{'map'}{$key} : $!") unless defined $share; + # share is now deleted since destroy == 1 and $share goes out of scope + } +@@ -830,11 +838,13 @@ sub walk { + require "Data/Dumper.pm"; + + # make sure the cache actually exists here +- my $test = IPC::ShareLite->new('-key' => $key, ++ my $test = eval { ++ IPC::ShareLite->new('-key' => $key, + '-mode' => 0666, + '-size' => $segment_size, + '-create' => 0, + '-destroy' => 0); ++ }; + die "Unable to find a cache at key $key : $!" unless defined $test; + + my %self; +@@ -911,10 +921,12 @@ sub remove { + + # delete the root segment + { +- my $share = IPC::ShareLite->new('-key' => $key, ++ my $share = eval { ++ IPC::ShareLite->new('-key' => $key, + '-size' => $segment_size, + '-create' => 0, + '-destroy' => 1); ++ }; + confess("IPC::SharedCache: Unable to get shared cache block $key : $!") unless defined $share; + # share is now deleted since destroy == 1 and $share goes out of scope + } +@@ -938,11 +950,13 @@ sub _init_root { + return if defined $root; + + # try to get a handle on an existing root for this key +- $root = IPC::ShareLite->new('-key' => $ipc_key, ++ $root = eval { ++ IPC::ShareLite->new('-key' => $ipc_key, + '-mode' => $options->{ipc_mode}, + '-size' => $options->{ipc_segment_size}, + '-create' => 0, + '-destroy' => 0); ++ }; + if (defined $root) { + $ROOT_SHARE_CACHE{$ipc_key} = $root; + return; +@@ -961,12 +975,14 @@ sub _init_root { + # if $options->{debug}; + + # try to create it if that didn't work (and do initialization) +- $root = IPC::ShareLite->new('-key' => $options->{ipc_key}, ++ $root = eval { ++ IPC::ShareLite->new('-key' => $options->{ipc_key}, + '-mode' => $options->{ipc_mode}, + '-size' => $options->{ipc_segment_size}, + '-create' => 1, + '-exclusive' => 1, + '-destroy' => 0); ++ }; + confess("IPC::SharedCache object initialization : Unable to initialize root ipc shared memory segment : $!") + unless defined($root); + +@@ -1032,11 +1048,13 @@ sub _get_share_object { + my $options = $self->{options}; + + # we've got a key, get the share and cache it +- my $share = IPC::ShareLite->new('-key' => $obj_ipc_key, ++ my $share = eval { ++ IPC::ShareLite->new('-key' => $obj_ipc_key, + '-mode' => $options->{ipc_mode}, + '-size' => $options->{ipc_segment_size}, + '-create' => 0, + '-destroy' => 0); ++ }; + confess("IPC::SharedCache: Unable to get shared cache block $obj_ipc_key : $!") unless defined $share; + + # get the cache block diff --git a/perl-IPC-SharedCache.spec b/perl-IPC-SharedCache.spec new file mode 100644 index 0000000..8e48406 --- /dev/null +++ b/perl-IPC-SharedCache.spec @@ -0,0 +1,74 @@ +Name: perl-IPC-SharedCache +Version: 1.3 +Release: 1 +Summary: Perl module to manage a cache in SysV IPC shared memory +License: GPLv2+ +URL: https://metacpan.org/release/IPC-SharedCache +Source0: https://cpan.metacpan.org/modules/by-module/IPC/IPC-SharedCache-%{version}.tar.gz +Patch0: IPC-SharedCache-1.3-test.patch +BuildArch: noarch +# Build +BuildRequires: coreutils +BuildRequires: findutils +BuildRequires: make +BuildRequires: perl-generators +BuildRequires: perl-interpreter +BuildRequires: perl(ExtUtils::MakeMaker) +# Module +BuildRequires: perl(Carp) +BuildRequires: perl(integer) +BuildRequires: perl(IPC::ShareLite) >= 0.06 +BuildRequires: perl(Storable) +BuildRequires: perl(strict) +BuildRequires: perl(vars) +# Test Suite +# (no additional dependencies) +# Dependencies +Requires: perl(IPC::ShareLite) >= 0.06 + +%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(IPC::ShareLite\\)$ + +%description +This module provides a shared memory cache accessed as a tied hash. +Shared memory is an area of memory that is available to all processes. +It is accessed by choosing a key, the ipc_key argument to tie. Every +process that accesses shared memory with the same key gets access to +the same region of memory. In some ways it resembles a file system, +but it is not hierarchical and it is resident in memory. This makes +it harder to use than a filesystem but much faster. The data in +shared memory persists until the machine is rebooted or it is +explicitly deleted. + + +%prep +%setup -q -n IPC-SharedCache-%{version} + +# Debian patch for tests, which fixes problem of HTML::Template +%patch -P0 -p1 + +%build +perl Makefile.PL INSTALLDIRS=vendor +make %{?_smp_mflags} + + +%install +make pure_install DESTDIR=%{buildroot} +find %{buildroot} -type f -name .packlist -delete +%{_fixperms} -c %{buildroot} + + +%check +make test + + + +%files +%license LICENSE +%doc ANNOUNCE Changes README +%{perl_vendorlib}/IPC/ +%{_mandir}/man3/IPC::SharedCache.3* + + +%changelog +* Mon Nov 04 2024 fu-shanqing - 1.3-1 +- init package diff --git a/sources b/sources new file mode 100644 index 0000000..00caa2b --- /dev/null +++ b/sources @@ -0,0 +1 @@ +4d5d159a6b41d42918b7c1fceafb43ae IPC-SharedCache-1.3.tar.gz -- cgit v1.2.3