File: Tarballs.pm

package info (click to toggle)
ocsinventory-agent 2%3A2.10.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,424 kB
  • sloc: perl: 26,492; xml: 773; objc: 528; sh: 386; ansic: 333; makefile: 12
file content (43 lines) | stat: -rw-r--r-- 1,510 bytes parent folder | download | duplicates (4)
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
# Write by Simon CLARA 2010-01-25
#
# The complete name of the package
# the path MUST be valid or the package won't be loaded
package Ocsinventory::Agent::Backend::OS::Generic::Tarballs;
use strict;
# I need to declare $runAfter because of the strict mode 
use vars qw($runAfter);
# The package must be run after OS::Generic
$runAfter = ["Ocsinventory::Agent::Backend::OS::Generic"];

# This is the check function. The agent runs it just once the module is loaded.
# If the function return false, the module and its children are not executed
# eg: OS::Linux and OS::Linux::* won't executed if this run() function return
# false

# Check if we are on a linux server
sub check { $^O =~ /^linux$/ }
# uncomment this if you want check for FreeBSD server
# sub check {can_run("pkg_info")}

# its the main function of the script, it's called during the hardware inventory
sub run {
    my $params = shift;
    # I need to get the inventory object to update it
    my $inventory = $params->{inventory};

    # our software are in /usr/local/src/
    foreach (`ls /usr/local/src/*.{bz2,tar.gz}`){
        /^(\/.*\/)(\S+)-(\d+\S*)(\.tar.gz|\.bz2)$/i;
        my $name = $2;
        my $version = $3;
        my $comments = "Software in /usr/local/src/ \n".`$2 --version`;
        # and I updated the information collected
        $inventory->addSoftwares({
            COMMENTS => $comments,
            NAME => $name,
            VERSION => $version
        });
    }
}

1;