Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7260 dpurdie 1
#!/usr/bin/perl
2
#
3
#   This simple CGI script is deployed to the package server within the
4
#   http subsystem ( lighttpd or apache )
5
#   
6
#   The function is used by Release Manager to locate build logs for a specific build
7
#   
8
#   This script must work within both lighttpd and apache. Issues: 
9
#       * lighttpd cannot return error codes
10
#   
11
use CGI qw(:standard);
12
use JSON;
13
my $cgi = CGI->new();
14
print header('application/json');
15
my $json->{result} = 1;
16
 
17
my $rootDir='/export/devl/abtlog';
18
my $rootDirLen = 1+length($rootDir);
19
 
20
if (! -d $rootDir) {
21
    $json->{result} = -1;
22
    $json->{error} = "ABT Root directory does not exist"
23
 
24
} elsif ( ! defined $cgi->param("rtagId") ) {
25
    $json->{result} = -1;
26
    $json->{error} = "Parameter not present: rtagId"
27
 
28
} elsif ( ! defined $cgi->param("buildRef") ) {
29
    $json->{result} = -1;
30
    $json->{error} = "Parameter not present: buildRef"
31
 
32
} else  {
33
 
34
    # Expect files in the path
35
    #   /export/devl/abtlog/<BuildMachine>/<rtgId>/<BuildRef>/<PackageVersion>.log
36
 
37
    my $globStr = $rootDir . '/*/'. scalar $cgi->param("rtagId") .'/' .  scalar $cgi->param("buildRef") . '/*.log';
38
    push @data, glob($globStr);
39
    my @clean =  map {substr($_,$rootDirLen)} @data;
40
 
41
    $json->{data} = \@clean;
42
 
43
    #$json->{ref} =  scalar $cgi->param("buildRef");
44
    #$json->{glob} =  $globStr;
45
    #$json->{dataRaw} = \@data;
46
}
47
 
48
my $json_text = to_json($json);
49
print $json_text;
50