source: trunk/util/arb_check_build_env.pl

Last change on this file was 19052, checked in by westram, 3 years ago
  • fix r19043 - did always check all hardcoded tools!
  • Property svn:executable set to *
File size: 2.8 KB
Line 
1#!/usr/bin/perl
2#
3# This script checks whether all tools needed for ARB compilation are found in path.
4
5use strict;
6use warnings;
7
8my @commands = (
9                'bash',
10                'cat',
11                'chmod',
12                'cp',
13                'find',
14                'grep',
15                'gzip',
16                'ln',
17                'ls',
18                'lynx',
19                'mkdir',
20                'mv',
21                'patch',
22                'perl',
23                'rm',
24                'sed',
25                'sort',
26                'tar',
27                'test',
28                'time',
29                'touch',
30                'uniq',
31                'xmllint',
32                'xsltproc',
33               );
34
35sub findPath($\@) {
36  my ($command,$path_dirs_r) = @_;
37  my ($found,$executable) = (undef,undef);
38
39  if (-e $command) {
40    $found = $command;
41    if (-X $command) { $executable = $command; }
42  }
43
44  if (not defined $executable) {
45    foreach (@$path_dirs_r) {
46      my $full = $_.'/'.$command;
47      if (-e $full) {
48        $found = $full;
49        if (-X $full) { $executable = $full; }
50      }
51    }
52  }
53  return ($found,$executable);
54}
55
56sub main() {
57  my $check_hardcoded_tools = 1;
58  my @cli_commands = ();
59  foreach (@ARGV) {
60    s/ .*$//og; # skip anything from first space to EOL
61    if ($_ eq '--check-only') {
62      $check_hardcoded_tools = 0;
63    }
64    else {
65      push @cli_commands, $_;
66    }
67  }
68
69  if ($check_hardcoded_tools) {
70    my %commands = map { $_ => 1; } @commands;
71    foreach (@cli_commands) { $commands{$_} = 1; }
72    @commands = sort keys %commands;
73  }
74  else {
75    @commands = @cli_commands;
76  }
77
78  my $path = $ENV{PATH};
79  if (not defined $path) { die "Environmentvariable 'PATH' is undefined"; }
80  my @path_dirs = split(':',$path);
81
82  my @missing       = ();
83  my @notExecutable = ();
84
85  foreach (@commands) {
86    my ($found,$executable) = findPath($_,@path_dirs);
87    if (not defined $executable) { # not ok
88      if (defined $found) { push @notExecutable, $_; }
89      else { push @missing, $_; }
90    }
91  }
92
93  my $missing = scalar(@missing);
94  my $notExecutable = scalar(@notExecutable);
95
96  if (($missing+$notExecutable)==0) {
97    my $count = scalar(@commands);
98    print "Located $count tools required for ARB compilation.\n";
99  }
100  else {
101    my $missingList       = join(', ', @missing);
102    my $notExecutableList = join(', ', @notExecutable);
103
104    my $msg = "The following tools are missing:\n";
105    if ($missing>0)       { $msg .= "    $missingList\n"; }
106    if ($notExecutable>0) { $msg .= "    $notExecutableList (found but not executable)\n"; }
107    $msg .= "These tools are vital to compile ARB, so\n";
108    $msg .= "please ensure that these tools are installed and that either\n";
109    $msg .= "- their installation directory is in PATH or\n";
110    $msg .= "- they are linked into the PATH\n\n";
111
112    die $msg;
113  }
114}
115
116main();
117
Note: See TracBrowser for help on using the repository browser.