Changeset 425 for trunk


Ignore:
Timestamp:
Mar 12, 2019, 4:49:32 PM (6 years ago)
Author:
ataylor
Message:

Updated old-style installer for compatibility with existing installations on ArcaOS etc.

Location:
trunk/installer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/installer/MainFormUnit.pas

    r409 r425  
    2323  Description = 'NewView Install';
    2424
    25   Version =        'V1.10.0'; // $SS_REQUIRE_NEW_VERSION$
    26   BldLevelVersion = '1.10.0'; // Embedded for IBM BLDLEVEL tool
     25  Version =        'V1.10.1'; // $SS_REQUIRE_NEW_VERSION$
     26  BldLevelVersion = '1.10.1'; // Embedded for IBM BLDLEVEL tool
    2727
    2828  // BLDLevel - compatible - mostly
     
    414414  FSystemDLLDir := FSystemDir + 'dll\';
    415415
    416   // ecs things
     416  // aos/ecs things
    417417  FEnv_OSDir := GetEnvironmentFolder( 'OSDIR' );
    418418  FEnv_Programs := GetEnvironmentFolder( 'PROGRAMS' );
     
    570570    begin
    571571      DoErrorDlg( 'Install Error',
    572                   'Unable to acces ' + StrCRLF
     572                  'Unable to access ' + StrCRLF
    573573                  + ' ' + DestinationPath + StrCRLF
    574574                  + SysErrorMessage( rc ) );
     
    976976end;
    977977
     978function MoveFileError( const Source: string;
     979                        const Dest: string;
     980                        const IsModule: boolean;
     981                        var SourceInUse: boolean ): boolean;
     982var
     983  rc: APIRET;
     984  szSource: cstring;
     985  FileHandle: HFILE;
     986  ActionTaken: ULONG;
     987begin
     988  // First copy the file
     989  Result := CopyFileError( Source,
     990                           Dest  );
     991  if not Result then exit;
     992
     993  // Now delete the original
     994  szSource := Source;
     995  // see if it's in use.
     996  rc := DosOpen( szSource,
     997                 FileHandle,
     998                 ActionTaken,
     999                 0,         // new size: not used
     1000                 0,         // attributes: not used
     1001                 OPEN_ACTION_FAIL_IF_NEW + OPEN_ACTION_OPEN_IF_EXISTS,
     1002                 OPEN_FLAGS_FAIL_ON_ERROR + OPEN_SHARE_DENYREADWRITE
     1003                 + OPEN_ACCESS_READWRITE,
     1004                 nil );     // e.a.s: not used
     1005  DosClose( FileHandle );
     1006  if rc = ERROR_SHARING_VIOLATION then
     1007  begin
     1008    // file in use
     1009    if not IsModule then
     1010    begin
     1011      Result := false;
     1012      DoErrorDlg( 'Installation Error',
     1013                  'This file is in use: ' + StrCRLF
     1014                  + ' ' + Source + StrCRLF
     1015                  + 'and cannot be moved.' );
     1016      exit;
     1017    end;
     1018
     1019    // unlock the module
     1020    SourceInUse := true;
     1021    rc := DosReplaceModule( Addr( szSource ),
     1022                            nil,
     1023                            nil );
     1024    if rc <> 0 then
     1025    begin
     1026      // error
     1027      Result := false;
     1028      DoErrorDlg( 'Install Error',
     1029                  'Could not unlock ' + StrCRLF
     1030                  + ' ' + Source + StrCRLF
     1031                  + SysErrorMessage( rc ) );
     1032
     1033      exit;
     1034    end;
     1035  end;
     1036  Result := DeleteFile( Source );
     1037end;
     1038
    9781039// Do a full install, replacing parts of the operating system
    9791040// as needed.
     
    9901051  ObjectID: string;
    9911052  rc: longint;
     1053  HelpMgrDllPath: string;
     1054  HelpMgrOriginal: string;
    9921055  HelpMgrBackupPath: string;
    9931056  StubBackupPath: string;
     
    10711134
    10721135  // install viewer app to either x:\os2
    1073   // or on eCS, %OSDIR%\bin
     1136  // or on ArcaOS or eCS, %OSDIR%\bin
    10741137  if FEnv_OSDir <> '' then
    10751138  begin
    1076     // ecs - with a dir specified
     1139    // aos/ecs - with a dir specified
    10771140    AppDir := FEnv_OSDir + 'bin\';
    10781141  end
     
    10831146  end;
    10841147
    1085   LanguageDir := AppDir; // for now.
     1148  if FEnv_OSDir <> '' then
     1149  begin
     1150    LanguageDir := FEnv_OSDir + 'lang\';
     1151  end
     1152  else
     1153  begin
     1154    LanguageDir := AppDir; // for now.
     1155  end;
    10861156
    10871157  // Where shall we put the programs eh?
    10881158  FAppInstallPath := AppDir + 'NewView.exe';
    10891159  FStubInstallPath := FSystemDir + 'view.exe';
    1090   FDllInstallPath := FSystemDLLDir + 'newview.dll';
     1160
     1161  if FEnv_OSDir <> '' then
     1162  begin
     1163    FDllInstallPath := FEnv_OSDir + 'dll\';
     1164  end
     1165  else
     1166  begin
     1167    FDllInstallPath := FSystemDLLDir;
     1168  end;
    10911169
    10921170  // check for existing files that might conflict
     
    11881266  if GetInstallType = itComplete then
    11891267  begin
     1268    HelpMgrDllPath    := FDllInstallPath + 'HelpMgr.dll';
     1269    HelpMgrOriginal   := FSystemDLLDir + 'HelpMgr.dll';
    11901270    HelpMgrBackupPath := FSystemDLLDir + 'HelpMgr.bak';
     1271
     1272    // Back up the original HELPMGR.DLL. We have to do this separately
     1273    // (rather than in Installfile) because it might not be in the same
     1274    // place as our replacement.
     1275    if FileExists( HelpMgrOriginal ) and
     1276       not FileExists( HelpMgrBackupPath ) then
     1277    begin
     1278      if not MoveFileError( HelpMgrOriginal,
     1279                            HelpMgrBackupPath,
     1280                            true, FDLLInUse ) then
     1281        exit;
     1282    end;
     1283
     1284    // Now install the new HelpMgr
    11911285    if not InstallFile( 'HelpMgr.dll',
    1192                         FSystemDLLDir + 'HelpMgr.dll',
    1193                         HelpMgrBackupPath,
     1286                        HelpMgrDllPath,
     1287                        '',
    11941288                        true,
    11951289                        FDLLInUse ) then
     
    12261320  // newview.dll
    12271321  if not InstallFile( 'NewView.dll',
    1228                       FDllInstallPath,
     1322                      FDllInstallPath + 'newview.dll',
    12291323                      '', // no backup
    12301324                      false, // not in use
Note: See TracChangeset for help on using the changeset viewer.