-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller_script_1.6_test.iss
185 lines (162 loc) · 8.05 KB
/
installer_script_1.6_test.iss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "ManhwaViewer"
#define MyAppVersion "1.6.5"
#define MyAppPublisher "Cariel Becker"
#define MyAppURL "https://www.cariel-becker.com/"
#define MyAppExeName "manhwaviewer.exe"
#define MyAppAssocName MyAppName + " File"
#define MyAppAssocExt ".mwa1"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt
#define MyAppDir ".\output\manhwaviewer\"
#define MyAppId "E23667B7-D8F3-465C-B04E-BC39534DF28C"
[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={#MyAppId}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}{#MyAppVersion}
ChangesAssociations=yes
DisableProgramGroupPage=yes
;InfoBeforeFile=Hello
;InfoAfterFile=Bye
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
PrivilegesRequiredOverridesAllowed=dialog
OutputDir=.\
OutputBaseFilename=manhwaviewer-v1.6.5-win10-11-x64-test-installer
SetupIconFile=./data/Untitled-1.ico
;Password=88ef5ac2-477c-41c2-afb5-5689a3ae98a5
;Encryption=yes
Compression=lzma
SolidCompression=yes
WizardStyle=modern
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "armenian"; MessagesFile: "compiler:Languages\Armenian.isl"
Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
Name: "bulgarian"; MessagesFile: "compiler:Languages\Bulgarian.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: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.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
[Files]
Source: ".\output\manhwaviewer\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: ".\output\manhwaviewer\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Registry]
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[UninstallDelete]
; Delete specific file types within _internal directory but preserve config.py
Type: files; Name: "{app}\_internal\*.*"
//; Excludes: "config.py", {app}\_internal\cache\*.*, {app}\_internal\data\*.*, {app}\_internal\libs\*.*, {app}\_internal\extensions\*.*"
; Manually specify each directory from which to delete files, excluding config.py and entire subdirectories you want to keep
Type: files; Name: "{app}\_internal\certifi\*.*"
Type: files; Name: "{app}\_internal\charset_normalizer\*.*"
Type: files; Name: "{app}\_internal\lxml\*.*"
Type: files; Name: "{app}\_internal\modules\*.*"
Type: files; Name: "{app}\_internal\PIL\*.*"
Type: files; Name: "{app}\_internal\PySide6\*.*"
Type: files; Name: "{app}\_internal\shiboken6\*.*"
Type: files; Name: "{app}\_internal\stdlib_list\*.*"
; Delete any empty directories within the _internal directory
Type: dirifempty; Name: "{app}\_internal\*"
; Delete the main executable
Type: files; Name: "{app}\manhwaviewer.exe"
[Code]
var
TempDir: String;
OldAppDir: String; // This will store the old installation path
function InitializeSetup(): Boolean;
var
UninstallString: String;
ResultCode: Integer;
begin
Result := True;
TempDir := ExpandConstant('{tmp}\ManhwaViewerBackup');
// Attempt to get the old installation directory from the registry
if not RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppID}', 'InstallLocation', OldAppDir) then
if not RegQueryStringValue(HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppID}', 'InstallLocation', OldAppDir) then
OldAppDir := ''; // Fallback if no registry entry is found
if OldAppDir <> '' then
begin
// Create temporary directory
if not DirExists(TempDir) then
CreateDir(TempDir);
// Backup the SQLite DLL and data, excluding the database file
FileCopy(OldAppDir + '\_internal\sqlite3.dll', TempDir + '\sqlite3.dll', False);
FileCopy(OldAppDir + '\data\*.*', TempDir + '\data\', True);
DeleteFile(TempDir + '\data\data.db');
FileCopy(OldAppDir + '\cache\*.*', TempDir + '\cache\', True);
// Check for uninstall string in both per-user and per-machine locations
if not RegQueryStringValue(HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{{#MyAppID}}', 'UninstallString', UninstallString) then
if not RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{{#MyAppID}}', 'UninstallString', UninstallString) then
UninstallString := '';
if UninstallString <> '' then
begin
if Exec(ExpandConstant(UninstallString), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
// Uninstall was successful
end
else
begin
MsgBox('Failed to execute the uninstaller.', mbError, MB_OK);
Result := False;
Exit;
end;
end;
end
else
begin
// Handle case where the old directory cannot be found
MsgBox('Old installation not found. Continuing installation.', mbInformation, MB_OK);
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
NewAppDir: String;
begin
if CurStep = ssPostInstall then
begin
NewAppDir := ExpandConstant('{app}');
// Restore data and cache
FileCopy(TempDir + '\data\*', NewAppDir + '\data\', True);
FileCopy(TempDir + '\cache\*', NewAppDir + '\cache\', True);
// Additional logic for database migration goes here
end;
end;