ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/setarchitecture.pm
(Generate patch)

Comparing COMP/SCRAM/src/Utilities/setarchitecture.pm (file contents):
Revision 1.7 by sashby, Fri Jul 12 13:43:26 2002 UTC vs.
Revision 1.8 by sashby, Fri Jul 12 16:37:10 2002 UTC

# Line 24 | Line 24 | sub setarch
24     {
25     my $uname=`uname -a`;
26     my ($OSname, $hostname, $OSversion, @rest) = split / /, $uname;
27 +      my $lddcmd="ldd /bin/ls";
28  
29 <   # Retain only the first two version digits:
29 >   # Retain only the first two version digits
30 >   # of os version from uname:
31     if ( $OSname =~ SunOS )
32        {
33        $OSversion =~ s/^(.\..)\..*/\1/;
34        }
35 <  
36 <   if ( $OSname =~ Linux )
35 >   # Linux:
36 >   elsif ( $OSname =~ Linux )
37        {
38        # Firstly we check for the kernel version.
39        $OSversion =~ s/^(.\..)\..*/\1/;
40        # Now, we also check for the libc version to confirm (or otherwise)
41        # the choice determined by the previous step:
40 #      my $lddcmd="ldd /bin/ls";
41 #      my ($match) = (`$lddcmd|grep libc` =~ /\s+libc\.so.*\s\=.*\s(.*)\s.*/);
42        # Open the ldd command as a pipe:
43 < #      my $pid=open(LDD,"$lddcmd 2>&1 |");
44 < #      exit(1) unless (defined($pid));
45 <
46 <      # Loop over lines of output:
47 < #      while (<LDD>)
48 < #        {
49 < #        chomp $_;
50 < #        if (my ($match) = ($_ =~ /\s+libc\.so.*\s.*\s(.*)\s.*/))
51 < #           {
52 < #           print "> LDD Match: ",$match,"\n";
53 < #           last;
54 < #           }
55 < #        }
56 <      #
57 <      # Grab something that looks like "libc.*":
58 <      
59 <      # Check if this libc thing is a soft link (it should be):
43 >      my $pid = open(LDD,"$lddcmd 2>&1 |");
44  
45 <      # Find out what the thingy is that the link points to:
45 >      # Check that we were able to fork:
46 >      if (defined($pid))
47 >         {
48 >         # Loop over lines of output:
49 >         while (<LDD>)
50 >            {
51 >            chomp $_;
52 >            # Grab something that looks like "libc.*":
53 >            if (my ($libc) = ($_ =~ /\s+libc\.so.*\s.*\s(.*)\s.*/))
54 >               {
55 >               # Check if this libc thing is a soft link (it should be), then
56 >               # find out what the thingy is that the link points to:
57 >               if ( -l $libc && defined($value = readlink $libc))
58 >                  {
59 >                  # Extract the useful numeric info from this:    
60 >                  my ($libcmaj,$libcmin,$libcpatch) = ($value =~ /^libc-([0-9])\.([0-9])\.([0-9])\.so/);
61  
62 <      #
62 >                  # Set the arch accordingly:
63 >                  if ($libcmaj == 2 && $libcmin == 1 && $libcpatch >= 3)
64 >                     {
65 >                     $ENV{SCRAM_ARCH}="Linux__2.2";
66 >                     }
67 >                  
68 >                  if ($libcmaj == 2 && $libcmin == 2 && $libcpatch >= 4)
69 >                     {
70 >                     $ENV{SCRAM_ARCH}="Linux__2.4";
71 >                     }
72 >                  }
73 >               # No need to check other lines:
74 >               last;
75 >               }
76 >            }
77 >         }
78 >      else
79 >         # Fork failed, so we must fall back to
80 >         # the normal mechanism to define the arch:
81 >         {
82 >         $ENV{SCRAM_ARCH}="${OSname}__${OSversion}";
83 >         }
84 >      }
85 >   else
86 >      {
87 >      # At this point it looks like the platform is "other".
88 >      # Set SCRAM_ARCH anyway to the default:
89 >      $ENV{SCRAM_ARCH}="${OSname}__${OSversion}";
90        }
91    
92 <   # Set arch flag to [OS type]__[OSversion]:
92 >   # Set arch flag to [OS type]__[OSversion] if not set by now:
93     if ( ! defined $ENV{SCRAM_ARCH} )
94        {
95        $ENV{SCRAM_ARCH}="${OSname}__${OSversion}";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines