source: branches/3.3/MondoRescue/Makefile.PL @ 3644

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