1 |
commit: 66ce54b9fb3a062ff9ff1b164de659f47aa9cb25 |
2 |
Author: Kent Fredric <kentfredric <AT> gmail <DOT> com> |
3 |
AuthorDate: Mon Oct 31 18:03:56 2011 +0000 |
4 |
Commit: Kent Fredric <kentfredric <AT> gmail <DOT> com> |
5 |
CommitDate: Mon Oct 31 18:03:56 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/perl-overlay.git;a=commit;h=66ce54b9 |
7 |
|
8 |
[scripts/dual-life.pl] early stage of dual-life script, shows delta between arbitrary corelist perls |
9 |
|
10 |
--- |
11 |
scripts/dual-life.pl | 199 ++++++++++++++++++++++++++++++++++++++++++++++++++ |
12 |
1 files changed, 199 insertions(+), 0 deletions(-) |
13 |
|
14 |
diff --git a/scripts/dual-life.pl b/scripts/dual-life.pl |
15 |
new file mode 100644 |
16 |
index 0000000..458e1f9 |
17 |
--- /dev/null |
18 |
+++ b/scripts/dual-life.pl |
19 |
@@ -0,0 +1,199 @@ |
20 |
+#!/usr/bin/env perl |
21 |
+ |
22 |
+use 5.14.2; |
23 |
+use strict; |
24 |
+use warnings; |
25 |
+ |
26 |
+# FILENAME: dual-life.pl |
27 |
+# CREATED: 01/11/11 05:49:45 by Kent Fredric (kentnl) <kentfredric@×××××.com> |
28 |
+# ABSTRACT: find/report dual-life modules. |
29 |
+use Module::CoreList; |
30 |
+use Data::Dump qw( pp ); |
31 |
+use FindBin; |
32 |
+use version; |
33 |
+ |
34 |
+use lib "$FindBin::Bin/lib"; |
35 |
+ |
36 |
+my $pv = shift(@ARGV); |
37 |
+ |
38 |
+my $perls = { |
39 |
+ masked_future => CoreGroup->new( name => 'masked_future', perls => [qw( 5.14.0 5.14.1 5.14.2 )] ), |
40 |
+ masked_past => CoreGroup->new( name => 'masked_past', perls => [qw( 5.8.8 5.10.1 )] ), |
41 |
+ testing => CoreGroup->new( name => 'testing', perls => [qw()] ), |
42 |
+ stable => CoreGroup->new( name => 'stable', perls => [qw( 5.12.3 5.12.4 )] ), |
43 |
+}; |
44 |
+ |
45 |
+ |
46 |
+pp $perls->{masked_future}->get_perl(qw( 5.14.2 ))->delta( |
47 |
+ $perls->{stable}->get_perl(qw( 5.12.4 )) ); |
48 |
+ |
49 |
+#for my $group ( $perls->{masked_future} ) { |
50 |
+# for my $perl ( values $group->perls ) { |
51 |
+# for my $module ( values $perl->modules ) { |
52 |
+# say $module->to_s; |
53 |
+# } |
54 |
+# } |
55 |
+#} |
56 |
+ |
57 |
+#pp $perls; |
58 |
+ |
59 |
+exit 0; |
60 |
+ |
61 |
+BEGIN { |
62 |
+ |
63 |
+ package CoreList::Module; |
64 |
+ use Moose; |
65 |
+ has name => ( isa => 'Str', is => 'rw', required => 1 ); |
66 |
+ has version => ( isa => 'Maybe[Str]', is => 'rw', required => 1 ); |
67 |
+ has perl => ( isa => 'Str', is => 'rw', required => 1 ); |
68 |
+ has coregroup => ( isa => 'Str', is => 'rw', required => 1 ); |
69 |
+ __PACKAGE__->meta->make_immutable; |
70 |
+ |
71 |
+ sub to_s { |
72 |
+ my $self = shift; |
73 |
+ return sprintf '%s %s %s %s', $self->coregroup, $self->perl, $self->name, $self->version // 'undef'; |
74 |
+ } |
75 |
+ |
76 |
+} |
77 |
+ |
78 |
+BEGIN { |
79 |
+ |
80 |
+ package CoreList::Single; |
81 |
+ use Moose; |
82 |
+ |
83 |
+ has 'perl' => ( isa => 'Str', is => 'rw', required => 1 ); |
84 |
+ |
85 |
+ has 'modules' => ( |
86 |
+ isa => 'HashRef[CoreList::Module]', |
87 |
+ is => 'rw', |
88 |
+ lazy_build => 1, |
89 |
+ traits => [qw( Hash )], |
90 |
+ handles => { |
91 |
+ 'module_names' => 'keys', |
92 |
+ 'has_module' => 'exists', |
93 |
+ 'module' => 'get', |
94 |
+ }, |
95 |
+ ); |
96 |
+ |
97 |
+ has 'released' => ( isa => 'Str', is => 'rw', lazy_build => 1 ); |
98 |
+ |
99 |
+ has 'perl_version' => ( isa => 'Str', is => 'rw', lazy_build => 1 ); |
100 |
+ |
101 |
+ has 'coregroup' => ( isa => 'Str', is => 'rw', required => 1 ); |
102 |
+ |
103 |
+ __PACKAGE__->meta->make_immutable; |
104 |
+ |
105 |
+ |
106 |
+ sub delta { |
107 |
+ my ( $self, $other ) = @_ ; |
108 |
+ my ( %all ) = map { $_ , 1 } |
109 |
+ $self->module_names, |
110 |
+ $other->module_names; |
111 |
+ my %diffs; |
112 |
+ for my $module ( keys %all ) { |
113 |
+ if( $self->has_module( $module ) and not $other->has_module( $module ) ) { |
114 |
+ $diffs{$module} = { |
115 |
+ kind => 'ours', |
116 |
+ available_in => $self->perl_version, |
117 |
+ not_available_in => $other->perl_version, |
118 |
+ module => $module, |
119 |
+ available_version => $self->module( $module )->version, |
120 |
+ }; |
121 |
+ next; |
122 |
+ } |
123 |
+ if( not $self->has_module( $module ) and $other->has_module( $module ) ) { |
124 |
+ $diffs{$module} = { |
125 |
+ kind => 'theirs', |
126 |
+ available_in => $other->perl_version, |
127 |
+ not_available_in => $self->perl_version, |
128 |
+ module => $module, |
129 |
+ available_version => $other->module( $module )->version, |
130 |
+ }; |
131 |
+ next; |
132 |
+ } |
133 |
+ if ( ( $self->module( $module )->version // 'undef' ) ne ( $other->module($module)->version // 'undef' ) ) { |
134 |
+ $diffs{$module} = { |
135 |
+ kind => 'cross', |
136 |
+ module => $module, |
137 |
+ our_version => $self->module( $module )->version, |
138 |
+ their_version => $other->module( $module )->version, |
139 |
+ our_perl => $self->perl_version, |
140 |
+ their_perl => $other->perl_version, |
141 |
+ }; |
142 |
+ } |
143 |
+ |
144 |
+ } |
145 |
+ return \%diffs; |
146 |
+ } |
147 |
+ |
148 |
+ |
149 |
+ # BUILDERS |
150 |
+ sub _build_perl_version { |
151 |
+ require version; |
152 |
+ my $self = shift; |
153 |
+ return version->parse( $self->perl )->numify; |
154 |
+ } |
155 |
+ |
156 |
+ sub _version_string { |
157 |
+ my $self = shift; |
158 |
+ return $self->perl . ' ( ' . $self->perl_version . ' )'; |
159 |
+ } |
160 |
+ |
161 |
+ sub _build_released { |
162 |
+ require Module::CoreList; |
163 |
+ my $self = shift; |
164 |
+ if ( not exists $Module::CoreList::released{ $self->perl_version } ) { |
165 |
+ die "Version " . $self->_version_string . " is not in the \$released stash"; |
166 |
+ } |
167 |
+ return $Module::CoreList::released{ $self->perl_version }; |
168 |
+ } |
169 |
+ |
170 |
+ sub _build_modules { |
171 |
+ require Module::CoreList; |
172 |
+ my $self = shift; |
173 |
+ if ( not exists $Module::CoreList::version{ $self->perl_version } ) { |
174 |
+ die "Version " . $self->_version_string . " is not in the \$version stash"; |
175 |
+ } |
176 |
+ |
177 |
+ my $stash = $Module::CoreList::version{ $self->perl_version }; |
178 |
+ |
179 |
+ return { |
180 |
+ map { |
181 |
+ $_, |
182 |
+ CoreList::Module->new( |
183 |
+ perl => $self->perl_version, |
184 |
+ coregroup => $self->coregroup, |
185 |
+ name => $_, |
186 |
+ version => $stash->{$_} |
187 |
+ ) |
188 |
+ } keys $stash |
189 |
+ }; |
190 |
+ } |
191 |
+} |
192 |
+ |
193 |
+BEGIN { |
194 |
+ |
195 |
+ package CoreGroup; |
196 |
+ use Moose; |
197 |
+ |
198 |
+ has _perls => ( isa => 'ArrayRef[Str]', is => 'rw', required => 1, init_arg => 'perls' ); |
199 |
+ |
200 |
+ has perls => ( isa => 'HashRef[CoreList::Single]', is => 'rw', lazy_build => 1, init_arg => undef ); |
201 |
+ has name => ( isa => 'Str', is => 'rw', required => 1 ); |
202 |
+ |
203 |
+ __PACKAGE__->meta->make_immutable; |
204 |
+ |
205 |
+ sub get_perl { |
206 |
+ my ($self,$perlv) = @_; |
207 |
+ if ( not exists $self->perls->{$perlv} ) { |
208 |
+ die "No key $perlv"; |
209 |
+ } |
210 |
+ return $self->perls->{$perlv}; |
211 |
+ } |
212 |
+ # BUILDERS |
213 |
+ sub _build_perls { |
214 |
+ my $self = shift; |
215 |
+ return { map { $_ , CoreList::Single->new( coregroup => $self->name, perl => $_ ) } @{ $self->_perls } }; |
216 |
+ } |
217 |
+ |
218 |
+} |