line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::ACPS::RPM; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1550
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use v5.10; |
5
|
|
|
|
|
|
|
use Dist::Zilla::MintingProfile::ACPS; |
6
|
|
|
|
|
|
|
use Dist::Zilla::PluginBundle::ACPS; |
7
|
|
|
|
|
|
|
use Path::Class qw( dir file ); |
8
|
|
|
|
|
|
|
use File::HomeDir; |
9
|
|
|
|
|
|
|
use File::Copy qw( copy ); |
10
|
|
|
|
|
|
|
use List::MoreUtils qw( uniq ); |
11
|
|
|
|
|
|
|
use Template; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: RPM Dist::Zilla plugin for ACPS |
14
|
|
|
|
|
|
|
our $VERSION = '0.30'; # VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::Plugin'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use namespace::autoclean; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'spec_template' => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
default => sub { |
23
|
|
|
|
|
|
|
Dist::Zilla::PluginBundle::ACPS |
24
|
|
|
|
|
|
|
->share_dir |
25
|
|
|
|
|
|
|
->subdir('rpm') |
26
|
|
|
|
|
|
|
->file('dist.spec.tt') |
27
|
|
|
|
|
|
|
->stringify; |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has 'prefer_make_maker' => ( |
32
|
|
|
|
|
|
|
is => 'ro', |
33
|
|
|
|
|
|
|
default => 0, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has 'filter_requires' => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub mvp_multivalue_args { qw(filter_requires) } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub mk_spec { |
44
|
|
|
|
|
|
|
my($self, $archive, $spec_filename) = @_; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# this is different from the superclass, we allow fully qualified filenames, because |
47
|
|
|
|
|
|
|
# we want to keep the spec template in the share directory with the other profile |
48
|
|
|
|
|
|
|
# stuff. |
49
|
|
|
|
|
|
|
my $template = $self->spec_template =~ /^\// ? $self->spec_template : $self->zilla->root->file($self->spec_template); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $tt2 = Template->new( ABSOLUTE => 1 ); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $release = do { |
54
|
|
|
|
|
|
|
my $name = $self->zilla->name; |
55
|
|
|
|
|
|
|
my $version = $self->zilla->version; |
56
|
|
|
|
|
|
|
$self->log("% ap nextrelease acps-$name $version"); |
57
|
|
|
|
|
|
|
`ap nextrelease acps-$name $version`; |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
chomp $release; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $vars = { |
62
|
|
|
|
|
|
|
zilla => $self->zilla, |
63
|
|
|
|
|
|
|
rpm => { |
64
|
|
|
|
|
|
|
prefer_make_maker => $self->prefer_make_maker, |
65
|
|
|
|
|
|
|
archive => $archive, |
66
|
|
|
|
|
|
|
version => $self->zilla->version, |
67
|
|
|
|
|
|
|
release => $release, |
68
|
|
|
|
|
|
|
requires => [map { "perl($_)" } uniq sort grep !/^perl$/, $self->zilla->prereqs->requirements_for('runtime', 'requires')->required_modules], |
69
|
|
|
|
|
|
|
build_requires => [map { "perl($_)" } uniq sort grep !/^perl$/, map { $self->zilla->prereqs->requirements_for($_, 'requires')->required_modules } qw( configure build test runtime )], |
70
|
|
|
|
|
|
|
filter_requires => $self->filter_requires, |
71
|
|
|
|
|
|
|
}, |
72
|
|
|
|
|
|
|
}; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$template .= ''; # make sure this is a string and not an object |
75
|
|
|
|
|
|
|
$self->log("using spec template: " . $template); |
76
|
|
|
|
|
|
|
my $spec_text = ''; |
77
|
|
|
|
|
|
|
$tt2->process($template, $vars, \$spec_text) || $self->log_fatal("TT2 error: " . $tt2->error); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$self->log("creating spec: " . $spec_filename) |
80
|
|
|
|
|
|
|
if defined $spec_filename; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
return $spec_text; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub mk_rpm { |
86
|
|
|
|
|
|
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$self->log_fatal("first create a ~/rpmbuild directory (and make sure rpmbuild is installed)") |
89
|
|
|
|
|
|
|
unless -d dir(File::HomeDir->my_home, 'rpmbuild'); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
mkdir dir(File::HomeDir->my_home, 'rpmbuild', $_) for qw( BUILD RPMS SOURCES SPECS SRPMS ); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $tar = sprintf('%s-%s.tar.gz',$self->zilla->name,$self->zilla->version); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$self->log_fatal("could not find tar file (expected $tar to work)") unless -f $tar; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# create .rpmmacros file if it doesn't already exist. |
98
|
|
|
|
|
|
|
do { |
99
|
|
|
|
|
|
|
my $rpmmacros_file = file(File::HomeDir->my_home, '.rpmmacros'); |
100
|
|
|
|
|
|
|
unless(-f $rpmmacros_file) |
101
|
|
|
|
|
|
|
{ |
102
|
|
|
|
|
|
|
$self->log("creating " . $rpmmacros_file); |
103
|
|
|
|
|
|
|
my $fh = $rpmmacros_file->openw; |
104
|
|
|
|
|
|
|
say $fh '%packager %(echo "$USER")'; |
105
|
|
|
|
|
|
|
say $fh '%_topdir %(echo $HOME)/rpmbuild'; |
106
|
|
|
|
|
|
|
$fh->close; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
}; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# copy tar to SOURCES directory |
111
|
|
|
|
|
|
|
do { |
112
|
|
|
|
|
|
|
my $from = $tar; |
113
|
|
|
|
|
|
|
my $to = file(File::HomeDir->my_home, 'rpmbuild', 'SOURCES', $tar); |
114
|
|
|
|
|
|
|
$self->log("copy tar: $to"); |
115
|
|
|
|
|
|
|
copy($from, $to) || $self->log_fatal("Copy failed: $!"); |
116
|
|
|
|
|
|
|
}; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# generate spec file |
119
|
|
|
|
|
|
|
my $spec = do { |
120
|
|
|
|
|
|
|
my $outfile = Path::Class::File->new(File::HomeDir->my_home, qw( rpmbuild SPECS ), $self->zilla->name . '.spec'); |
121
|
|
|
|
|
|
|
my $out = $outfile->openw; |
122
|
|
|
|
|
|
|
$self->log("creating spec: " . $outfile); |
123
|
|
|
|
|
|
|
print $out $self->mk_spec($tar); |
124
|
|
|
|
|
|
|
$outfile; |
125
|
|
|
|
|
|
|
}; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# build rpm |
128
|
|
|
|
|
|
|
my @rpms = split /\n/, `ap build $spec`; |
129
|
|
|
|
|
|
|
$self->log("generate rpm: " . $_) for @rpms; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
@rpms; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub install_rpm |
135
|
|
|
|
|
|
|
{ |
136
|
|
|
|
|
|
|
my($self, @rpms) = @_; |
137
|
|
|
|
|
|
|
$self->log("installing rpm: " . $_) for @rpms; |
138
|
|
|
|
|
|
|
`ap install @rpms`; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub upload_rpm |
142
|
|
|
|
|
|
|
{ |
143
|
|
|
|
|
|
|
my($self, @rpms) = @_; |
144
|
|
|
|
|
|
|
$self->log("uploading rpm: " . $_) for @rpms; |
145
|
|
|
|
|
|
|
`ap upload @rpms`; |
146
|
|
|
|
|
|
|
$self->log("createrepo on build"); |
147
|
|
|
|
|
|
|
`restyumclient-createrepo build`; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=pod |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 NAME |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Dist::Zilla::Plugin::ACPS::RPM - RPM Dist::Zilla plugin for ACPS |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 VERSION |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
version 0.30 |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 SYNOPSIS |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
[ACPS::RPM] |
169
|
|
|
|
|
|
|
; spec_template = foo.spec.tt ; by default this is pulled @ACPS |
170
|
|
|
|
|
|
|
; prefer_make_maker = 1 ; default is 0, set to 1 to use MakeMaker instead of Module::Build |
171
|
|
|
|
|
|
|
; filter_requires = '^perl(Filter::Module)$' ; specify requires which should be filtered out. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 DESCRIPTION |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This builds rpms for the ACPS environment. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 OPTIONS |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 spec_template |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
The TT2 template for generating the spec file. If not specified on |
182
|
|
|
|
|
|
|
that comes bundled with @ACPS is used. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head2 prefer_make_maker |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
This generates a spec file which prefers MakeMaker over Moduke::Build. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 filter_requires |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Specify requirements to filter out. May be specified multiple times. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 AUTHOR |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Graham Ollis <gollis@sesda3.com> |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This software is copyright (c) 2012 by NASA GSFC. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
201
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=cut |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
__END__ |
207
|
|
|
|
|
|
|
|