4
////////////////////// string defines ////////////////////////////
6
#define UNINST_LOGFILE_NAME "Uninst.isu"
8
//////////////////// installation declarations ///////////////////
10
// ---- script prototypes -----
13
prototype ShowDialogs();
14
prototype MoveFileData();
15
prototype HandleMoveDataError( NUMBER );
16
prototype ProcessBeforeDataMove();
17
prototype ProcessAfterDataMove();
18
prototype SetupRegistry();
19
prototype SetupFolders();
20
prototype CleanUpInstall();
21
prototype SetupInstall();
22
prototype SetupScreen();
23
prototype CheckRequirements();
24
prototype DialogShowSdShowInfoList();
25
prototype DialogShowSdAskDestPath();
26
prototype DialogShowSdSetupType();
27
prototype DialogShowSdComponentDialog2();
28
prototype DialogShowSdWelcome();
29
prototype DialogShowSdFinishReboot();
32
prototype ForwardSlashify ( STRING, BYREF STRING );
33
prototype CreateHappyScript ( STRING, STRING );
34
prototype CreateHappyBat ( STRING );
36
// ----- global variables ------
39
BOOL bWinNT, bIsShellExplorer, bInstallAborted, bIs32BitSetup;
41
STRING svName, svCompany, svSerial;
47
// your global variables
48
STRING szBinDir, szBinDirUnslashed,
49
szLibDir, szLibDirUnslashed,
53
///////////////////////////////////////////////////////////////////////////////
57
// The setup begins here by hiding the visible setup
58
// window. This is done to allow all the titles, images, etc. to
59
// be established before showing the main window. The following
60
// logic then performs the setup in a series of steps.
62
///////////////////////////////////////////////////////////////////////////////
64
Disable( BACKGROUND );
72
if (ShowDialogs()<0) goto end_install;
74
if (ProcessBeforeDataMove()<0) goto end_install;
76
if (MoveFileData()<0) goto end_install;
78
if (ProcessAfterDataMove()<0) goto end_install;
80
if (SetupRegistry()<0) goto end_install;
82
if (SetupFolders()<0) goto end_install;
89
// If an unrecoverable error occurred, clean up the partial installation.
90
// Otherwise, exit normally.
92
if (bInstallAborted) then
98
///////////////////////////////////////////////////////////////////////////////
100
// Function: ShowDialogs //
102
// Purpose: This function manages the display and navigation //
103
// the standard dialogs that exist in a setup. //
105
///////////////////////////////////////////////////////////////////////////////
106
function ShowDialogs()
111
// beginning of dialogs label
114
nResult = DialogShowSdWelcome();
115
if (nResult = BACK) goto Dlg_Start;
118
nResult = DialogShowSdShowInfoList();
119
if (nResult = BACK) goto Dlg_SdWelcome;
122
nResult = DialogShowSdAskDestPath();
123
if (nResult = BACK) goto Dlg_SdShowInfoList;
126
nResult = DialogShowSdSetupType();
127
if (nResult = BACK) goto Dlg_SdAskDestPath;
129
Dlg_SdComponentDialog2:
130
if ((nResult = BACK) && (svSetupType != "Custom") && (svSetupType != "")) then
131
goto Dlg_SdSetupType;
133
nResult = DialogShowSdComponentDialog2();
134
if (nResult = BACK) goto Dlg_SdSetupType;
137
//nResult = DialogShowSdSelectFolder();
138
//if (nResult = BACK) goto Dlg_SdComponentDialog2;
144
///////////////////////////////////////////////////////////////////////////////
146
// Function: ProcessBeforeDataMove //
148
// Purpose: This function performs any necessary operations prior to the //
149
// actual data move operation. //
151
///////////////////////////////////////////////////////////////////////////////
152
function ProcessBeforeDataMove()
157
InstallationInfo( @COMPANY_NAME, @PRODUCT_NAME, @PRODUCT_VERSION, @PRODUCT_KEY );
159
svLogFile = UNINST_LOGFILE_NAME;
161
nResult = DeinstallStart( svDir, svLogFile, @UNINST_KEY, 0 );
162
if (nResult < 0) then
163
MessageBox( @ERROR_UNINSTSETUP, WARNING );
166
szAppPath = TARGETDIR; // TODO : if your application .exe is in a subdir of TARGETDIR then add subdir
168
if ((bIs32BitSetup) && (bIsShellExplorer)) then
169
RegDBSetItem( REGDB_APPPATH, szAppPath );
170
RegDBSetItem( REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY );
171
RegDBSetItem( REGDB_UNINSTALL_NAME, @UNINST_DISPLAY_NAME );
173
// TODO : update any items you want to process before moving the data
176
ComponentSetTarget( MEDIA, "<DOCDIR>", TARGETDIR ^ "\\doc" );
181
///////////////////////////////////////////////////////////////////////////////
183
// Function: MoveFileData //
185
// Purpose: This function handles the data movement for //
188
///////////////////////////////////////////////////////////////////////////////
189
function MoveFileData()
190
NUMBER nResult, nDisk;
194
SetStatusWindow( 0, "" );
195
Disable( DIALOGCACHE );
197
StatusUpdate( ON, 100 );
198
nResult = ComponentMoveData( MEDIA, nDisk, 0 );
200
HandleMoveDataError( nResult );
209
///////////////////////////////////////////////////////////////////////////////
211
// Function: HandleMoveDataError //
213
// Purpose: This function handles the error (if any) during the move data //
216
///////////////////////////////////////////////////////////////////////////////
217
function HandleMoveDataError( nResult )
218
STRING szErrMsg, svComponent , svFileGroup , svFile;
229
ComponentError ( MEDIA , svComponent , svFileGroup , svFile , nResult );
230
szErrMsg = @ERROR_MOVEDATA + "\n\n" +
231
@ERROR_COMPONENT + " " + svComponent + "\n" +
232
@ERROR_FILEGROUP + " " + svFileGroup + "\n" +
233
@ERROR_FILE + " " + svFile;
234
SprintfBox( SEVERE, @TITLE_CAPTIONBAR, szErrMsg, nResult );
235
bInstallAborted = TRUE;
242
///////////////////////////////////////////////////////////////////////////////
244
// Function: ProcessAfterDataMove //
246
// Purpose: This function performs any necessary operations needed after //
247
// all data has been moved. //
249
///////////////////////////////////////////////////////////////////////////////
250
function ProcessAfterDataMove()
252
STRING szTemp, szRes, szPathEntry, szDrive;
253
NUMBER nvSize,nvType, nResult, nPos, nSuccess;
260
///////////////////////////////////////////////////////////////////////////////
262
// Function: SetupRegistry //
264
// Purpose: This function makes the registry entries for this setup. //
266
///////////////////////////////////////////////////////////////////////////////
267
function SetupRegistry()
269
STRING szProjectDir, szProjectVersionDir, szTargetDir;
272
// TODO : Add all your registry entry keys here
276
nResult = CreateRegistrySet( "" );
278
// By now, we will have had the following Registry
279
// entries generated (see ProcessBeforeDataMove() ):
281
// HK_L_M\Software\Glasgow University\Happy\<version no.>
283
// For Happy, we store and use the install info inside
284
// HK_L_M\Software\Haskell\Happy (== %ROOT%)
286
// So, we perform the following tasks here:
288
// * Checks to see if %ROOT% is defined.
289
// If not, creates it.
290
// * Checks for %ROOT%\Version is defined.
291
// * Create %ROOT%\<version>.
292
// * Create %ROOT%\<version>\libdir
293
// (This key will be given a value later.)
294
// * Create %ROOT%\syslib\ and fill it in
295
// with the syslibs that has been installed.
296
// * %ROOT%\syslib\name\<way>
297
// is added for each kind (e.g., seq, conc)
298
// syslib we're installing.
300
// When we eventually reach the end, the registry
301
// should be ready for use by the installed app.
303
// Check to see if we've already installed
304
// a version of Happy on this box..
305
RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
307
szProjectDir = @HASKELL_REG_ROOT ^ @PRODUCT_NAME;
309
// check whether we've already got the Registry sub-tree we're
310
// about to add to. If not, then we create it
311
// level-by-level, so as to ensure that the uninstaller
312
// can clean up after us.
313
if ( RegDBKeyExist ( @HASKELL_REG_ROOT ) < 0) then
314
RegDBCreateKeyEx (@HASKELL_REG_ROOT, "");
316
if ( RegDBKeyExist ( szProjectDir ) < 0 ) then
317
RegDBCreateKeyEx ( szProjectDir, "");
320
// Note: we overwrite any existing value.
321
RegDBSetKeyValueEx( szProjectDir, "Version", REGDB_STRING,
324
szProjectVersionDir = szProjectDir ^ @PRODUCT_KEY;
326
if ( RegDBKeyExist ( szProjectVersionDir ) < 0) then
327
RegDBCreateKeyEx ( szProjectVersionDir, "");
330
// Here starts the Happy specific part
332
ForwardSlashify (TARGETDIR, szTargetDir);
333
// fill in the all-important path to where the binary and templates have been parked.
334
szBinDir = szTargetDir + "/bin";
335
szBinDirUnslashed = TARGETDIR ^ "\\bin";
336
RegDBSetKeyValueEx ( szProjectVersionDir, "bindir", REGDB_STRING,
339
szLibDir = szTargetDir + "/lib";
340
szLibDirUnslashed = TARGETDIR ^ "\\lib";
341
RegDBSetKeyValueEx ( szProjectVersionDir, "libdir", REGDB_STRING,
344
szLibExecDir = szTargetDir + "/lib";
345
RegDBSetKeyValueEx ( szProjectVersionDir, "libexecdir", REGDB_STRING,
352
///////////////////////////////////////////////////////////////////////////////
354
// Function: SetupFolders
356
// Purpose: This function creates all the folders and shortcuts for the
357
// setup. This includes program groups and items for Windows 3.1.
359
///////////////////////////////////////////////////////////////////////////////
360
function SetupFolders()
362
STRING svResult, szTemp;
366
// TODO : Add all your folder (program group) along with shortcuts (program items)
369
// CreateProgramFolder, AddFolderIcon....
372
CreateHappyScript(szBinDirUnslashed, "happy");
373
CreateHappyBat(szBinDirUnslashed);
375
nResult = CreateShellObjects( "" );
380
///////////////////////////////////////////////////////////////////////////////
382
// Function: CleanUpInstall //
384
// Purpose: This cleans up the setup. Anything that should //
385
// be released or deleted at the end of the setup should //
388
///////////////////////////////////////////////////////////////////////////////
389
function CleanUpInstall()
392
if (bInstallAborted) then
396
DialogShowSdFinishReboot();
398
if (BATCH_INSTALL) then // ensure locked files are properly written
399
CommitSharedFiles(0);
405
///////////////////////////////////////////////////////////////////////////////
407
// Function: SetupInstall //
409
// Purpose: This will setup the installation. Any general initialization //
410
// needed for the installation should be performed here. //
412
///////////////////////////////////////////////////////////////////////////////
413
function SetupInstall()
417
Enable( CORECOMPONENTHANDLING );
419
bInstallAborted = FALSE;
421
GetDisk(WINDIR, svDir);
423
if (bIs32BitSetup) then
424
svDir = svDir + "\\" ^ @PRODUCT_NAME_SHORT ^ @PRODUCT_KEY;
426
// We're (=>ghc) 32 through and through, but for the sake of
428
svDir = svDir + "\\" ^ @PRODUCT_NAME_SHORT ^ @PRODUCT_NAME16;
433
SdProductName( @PRODUCT_NAME );
435
Enable( DIALOGCACHE );
440
///////////////////////////////////////////////////////////////////////////////
442
// Function: SetupScreen //
444
// Purpose: This function establishes the screen look. This includes //
445
// colors, fonts, and text to be displayed. //
447
///////////////////////////////////////////////////////////////////////////////
448
function SetupScreen()
451
SetColor ( BACKGROUND, BLUE );
452
Enable( FULLWINDOWMODE );
453
Enable( INDVFILESTATUS );
455
SetTitle( @TITLE_MAIN, 24, WHITE );
457
SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION ); // Caption bar text.
459
Enable( BACKGROUND );
464
///////////////////////////////////////////////////////////////////////////////
466
// Function: CheckRequirements //
468
// Purpose: This function checks all minimum requirements for the //
469
// application being installed. If any fail, then the user //
470
// is informed and the setup is terminated. //
472
///////////////////////////////////////////////////////////////////////////////
473
function CheckRequirements()
474
NUMBER nvDx, nvDy, nvResult;
480
bIsShellExplorer = FALSE;
482
// Check screen resolution.
483
GetExtents( nvDx, nvDy );
486
MessageBox( @ERROR_VGARESOLUTION, WARNING );
490
// set 'setup' operation mode
491
bIs32BitSetup = TRUE;
492
GetSystemInfo( ISTYPE, nvResult, svResult );
493
if (nvResult = 16) then
494
bIs32BitSetup = FALSE; // running 16-bit setup
495
return 0; // no additional information required
498
// --- 32-bit testing after this point ---
500
// Determine the target system's operating system.
501
GetSystemInfo( OS, nvResult, svResult );
503
if (nvResult = IS_WINDOWSNT) then
504
// Running Windows NT.
507
// Check to see if the shell being used is EXPLORER shell.
508
if (GetSystemInfo( OSMAJOR, nvResult, svResult ) = 0) then
509
if (nvResult >= 4) then
510
bIsShellExplorer = TRUE;
514
elseif (nvResult = IS_WINDOWS95 ) then
515
bIsShellExplorer = TRUE;
522
///////////////////////////////////////////////////////////////////////////////
524
// Function: DialogShowSdWelcome //
526
// Purpose: This function handles the standard welcome dialog. //
529
///////////////////////////////////////////////////////////////////////////////
530
function DialogShowSdWelcome()
532
STRING szTitle, szMsg;
537
nResult = SdWelcome( szTitle, szMsg );
543
///////////////////////////////////////////////////////////////////////////////
545
// Function: DialogShowSdShowInfoList //
547
// Purpose: This function displays the general information list dialog. //
550
///////////////////////////////////////////////////////////////////////////////
551
function DialogShowSdShowInfoList()
554
STRING szTitle, szMsg, szFile;
557
szFile = SUPPORTDIR ^ "announce";
559
list = ListCreate( STRINGLIST );
560
ListReadFromFile( list, szFile );
563
nResult = SdShowInfoList( szTitle, szMsg, list );
571
///////////////////////////////////////////////////////////////////////////////
573
// Function: DialogShowSdAskDestPath //
575
// Purpose: This function asks the user for the destination directory. //
577
///////////////////////////////////////////////////////////////////////////////
578
function DialogShowSdAskDestPath()
580
STRING szTitle, szMsg;
585
nResult = SdAskDestPath( szTitle, szMsg, svDir, 0 );
593
///////////////////////////////////////////////////////////////////////////////
595
// Function: DialogShowSdSetupType //
597
// Purpose: This function displays the standard setup type dialog. //
599
///////////////////////////////////////////////////////////////////////////////
600
function DialogShowSdSetupType()
601
NUMBER nResult, nType;
602
STRING szTitle, szMsg;
613
svSetupType = "Typical";
619
nResult = SetupType( szTitle, szMsg, "", nType, 0 );
623
svSetupType = "Compact";
625
svSetupType = "Typical";
627
svSetupType = "Custom";
634
///////////////////////////////////////////////////////////////////////////////
636
// Function: DialogShowSdComponentDialog2 //
638
// Purpose: This function displays the custom component dialog. //
641
///////////////////////////////////////////////////////////////////////////////
642
function DialogShowSdComponentDialog2()
644
STRING szTitle, szMsg;
647
if ((svSetupType != "Custom") && (svSetupType != "")) then
653
nResult = SdComponentDialog2( szTitle, szMsg, svDir, "" );
659
///////////////////////////////////////////////////////////////////////////////
661
// Function: DialogShowSdFinishReboot //
663
// Purpose: This function will show the last dialog of the product. //
664
// It will allow the user to reboot and/or show some readme text. //
666
///////////////////////////////////////////////////////////////////////////////
667
function DialogShowSdFinishReboot()
668
NUMBER nResult, nDefOptions;
669
STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
673
if (!BATCH_INSTALL) then
680
szTitle = "Installation is now complete.";
681
nResult = SdFinish( szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2 );
684
nDefOptions = SYS_BOOTMACHINE;
688
nResult = SdFinishReboot( szTitle, szMsg1, nDefOptions, szMsg2, 0 );
693
function ForwardSlashify ( szStr , theRes )
695
STRING szTemp, szRes;
697
// Tortuous piece of code to convert backslashes into
699
nPos = StrFind ( szStr, "\\");
702
StrSub ( szTemp, szStr, 0, nPos);
703
szRes = szRes + szTemp + "/";
704
StrSub ( szTemp, szStr, nPos + 1, StrLength ( szStr) - nPos );
706
nPos = StrFind ( szStr, "\\" );
708
StrSub ( szTemp, szStr, 0, StrLength (szStr));
709
szRes = szRes + szTemp;
714
function CreateHappyScript ( szPath, szFileName )
717
OpenFileMode (FILE_MODE_APPEND);
718
if ( CreateFile ( writeHandle, szPath, szFileName ) < 0 ) then
719
MessageBox ("CreateFile " + szPath ^ szFileName + " failed", INFORMATION);
721
WriteLine (writeHandle, "#! /bin/sh" );
722
WriteLine (writeHandle, "happy.bat $*" );
724
// There's no way to set the 'x' bit using SetFileInfo(), but, luckily,
725
// it is not needed to run #! scripts under cygwin
726
SetFileInfo ( szPath ^ "\\" + szFileName, FILE_ATTRIBUTE, FILE_ATTR_NORMAL, "");
730
function CreateHappyBat ( szPath )
734
szFileName = "happy.bat";
735
OpenFileMode (FILE_MODE_APPEND);
736
if ( CreateFile ( writeHandle, szPath, szFileName ) < 0 ) then
737
MessageBox ("CreateFile " + szPath ^ szFileName + " failed", INFORMATION);
739
WriteLine (writeHandle, "@echo off" );
740
WriteLine (writeHandle, "set HAPPYLIB=" + szLibDir + "/happy" );
741
WriteLine (writeHandle, "set HAPPYBIN=" + szLibDirUnslashed ^ "happy.exe" );
742
WriteLine (writeHandle, "%HAPPYBIN% --template %HAPPYLIB% %*" );
744
SetFileInfo ( szPath ^ szFileName, FILE_ATTRIBUTE, FILE_ATTR_NORMAL, "");
b'\\ No newline at end of file'