| 1 |
; Script generated by the Inno Setup Script Wizard. |
| 2 |
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! |
| 3 |
|
| 4 |
; BUILD_DIR can be passed via command line: iscc -DBUILD_DIR="C:\path\to\build" |
| 5 |
#ifndef BUILD_DIR |
| 6 |
# define BUILD_DIR "..\build" |
| 7 |
#endif |
| 8 |
|
| 9 |
#define MyAppName "FontForge" |
| 10 |
#define MyAppFolder "FontForgeBuilds" |
| 11 |
#define MyAppVersion GetDateTimeString('yyyymmdd', '', ''); |
| 12 |
#define MyAppVersionDesc GetDateTimeString('yyyy-mm-dd', '', ''); |
| 13 |
#define MyAppPublisher "FontForgeBuilds" |
| 14 |
#define MyAppURL "http://www.fontforge.org" |
| 15 |
#define MyAppExeName "run_fontforge.exe" |
| 16 |
#define MyInstallEpoch "1" |
| 17 |
|
| 18 |
#ifdef MSYSTEM |
| 19 |
# if MSYSTEM == "UCRT64" |
| 20 |
# define ARCH="x64compatible" |
| 21 |
# define ARCHDESC="x64" |
| 22 |
# endif |
| 23 |
# if MSYSTEM == "CLANGARM64" |
| 24 |
# define ARCH="arm64" |
| 25 |
# define ARCHDESC="arm64" |
| 26 |
# endif |
| 27 |
#endif |
| 28 |
#ifndef ARCH |
| 29 |
# define ARCH="x64" |
| 30 |
# define ARCHDESC="x64_unknown" |
| 31 |
#endif |
| 32 |
#define ARCHBITS="64" |
| 33 |
#define OTHERBITS="32" |
| 34 |
|
| 35 |
[Setup] |
| 36 |
; NOTE: The value of AppId uniquely identifies this application. |
| 37 |
; Do not use the same AppId value in installers for other applications. |
| 38 |
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) |
| 39 |
AppId={{56748B9C-19AE-4689-B8C5-5A45AE0A993A} |
| 40 |
AppName={#MyAppName} |
| 41 |
AppVersion={#MyAppVersion} |
| 42 |
;AppVerName={#MyAppName} {#MyAppVersion} |
| 43 |
AppPublisher={#MyAppPublisher} |
| 44 |
AppPublisherURL={#MyAppURL} |
| 45 |
AppSupportURL={#MyAppURL} |
| 46 |
AppUpdatesURL={#MyAppURL} |
| 47 |
ArchitecturesInstallIn64BitMode={#ARCH} |
| 48 |
DefaultDirName={commonpf}\{#MyAppFolder} |
| 49 |
DefaultGroupName={#MyAppName} |
| 50 |
AllowNoIcons=yes |
| 51 |
InfoBeforeFile={#BUILD_DIR}\ReleasePackage\VERSION.txt |
| 52 |
OutputDir=. |
| 53 |
OutputBaseFilename=FontForge-{#MyAppVersionDesc}-Windows-{#ARCHDESC} |
| 54 |
SetupIconFile=Graphics\fontforge-installer-icon.ico |
| 55 |
UninstallDisplayIcon={app}\fontforge-installer-icon.ico |
| 56 |
;WizardImageFile=Graphics\fontforge-wizard.bmp |
| 57 |
WizardSmallImageFile=Graphics\fontforge-wizard.bmp |
| 58 |
Compression=lzma2/max |
| 59 |
SolidCompression=yes |
| 60 |
ChangesAssociations=yes |
| 61 |
PrivilegesRequired=poweruser |
| 62 |
|
| 63 |
[Languages] |
| 64 |
Name: "english"; MessagesFile: "compiler:Default.isl" |
| 65 |
Name: "armenian"; MessagesFile: "compiler:Languages\Armenian.isl" |
| 66 |
Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl" |
| 67 |
Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl" |
| 68 |
Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl" |
| 69 |
Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl" |
| 70 |
Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl" |
| 71 |
Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl" |
| 72 |
Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl" |
| 73 |
Name: "french"; MessagesFile: "compiler:Languages\French.isl" |
| 74 |
Name: "german"; MessagesFile: "compiler:Languages\German.isl" |
| 75 |
Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl" |
| 76 |
;Name: "icelandic"; MessagesFile: "compiler:Languages\Icelandic.isl" |
| 77 |
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl" |
| 78 |
Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl" |
| 79 |
Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl" |
| 80 |
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl" |
| 81 |
Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl" |
| 82 |
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl" |
| 83 |
Name: "slovak"; MessagesFile: "compiler:Languages\Slovak.isl" |
| 84 |
Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl" |
| 85 |
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl" |
| 86 |
Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl" |
| 87 |
Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl" |
| 88 |
|
| 89 |
[Tasks] |
| 90 |
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked |
| 91 |
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 |
| 92 |
|
| 93 |
[Files] |
| 94 |
Source: "{#BUILD_DIR}\ReleasePackage\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Excludes: "fontforge.bat" |
| 95 |
Source: "fontforge.bat"; DestDir: "{app}"; Flags: ignoreversion; |
| 96 |
Source: "Graphics\fontforge-installer-icon.ico"; DestDir: "{app}"; Flags: ignoreversion; |
| 97 |
; NOTE: Don't use "Flags: ignoreversion" on any shared system files |
| 98 |
|
| 99 |
[Icons] |
| 100 |
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" |
| 101 |
Name: "{group}\{#MyAppName} console"; Filename: "{app}\fontforge.bat" |
| 102 |
Name: "{group}\{#MyAppName} interactive console"; Filename: "{app}\fontforge-console.bat" |
| 103 |
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" |
| 104 |
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon |
| 105 |
|
| 106 |
[Registry] |
| 107 |
;Root: HKLM; Subkey: "Software\FontForge"; Flags: uninsdeletekey |
| 108 |
Root: HKCR; Subkey: ".sfd"; ValueType: string; ValueName: ""; ValueData: "FontForgeProject"; Flags: uninsdeletevalue |
| 109 |
Root: HKCR; Subkey: "FontForgeProject"; ValueType: string; ValueName: ""; ValueData: "FontForge Project"; Flags: uninsdeletekey |
| 110 |
Root: HKCR; Subkey: "FontForgeProject\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\share\fontforge\sfd-icon.ico" |
| 111 |
Root: HKCR; Subkey: "FontForgeProject\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1""" |
| 112 |
|
| 113 |
[Run] |
| 114 |
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent |
| 115 |
|
| 116 |
[Code] |
| 117 |
procedure RecursiveDelete(Folder : String; Pattern : String; Extensions : TStringList); |
| 118 |
var |
| 119 |
SearchPath : String; |
| 120 |
FilePath : String; |
| 121 |
FindRec : TFindRec; |
| 122 |
begin |
| 123 |
//First search the current folder for any files matching the pattern |
| 124 |
SearchPath := ExpandConstant(Folder + '\' + Pattern); |
| 125 |
Log('[Recursive] searching ' + SearchPath); |
| 126 |
if FindFirst(SearchPath, FindRec) then begin |
| 127 |
try |
| 128 |
repeat |
| 129 |
if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then begin |
| 130 |
if Extensions.IndexOf(ExtractFileExt(FindRec.Name)) <> -1 then begin |
| 131 |
FilePath := ExpandConstant(Folder + '\' + FindRec.Name); |
| 132 |
Log('[Recursive] Deleting ' + FilePath); |
| 133 |
DeleteFile(FilePath); |
| 134 |
end; |
| 135 |
end; |
| 136 |
until not FindNext(FindRec); |
| 137 |
finally |
| 138 |
FindClose(FindRec); |
| 139 |
end; |
| 140 |
end; |
| 141 |
|
| 142 |
//Now recursively search any subdirectories |
| 143 |
SearchPath := ExpandConstant(Folder + '\*'); |
| 144 |
Log('[Recursive] searching ' + SearchPath); |
| 145 |
if FindFirst(SearchPath, FindRec) then begin |
| 146 |
try |
| 147 |
repeat |
| 148 |
if ((FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY) <> 0) and |
| 149 |
(CompareStr(FindRec.Name, '.') <> 0) and (CompareStr(FindRec.Name, '..') <> 0) then begin |
| 150 |
FilePath := ExpandConstant(Folder + '\' + FindRec.Name); |
| 151 |
Log('[Recursive] now searching: ' + FilePath); |
| 152 |
RecursiveDelete(FilePath, Pattern, Extensions); |
| 153 |
end; |
| 154 |
until not FindNext(FindRec); |
| 155 |
finally |
| 156 |
FindClose(FindRec); |
| 157 |
end; |
| 158 |
end; |
| 159 |
end; |
| 160 |
|
| 161 |
|
| 162 |
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); |
| 163 |
var ExtensionsToDelete : TStringList; |
| 164 |
begin |
| 165 |
if CurUninstallStep = usUninstall then |
| 166 |
begin |
| 167 |
if MsgBox('Do you want to remove user preferences?', mbConfirmation, MB_YESNO) = IDYES then |
| 168 |
begin |
| 169 |
DelTree(ExpandConstant('{userappdata}\FontForge'), True, True, True); |
| 170 |
end; |
| 171 |
|
| 172 |
Log('Removing Python cache files (.pyc/.pyo)...'); |
| 173 |
ExtensionsToDelete := TStringList.Create; |
| 174 |
ExtensionsToDelete.Add('.pyc'); |
| 175 |
ExtensionsToDelete.Add('.pyo'); |
| 176 |
RecursiveDelete('{app}\lib\python3.*', '*.py*', ExtensionsToDelete); |
| 177 |
ExtensionsToDelete.Free; |
| 178 |
end; |
| 179 |
end; |
| 180 |
|
| 181 |
|
| 182 |
///////////////////////////////////////////////////////////////////// |
| 183 |
function GetUninstallString(): String; |
| 184 |
var |
| 185 |
sUnInstKey: Integer; |
| 186 |
sUnInstPath: String; |
| 187 |
sUnInstallString: String; |
| 188 |
sPreviousInstallEpoch: String; |
| 189 |
bIsOtherArch: Boolean; |
| 190 |
begin |
| 191 |
sUnInstKey := HKLM{#ARCHBITS}; |
| 192 |
sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1'); |
| 193 |
sUnInstallString := ''; |
| 194 |
bIsOtherArch := false; |
| 195 |
if not RegQueryStringValue(sUnInstKey, sUnInstPath, 'UninstallString', sUnInstallString) then begin |
| 196 |
sUnInstKey := HKCU{#ARCHBITS}; |
| 197 |
if not RegQueryStringValue(sUnInstKey, sUnInstPath, 'UninstallString', sUnInstallString) then begin |
| 198 |
sUnInstKey := HKLM{#OTHERBITS}; |
| 199 |
if not RegQueryStringValue(sUnInstKey, sUnInstPath, 'UninstallString', sUnInstallString) then begin |
| 200 |
sUnInstKey := HKCU{#OTHERBITS}; |
| 201 |
RegQueryStringValue(sUnInstKey, sUnInstPath, 'UninstallString', sUnInstallString); |
| 202 |
end; |
| 203 |
if sUninstallString <> '' then begin |
| 204 |
bIsOtherArch := true; |
| 205 |
end; |
| 206 |
end; |
| 207 |
end; |
| 208 |
if (sUninstallString <> '') and (not bIsOtherArch) then |
| 209 |
begin |
| 210 |
sPreviousInstallEpoch := GetPreviousData('InstallEpoch', '') |
| 211 |
Log('Previous install epoch is: ' + sPreviousInstallEpoch + ' vs current: {#MyInstallEpoch}') |
| 212 |
if sPreviousInstallEpoch = '{#MyInstallEpoch}' then begin |
| 213 |
sUninstallString := ''; |
| 214 |
end |
| 215 |
end; |
| 216 |
Result := sUnInstallString; |
| 217 |
end; |
| 218 |
|
| 219 |
|
| 220 |
///////////////////////////////////////////////////////////////////// |
| 221 |
function IsUpgrade(): Boolean; |
| 222 |
begin |
| 223 |
Result := (GetUninstallString() <> ''); |
| 224 |
end; |
| 225 |
|
| 226 |
|
| 227 |
///////////////////////////////////////////////////////////////////// |
| 228 |
function UnInstallOldVersion(): Integer; |
| 229 |
var |
| 230 |
sUnInstallString: String; |
| 231 |
iResultCode: Integer; |
| 232 |
begin |
| 233 |
// Return Values: |
| 234 |
// 1 - uninstall string is empty |
| 235 |
// 2 - error executing the UnInstallString |
| 236 |
// 3 - successfully executed the UnInstallString |
| 237 |
|
| 238 |
// default return value |
| 239 |
Result := 0; |
| 240 |
|
| 241 |
// get the uninstall string of the old app |
| 242 |
sUnInstallString := GetUninstallString(); |
| 243 |
if sUnInstallString <> '' then begin |
| 244 |
sUnInstallString := RemoveQuotes(sUnInstallString); |
| 245 |
if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then |
| 246 |
Result := 3 |
| 247 |
else |
| 248 |
Result := 2; |
| 249 |
end else |
| 250 |
Result := 1; |
| 251 |
end; |
| 252 |
|
| 253 |
///////////////////////////////////////////////////////////////////// |
| 254 |
function InitializeSetup(): Boolean; |
| 255 |
var |
| 256 |
iUninstallOldResult : Integer; |
| 257 |
begin |
| 258 |
Result := true |
| 259 |
if (IsUpgrade()) then |
| 260 |
begin |
| 261 |
if MsgBox('The previous version of FontForge must be uninstalled first. Continue?', mbConfirmation, MB_YESNO) = IDYES then |
| 262 |
begin |
| 263 |
iUninstallOldResult := UnInstallOldVersion(); |
| 264 |
Result := (iUninstallOldResult <> 2); |
| 265 |
end else |
| 266 |
Result := False; |
| 267 |
end; |
| 268 |
end; |
| 269 |
|
| 270 |
procedure RegisterPreviousData(PreviousDataKey: Integer); |
| 271 |
begin |
| 272 |
SetPreviousData(PreviousDataKey, 'InstallEpoch', '{#MyInstallEpoch}'); |
| 273 |
end; |
| 274 |
|
| 275 |
procedure CurStepChanged(CurStep: TSetupStep); |
| 276 |
begin |
| 277 |
if (CurStep=ssInstall) then |
| 278 |
begin |
| 279 |
if (IsUpgrade()) then |
| 280 |
begin |
| 281 |
if MsgBox('The previous version of FontForge must be uninstalled first. Continue?', mbConfirmation, MB_YESNO) = IDYES then |
| 282 |
UnInstallOldVersion() |
| 283 |
else |
| 284 |
Abort; |
| 285 |
end; |
| 286 |
end; |
| 287 |
end; |