| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CPANPLUS::Dist::SUSE; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
90944
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
41
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
35
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base 'CPANPLUS::Dist::RPM'; |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
4310
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use English; |
|
9
|
|
|
|
|
|
|
# imports error(), msg() |
|
10
|
|
|
|
|
|
|
use CPANPLUS::Error; |
|
11
|
|
|
|
|
|
|
use IPC::Cmd qw{ run can_run }; |
|
12
|
|
|
|
|
|
|
use Path::Class; |
|
13
|
|
|
|
|
|
|
use SUPER; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
CPANPLUS::Dist::SUSE - To build RPM files from cpan for SUSE |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 VERSION |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Version 0.03 |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
CPANPLUS::Dist::SUSE is a distribution class to create SUSE packages |
|
28
|
|
|
|
|
|
|
from CPAN modules, and all its dependencies. This allows you to have |
|
29
|
|
|
|
|
|
|
the most recent copies of CPAN modules installed, using your package |
|
30
|
|
|
|
|
|
|
manager of choice, but without having to wait for central repositories |
|
31
|
|
|
|
|
|
|
to be updated. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
You can either install them using the API provided in this package, or |
|
34
|
|
|
|
|
|
|
manually via rpm. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
This is a simple module which inherits from CPANPLUS::Dist::RPM that |
|
37
|
|
|
|
|
|
|
allows for creating RPM packages under SUSE. In particular, this |
|
38
|
|
|
|
|
|
|
RPM spec file has been tested in SLES 11. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
It also honors Module::Build if Build.PL is in the distribution. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Simple way of creating and installing a module is: |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
cpan2dist --verbose --format CPANPLUS::Dist::SUSE --buildprereq --dist-opts="--replacefiles=" --install Module::Builder |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
"--replacefiles=" can be used when you want to install with rpm option |
|
47
|
|
|
|
|
|
|
"--replacefiles" |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
You can also check for CPANPLUS::Dist::Fedora for information. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 format_available |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Checks if /etc/SuSE-release file exists |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub format_available { |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Check SUSE release file |
|
62
|
|
|
|
|
|
|
if ( !-f '/etc/SuSE-release' ) { |
|
63
|
|
|
|
|
|
|
error('Not on a SUSE system'); |
|
64
|
|
|
|
|
|
|
return 0; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return super; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# my $bool = $self->_has_been_built; |
|
71
|
|
|
|
|
|
|
# |
|
72
|
|
|
|
|
|
|
# Returns true if there's already a package built for this module. |
|
73
|
|
|
|
|
|
|
# |
|
74
|
|
|
|
|
|
|
sub _has_been_built { |
|
75
|
|
|
|
|
|
|
my ( $self, $name, $vers ) = @_; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# FIXME this entire method should be overridden to first check the local |
|
78
|
|
|
|
|
|
|
# rpmdb, then check the yum repos via repoquery. As is we're pretty |
|
79
|
|
|
|
|
|
|
# broken right now |
|
80
|
|
|
|
|
|
|
# |
|
81
|
|
|
|
|
|
|
# For now, just call super |
|
82
|
|
|
|
|
|
|
return super; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _is_module_build_compat { |
|
86
|
|
|
|
|
|
|
my $self = shift @_; |
|
87
|
|
|
|
|
|
|
my $module = shift @_ || $self->parent; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $makefile = $module->_status->extract . '/Makefile.PL'; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#my $buildfile = $module->_status->extract . '/Build.PL'; |
|
92
|
|
|
|
|
|
|
if ( !-f $makefile ) { |
|
93
|
|
|
|
|
|
|
return 0; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
$makefile = file $makefile; |
|
96
|
|
|
|
|
|
|
my $content = $makefile->slurp; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
return $content =~ /Module::Build::Compat/; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 install |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Overrides the install method of RPM allowing for extra |
|
104
|
|
|
|
|
|
|
rpm install arguments in dist-opts, be aware that you |
|
105
|
|
|
|
|
|
|
need to specify it as |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
cpan2dist ... --dist-opts="--aid= --allfiles= --relocate=/a=/b" |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
--aid --allfiles --badreloc |
|
110
|
|
|
|
|
|
|
--excludedocs --force -h,--hash |
|
111
|
|
|
|
|
|
|
--ignoresize --ignorearch --ignoreos |
|
112
|
|
|
|
|
|
|
--includedocs --justdb --nodeps |
|
113
|
|
|
|
|
|
|
--nodigest --nosignature --nosuggest |
|
114
|
|
|
|
|
|
|
--noorder --noscripts --notriggers |
|
115
|
|
|
|
|
|
|
--oldpackage --percent |
|
116
|
|
|
|
|
|
|
--repackage --replacefiles --replacepkgs |
|
117
|
|
|
|
|
|
|
--test |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub install { |
|
122
|
|
|
|
|
|
|
my $self = shift @_; |
|
123
|
|
|
|
|
|
|
my %opts = $self->_parse_args(@_); |
|
124
|
|
|
|
|
|
|
my @valid_singleoptions = ( |
|
125
|
|
|
|
|
|
|
"--aid", "--allfiles", "--badreloc", "--excludedocs", |
|
126
|
|
|
|
|
|
|
"--force", "--hash", "--ignoresize", "--ignorearch", |
|
127
|
|
|
|
|
|
|
"--ignoreos", "--includedocs", "--justdb", "--nodeps", |
|
128
|
|
|
|
|
|
|
"--nodigest", "--nosignature", "--nosuggest", "--noorder", |
|
129
|
|
|
|
|
|
|
"--noscripts", "--notriggers", "--oldpackage", "--percent", |
|
130
|
|
|
|
|
|
|
"--repackage", "--replacefiles", "--replacepkgs", "--test" |
|
131
|
|
|
|
|
|
|
); |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
#my $rpm = $self->status->rpm; |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
my $otheropts = ''; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
foreach my $o (@valid_singleoptions) { |
|
138
|
|
|
|
|
|
|
$otheropts .= $o if ( exists( $opts{$o} ) ); |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
my $rpmcmd = 'rpm -Uvh ' . $otheropts . ' ' . $self->status->rpmpath; |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
if ( $EUID != 0 ) { |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
msg 'trying to invoke rpm via sudo'; |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
$rpmcmd = "sudo $rpmcmd"; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
my $buffer; |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $success = run( |
|
153
|
|
|
|
|
|
|
command => $rpmcmd, |
|
154
|
|
|
|
|
|
|
verbose => $opts{verbose}, |
|
155
|
|
|
|
|
|
|
buffer => \$buffer, |
|
156
|
|
|
|
|
|
|
); |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
if ( !( defined($success) ) || not $success ) { |
|
159
|
|
|
|
|
|
|
error "error installing! ($success)"; |
|
160
|
|
|
|
|
|
|
printf STDERR $buffer; |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
#die; |
|
163
|
|
|
|
|
|
|
return $self->status->installed(0); |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
return $self->status->installed(1); |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
1; |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
__DATA__ |