; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! ; BUILD_DIR can be passed via command line: iscc -DBUILD_DIR="C:\path\to\build" #ifndef BUILD_DIR # define BUILD_DIR "..\build" #endif #define MyAppName "FontForge" #define MyAppFolder "FontForgeBuilds" #define MyAppVersion GetDateTimeString('yyyymmdd', '', ''); #define MyAppVersionDesc GetDateTimeString('yyyy-mm-dd', '', ''); #define MyAppPublisher "FontForgeBuilds" #define MyAppURL "http://www.fontforge.org" #define MyAppExeName "run_fontforge.exe" #define MyInstallEpoch "1" #ifdef MSYSTEM # if MSYSTEM == "UCRT64" # define ARCH="x64compatible" # define ARCHDESC="x64" # endif # if MSYSTEM == "CLANGARM64" # define ARCH="arm64" # define ARCHDESC="arm64" # endif #endif #ifndef ARCH # define ARCH="x64" # define ARCHDESC="x64_unknown" #endif #define ARCHBITS="64" #define OTHERBITS="32" [Setup] ; NOTE: The value of AppId uniquely identifies this application. ; Do not use the same AppId value in installers for other applications. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) AppId={{56748B9C-19AE-4689-B8C5-5A45AE0A993A} AppName={#MyAppName} AppVersion={#MyAppVersion} ;AppVerName={#MyAppName} {#MyAppVersion} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} ArchitecturesInstallIn64BitMode={#ARCH} DefaultDirName={commonpf}\{#MyAppFolder} DefaultGroupName={#MyAppName} AllowNoIcons=yes InfoBeforeFile={#BUILD_DIR}\ReleasePackage\VERSION.txt OutputDir=. OutputBaseFilename=FontForge-{#MyAppVersionDesc}-Windows-{#ARCHDESC} SetupIconFile=Graphics\fontforge-installer-icon.ico UninstallDisplayIcon={app}\fontforge-installer-icon.ico ;WizardImageFile=Graphics\fontforge-wizard.bmp WizardSmallImageFile=Graphics\fontforge-wizard.bmp Compression=lzma2/max SolidCompression=yes ChangesAssociations=yes PrivilegesRequired=poweruser [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" Name: "armenian"; MessagesFile: "compiler:Languages\Armenian.isl" Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl" Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl" Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl" Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl" Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl" Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl" Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl" Name: "french"; MessagesFile: "compiler:Languages\French.isl" Name: "german"; MessagesFile: "compiler:Languages\German.isl" Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl" ;Name: "icelandic"; MessagesFile: "compiler:Languages\Icelandic.isl" Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl" Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl" Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl" Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl" Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl" Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl" Name: "slovak"; MessagesFile: "compiler:Languages\Slovak.isl" Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl" Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl" Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl" Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl" [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 [Files] Source: "{#BUILD_DIR}\ReleasePackage\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Excludes: "fontforge.bat" Source: "fontforge.bat"; DestDir: "{app}"; Flags: ignoreversion; Source: "Graphics\fontforge-installer-icon.ico"; DestDir: "{app}"; Flags: ignoreversion; ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons] Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{group}\{#MyAppName} console"; Filename: "{app}\fontforge.bat" Name: "{group}\{#MyAppName} interactive console"; Filename: "{app}\fontforge-console.bat" Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon [Registry] ;Root: HKLM; Subkey: "Software\FontForge"; Flags: uninsdeletekey Root: HKCR; Subkey: ".sfd"; ValueType: string; ValueName: ""; ValueData: "FontForgeProject"; Flags: uninsdeletevalue Root: HKCR; Subkey: "FontForgeProject"; ValueType: string; ValueName: ""; ValueData: "FontForge Project"; Flags: uninsdeletekey Root: HKCR; Subkey: "FontForgeProject\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\share\fontforge\sfd-icon.ico" Root: HKCR; Subkey: "FontForgeProject\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1""" [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent [Code] procedure RecursiveDelete(Folder : String; Pattern : String; Extensions : TStringList); var SearchPath : String; FilePath : String; FindRec : TFindRec; begin //First search the current folder for any files matching the pattern SearchPath := ExpandConstant(Folder + '\' + Pattern); Log('[Recursive] searching ' + SearchPath); if FindFirst(SearchPath, FindRec) then begin try repeat if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then begin if Extensions.IndexOf(ExtractFileExt(FindRec.Name)) <> -1 then begin FilePath := ExpandConstant(Folder + '\' + FindRec.Name); Log('[Recursive] Deleting ' + FilePath); DeleteFile(FilePath); end; end; until not FindNext(FindRec); finally FindClose(FindRec); end; end; //Now recursively search any subdirectories SearchPath := ExpandConstant(Folder + '\*'); Log('[Recursive] searching ' + SearchPath); if FindFirst(SearchPath, FindRec) then begin try repeat if ((FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY) <> 0) and (CompareStr(FindRec.Name, '.') <> 0) and (CompareStr(FindRec.Name, '..') <> 0) then begin FilePath := ExpandConstant(Folder + '\' + FindRec.Name); Log('[Recursive] now searching: ' + FilePath); RecursiveDelete(FilePath, Pattern, Extensions); end; until not FindNext(FindRec); finally FindClose(FindRec); end; end; end; procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); var ExtensionsToDelete : TStringList; begin if CurUninstallStep = usUninstall then begin if MsgBox('Do you want to remove user preferences?', mbConfirmation, MB_YESNO) = IDYES then begin DelTree(ExpandConstant('{userappdata}\FontForge'), True, True, True); end; Log('Removing Python cache files (.pyc/.pyo)...'); ExtensionsToDelete := TStringList.Create; ExtensionsToDelete.Add('.pyc'); ExtensionsToDelete.Add('.pyo'); RecursiveDelete('{app}\lib\python3.*', '*.py*', ExtensionsToDelete); ExtensionsToDelete.Free; end; end; ///////////////////////////////////////////////////////////////////// function GetUninstallString(): String; var sUnInstKey: Integer; sUnInstPath: String; sUnInstallString: String; sPreviousInstallEpoch: String; bIsOtherArch: Boolean; begin sUnInstKey := HKLM{#ARCHBITS}; sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1'); sUnInstallString := ''; bIsOtherArch := false; if not RegQueryStringValue(sUnInstKey, sUnInstPath, 'UninstallString', sUnInstallString) then begin sUnInstKey := HKCU{#ARCHBITS}; if not RegQueryStringValue(sUnInstKey, sUnInstPath, 'UninstallString', sUnInstallString) then begin sUnInstKey := HKLM{#OTHERBITS}; if not RegQueryStringValue(sUnInstKey, sUnInstPath, 'UninstallString', sUnInstallString) then begin sUnInstKey := HKCU{#OTHERBITS}; RegQueryStringValue(sUnInstKey, sUnInstPath, 'UninstallString', sUnInstallString); end; if sUninstallString <> '' then begin bIsOtherArch := true; end; end; end; if (sUninstallString <> '') and (not bIsOtherArch) then begin sPreviousInstallEpoch := GetPreviousData('InstallEpoch', '') Log('Previous install epoch is: ' + sPreviousInstallEpoch + ' vs current: {#MyInstallEpoch}') if sPreviousInstallEpoch = '{#MyInstallEpoch}' then begin sUninstallString := ''; end end; Result := sUnInstallString; end; ///////////////////////////////////////////////////////////////////// function IsUpgrade(): Boolean; begin Result := (GetUninstallString() <> ''); end; ///////////////////////////////////////////////////////////////////// function UnInstallOldVersion(): Integer; var sUnInstallString: String; iResultCode: Integer; begin // Return Values: // 1 - uninstall string is empty // 2 - error executing the UnInstallString // 3 - successfully executed the UnInstallString // default return value Result := 0; // get the uninstall string of the old app sUnInstallString := GetUninstallString(); if sUnInstallString <> '' then begin sUnInstallString := RemoveQuotes(sUnInstallString); if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then Result := 3 else Result := 2; end else Result := 1; end; ///////////////////////////////////////////////////////////////////// function InitializeSetup(): Boolean; var iUninstallOldResult : Integer; begin Result := true if (IsUpgrade()) then begin if MsgBox('The previous version of FontForge must be uninstalled first. Continue?', mbConfirmation, MB_YESNO) = IDYES then begin iUninstallOldResult := UnInstallOldVersion(); Result := (iUninstallOldResult <> 2); end else Result := False; end; end; procedure RegisterPreviousData(PreviousDataKey: Integer); begin SetPreviousData(PreviousDataKey, 'InstallEpoch', '{#MyInstallEpoch}'); end; procedure CurStepChanged(CurStep: TSetupStep); begin if (CurStep=ssInstall) then begin if (IsUpgrade()) then begin if MsgBox('The previous version of FontForge must be uninstalled first. Continue?', mbConfirmation, MB_YESNO) = IDYES then UnInstallOldVersion() else Abort; end; end; end;