source: MondoRescue/tags/3.2.1/MondoRescue/Makefile.PL

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