source: branches/3.2/MondoRescue/Makefile.PL @ 3239

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