| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Module::Release::PermissionFix; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1105
|
use 5.006001; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
46
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
32
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
6
|
1
|
|
|
1
|
|
1354
|
use parent qw(Exporter); |
|
|
1
|
|
|
|
|
348
|
|
|
|
1
|
|
|
|
|
6
|
|
|
7
|
1
|
|
|
1
|
|
1283
|
use Archive::Tar; |
|
|
1
|
|
|
|
|
231158
|
|
|
|
1
|
|
|
|
|
97
|
|
|
8
|
1
|
|
|
1
|
|
12
|
use Carp qw(croak); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
547
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT = qw(fix_permission); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.101'; |
|
13
|
|
|
|
|
|
|
$VERSION = eval { return $VERSION }; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Module::Release::PermissionFix - Fixes the permissions on .tar.gz files. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
The release-csjewell script will automatically load this module in order |
|
22
|
|
|
|
|
|
|
to make sure that the permissions on the file uploaded are correct and |
|
23
|
|
|
|
|
|
|
PAUSE will be able to index it. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
The reason for this module is that .tar files created on Windows often have |
|
26
|
|
|
|
|
|
|
permissions that are insane on Unix systems. PAUSE checks for those, and will |
|
27
|
|
|
|
|
|
|
not index them. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use Module::Release '2.00_04'; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# ... |
|
34
|
|
|
|
|
|
|
$release->dist; # Needs to be after the last execution of this line. |
|
35
|
|
|
|
|
|
|
# ... |
|
36
|
|
|
|
|
|
|
$release->load_mixin( 'Module::Release::PermissionFix' ); |
|
37
|
|
|
|
|
|
|
$release->fix_permission(); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 INTERFACE |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=over 4 |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item fix_permission |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Fixes the permissions on the distribution file (0444 becomes 0664, and |
|
46
|
|
|
|
|
|
|
0555 becomes 0755). |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub fix_permission { |
|
51
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
local $Archive::Tar::DO_NOT_USE_PREFIX = 1; |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $dist = $self->local_file; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
##no critic (ProhibitMagicNumbers ProhibitLeadingZeros) |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $fixes; |
|
60
|
0
|
|
|
|
|
|
my $tar = Archive::Tar->new; |
|
61
|
0
|
|
|
|
|
|
$tar->read($dist); |
|
62
|
0
|
|
|
|
|
|
my @files = $tar->get_files; |
|
63
|
0
|
|
|
|
|
|
foreach my $file (@files) { |
|
64
|
0
|
|
|
|
|
|
my $fixedmode = my $mode = $file->mode; |
|
65
|
0
|
|
|
|
|
|
my $filetype = q{}; |
|
66
|
0
|
0
|
|
|
|
|
if ( $file->is_file ) { |
|
|
|
0
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
$filetype = 'file'; |
|
68
|
0
|
0
|
|
|
|
|
if ( substr( ${ $file->get_content_by_ref }, 0, 2 ) eq q{#!} ) { |
|
|
0
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
$fixedmode = 0775; |
|
70
|
|
|
|
|
|
|
} else { |
|
71
|
0
|
|
|
|
|
|
$fixedmode = 0664; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
} elsif ( $file->is_dir ) { |
|
74
|
0
|
|
|
|
|
|
$filetype = 'dir'; |
|
75
|
0
|
|
|
|
|
|
$fixedmode = 0775; |
|
76
|
|
|
|
|
|
|
} else { |
|
77
|
0
|
|
|
|
|
|
next; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
0
|
0
|
|
|
|
|
next if $mode eq $fixedmode; |
|
80
|
0
|
|
|
|
|
|
$file->mode($fixedmode); |
|
81
|
0
|
|
|
|
|
|
$fixes++; |
|
82
|
0
|
|
|
|
|
|
$self->_debug( sprintf "Change mode %03o to %03o for %s '%s'\n", |
|
83
|
|
|
|
|
|
|
$mode, $fixedmode, $filetype, $file->name ); |
|
84
|
|
|
|
|
|
|
} ## end foreach my $file (@files) |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
if ($fixes) { |
|
87
|
0
|
0
|
|
|
|
|
rename $dist, "$dist.bak" |
|
88
|
|
|
|
|
|
|
or croak "Cannot rename file '$dist' to '$dist.bak': $!"; |
|
89
|
0
|
|
|
|
|
|
$tar->write( $dist, 9 ); |
|
90
|
0
|
|
|
|
|
|
$self->_print("Permissions fixed: $dist.\n"); |
|
91
|
|
|
|
|
|
|
} else { |
|
92
|
0
|
|
|
|
|
|
$self->_print("Permissions didn't need fixed: $dist.\n"); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
return; |
|
96
|
|
|
|
|
|
|
} ## end sub fix_permission |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=back |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L<Module::Release> |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This source is on the Open Repository: |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L<http://svn.ali.as/cpan/trunk/Module-Release-CSJEWELL/> |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 AUTHOR |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Curtis Jewell, C<< <csjewell@cpan.org> >> |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Copyright (c) 2009, Curtis Jewell C<< <csjewell@cpan.org> >>. All rights reserved. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
|
120
|
|
|
|
|
|
|
modify it under the same terms as Perl itself, either version |
|
121
|
|
|
|
|
|
|
5.8.1 or any later version. See L<perlartistic> and L<perlgpl>. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
124
|
|
|
|
|
|
|
LICENSE file included with this module. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
|
129
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
|
130
|
|
|
|
|
|
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
|
131
|
|
|
|
|
|
|
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER |
|
132
|
|
|
|
|
|
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
133
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
|
134
|
|
|
|
|
|
|
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
|
135
|
|
|
|
|
|
|
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
|
136
|
|
|
|
|
|
|
NECESSARY SERVICING, REPAIR, OR CORRECTION. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|
139
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
|
140
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE |
|
141
|
|
|
|
|
|
|
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
|
142
|
|
|
|
|
|
|
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
|
143
|
|
|
|
|
|
|
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
|
144
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
|
145
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
|
146
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
|
147
|
|
|
|
|
|
|
SUCH DAMAGES. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; |