MegaDistro/RpmMaker/Config.pm untested

filter: Statementstmt 0.0% 0 / 64 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 88 CC 7 SCAR 32.4
CC
7
Cov
0%
build_pre
56.0
_init_globals
2.0
BEGIN
2.0
CRAP 25.6
1 package MegaDistro::RpmMaker::Config;
2  
3 use strict;
4 use warnings;
5  
6 use Exporter;
7 our @ISA = qw(Exporter);
8 our @EXPORT = qw(%buildtree $SPECFILE);
9 our @EXPORT_OK = qw( %metadata %stanza %OPTS build_pre );
10 our %EXPORT_TAGS;
11 $EXPORT_TAGS{'default'} = \@EXPORT;
12 $EXPORT_TAGS{'build'} = \@EXPORT_OK;
13
14 use lib '../MegaDistro';
15  
16 use File::Path;
17 use File::Spec::Functions qw(:ALL);
18  
19 use MegaDistro;
20 use MegaDistro::Config;
21  
22 # hash to contain the various directories needed for building the rpm, on the system
23 our %buildtree;
24  
25 #
26 # Package-specific configurables
27 #
28  
29 # the package metadata (headers)
30 our %metadata = (
31 # the package Summary
32 'summary' => 'A pre-compiled set of perl modules',
33
34 # the package Name
35 'name' => 'megadistro',
36
37 # the package Version
38 'version' => $MegaDistro::VERSION,
39
40 # the package Release number
41 'release' => '5',
42
43 # the package License
44 'license' => 'GPL',
45
46 # the package Group
47 'group' => 'Development/Libraries',
48
49 # the package Source location
50 'source' => 'http://search.cpan.org/CPAN/authors/id/D/DB/DBUCHMAN/megadistro-0.02.tar.gz',
51
52 # the package URL
53 'url' => 'http://search.cpan.org/~dbuchman/MegaDistro-0.02/',
54
55 # the package Requires (depends)
56 'requires' => 'perl >= 5.6.1',
57
58 # the package Obsolets (replaces)
59 'obsoletes' => 'megadistro < ' . $MegaDistro::VERSION,
60
61 # the package Conflicts
62 'conflicts' => 'megadistro < ' . $MegaDistro::VERSION,
63
64 # the package Vendor
65 'vendor' => 'Perl MegaDistro',
66
67 # the package Packager
68 'packager' => 'David Buchman',
69
70 # the package BuildRoot (virtual root, build directory)
71 'buildroot' => '%{_tmppath}/%{name}-%{version}-%{release}',
72
73 # allow rpm to automatically set dependencies
74 'autoreqprov' => 'no',
75
76 );
77  
78 # hash to contain various stanzas
79 our %stanza;
80  
81 # option lines (params), for each given stanza
82 our %OPTS;
83  
84 # the %description stanza
85 $stanza{'description'} = [
86 'The perl MegaDistro is a distributable binary, which contains a selection of pre-compiled modules.',
87 ];
88  
89 # the %prep stanza
90 $stanza{'prep'} = [
91 '',
92 ];
93
94 # the %setup stanza
95 $OPTS{'setup'} = '-q -c';
96 $stanza{'setup'} = [
97 '',
98 ];
99  
100 # the %files stanza
101 $stanza{'files'} = [
102 '%defattr(-,root,root)',
103 '/',
104 ];
105  
106 # the %install stanza
107 $stanza{'install'} = [
108 'rm -rf %{buildroot}',
109 'mkdir -p %{buildroot}',
110 'find %{_builddir} -type f -name .packlist -exec rm -f {} \';\'',
111 'find %{_builddir} -type f -name perllocal.pod -exec rm -f {} \';\'',
112 'cp -R %{_builddir}/%{name}-%{version}/usr %{buildroot}',
113 ];
114  
115  
116 sub _init_globals { #hack a la megadistro
117  
118 # rpmbuild-tree prefix
119 $buildtree{'prefixdir'} = catdir($Conf{'rootdir'}, 'rpmbuild');
120  
121 # SOURCES directory
122 $buildtree{'SOURCES'} = catdir($buildtree{'prefixdir'}, 'SOURCES');
123  
124 # BUILD directory
125 $buildtree{'BUILD'} = catdir($buildtree{'prefixdir'}, 'BUILD');
126  
127 # RPMS directory
128 $buildtree{'RPMS'} = catdir($buildtree{'prefixdir'}, 'RPMS');
129  
130 # SRPMS directory
131 $buildtree{'SRPMS'} = catdir($buildtree{'prefixdir'}, 'SRPMS');
132
133 # SPECS directory
134 $buildtree{'SPECS'} = catdir($buildtree{'prefixdir'}, 'SPECS');
135  
136 # the name of the rpm spec file
137 $buildtree{'specfile'} = catdir($buildtree{'SPECS'}, 'megadistro.spec');
138
139 # the name of the rpm rc file
140 $buildtree{'rcfile'} = $buildtree{'prefixdir'} . '/' . '.rpmrc';
141  
142 # the name of the default rcfile
143 $buildtree{'drcfile'} = '/usr/lib/rpm/rpmrc';
144
145 # the name of the rpm macros file
146 $buildtree{'macrosfile'} = $buildtree{'prefixdir'} . '/' . '.rpmmacros';
147
148 # the package BuildArch hardware platform
149 $metadata{'buildarch'} = `rpm --eval %{_build_arch} 2>&1`; chomp $metadata{'buildarch'};
150 }
151  
152 #
153 # Preparation
154 #
155 sub build_pre {
156 if ( $args{'trace'} ) {
157 print 'MegaDistro::SpecFile::Config : Executing sub-routine: build_pre' . "\n";
158 }
159
160 mkpath $buildtree{'SOURCES'} if ! -d $buildtree{'SOURCES'};
161 mkpath $buildtree{'BUILD'} if ! -d $buildtree{'BUILD'};
162 mkpath $buildtree{'RPMS'} if ! -d $buildtree{'RPMS'};
163 mkpath $buildtree{'SRPMS'} if ! -d $buildtree{'SRPMS'};
164 mkpath $buildtree{'SPECS'} if ! -d $buildtree{'SPECS'};
165 }
166  
167 1;