Ticket #916: ghc.iss.modified.in

File ghc.iss.modified.in, 4.5 KB (added by claus, 4 years ago)

modified installer builder script

Line 
1; Inno Setup documentation: http://www.jrsoftware.org/ishelp/
2
3[Setup]
4AppName=GHC
5AppVerName=GHC @ProjectVersion@
6DefaultDirName={sd}\ghc\ghc-@ProjectVersion@
7UsePreviousAppDir=no
8DefaultGroupName=GHC
9UninstallDisplayIcon={app}\bin\ghci.exe
10Compression=lzma
11SolidCompression=yes
12PrivilegesRequired=none
13ChangesAssociations=yes
14ChangesEnvironment=yes
15LicenseFile=distrib/windows-installer-licences.txt
16
17; tasks can be disabled selectively
18[Tasks]
19Name: fileassoc; Description: "Associate with .hs/.lhs files"
20Name: fileassoc\default; Description: "Make this version of GHCi the default"
21Name: fileassoc\addon; Description: "Add versioned GHCi to right-click menu"
22Name: fileassoc\icon; Description: "Add icon"
23Name: path; Description: "Add bin directories to PATH"
24
25; install main payload, license file and icon
26[Files]
27Source: "bindistprep\ghc-@ProjectVersion@\*"; DestDir: "{app}"; Flags: recursesubdirs
28Source: "distrib\windows-installer-licences.txt"; DestDir: "{app}\doc"
29Source: "distrib\hsicon.ico"; DestDir: "{app}\icons"
30
31; Start Menu shortcuts
32[Icons]
33Name: "{group}\@ProjectVersion@\GHCi"; Filename: "{app}\bin\ghci.exe"; WorkingDir: "{app}\bin"
34Name: "{group}\@ProjectVersion@\GHC Documentation"; Filename: "{app}\doc\html\index.html"
35Name: "{group}\@ProjectVersion@\GHC Library Documentation"; Filename: "{app}\doc\html\libraries\index.html"
36Name: "{group}\@ProjectVersion@\GHC Flag Reference"; Filename: "{app}\doc\html\users_guide\flag-reference.html"
37
38[Registry]
39; set up file associations
40; this does _not_ entirely follow the "play nice" proposal (cf. ticket #916)
41; future version should
42Root: HKCR; Subkey: ".hs"; ValueType: string; ValueName: ""; ValueData: "ghc_haskell"; Flags: uninsdeletevalue; Tasks: fileassoc
43Root: HKCR; Subkey: ".lhs"; ValueType: string; ValueName: ""; ValueData: "ghc_haskell"; Flags: uninsdeletevalue; Tasks: fileassoc
44Root: HKCR; Subkey: "ghc_haskell"; ValueType: string; ValueName: ""; ValueData: "Haskell Source File"; Flags: uninsdeletekeyifempty; Tasks: fileassoc
45
46; make this GHCi the default action
47Root: HKCR; Subkey: "ghc_haskell\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\bin\ghci.exe"" ""%1"""; Flags: uninsdeletevalue; Tasks: fileassoc\default
48
49; add versioned GHCi entry to right-click menu
50Root: HKCR; Subkey: "ghc_haskell\shell\Open with GHCi @ProjectVersion@"; ValueType: none; ValueName: ""; ValueData: ""; Flags: uninsdeletekey; Tasks: fileassoc\addon
51Root: HKCR; Subkey: "ghc_haskell\shell\Open with GHCi @ProjectVersion@\command"; ValueType: string; ValueName: ""; ValueData: """{app}\bin\ghci.exe"" ""%1"""; Flags: uninsdeletevalue; Tasks: fileassoc\addon
52
53; associate file type with icon
54Root: HKCR; Subkey: "ghc_haskell\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\icons\hsicon.ico"; Tasks: fileassoc\icon
55
56; these flags were always set in the past, by the installer
57; some programs may rely on them to find GHC
58Root: HKCU; Subkey: "Software\Haskell\GHC\ghc-@ProjectVersion@"; ValueType: string; ValueName: "InstallDir"; ValueData: "{app}"; Flags: uninsdeletekey
59Root: HKCU; Subkey: "Software\Haskell\GHC"; ValueType: string; ValueName: "InstallDir"; ValueData: "{app}"; Flags: uninsdeletevalue
60
61; set the PATH variable, for both GHC and Cabal
62Root: HKCU; Subkey: "Environment"; ValueName: "Path"; ValueType: "string"; ValueData: "{app}\bin;{olddata}";  Check: NotOnPathAlready('{app}\bin'); Flags: preservestringtype; Tasks: path
63Root: HKCU; Subkey: "Environment"; ValueName: "Path"; ValueType: "string"; ValueData: "{pf}\Haskell\bin;{olddata}";  Check: NotOnPathAlready('{pf}\Haskell\bin'); Flags: preservestringtype; Tasks: path
64
65
66; stolen from Gtk2Hs, I'm sure they like us :-)
67; @dcoutts++
68[Code]
69
70function NotOnPathAlready(NewValue : String): Boolean;
71var
72  Path: String;
73begin
74  // Log('Checking if Gtk2Hs\bin dir is already on the %PATH%');
75  if RegQueryStringValue(HKEY_CURRENT_USER, 'Environment', 'Path', Path) then
76  begin // Successfully read the value
77    // Log('HKCU\Environment\PATH = ' + Path);
78    NewValue := ExpandConstant(NewValue);
79    // Log('Looking for Gtk2Hs\bin dir in %PATH%: ' + BinDir + ' in ' + Path);
80    if Pos(LowerCase(NewValue), Lowercase(Path)) = 0 then
81    begin
82      // Log('Did not find Gtk2Hs\bin dir in %PATH% so will add it');
83      Result := True;
84    end
85    else
86    begin
87      // Log('Found Gtk2Hs bin dir in %PATH% so will not add it again');
88      Result := False;
89    end
90  end
91  else // The key probably doesn't exist
92  begin
93    // Log('Could not access HKCU\Environment\PATH so assume it is ok to add it');
94    Result := True;
95  end;
96end;
97