223 |
rodolico |
1 |
#! /usr/bin/env perl
|
|
|
2 |
|
|
|
3 |
use strict;
|
|
|
4 |
use warnings;
|
|
|
5 |
|
|
|
6 |
# find our location and use it for searching for libraries
|
|
|
7 |
BEGIN {
|
|
|
8 |
use FindBin;
|
|
|
9 |
use File::Spec;
|
|
|
10 |
# use libraries from the directory this script is in
|
|
|
11 |
use lib File::Spec->catdir($FindBin::Bin);
|
|
|
12 |
# and its parent
|
|
|
13 |
use lib File::Spec->catdir( $FindBin::Bin . '/../' );
|
|
|
14 |
eval( 'use YAML::Tiny' );
|
|
|
15 |
}
|
|
|
16 |
|
|
|
17 |
use Cwd qw(abs_path);
|
|
|
18 |
use sysinfosetup;
|
|
|
19 |
|
|
|
20 |
my $scriptDir = abs_path(File::Spec->catdir($FindBin::Bin) );
|
|
|
21 |
|
|
|
22 |
use Digest::MD5 qw(md5_hex);
|
|
|
23 |
use File::Copy;
|
|
|
24 |
|
|
|
25 |
# define the version number
|
|
|
26 |
# see https://metacpan.org/pod/release/JPEACOCK/version-0.97/lib/version.pod
|
|
|
27 |
use version;
|
|
|
28 |
our $VERSION = version->declare("v0.001.001");
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
use Data::Dumper;
|
|
|
32 |
use File::Basename;
|
|
|
33 |
use Getopt::Long;
|
|
|
34 |
|
|
|
35 |
Getopt::Long::Configure ("bundling"); # allow -vd --os='debian'
|
|
|
36 |
our $dryRun;
|
|
|
37 |
our $DEBUG;
|
|
|
38 |
my $os;
|
|
|
39 |
my $help = 0;
|
|
|
40 |
my $version = 0;
|
|
|
41 |
my $quiet = 0;
|
|
|
42 |
my $seedFileName = '';
|
|
|
43 |
|
|
|
44 |
# simple display if --help is passed
|
|
|
45 |
sub help {
|
|
|
46 |
use File::Basename;
|
|
|
47 |
print basename($0) . " $VERSION\n";
|
|
|
48 |
print <<END
|
|
|
49 |
$0 [options]
|
|
|
50 |
Options:
|
|
|
51 |
--os|-o - lower case name of operating system (debian, freebsd, etc...)
|
|
|
52 |
--dryrun|-n - do not actually do anything, just tell you what I'd do
|
|
|
53 |
--version|-v - display version and exit
|
|
|
54 |
--quiet|-q - Do not ask questions, just do stuff
|
|
|
55 |
--help|-g - Show this screen
|
|
|
56 |
--seed|-s - URL/Path to seed file for config
|
|
|
57 |
--debug - Show extra information (--nodebug is default)
|
|
|
58 |
END
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
################################################################
|
|
|
63 |
# Main Code #
|
|
|
64 |
################################################################
|
|
|
65 |
|
|
|
66 |
# handle any command line parameters that may have been passed in
|
|
|
67 |
|
|
|
68 |
GetOptions (
|
|
|
69 |
"os|o=s" => \$os, # pass in the operating system
|
|
|
70 |
"dryrun|n" => \$dryRun, # do NOT actually do anything
|
|
|
71 |
"seed|s=s" => \$seedFileName,
|
|
|
72 |
'help|h' => \$help,
|
|
|
73 |
'version|v' => \$version,
|
|
|
74 |
'quiet|q' => \$quiet,
|
|
|
75 |
'debug!' => \$DEBUG
|
|
|
76 |
) or die "Error parsing command line\n";
|
|
|
77 |
|
|
|
78 |
if ( $help ) { &help() ; exit; }
|
|
|
79 |
if ( $version ) { use File::Basename; print basename($0) . " $VERSION\n"; exit; }
|
|
|
80 |
|
|
|
81 |
my $returnValue = 0;
|
|
|
82 |
|
|
|
83 |
# first, find operating system
|
|
|
84 |
my $command = $scriptDir . '/determineOS';
|
|
|
85 |
$os = `$command` unless $os;
|
|
|
86 |
&logIt( "Detected operating system is [$os]" );
|
|
|
87 |
|
|
|
88 |
die "Could not detect operation system\n" unless $os;
|
|
|
89 |
# now, verify we have all the libraries we need and install them if necessary
|
|
|
90 |
$command = $scriptDir . '/validateDependencies'
|
|
|
91 |
. " -o $os"
|
|
|
92 |
. ( $quiet ? ' -q' : '' )
|
|
|
93 |
. ( $DEBUG ? ' --debug' : '')
|
|
|
94 |
. ( $dryRun ? ' -n' : '' );
|
|
|
95 |
&logIt( "Running command $command" );
|
|
|
96 |
system $command;
|
|
|
97 |
&logIt( "\tReturn value is $returnValue" );
|
|
|
98 |
|
225 |
rodolico |
99 |
$command = $scriptDir . '/checkFiles'
|
|
|
100 |
. " -o $os"
|
|
|
101 |
. ( $quiet ? ' -q' : '' )
|
|
|
102 |
. ( $DEBUG ? ' --debug' : '')
|
|
|
103 |
. ( $dryRun ? ' -n' : '')
|
|
|
104 |
. ( $seedFileName ? " -s $seedFileName " : '' );
|
|
|
105 |
&logIt( "Running command $command" );
|
|
|
106 |
system $command;
|
|
|
107 |
&logIt( "\tReturn value is $returnValue" );
|
|
|
108 |
|
229 |
rodolico |
109 |
# check permissions
|
|
|
110 |
$command = $scriptDir . '/permissions';
|
|
|
111 |
&logIt( "Running command $command" );
|
|
|
112 |
system $command;
|
225 |
rodolico |
113 |
|
229 |
rodolico |
114 |
# run configure
|
223 |
rodolico |
115 |
$command = $scriptDir . "/../configure"
|
|
|
116 |
. ( $quiet ? ' -q' : '' )
|
|
|
117 |
. ( $DEBUG ? ' --debug' : '')
|
229 |
rodolico |
118 |
. ( $dryRun ? ' -n' : '' );
|
223 |
rodolico |
119 |
&logIt( "Running command $command" );
|
|
|
120 |
system $command;
|
|
|
121 |
&logIt( "\tReturn value is $returnValue" );
|