/usr/share/arc/RTEInfo.pm is in nordugrid-arc-arex 1.1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | package RTEInfo;
use warnings;
use strict;
use LogUtils;
our $rte_options_schema = {
pgkdatadir => '',
configfile => '',
runtimedir => '*',
use_janitor => '*',
};
our $rte_info_schema = {
'*' => {
state => '',
description => '*',
}
};
our $log = LogUtils->getLogger(__PACKAGE__);
sub collect($) {
my ($options) = @_;
return {} unless $options->{runtimedir};
my $rtes = {};
add_static_rtes($options->{runtimedir}, $rtes);
add_janitor_res($options, $rtes);
return $rtes;
}
sub add_static_rtes {
my ($runtimedir, $rtes) = @_;
unless (opendir DIR, $runtimedir) {
$log->warning("Can't acess runtimedir: $runtimedir: $!");
return;
}
closedir DIR;
my $cmd = "find '$runtimedir' -type f ! -name '.*' ! -name '*~'";
unless (open RTE, "$cmd |") {
$log->warning("Failed to run: $cmd");
return;
}
while (my $dir = <RTE>) {
chomp $dir;
$dir =~ s#$runtimedir/*##;
$rtes->{$dir} = { state => 'installednotverified' };
}
}
sub add_janitor_res {
my ($options, $rtes) = @_;
return unless $options->{use_janitor};
my $jmodpath = $options->{pkgdatadir}.'/perl';
if (! -e "$jmodpath/Janitor/ArcUtils.pm") {
$log->warning("Janitor modules not found in '$jmodpath'");
$log->warning("The janitor package is not installed");
return;
}
eval { unshift @INC, $jmodpath; require Janitor::ArcUtils };
if ($@) {
$log->warning("Failed to load Janitor modules: $@");
return;
}
my $configfile = $options->{configfile};
Janitor::ArcUtils::listAll($configfile, $rtes);
# Hide unusable runtimes
for my $rte (keys %$rtes) {
my $state = $rtes->{$rte}{state};
next if $state eq "installednotverified";
next if $state eq "installedverified";
next if $state eq "installable";
next if $state eq "pendingremoval";
# installationfailed
# installedbroken
# pendingremoval
# UNDEFINEDVALUE
delete $rtes->{$rte};
}
}
#### TEST ##### TEST ##### TEST ##### TEST ##### TEST ##### TEST ##### TEST ####
sub test {
my $options = { pkgdatadir => '/scratch/adrianta/arc1/share/arc',
runtimedir => '/data/export/SOFTWARE/runtime',
configfile => '/etc/arc.conf',
use_janitor => 1,
};
require Data::Dumper; import Data::Dumper qw(Dumper);
LogUtils::level('VERBOSE');
$log->debug("Options:\n" . Dumper($options));
my $results = RTEInfo::collect($options);
$log->debug("Results:\n" . Dumper($results));
}
#test;
1;
|