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

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