Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit a762272

Browse files
committed
More generalized arguments
1 parent 7ff10e0 commit a762272

File tree

3 files changed

+76
-36
lines changed

3 files changed

+76
-36
lines changed

Elixir.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ DefaultGroupName=Elixir
2424
OutputBaseFilename=elixir-v{#ElixirVersion}-setup
2525
SetupIconFile=assets\drop.ico
2626
UninstallDisplayIcon={app}\drop.ico
27-
#ifdef SkipPages
27+
#ifdef SkipWelcome
2828
DisableWelcomePage=yes
2929
#endif
3030
WizardImageFile=assets\drop_banner.bmp

ElixirWeb.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Source: "compiler:Setup.e32"; DestDir: "{tmp}"; Flags: deleteafterinstall
4949
Source: "compiler:SetupLdr.e32"; DestDir: "{tmp}"; Flags: deleteafterinstall
5050

5151
[Run]
52-
Filename: "powershell.exe"; Parameters: "-File scripts\make-installer.ps1 --innoelixirweb"; WorkingDir: "{tmp}"; StatusMsg: "Preparing offline installer..."
52+
Filename: "powershell.exe"; Parameters: "-File scripts\make-installer.ps1 --start --friendly --no-compression --skip-welcome"; WorkingDir: "{tmp}"; StatusMsg: "Preparing offline installer..."
5353

5454
[Code]
5555
type

scripts/make-installer.ps1

Lines changed: 74 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
#### Initializations
2+
$cd = (Get-Item -Path ".\" -Verbose).FullName
3+
$isccDefine = ""
4+
$isccDir = ""
5+
$elixirVersion = ""
6+
$startInstaller = 0
7+
$friendly = 0
8+
19
#### Output functions
210
function Err ($str)
311
{
@@ -9,73 +17,104 @@ function Info ($str)
917
Write-Host " Info | " -foregroundcolor "green" -NoNewline
1018
Write-Host "$str"
1119
}
12-
function ExitMsg ()
20+
function FriendlyPause ()
1321
{
1422
Err("Something went wrong while making the offline installer. Elixir was not installed to your computer.")
1523
Err("You can report this issue at https://github.com/chyndman/elixir-windows-setup/issues")
1624
Write-Host " " -NoNewline
1725
pause
26+
}
27+
function ErrExit ($str)
28+
{
29+
if ($friendly -eq 1)
30+
{
31+
FriendlyPause
32+
}
1833
exit
1934
}
2035

21-
#### Initializations
22-
$cd = (Get-Item -Path ".\" -Verbose).FullName
23-
$isccDefine = ""
24-
$isccDir = $cd
25-
$elixirVersion = ""
26-
$startInstaller = 0
27-
2836
#### Script
2937
Info("Current directory:")
3038
Info(" $cd")
3139

3240
Info("Reading arguments...")
33-
foreach ($arg in $args)
41+
for ($i = 0; $i -lt $args.length; $i++)
3442
{
35-
Info(" $arg")
36-
if ($arg = "--innoelixirweb")
43+
Info(" " + $args[$i])
44+
if ($args[$i] -eq "--friendly")
45+
{
46+
$friendly = 1
47+
}
48+
if ($args[$i] -eq "--skip-welcome")
49+
{
50+
$isccDefine += " /dSkipWelcome"
51+
}
52+
if ($args[$i] -eq "--no-compression")
53+
{
54+
$isccDefine += " /dNoCompression"
55+
}
56+
if ($args[$i] -eq "--start")
3757
{
38-
$isccDefine = "/dSkipPages /dNoCompression"
3958
$startInstaller = 1
4059
}
60+
if ($args[$i] -eq "--isccdir")
61+
{
62+
$i++
63+
if ($args[$i] -ne $null)
64+
{
65+
Info(" " + $args[$i])
66+
$isccDir = $args[$i]
67+
}
68+
else
69+
{
70+
ErrExit("Invalid arguments")
71+
}
72+
}
4173
}
4274
Info("Finished reading arguments")
4375

44-
Info("Checking for ISCC.exe in $isccDir...")
45-
if (Test-Path $isccDir\ISCC.exe)
76+
Info("Checking for ISCC.exe in:")
77+
foreach ($dir in ($isccDir, $cd, "C:\Program Files (x86)\Inno Setup 5", $null))
4678
{
47-
Info("ISCC path: $isccDir\ISCC.exe")
48-
}
49-
else
50-
{
51-
Err("ISCC.exe not found in $isccDir")
52-
ExitMsg
79+
if ($dir -eq $null)
80+
{
81+
ErrExit("ISCC.exe not found")
82+
}
83+
if ($dir -ne "")
84+
{
85+
Info(" $dir")
86+
if (Test-Path $dir\ISCC.exe)
87+
{
88+
$isccDir = $dir
89+
Info("ISCC path: $isccDir\ISCC.exe")
90+
break;
91+
}
92+
}
5393
}
5494

55-
Info("Checking for elixir directory...")
56-
if (Test-Path .\elixir)
95+
Info("Checking for $cd\elixir...")
96+
if (Test-Path $cd\elixir)
5797
{
58-
Info("elixir directory exists")
98+
Info("$cd\elixir exists")
5999
}
60100
else
61101
{
62-
Info("Not found, checking for Precompiled.zip...")
63-
if (Test-Path .\Precompiled.zip)
102+
Info("Not found, checking for $cd\Precompiled.zip...")
103+
if (Test-Path $cd\Precompiled.zip)
64104
{
65-
Info("Precompiled.zip found")
66-
Info("Extracting Precompiled.zip to .\elixir...")
105+
Info("$cd\Precompiled.zip found")
106+
Info("Extracting $cd\Precompiled.zip to $cd\elixir...")
67107
scripts\extract-zip.ps1 $cd\Precompiled.zip $cd\elixir
68108
}
69109
else
70110
{
71-
Err("Precompiled.zip not found")
72-
ExitMsg
111+
ErrExit("$cd\Precompiled.zip not found")
73112
}
74113
}
75114

76115
if ($elixirVersion -eq "")
77116
{
78-
Info("Reading Elixir version from elixir\VERSION...")
117+
Info("Reading Elixir version from $cd\elixir\VERSION...")
79118
foreach ($line in (Get-Content $cd\elixir\VERSION))
80119
{
81120
$elixirVersion = $line
@@ -86,20 +125,21 @@ if ($elixirVersion -eq "")
86125

87126
$isccDefine = "`"/dElixirVersion=" + $elixirVersion + "`" " + $isccDefine
88127

128+
$isccDefine = $isccDefine.Trim()
89129
Info("Running $isccDir\ISCC.exe $isccDefine /Q Elixir.iss")
90130
& $isccDir\ISCC.exe $isccDefine /Q Elixir.iss
131+
91132
if ($LastExitCode -eq 0)
92133
{
93-
Info("Installer compiled successfully to .\Output\elixir-v$elixirVersion-setup.exe")
134+
Info("Installer compiled successfully to $cd\Output\elixir-v$elixirVersion-setup.exe")
94135
}
95136
else
96137
{
97-
Err("ISCC.exe failed with exit code $LastExitCode")
98-
ExitMsg
138+
ErrExit("ISCC.exe failed with exit code $LastExitCode")
99139
}
100140

101141
if ($startInstaller -eq 1)
102142
{
103143
Info("Starting installer...")
104-
start ".\Output\elixir-v$elixirVersion-setup.exe"
144+
start "$cd\Output\elixir-v$elixirVersion-setup.exe"
105145
}

0 commit comments

Comments
 (0)