[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] whichMacPerl v2



Hi all.  Please test this and report back, if you please.  Basically, I
want to know if it reports back what it should.  But if you have
suggestions for better code or something, send those too.

Here are the basic ideas:

(
  ASL=>AppleScriptLib 1.2.2,
  OSL=>ObjectSupportLib 1.2,
  CFM=>CFM-68K Runtime Enabler 4.0
)

(PPC && Mac OS 8 && ASL)                        = Regular distribution
(PPC && ASL && OSL)                             = Regular distribution
(PPC && !Mac OS 7.5.3+)                         = Regular distribution
(68K && Processor < 68020)                      = BigMacPerl
(68K && Mac OS 8 && !ASL)                       = BigMacPerl
(68K && !ASL && !OSL && !CFM && !Mac OS 7.5.3+) = BigMacPerl
Else                                            = CFM68K MacPerl

--
Chris Nandor               pudge@pobox.com           http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==                    MacPerl: Power and Ease                     ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



#!perl
#-----------------------------------------------------------------#
#  whichMacPerl
#  pudge
#  Check which version of MacPerl to install
#
#  Created:       Chris Nandor (pudge@pobox.com)         04-Dec-97
#  Last Modified: Chris Nandor (pudge@pobox.com)         17-Dec-97
#
#  Additional modifications by Alan Fry <ajf@afco.demon.co.uk>,
#    Paul Schinder <schinder@leprss.gsfc.nasa.gov>,
#    Matthias Neeracher <neeri@iis.ee.ethz.ch>,
#    Erryn Duncan <errynd@dlux.net>.
#-----------------------------------------------------------------#
#  The runtime application version of this script ("whichMacPerl")
#  will run on any Mac with System 7.  The text version of this
#  script ("whichMacPerl.pl") will run on any Mac that has both
#  the MacPerl 5.1.5r4 (or better) distribution and the BigMacPerl
#  distribution.
#-----------------------------------------------------------------#
use Mac::Files;
use Mac::Resources;
use Mac::Memory;
use Mac::Gestalt;
MacPerl::Quit(1);    # only quit if a Runtime
my($ext, %files, %yes, @which, $reg, $vers, $file, $prompt, $id, $nvers, $reqs);

#==========================================================#
# Init Vars
#==========================================================#
$ext = FindFolder(kOnSystemDisk(),kExtensionFolderType());
%files = (
  'ObjectSupportLib',['1.2',"$ext:ObjectSupportLib"],
  'AppleScriptLib',['1.2.2',"$ext:AppleScriptLib"],
  'CFM-68K Runtime Enabler',['4.0',
    (
      -e "$ext: CFM-68K Runtime Enabler" ?
      "$ext: CFM-68K Runtime Enabler" :
      "$ext:CFM-68K Runtime Enabler"
    )
  ],
);
$reg = 'I recommend installing the regular MacPerl distribution';
%which = (
  'appl',"$reg.",
  'bigappl',"$reg\nand then the BigMacPerl distribution.\n\n" .
            "Alternatively, follow the above upgrade tips and install\n" .
            'the CFM-68K distribution instead of the BigMacPerl distribution.',
  'cfm68k',"$reg and then the CFM-68K distribution.",
);

$upgrade = 0;

#==========================================================#
# Main Checks
#==========================================================#
if ($Gestalt{gestaltSysArchitecture()} ne gestaltPowerPC()) {
  print "You're running on a PowerPC-based Mac OS system.\n\n";
  if ($Gestalt{gestaltSystemVersion()} >= hex(800)) {
    foreach (keys %files) {
      &checkVers($files{$_}->[0], $files{$_}->[1], $_)
        if (/AppleScriptLib/);
    }
    print "\nWARNING: You need to have the above extensions up to date.\n",
          "They should be available on your System disks.\n\n"
      if $upgrade;
  } else {
    foreach (keys %files) {
      &checkVers($files{$_}->[0], $files{$_}->[1], $_)
        if (/AppleScriptLib|ObjectSupportLib/);
    }
    print "\nWARNING: You need to have the above extensions up to date.\n",
          "They should be available on your System disks.\n\n"
      if $upgrade;
    print "I recommend strongly upgrading to Mac OS 7.5.3 or greater.\n\n"
      if ($Gestalt{gestaltSystemVersion()} < hex(753));
  }
  recommend('appl');
} else {
  print "You're running on a Motorola 680x0-based Mac OS system.\n\n";
}
if ($Gestalt{gestaltProcessorType()} < gestalt68020()) {
  print "Wow! You seem to run on a rather old Mac.\n",
        "I'm afraid there is not much advice I can give you here.\n\n";
  recommend('appl');
}
foreach (keys %files) {
  if ($Gestalt{gestaltSystemVersion()} >= hex(800)) {
    &checkVers($files{$_}->[0], $files{$_}->[1], $_)
      if (/AppleScriptLib/);
  } else {
    &checkVers($files{$_}->[0], $files{$_}->[1], $_);
  }
}
print "\n";
if ($Gestalt{gestaltSystemVersion()} < hex(753)) {
  print "I'd recommend upgrading to Mac OS 7.5.3 or greater.\n\n";
  $upgrade = 1;
}
if ($upgrade) {recommend('bigappl')}
else {recommend('cfm68k')}

#==========================================================#
# Recommend Version
#==========================================================#
sub recommend {
  print "$which{$_[0]}\n\n";
  print "Hit the <RETURN> or <ENTER> key to quit.\n";
  while(<STDIN>){exit}
}

#==========================================================#
# Check Library Versions
#==========================================================#
sub checkVers {
  ($vers, $file, $prompt, $reqs, $id, $nvers) = @_;
  if (defined(OpenResFile($file))) {
    $id = Get1Resource('vers',1);
    if (defined($id)) {
      $nvers = $id->get();
    }
    CloseResFile(CurResFile());
  }
  $nvers =~ s/^.*?([\d\.]+), ©.*$/$1/m;
  write;
  $upgrade = $upgrade || !($nvers && $vers && $nvers ge $vers);
}

#==========================================================#
# Library Version Formats
#==========================================================#
format STDOUT_TOP =
Checking the versions of some system files:
  File                         Version Needed  Version Present
  ---------------------------  --------------  ---------------
.
format STDOUT =
  @<<<<<<<<<<<<<<<<<<<<<<<<<<  @>>>>>>>>>>>>>  @>>>>>>>>>>>>>>
  $prompt,                     $vers,          $nvers
.

#==========================================================#



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch