; Script generated by the My Inno Setup Extensions Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! ; My thanks to Robert Cowham for getting this installer ; started. Without him I doubt if I'd have bothered. TS 28/11/2002 [Setup] AppName=P4Ruby: The Perforce API for Ruby 1.8 AppVerName=P4Ruby 1.5953 (Ruby 1.8.2) AppPublisher=Tony Smith AppPublisherURL=http://www.smee.org AppSupportURL=http://public.perforce.com/guest/tony_smith/perforce/API/Ruby/index.html AppUpdatesURL=http://public.perforce.com/guest/tony_smith/perforce/API/Ruby/main/Changes DefaultDirName={code:RubyLibDir} DisableProgramGroupPage=yes DirExistsWarning=no DisableDirPage=yes SourceDir=.. OutputDir=..\current OutputBasefilename=p4ruby-main-1.8.2-setup WindowVisible=yes [Files] Source: "P4.so"; DestDir: "{code:RubyArchDir}"; Flags: ignoreversion; Source: "lib\P4.rb"; DestDir: "{code:RubyLibDir}"; Flags: ignoreversion; [Code] // This section is the Pascal script - various procedures called from above. program Setup; var RubyLibPath: String; RubyArchPath: String; RubyVersion: String; //--------------------------------------------------- // Called automatically at the start of initialization function InitializeSetup(): Boolean; var TempFile: String; Cmd: String; RubyBuildVer: String; Lines: TArrayOfString; i: Longint; ResultCode: Integer; begin // Make sure Ruby is installed and work out where to copy library Result := false; // Version of Ruby we're looking for RubyBuildVer := '1.8'; TempFile := GenerateUniqueName(GetTempDir(), '.ini'); // // Some fiddling to find appropriate way to get output - straight piping didn't seem to work. // We use Ruby's rbconfig.rb file to figure out where to put the files. Currently at least // I'm ignoring the site_lib directory as Ruby's own mkmf seems to so all existing P4/Ruby // installs will not have used the site_lib tree either. // // Note: use %q{} to do single quotes inside the Pascal quotes. It also saves us // having to escape the \'s in the file path as well as saving us from horrible // multiple quotes (e.g. '''' ) // Cmd := '"require %q{rbconfig}; '; Cmd := Cmd + 'File.open( %q{' + TempFile + '}, %q{w}) {'; Cmd := Cmd + ' |f|'; Cmd := Cmd + ' f.puts( %q{RubyLibPath=} + Config::CONFIG[ %q{rubylibdir} ] );'; Cmd := Cmd + ' f.puts( %q{RubyArchPath=} + Config::CONFIG[ %q{archdir} ] );'; Cmd := Cmd + ' f.puts( %q{RubyVersion=} + RUBY_VERSION );'; Cmd := Cmd + '}"'; Cmd := '-e ' + Cmd; if not Exec('ruby.exe', Cmd, GetTempDir(), SW_SHOWMINNOACTIVE, ewWaitUntilTerminated, ResultCode) then begin MsgBox('Can''t find ruby.exe in your path - Ruby doesn''t seem to be installed.' + #13#13 'Please fix this and try again!', mbError, MB_OK); end else begin if not LoadStringsFromFile(TempFile, Lines) then begin MsgBox('Error loading strings '' from file.', mbError, MB_OK); end else begin // Extract the RubyLibDir and RubyArchDir paths from the file for i := 0 to GetArrayLength( Lines ) - 1 do begin if ( Pos( 'RubyLibPath=', Lines[ i ] ) = 1 ) then begin RubyLibPath := Lines[ i ]; StringChange( RubyLibPath, 'RubyLibPath=', '' ); StringChange( RubyLibPath, '/', '\' ); // Convert to right seperators end; if ( Pos( 'RubyArchPath=', Lines[ i ] ) = 1 ) then begin RubyArchPath := Lines[ i ]; StringChange( RubyArchPath, 'RubyArchPath=', '' ); StringChange( RubyArchPath, '/', '\' ); // Convert to right seperators end; if ( Pos( 'RubyVersion=', Lines[ i ] ) = 1 ) then begin RubyVersion := Lines[ i ]; StringChange( RubyVersion, 'RubyVersion=', '' ); end; end; if ( ( Length( RubyLibPath ) > 0 ) and ( Length( RubyArchPath ) > 0 ) ) then begin Result := true end else begin MsgBox('Unable to determine Ruby lib and arch directories', mbError, MB_OK); end; if ( Length( RubyVersion ) > 0) then begin if ( Pos( RubyBuildVer, RubyVersion ) <> 1 ) then begin MsgBox( 'Incorrect Ruby Version. This installer is for Ruby ' + RubyBuildVer + '. You appear to be running Ruby ' + RubyVersion + '. If you have more than one Ruby installed, check your ' + 'PATH environment variable and make sure that Ruby ' + RubyBuildVer + ' is first in the PATH.', mbError, MB_OK ); Result := false; end; end; end; DeleteFile(TempFile); end; end; //---------------------------- function RubyLibDir(Default: String): String; begin Result := RubyLibPath; end; function RubyArchDir( Default: String): String; begin Result := RubyArchPath; end; begin end.