1 | use 5.006001; |
---|
2 | use ExtUtils::MakeMaker; |
---|
3 | |
---|
4 | # See lib/ExtUtils/MakeMaker.pm for details of how to influence |
---|
5 | # the contents of the Makefile that is written. |
---|
6 | WriteMakefile( |
---|
7 | NAME => 'PBPKG', |
---|
8 | DISTNAME => 'PBPKG', |
---|
9 | VERSION => 'PBVER', |
---|
10 | INST_SCRIPT => 'blib/bin', |
---|
11 | INSTALLDIRS => 'vendor', |
---|
12 | PREREQ_PM => { |
---|
13 | #HTTP::Headers => 1.59, |
---|
14 | #Template => 0, |
---|
15 | }, # e.g., Module::Name => 1.1 |
---|
16 | #ABSTRACT_FROM => 'bin/', # retrieve abstract from module |
---|
17 | AUTHOR => 'Bruno Cornec <bruno#mondorescue.org>', |
---|
18 | EXE_FILES => [ qw( bin/mr-analyze-lvm |
---|
19 | bin/mr-check-lvm |
---|
20 | bin/mr-process-ldd |
---|
21 | bin/mr-read-all-link |
---|
22 | bin/mr-kernel-get-modules |
---|
23 | ) ], |
---|
24 | ); |
---|
25 | |
---|
26 | package MY; |
---|
27 | |
---|
28 | sub postamble { |
---|
29 | |
---|
30 | # Determine location of etc conf files |
---|
31 | my $text =""; |
---|
32 | |
---|
33 | # Grab out any CONFDIR or other build param |
---|
34 | my $confdir = undef; |
---|
35 | my $target = undef; |
---|
36 | my $mandir = undef; |
---|
37 | my $cachedir = undef; |
---|
38 | my $sharedir = undef; |
---|
39 | |
---|
40 | while (my $arg = shift @ARGV) { |
---|
41 | my ($key, $value) = split /=/, $arg; |
---|
42 | if ($key =~ /^CONFDIR$/) { |
---|
43 | $confdir = $value; |
---|
44 | } elsif ($key =~ /^MANDIR$/) { |
---|
45 | $mandir = $value; |
---|
46 | } elsif ($key =~ /^CACHEDIR$/) { |
---|
47 | $cachedir = $value; |
---|
48 | } elsif ($key =~ /^SHAREDIR$/) { |
---|
49 | $sharedir = $value; |
---|
50 | } elsif ($key =~ /^TARGET$/) { |
---|
51 | $target = $value; |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | if (not defined $target) { |
---|
56 | $target = "/usr/local"; |
---|
57 | if (not defined $confdir) { |
---|
58 | $confdir = "$target/etc"; |
---|
59 | } |
---|
60 | if (not defined $cachedir) { |
---|
61 | $cachedir = "$target/var/cache"; |
---|
62 | } |
---|
63 | } else { |
---|
64 | $cachedir = $cachedir || "$target/var/cache"; |
---|
65 | if (not defined $confdir) { |
---|
66 | die "CONFDIR should be defined if PREFIX is defined"; |
---|
67 | } |
---|
68 | if (not defined $cachedir) { |
---|
69 | die "CACHEDIR should be defined if PREFIX is defined"; |
---|
70 | } |
---|
71 | } |
---|
72 | $sharedir = $sharedir || "$target/share"; |
---|
73 | $mandir = $mandir || "$sharedir/man"; |
---|
74 | |
---|
75 | my $conff = "etc/PBPROJ.conf"; |
---|
76 | open(CONF, ">> $conff") || die "Unable to append to $conff"; |
---|
77 | print CONF << "EOF"; |
---|
78 | # |
---|
79 | # Configuration information added at install time |
---|
80 | # |
---|
81 | # |
---|
82 | # installation target |
---|
83 | # |
---|
84 | mr_install_dir default = $target |
---|
85 | # |
---|
86 | # conf dir |
---|
87 | # |
---|
88 | mr_conf_dir default = $confdir/PBPROJ |
---|
89 | # |
---|
90 | # cache directory |
---|
91 | # |
---|
92 | mr_cache_dir default = $cachedir/PBPROJ |
---|
93 | # |
---|
94 | # share directory |
---|
95 | # |
---|
96 | mr_share_dir default = $sharedir/PBPROJ |
---|
97 | # |
---|
98 | # version |
---|
99 | # |
---|
100 | mr_version default = PBVER-rPBREV |
---|
101 | EOF |
---|
102 | close(CONF); |
---|
103 | # Create the dynamic content for MondoRescue |
---|
104 | my $dynf = "lib/MondoRescue/DynConf.pm"; |
---|
105 | open(DYN, "> $dynf") || die "Unable to create $dynf"; |
---|
106 | |
---|
107 | $text .= "install ::\n"; |
---|
108 | $text .= "\t".'@echo PBPKG PBVER-rPBREV will be installed under $(DESTDIR)'."\n"; |
---|
109 | $text .= "\t".'install -m 755 -d $(DESTDIR)'."$confdir/PBPROJ".' $(DESTDIR)'."$cachedir/PBPROJ".' $(DESTDIR)'."$sharedir/PBPROJ\n"; |
---|
110 | $text .= "\t".'cp etc/PBPROJ.conf $(DESTDIR)'."$confdir/PBPROJ/PBPROJ.conf.dist ; install -m 755 -d ".' $(DESTDIR)'."$mandir/man5 ; perl -p -e 's/^# //; s/^#//' etc/PBPROJ.conf | pod2man --name=PBPROJ.conf --release=PBVER-rPBREV --section=5 > ".'$(DESTDIR)'."$mandir/man5/PBPROJ.conf.5\n"; |
---|
111 | $text .= "\t".'(cd $(DESTDIR)'."$confdir/PBPROJ/ ; md5sum PBPROJ.conf.dist > ".'$(DESTDIR)'."$confdir/PBPROJ/PBPROJ.conf.dist.md5)\n"; |
---|
112 | $text .= "\t".'if [ ! -f "'.'$(DESTDIR)'."$confdir/PBPROJ/PBPROJ.conf".'" ]; then echo "# Local configuration file for Mondorescue" > $(DESTDIR)'."$confdir/PBPROJ/PBPROJ.conf".'; echo "# Adapt content taken from the distribution conf file PBPROJ.conf.dist which should remain untouched" >> $(DESTDIR)'."$confdir/PBPROJ/PBPROJ.conf ; fi\n"; |
---|
113 | $text .= "\t".'cp lib/MondoRescue/DynConf.pm $(DESTDIR)/$(VENDORLIBEXP)/MondoRescue/'."\n"; |
---|
114 | |
---|
115 | # Now generate a perl module used by every other one in the project |
---|
116 | print DYN << "EOF"; |
---|
117 | #!/usr/bin/perl -w |
---|
118 | # |
---|
119 | # Declare variables for the MondoRescue project |
---|
120 | # This module has been GENERATED at installation time |
---|
121 | # DO NOT MODIFY WITHOUT GOOD REASONS. |
---|
122 | # |
---|
123 | # Copyright B. Cornec 2008-2014 |
---|
124 | # Provided under the GPL v2 |
---|
125 | # |
---|
126 | package MondoRescue::DynConf; |
---|
127 | |
---|
128 | use strict 'vars'; |
---|
129 | |
---|
130 | # Inherit from the "Exporter" module which handles exporting functions. |
---|
131 | |
---|
132 | use Exporter; |
---|
133 | |
---|
134 | # Export, by default, all the functions into the namespace of |
---|
135 | # any code which uses this module. |
---|
136 | our \@ISA = qw(Exporter); |
---|
137 | our \@EXPORT = qw(mr_dynconf_init); |
---|
138 | |
---|
139 | =pod |
---|
140 | |
---|
141 | =head1 NAME |
---|
142 | |
---|
143 | MondoRescue::DynConf, part of the mondorescue.org project |
---|
144 | |
---|
145 | =head1 DESCRIPTION |
---|
146 | |
---|
147 | This modules provides environment variables setup for the Mondorescue project |
---|
148 | |
---|
149 | =head1 USAGE |
---|
150 | |
---|
151 | =over 4 |
---|
152 | |
---|
153 | =item B<mr_dynconf_init> |
---|
154 | |
---|
155 | This function returns all the installation PATH info needed by the project |
---|
156 | It takes no parameter and returns 2 values |
---|
157 | First value is the conf dir |
---|
158 | Second value is the project name |
---|
159 | |
---|
160 | =cut |
---|
161 | |
---|
162 | sub mr_dynconf_init { |
---|
163 | return("$confdir/PBPROJ","PBPROJ"); |
---|
164 | } |
---|
165 | 1; |
---|
166 | =pod |
---|
167 | =back |
---|
168 | |
---|
169 | =head1 WEB SITES |
---|
170 | |
---|
171 | The main Web site of the project is available at L<http://www.mondorescue.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.mondorescue.org/>. |
---|
172 | |
---|
173 | =head1 USER MAILING LIST |
---|
174 | |
---|
175 | The mailing list of the project is available at L<mailto:mondo\@lists.sf.net> |
---|
176 | |
---|
177 | =head1 AUTHORS |
---|
178 | |
---|
179 | The Mondorescue.org team L<http://www.mondorescue.org/> lead by Bruno Cornec L<mailto:bruno\@mondorescue.org>. |
---|
180 | |
---|
181 | =head1 COPYRIGHT |
---|
182 | |
---|
183 | mrmini is distributed under the GPL v2.0 license |
---|
184 | described in the file C<COPYING> included with the distribution. |
---|
185 | |
---|
186 | =cut |
---|
187 | |
---|
188 | |
---|
189 | EOF |
---|
190 | close(DYN); |
---|
191 | return($text); |
---|
192 | } |
---|