-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.PL
executable file
·125 lines (101 loc) · 2.74 KB
/
Makefile.PL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
use inc::Module::Install;
use Cwd;
use File::Spec;
my $version;
## if the file VERSION exists, it contains our versoin; otherwise,
## we use the version encoded in the containing directory name as our version,
## and create the VERSION file.
if ( -r 'VERSION' )
{
open(VERS, 'VERSION');
do {
$version = <VERS>;
} while ($version !~ /[\w\d]+/);
close(VERS);
chomp($version);
print("Version $version\n");
}
else
{
my @dirs;
my $version_from_dir;
my $vers;
# pull the current working directory into a list of parent directories
@dirs = File::Spec->splitdir(getcwd());
# our containing directory will be named by our release number
$version_from_dir = pop(@dirs);
# make sure that the previous comment is true
if (! (defined($version_from_dir) && ($version_from_dir =~ /^\d+/)))
{
$version_from_dir = 'DEVELOPMENT';
}
elsif ($version_from_dir =~ /^\d{8}/)
{
$version_from_dir = "RC_$version_from_dir";
}
$version = $version_from_dir;
# create version line
$vers = 'my $VERSION = \'' . $version_from_dir . "';\n";
open(VERS, '>VERSION') or die("Unable to create VERSION file: $!");
print(VERS "$version_from_dir\n");
close(VERS);
## set the $VERSION variable in each file to whatever we figured
## out above. Since our files are named *.pl before packaging, we'll
## write the modified version to the base filename without the .pl
my $file;
foreach $file (glob('bin/*.pl'), glob('lib/ConsoleClient.pm'))
{
my $newfilename;
my @newfile;
my $line;
# don't re-name our library modules
if ($file =~ /\.pm$/)
{
$newfilename = $file;
}
else
{
($newfilename) = ($file =~ /(.*)\.pl$/);
}
open(ORIG, $file) or die("Unable to read $file: $!");
# remove all '$VERSION =' lines and replace them with this version
foreach $line (<ORIG>)
{
if ($line =~ /\s*\$VERSION\s*=/)
{
push(@newfile, $vers);
}
else
{
push(@newfile, $line);
}
}
close(ORIG);
# write consoled
open(TAGGED, ">$newfilename") or die("Can't write tagged $newfilename: $!");
foreach $line (@newfile)
{
print(TAGGED $line);
}
close(TAGGED);
chmod(0755, $newfilename);
}
}
# Define metadata
name 'Consoled_Utils';
abstract "Perl library and scripts for consoled clients";
author "Catherine Mitchell";
perl_version '5.14';
license 'perl';
version $version;
# say what we need
configure_requires 'File::Copy' => 0;
configure_requires 'Module::Load::Conditional' => 0;
# say what doesn't need to be indexed
no_index 'directory' => 'docs';
# copy renamed scripts to install locations
install_script 'bin/consoleMonitor';
install_script 'bin/consoleUtil';
install_script 'bin/usecon';
install_script 'bin/lscon';
WriteAll;