1 | |
---|
2 | use inc::Module::Install; |
---|
3 | |
---|
4 | # Hack to be able to run a post install script |
---|
5 | sub MY::postamble |
---|
6 | { |
---|
7 | |
---|
8 | my $re; |
---|
9 | |
---|
10 | $re = ' |
---|
11 | install :: all pure_install doc_install |
---|
12 | $(NOECHO) $(NOOP)'; |
---|
13 | |
---|
14 | $re .= "\n\t[ ! -f run-postinst ] || $^X postinst.pl\n"; |
---|
15 | |
---|
16 | return $re; |
---|
17 | } |
---|
18 | |
---|
19 | require 'lib/Ocsinventory/Agent/Config.pm'; |
---|
20 | use Config; |
---|
21 | |
---|
22 | my $version = $Ocsinventory::Agent::Config::VERSION; |
---|
23 | if (-d '.bzr') { |
---|
24 | chomp( my $bzrRev = `bzr revno`); |
---|
25 | $version .= "~bzr".$bzrRev; |
---|
26 | } |
---|
27 | |
---|
28 | name 'Ocsinventory-Unix-Agent'; |
---|
29 | include 'Module::AutoInstall'; |
---|
30 | abstract 'Ocs-Inventory unified Agent for UNIX, Linux and MacOSX'; |
---|
31 | license 'gpl'; |
---|
32 | version $version; |
---|
33 | perl_version '5.006'; |
---|
34 | requires 'Digest::MD5' => undef; |
---|
35 | requires 'XML::Simple' => undef; |
---|
36 | requires 'LWP' => undef; |
---|
37 | requires 'File::Temp' => undef; |
---|
38 | recommends 'Net::IP' => undef; |
---|
39 | recommends 'Compress::Zlib'; |
---|
40 | recommends 'Proc::Daemon' => undef; |
---|
41 | recommends 'Proc::PID::File' => undef; |
---|
42 | |
---|
43 | install_script 'ocsinventory-agent'; |
---|
44 | |
---|
45 | |
---|
46 | # We want a release bundled with the needed dependency to be able to |
---|
47 | # prepare a standalone binary with PAR::Packer |
---|
48 | if ($ENV{OCS_BUNDLE_RELEASE}) { |
---|
49 | foreach my $module (qw/Archive::Zip HTML::Parser LWP URI XML::NamespaceSupport Net::IP HTML::Tagset Proc::Daemon Module::ScanDeps PAR::Packer AutoLoader PAR PAR::Dist File::Remove YAML::Tiny Getopt::ArgvFile ExtUtils::Install ExtUtils::ParseXS XML::SAX XML::Simple/) { |
---|
50 | bundle $module; |
---|
51 | requires $module; |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | #Ugly hack to include ipdiscover binary compilation and install fo Linux systems |
---|
56 | if ($^O =~ /^linux$/i && can_cc()) { |
---|
57 | my $cc=$Config::Config{cc}; |
---|
58 | system("$cc resources/ipdiscover/ipdiscover.c -o ipdiscover"); |
---|
59 | if (-f 'ipdiscover') { |
---|
60 | install_script 'ipdiscover'; |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | if (defined ($ENV{PERL_AUTOINSTALL}) || defined ($ENV{PERL_AUTOINSTALL})) { |
---|
66 | unlink 'run-postinst'; |
---|
67 | } else { |
---|
68 | open POSTINST, '>run-postinst' or die $!; |
---|
69 | close POSTINST; |
---|
70 | } |
---|
71 | |
---|
72 | |
---|
73 | if (!can_use('Compress::Zlib')) { |
---|
74 | print "Please install Compress::Zlib if you use an OCS server prior 1.02.\n"; |
---|
75 | } |
---|
76 | |
---|
77 | if (!can_use('Crypt::SSLeay')) { |
---|
78 | print "Please install Crypt::SSLeay if you want to use SSL.\n"; |
---|
79 | } |
---|
80 | |
---|
81 | if (!can_use('Net::SSLeay')) { |
---|
82 | print "Please install Net::SSLeay if you want to use the software deployment.\n"; |
---|
83 | } |
---|
84 | |
---|
85 | |
---|
86 | if (!can_run('ipdiscover') && !can_run('nmap')) { |
---|
87 | print "Please install nmap "; |
---|
88 | print "or ipdiscover " if $^O =~ /^linux$/i; |
---|
89 | print "if you want to use the network ". |
---|
90 | "discover feature.\n"; |
---|
91 | } |
---|
92 | |
---|
93 | if (!can_use('Net::IP')) { |
---|
94 | print "Net::IP is strongly recommended since it's required to retrieve " |
---|
95 | ."network information\n"; |
---|
96 | } |
---|
97 | |
---|
98 | if (!can_use('Proc::Daemon') || !can_use('Proc::PID::File')) { |
---|
99 | print "Please install Proc::Daemon and Proc::PID::File if you ". |
---|
100 | "want to use the daemon monde.\n"; |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | my $archname; |
---|
105 | eval { # config_re is not available on Perl 5.6 |
---|
106 | my @t = Config::config_re('archname'); |
---|
107 | $archname = $t[0]; |
---|
108 | }; |
---|
109 | if ($^O =~ /(linux|bsd)/i && (!$archname ||$archname =~ /(i[3456x]86|x86_64|amd64)/i)) { |
---|
110 | foreach (qw/dmidecode lspci/) { |
---|
111 | if (!can_run($_)) { |
---|
112 | print "\n"; |
---|
113 | print "[WARNING] $_ is needed if you want a complete inventory on x86 and AMD64/x86_64.\n"; |
---|
114 | print "\n"; |
---|
115 | } |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | if ($^O =~ /^darwin$/ && !can_use('Mac::SysProfile')) { |
---|
120 | print "\n"; |
---|
121 | print "[WARNING] Mac::SysProfile is needed on MacOS to detect most of the device information.\n"; |
---|
122 | print "\n"; |
---|
123 | requires 'Mac::SysProfile' => undef; |
---|
124 | } |
---|
125 | |
---|
126 | # memconf is needed by Solaris backend module |
---|
127 | if ($^O =~ /^solaris$/i) { |
---|
128 | install_script 'memconf'; |
---|
129 | } |
---|
130 | |
---|
131 | #for i in inc/BUNDLES/* ; do rm -rf `basename $i` ;done` |
---|
132 | #auto_install; |
---|
133 | WriteAll; |
---|
134 | |
---|