ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/Architecture.pm
Revision: 1.2
Committed: Fri Dec 10 13:41:43 2004 UTC (20 years, 5 months ago) by sashby
Content type: text/plain
Branch: MAIN
CVS Tags: v102p1, V1_0_1, V1_0_0
Changes since 1.1: +94 -56 lines
Log Message:
Merged V1_0 branch to HEAD

File Contents

# User Rev Content
1 sashby 1.2 #____________________________________________________________________
2     # File: Architecture.pm
3     #____________________________________________________________________
4     #
5     # Author: Shaun Ashby <Shaun.Ashby@cern.ch>
6     # Update: 2003-10-23 17:20:41+0200
7     # Revision: $Id: Architecture.pm,v 1.1.4.2 2004/05/10 16:29:23 sashby Exp $
8 williamc 1.1 #
9 sashby 1.2 # Copyright: 2003 (C) Shaun Ashby
10 williamc 1.1 #
11 sashby 1.2 #--------------------------------------------------------------------
12     package Architecture;
13     require 5.004;
14     use Exporter;
15    
16     @ISA=qw(Exporter);
17     @EXPORT_OK=qw( );
18 williamc 1.1
19 sashby 1.2 sub new()
20     {
21     ###############################################################
22     # new() #
23     ###############################################################
24     # modified : Thu Oct 23 17:21:05 2003 / SFA #
25     # params : #
26     # : #
27     # function : #
28     # : #
29     ###############################################################
30     my $proto=shift;
31     my $class=ref($proto) || $proto;
32     my $self={};
33    
34     bless $self,$class;
35    
36     $self->_initarch();
37    
38     return $self;
39     }
40    
41     sub arch()
42     {
43     my $self=shift;
44    
45     @_ ? $self->{arch} = shift
46     : $self->{arch};
47     }
48    
49     # A subroutine to determine the architecture. This
50     # is done by parsing the architecture map contained as
51     # data inside SCRAM_SITE.pm and looking for an appropriate
52     # match for our platform:
53     sub _initarch()
54     {
55     my $self=shift;
56     $self->parse_architecture_map();
57     return $self;
58     }
59    
60     # Parse the map data:
61     sub parse_architecture_map()
62     {
63     my $self=shift;
64     my $matches={};
65    
66     require Installation::SCRAM_SITE;
67     my $architectures = &Installation::SCRAM_SITE::read_architecture_map();
68    
69     while (my ($archstring,$archtest) = each %{$architectures})
70     {
71     my $rval = eval join(" ",@$archtest);
72    
73     if ($rval)
74     {
75     # Store the matched string:
76     $matches->{$archstring}=1;
77    
78     if ((my $nkeys = keys %{$matches}) > 1)
79     {
80     print "\n";
81     print "SCRAM: WARNING: more than one architecture definition in ","\n";
82     print " SCRAM_SITE matches current platform!","\n";
83     print "Unable to set the architecture correctly!","\n";
84     print "\n";
85     exit(1);
86     }
87     # Store the match (only the *first* match in the case
88     # of multiple matches):
89     $self->arch($archstring);
90     }
91     else
92     {
93     next;
94     }
95     }
96     }
97 williamc 1.1
98 sashby 1.2 1;