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

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