-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmbuildthread.pas
More file actions
2140 lines (1935 loc) · 75.3 KB
/
mbuildthread.pas
File metadata and controls
2140 lines (1935 loc) · 75.3 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
Business Source License 1.1
Parameters
Licensor: InstallAware Software
Licensed Work: InstallAware (Multi Platform) 2026
The Licensed Work is (C) 1996-2026 InstallAware Software
Additional Use Grant: You may make use of the Licensed Work, provided that
you may not use the Licensed Work at a Sanctioned Entity.
Sanctioned Entities are individuals, organizations, or
legal persons who have been formally designated by the
Licensor as having materially violated intellectual
property rights, breached license terms, or engaged in
unethical exploitation of (open-source) technologies,
including this software.
As of the first publicly available distribution of this
specific version of the Licensed Work under this
License, the following are designated as Sanctioned
Entities:
Future US, Inc.
L3Harris Technologies, Inc.
Unisys Corporation
Wolters Kluwer N.V.
This includes any individuals, organizations, or
entities, acting in any capacity and at any time,
either directly or indirectly, on behalf of or under
the control and influence of the Sanctioned Entities,
such as (but not only) current and future:
Subsidiaries
Affiliates
Contractors
Agents
Employees
Parent companies
Acquisitions
Assignees
Joint Ventures
Franchisees
Entities may petition the Licensor for removal from the
Sanctioned Entities list. Any such removal is at the
sole discretion of the Licensor and must be issued in a
public update to the Licensed Work under this License
as documented in this Additional Use Grant parameter.
Change Date: 2030-01-05
Change License: GNU Affero General Public License version 3 (AGPLv3)
For information about alternative licensing arrangements for the Software,
please visit: https://www.installaware.com/
Notice
The Business Source License (this document, or the “License”) is not an Open
Source license. However, the Licensed Work will eventually be made available
under an Open Source License, as stated in this License.
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
“Business Source License” is a trademark of MariaDB Corporation Ab.
Terms
The Licensor hereby grants you the right to copy, modify, create derivative
works, redistribute, and make non-production use of the Licensed Work. The
Licensor may make an Additional Use Grant, above, permitting limited
production use.
Effective on the Change Date, or the fourth anniversary of the first publicly
available distribution of a specific version of the Licensed Work under this
License, whichever comes first, the Licensor hereby grants you rights under
the terms of the Change License, and the rights granted in the paragraph
above terminate.
If your use of the Licensed Work does not comply with the requirements
currently in effect as described in this License, you must purchase a
commercial license from the Licensor, its affiliated entities, or authorized
resellers, or you must refrain from using the Licensed Work.
All copies of the original and modified Licensed Work, and derivative works
of the Licensed Work, are subject to this License. This License applies
separately for each version of the Licensed Work and the Change Date may vary
for each version of the Licensed Work released by Licensor.
You must conspicuously display this License on each original or modified copy
of the Licensed Work. If you receive the Licensed Work in original or
modified form from a third party, the terms and conditions set forth in this
License apply to your use of that work.
Any use of the Licensed Work in violation of this License will automatically
terminate your rights under this License for the current and all other
versions of the Licensed Work.
This License does not grant you any right in any trademark or logo of
Licensor or its affiliates (provided that you may use a trademark or logo of
Licensor as expressly required by this License).
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
TITLE.
MariaDB hereby grants you permission to use this License’s text to license
your works, and to refer to it using the trademark “Business Source License”,
as long as you comply with the Covenants of Licensor below.
Covenants of Licensor
In consideration of the right to use this License’s text and the “Business
Source License” name and trademark, Licensor covenants to MariaDB, and to all
other recipients of the licensed work to be provided by Licensor:
1. To specify as the Change License the GPL Version 2.0 or any later version,
or a license that is compatible with GPL Version 2.0 or a later version,
where “compatible” means that software provided under the Change License can
be included in a program with software provided under GPL Version 2.0 or a
later version. Licensor may specify additional Change Licenses without
limitation.
2. To either: (a) specify an additional grant of rights to use that does not
impose any additional restriction on the right granted in this License, as
the Additional Use Grant; or (b) insert the text “None”.
3. To specify a Change Date.
4. Not to modify this License in any other way.
}
unit mbuildthread;
{$MODE Delphi}
interface
uses
SysUtils, Classes, mUtils, uTahoe, LCLIntf, LCLType, LMessages,
FileUtil, uSevenZIPAPI{$IFNDEF WINDOWS}, BaseUnix, Unix{$ELSE}, Windows{$ENDIF};
type
StringBlock = record
lpString: array[0..15] of PWideChar;
end;
TBuildThread = class(TThread)
private
scsB: Boolean;
scsID: Integer;
scsURL: String;
protected
function GetWeblockPwd(Weblock: String): String;
procedure Execute; override;
procedure BuildStub;
procedure InjectMPStub(Engine, Translations, Package, Splash, Output: String);
procedure miaReplaceLang(LanguageName, UlteriorDependent: String; LanguageCode: Integer);
procedure miaReplaceLangEx(UlteriorDependent: String);
function PrepTempLangFile(DefLang: String): String;
procedure PreparePippin(l: TStrings);
function SearchString(pFileName: String; nLength: LongWord; pString: AnsiString; nStartSmartPosition: LongWord): Integer;
function ReplaceString(pFileName: String; nSmartPosition, nOldStrLen: LongWord; pOldString: AnsiString; nNewStrLen: LongWord; pNewString: AnsiString): Integer;
function SerialCheckSubEx(ID: Integer): Boolean;
procedure SerialCheckSubEy;
public
procedure DisplayUpdateEy;
procedure DisplayUpdate;
procedure TimerExEnable;
procedure TimerExDisable;
function GetCodeSignName: String;
procedure DoGenericCodeSignEx(Target: String);
procedure DoGenericCodeSign(Target: String; Iteration: Integer = 0);
{$IFDEF DARWIN}
procedure DoGenericDMGSign(Target, TeamID, AppleID, AppPass: String);
{$ENDIF}
function DisplayUpdateEx(Status: String): Boolean;
function DisplayUpdateExEy(Status: String): Boolean;
function GetCompilerVariableValueDirect(Variable: String): String;
function ProcessBuildEvents(Kind: String): String;
end;
function GetCompilerVariableValueDirectEx(Variable: String): String;
var
{$IFDEF DARWIN}
DoGenericCodeSignList: TStringList;
{$ENDIF}
SubDat: AnsiString = #0 + 'ALLA-ALLANODISH-AS-DISH-DISH-AS-SENYORIT-ALLA-ALLANODISH-AS-DISH-DISH-AS-SENYORIT-ALLA-ALLANODISH-AS-DISH-DISH-AS-SENYORIT';
Cancelled, BuildFinished, Success: Boolean;
UpdateString: String;
CompressionProfile: String;
BuildForm: Integer;
BuildFormEx: Boolean;
SetupEXE, SetupMSI, SetupMSP, SetupMSIEx: String;
implementation
uses
mscriptexec, mbuild, mautomate;
const
SUpgradedPackage = 'Upgraded Package\';
SUpgradedPackageData = 'Upgraded Package\data\';
STmp = '.tmp';
SLog = '.log';
SUpgradedPackage_1 = 'Upgraded Package';
SRepack_1 = '.repack\';
SBasePackage = 'Base Package ';
resourcestring
SClearedOutputFolder = 'Cleared output folder ';
SAbortedByUser = 'Aborted by user';
SUntitledMsi = 'untitled.msi';
SCreatedWindowsInstallerDatabase = 'Created collection';
SUnableToMergeWindowsInstallerDat = 'Unable to merge Windows Installer database with module ';
SMergedWindowsInstallerDatabaseWi = 'Merged Windows Installer database with module ';
SUntitledExe = 'untitled';
SUnableToNotarize = 'Notarizing failed!';
SUnableToStaple = 'Stapling failed!';
SNotarizing = 'Notarizing (this may take an extended amount of time): ';
SStapling = 'Stapling: ';
SCodeSigning = 'Code signing: ';
SCodeSigningEx = 'Double code signing: ';
SCodeSigningEy = 'Code signing with custom hooks: ';
SBuiltInstallationExecutable = 'Built installation executable';
SSigningInstallationExecutable = 'Signing installation executable';
SUnableToCodeSign = 'Code signing failed!';
SUnableToSignInstallationExecutab = 'Unable to sign installation executable';
SInjectedSetupLanguages = 'Injected setup languages';
SStoringSupportFiles = 'Storing support files: ';
SUnableToFindSupportFile = 'Unable to find support file ';
SUseTheProjectManagerWindowToUpda = ', use the Project Manager window to update or remove the reference';
SOperationCancelled = 'Operation cancelled';
SOutOfMemoryDuringCompressionPlea = 'Out of memory during compression - please reduce your project''s compression level using the Project Options dialog and then try again';
SPleaseCheckYourProjectNamesAndFo = 'Please check your project names and folders are made of alpha-numeric characters only';
SUnableToBuildRuntimeFiles = 'Unable to build runtime files: ';
SInjectedRuntimeFiles = 'Injected runtime files';
SCompressingInstall = 'Compressing install: ';
SUnableToBuildSetupFiles = 'Unable to build setup files: ';
SCompressedSetupFiles = 'Compressed setup files';
SUnableToBuildWebMediaBlock = 'Unable to build web media block: ';
SCompressedWebMediaBlock = 'Compressed web media block ';
SFinishedGeneratingWebMediaBlocks = 'Finished generating web media blocks';
SPreparedSFXData = 'Prepared SFX data';
SCreatedSFXFile = 'Created SFX file';
SCleanedUp = 'Cleaned up';
SBeginningProcessingForPatch = 'Beginning processing for patch ';
SProcessedBasePackage = 'Processed base package ';
SNoCompatibleBasePackagesFoundFor = 'No compatible base packages found for upgrade package';
SUnableToCreatePatchDatabase = 'Unable to create patch database';
SLocatingCompressedPatchDataStrea = 'Locating compressed patch data stream';
SUnableToLocateCompressedPatchDat = 'Unable to locate compressed patch data stream';
SInitializingCompressedDataStream = 'Initializing compressed data stream for recompression';
SUnableToInitializeCompressedData = 'Unable to initialize compressed data stream for recompression';
SReinjectingInitializedPatchDataS = 'Reinjecting initialized patch data stream';
SUnableToReinjectInitializedPatch = 'Unable to reinject initialized patch data stream';
SCompressingPatch = 'Compressing patch: ';
SUnableToBuildPatchFiles = 'Unable to build patch files: ';
SCompressedPatchFiles = 'Compressed patch files';
SCleanedUpAfterPatch = 'Cleaned up after patch';
SSigningInstallation = 'Signing installation';
SUnableToSignPackage = 'Unable to sign package';
SErrorDuringBuild = 'Error during build: ';
function GetCompilerVariableValueDirectEx(Variable: String): String;
var
i: Integer;
begin
Result := '';
for i := 1 to CompilerVariableDirect.Count do
if i mod 2 = 1 then
begin
if AnsiCompareText(CompilerVariableDirect[i -1], Variable) = 0 then
begin
Result := CompilerVariableDirect[i];
Exit;
end;
end;
end;
procedure TBuildThread.DoGenericCodeSign(Target: String; Iteration: Integer = 0);
var
s: String;
i, j: Integer;
l: TStringList;
Wide1, Wide2: String;
begin
if thProjectStruct.aSign then
begin
s := '';
WidenColonDelimParam(thProjectStruct.aKey, Wide1, Wide2);
{$IFDEF WINDOWS}
s := CompilerGetVariable('CODE-SIGN-HOOKS', thProjectStruct.Conditionals);
if (AnsiCompareText('#CODE-SIGN-HOOKS#', s) <> 0) then
begin
s := SubstituteCompilerVariables(SingleLineToMultiLine(s), thProjectStruct.Conditionals);
l := TStringList.Create;
l.Text := s;
for j := 1 to l.Count do
begin
s := StringReplace(l[j -1], '%1', Target, [rfReplaceAll, rfIgnoreCase]);
if s <> '' then
begin
UpdateString := SCodeSigningEy + Target;
DisplayUpdateEx(UpdateString);
if Cancelled then
raise Exception.Create(SAbortedByUser);
i := LaunchAppAndWaitWindows(s, false, True);
if Cancelled then
raise Exception.Create(SAbortedByUser);
if i <> 0 then
begin
Iteration := Iteration +1;
if Iteration = 3 then
raise Exception.Create(SUnableToCodeSign);
DoGenericCodeSign(Target, Iteration);
end;
end;
end;
l.Free;
Exit;
end;
if Wide2 <> '' then
begin
s := 'sign ';
Wide2 := StringReplace(Wide2, '/', '\', [rfReplaceAll, rfIgnoreCase]);
s := s + '/f "' + Wide2 + '" ';
WidenColonDelimParam(thProjectStruct.aTimeStamp, Wide1, Wide2);
if Wide1 <> '' then
s := s + '/t "' + Wide1 + '" ';
if thProjectStruct.aInfo <> '' then
s := s + '/du "' + thProjectStruct.aInfo + '" ';
s := s + '/d "' + thProjectStruct.Name + '" ';
if thProjectStruct.CodeSignPassword <> '' then
s := s + '/p "' + thProjectStruct.CodeSignPassword + '" ';
s := s + '"' + Target + '"';
UpdateString := SCodeSigning + Target;
DisplayUpdateEx(UpdateString);
if Cancelled then
raise Exception.Create(SAbortedByUser);
i := LaunchAppAndWait(EXEDIR + 'authenticode\signtool.exe', s, false, True);
if (i = 0) then
begin
s := 'sign /fd SHA256 /as ';
WidenColonDelimParam(thProjectStruct.aKey, Wide1, Wide2);
Wide2 := StringReplace(Wide2, '/', '\', [rfReplaceAll, rfIgnoreCase]);
s := s + '/f "' + Wide2 + '" ';
WidenColonDelimParam(thProjectStruct.aTimeStamp, Wide1, Wide2);
if Wide1 <> '' then
s := s + '/tr "' + Wide1 + '" /td sha256 ';
if thProjectStruct.aInfo <> '' then
s := s + '/du "' + thProjectStruct.aInfo + '" ';
s := s + '/d "' + thProjectStruct.Name + '" ';
if thProjectStruct.CodeSignPassword <> '' then
s := s + '/p "' + thProjectStruct.CodeSignPassword + '" ';
s := s + '"' + Target + '"';
UpdateString := SCodeSigningEx + Target;
DisplayUpdateEx(UpdateString);
if Cancelled then
raise Exception.Create(SAbortedByUser);
i := LaunchAppAndWait(EXEDIR + 'authenticode\signtool.exe', s, false, True);
end;
if Cancelled then
raise Exception.Create(SAbortedByUser);
if i = 1 then
begin
Iteration := Iteration +1;
if Iteration = 3 then
raise Exception.Create(SUnableToCodeSign);
DoGenericCodeSign(Target, Iteration);
end;
end;
{$ELSE}
{$IFDEF DARWIN}
s := '-vvv --force --strict --options=runtime ';
s := s + '--timestamp ';
WidenColonDelimParam(thProjectStruct.aCertificate, Wide1, Wide2);
s := s + '-s "' + Wide1 + '" "' + Target + '"';
UpdateString := SCodeSigning + Target;
DisplayUpdateEx(UpdateString);
if Cancelled then
raise Exception.Create(SAbortedByUser);
if (LaunchAppAndWait('codesign', s, false, True) <> 0) or
(LaunchAppAndWait('codesign', '--verify --verbose --strict "' + Target + '"', false, True) <> 0) then
begin
Iteration := Iteration +1;
if Iteration = 3 then
raise Exception.Create(SUnableToCodeSign);
DoGenericCodeSign(Target, Iteration);
end;
if Cancelled then
raise Exception.Create(SAbortedByUser);
{$ENDIF}
{$ENDIF}
end;
end;
{$IFDEF DARWIN}
procedure TBuildThread.DoGenericDMGSign(Target, TeamID, AppleID, AppPass: String);
begin
UpdateString := SNotarizing + Target;
DisplayUpdateEx(UpdateString);
if Cancelled then
raise Exception.Create(SAbortedByUser);
if TeamID='' then
raise Exception.Create(SUnableToNotarize + ' Team ID missing')
else if AppleID ='' then
raise Exception.Create(SUnableToNotarize + ' Apple ID missing')
else if AppPass ='' then
raise Exception.Create(SUnableToNotarize + ' Application Specific Password missing');
if LaunchAppAndWait('xcrun','notarytool submit'+
' "'+Target+'"'+
' --apple-id "'+AppleID+'"'+
' --password "'+AppPass+'"'+
' --team-id "'+TeamID+'"'+
' --wait', false, True) <> 0 then
raise Exception.Create(SUnableToNotarize);
if Cancelled then
raise Exception.Create(SAbortedByUser);
UpdateString := SStapling + Target;
DisplayUpdateEx(UpdateString);
if LaunchAppAndWait('xcrun', 'stapler staple "'+Target+'"', false, True) <> 0 then
raise Exception.Create(SUnableToStaple);
end;
{$ENDIF}
procedure TBuildThread.DoGenericCodeSignEx(Target: String);
var
inStream, outStream: TFileStream;
begin
inStream := TFileStream.Create(EXEDIR + 'buffer.exe',
fmOpenRead or fmShareDenyWrite);
outStream := TFileStream.Create(Target + '-rebuffering', fmCreate or fmShareDenyRead);
outStream.CopyFrom(inStream, inStream.Size);
inStream.Free;
inStream := TFileStream.Create(Target, fmOpenRead or fmShareDenyWrite);
outStream.CopyFrom(inStream, inStream.Size);
inStream.Free;
outStream.Free;
DeleteFile(PChar(Target));
RenameFile(Target + '-rebuffering', Target);
DoGenericCodeSign(Target);
end;
procedure TBuildThread.BuildStub;
var
i, j, k, iX: Integer;
s, sX, sZ, s1, s2: String;
h: THandle;
p: PChar;
b: Pointer;
ls: TList;
l, lX, lY, lZ, lXX, lXY, lXZ, lYEx, lZEx, LZEy: TStringList;
t, tX, tY, tZ: TextFile;
inStream, outStream: TFileStream;
fd: TSearchRec;
PlugDLLs: TStringList;
cantCreateFolder,
iaInitializationError,
unableRemoveTmpFiles,
unableCreateFile,
internalError,
downloadCorrupt1,
downloadCorrupt2,
unknownError,
cantLoadConf,
confFailed,
isPwdProtected,
ok,
cancel,
cantCreateTmpFolder,
cantOpenDataStream,
cantFindFile,
incorrectFile,
cantCreateOutputFolder,
confirmCancel,
title,
extractingMsg: String;
uS, uSX: String;
uI, uIX, uIY: Integer;
UlteriorString, UlteriorTemp, UlteriorTempLang, UlteriorRoundabout, UlteriorDependent: String;
Wide1, Wide2: String;
escondidoX: String;
BOM: Char;
sY, sYX: String;
pPin: Boolean;
bS: String;
sI: String;
CodeSignCorp: String;
rX, rY, rZ, rZEx: String;
rI, rIX: Integer;
nTeamID, nAppleID, nAppPass: String;
nI: Integer;
masterStub, masterStubX, masterStubEx, UlteriorStringEx, sEx, SetupEXEEx: String;
inStreamEx, outStreamEx: TFileStream;
{$IFDEF LINUX}
luxLinux: Boolean;
{$ENDIF}
begin
try
try
masterStubX := CompilerGetVariable('NOGUI', thProjectStruct.Conditionals);
if masterStubX = '#NOGUI#' then masterStubX := '';
if masterStubX = '' then
{$IFDEF LINUX}
masterStubX := 'AUTO';
{$ELSE}
masterStubX := 'FALSE';
{$ENDIF}
if AnsiCompareText(masterStubX, 'AUTO') = 0 then
begin
{$IFDEF WINDOWS}
masterStub := 'miacstub.exe';
masterStubEx := 'miaxstub.exe';
{$ELSE}
masterStub := 'miacstub';
masterStubEx := 'miaxstub';
{$ENDIF}
end
else
if AnsiCompareText(masterStubX, 'TRUE') = 0 then
begin
{$IFDEF WINDOWS}
masterStub := 'miacstub.exe';
{$ELSE}
masterStub := 'miacstub';
{$ENDIF}
masterStubEx := '';
end
else
begin
{$IFDEF WINDOWS}
masterStub := 'miaxstub.exe';
{$ELSE}
masterStub := 'miaxstub';
{$ENDIF}
masterStubEx := '';
end;
UlteriorString := CreateGUIDUp;
UlteriorStringEx := CreateGUIDUp;
UlteriorTemp := CreateGUIDUp;
UlteriorRoundabout := CreateGUIDUp;
UlteriorDependent := CreateGUIDUp;
CodeSignCorp := '';
sY := CompilerGetVariable('SKIP_WEBLOCK_SIGN', thProjectStruct.Conditionals);
if (AnsiCompareText('#SKIP_WEBLOCK_SIGN#', sY) = 0) or (not (AnsiCompareText(sY, 'TRUE') = 0)) then
CodeSignCorp := GetCodeSignName;
WeblockPasswords.Clear;
if CodeSignCorp <> '' then
begin
WeblockPasswords.Add('myahtfx');
WeblockPasswords.Add(ObsWeblock(CodeSignCorp));
end;
if thProjectStruct.PassEnabled then
begin
WeblockPasswords.Add('OFFLINE');
WeblockPasswords.Add(ObsWeblock(thProjectStruct.Password));
end;
WipeFolder(thBuildToFolder, True);
UpdateString := SClearedOutputFolder + thBuildToFolder;
bS := ProcessBuildEvents('PRE-BUILD');
if bS <> '' then
raise Exception.Create('Pre-Build command "' + bS + '" failed');
DisplayUpdateEx(UpdateString);
if BuildForm = 3 then
thBuildToFolder := thBuildToFolder + SUpgradedPackage;
ForceDirectories(thBuildToFolder);
if Cancelled then
raise Exception.Create(SAbortedByUser);
lXX := TStringList.Create;
lXY := TStringList.Create;
lXZ := TStringList.Create;
PlugDLLs := TStringList.Create;
if Cancelled then
raise Exception.Create(SAbortedByUser);
if thProjectStruct.OutputFile = '' then
begin
if thCurrentProjectName = '' then
s := SUntitledMsi
else
s := ExtractFileNameOnly(thCurrentProjectName) + '.msi';
end
else s := thProjectStruct.OutputFile + '.msi';
s := thBuildToFolder + s;
CompileMSI(s, Self, (BuildForm = 2) or BuildFormEx, thGlobalLists, thScriptTypes, thScriptReferences,
thScriptComments, thProjectStruct.Conditionals, thProjectStruct.BuildLayout,
thProjectStruct.Language, thProjectStruct.Name,
thProjectStruct.cFiles, thProjectStruct.cRegistry, thProjectStruct.cFeatures,
thProjectStruct.cHashes, GetCompilerDirect('INSTALLAWARE_DRM_APPLICATION'), pPin,
thProjectStruct.aSign, Self);
SetupMSI := s;
UpdateString := SCreatedWindowsInstallerDatabase;
DisplayUpdateEx(UpdateString);
if Cancelled then
raise Exception.Create(SAbortedByUser);
{$IFDEF WINDOWS}
Windows.CopyFile(PChar(EXEDIR + 'windows/' + masterStub),
{$ELSE}
{$IFDEF LINUX}
FileCopyFile(PChar(EXEDIR + 'linux/' + masterStub),
{$ELSE}
FileCopyFile(PChar(EXEDIR + 'macos/' + masterStub),
{$ENDIF}
{$ENDIF}
PChar(EXEDIR + UlteriorString),
false);
if masterStubEx <> '' then
begin
{$IFDEF WINDOWS}
Windows.CopyFile(PChar(EXEDIR + 'windows/' + masterStubEx),
{$ELSE}
{$IFDEF LINUX}
FileCopyFile(PChar(EXEDIR + 'linux/' + masterStubEx),
{$ELSE}
FileCopyFile(PChar(EXEDIR + 'macos/' + masterStubEx),
{$ENDIF}
{$ENDIF}
PChar(EXEDIR + UlteriorStringEx),
false);
end;
s := EXEDIR + UlteriorString;
sEx := EXEDIR + UlteriorStringEx;
inStream := TFileStream.Create(s, fmOpenRead or fmShareDenyWrite);
if masterStubEx <> '' then
inStreamEx := TFileStream.Create(sEx, fmOpenRead or fmShareDenyWrite)
else
inStreamEx := nil;
if thProjectStruct.OutputFile = '' then
begin
if thCurrentProjectName = '' then
{$IFDEF WINDOWS}
s := SUntitledExe + '.exe'
{$ELSE}
s := SUntitledExe
{$ENDIF}
else
{$IFDEF WINDOWS}
s := ExtractFileNameOnly(thCurrentProjectName) + '.exe';
{$ELSE}
s := ExtractFileNameOnly(thCurrentProjectName);
{$ENDIF}
end
{$IFDEF WINDOWS}
else s := thProjectStruct.OutputFile + '.exe';
{$ELSE}
else s := thProjectStruct.OutputFile;
{$ENDIF}
s := thBuildToFolder + s;
sEx := AssertDir(ExtractFilePath(s)) + ExtractFileNameOnly(s) + 'Ex'{$IFDEF WINDOWS}+ '.exe'{$ENDIF};
{$IFDEF DARWIN}
ForceDirectories(s + '.app/Contents/MacOS/');
ForceDirectories(s + '.app/Contents/Resources/');
ForceDirectories(s + '.app/Contents/' + Ventura + '/');
FileCopyFile(EXEDIR + 'MacOS/miaxstub.app/Contents/Info.plist',
s + '.app/Contents/Info.plist', false);
VersionIfy(s + '.app/Contents/Info.plist', thProjectStruct.Version);
if (AnsiCompareText(masterStubX, 'TRUE') = 0) or (AnsiCompareText(masterStubX, 'AUTO') = 0)then
NoGuify(s + '.app/Contents', BuildForm);
FileCopyFile(EXEDIR + 'MacOS/miaxstub.app/Contents/PkgInfo',
s + '.app/Contents/PkgInfo', false);
{$ENDIF}
SetupEXE := s;
SetupEXEEx := sEx;
outStream := TFileStream.Create(s, fmCreate or fmShareExclusive);
if MasterStubEx <> '' then
outStreamEx := TFileStream.Create(sEx, fmCreate or fmShareExclusive)
else
outStreamEx := nil;
GetMem(b, inStream.Size);
inStream.Read(b^, inStream.Size);
if AnsiCompareText(GetCompilerVariableValueDirect('NOEXE'), 'TRUE') <> 0 then
begin
outStream.Write(b^, inStream.Size);
if outStreamEx <> nil then
begin
FreeMem(b);
GetMem(b, inStreamEx.Size);
inStreamEx.Read(b^, inStreamEx.Size);
outStreamEx.Write(b^, inStreamEx.Size);
end;
end;
FreeMem(b);
inStream.Free;
if inStreamEx <> nil then
inStreamEx.Free;
{$IFDEF DARWIN}
outStream.Free;
outStream := TFileStream.Create(s + '.msi', fmCreate or fmShareExclusive);
if outStreamEx <> nil then
begin
outStreamEx.Free;
outStreamEx := TFileStream.Create(sEx + '.msi', fmCreate or fmShareExclusive);
end;
{$ENDIF}
try
escondidoX := thProjectStruct.Conditionals;
SetMakeContext(thGlobalLists, thScriptTypes, thScriptReferences, thScriptComments,
escondidoX, ls, sX, thProjectStruct.BuildLayout,
thProjectStruct.Language, thProjectStruct.Name,
thProjectStruct.aSign);
StrCopy(thProjectStruct.Conditionals, PChar(escondidoX));
l := TStringList.Create;
for i := 1 to thScriptTypes.Count do
l.Add(thScriptTypes[i -1]);
l.Add('$');
for i := 1 to thScriptReferences.Count do
l.Add(thScriptReferences[i -1]);
l.Add('$');
for i := 1 to ls.Count do
while TStringList(ls[i -1]).IndexOf('$') <> -1 do
TStringList(ls[i -1])[TStringList(ls[i -1]).IndexOf('$')] := '$WILD_DOLLAR$';
for i := 1 to ls.Count do
for j := 1 to TStringList(ls[i -1]).Count do
if AnsiPos('$MYAH_CARET$', TStringList(ls[i -1])[j -1]) = 0 then
l.Add(TStringList(ls[i -1])[j -1])
else
l.Add('FALSE');
for i := 1 to ls.Count do
while TStringList(ls[i -1]).IndexOf('$WILD_DOLLAR$') <> -1 do
TStringList(ls[i -1])[TStringList(ls[i -1]).IndexOf('$WILD_DOLLAR$')] := '$';
l.Add('$');
for i := 1 to thScriptComments.Count do
l.Add(thScriptComments[i -1]);
l.Add('$');
finally
SetEditContext(ls, thScriptTypes);
end;
l.Add(thProjectStruct.Code);
l.Add(thProjectStruct.Name);
l.Add('$');
l.Add(thProjectStruct.Manufacturer);
l.Add(thProjectStruct.arContact);
l.Add(thProjectStruct.arHelp);
l.Add(thProjectStruct.arUpdates);
l.Add(thProjectStruct.arComments);
l.Add(thProjectStruct.Version);
for i := 1 to WeblockPasswords.Count do
l.Add(WeblockPasswords[i -1]);
l.Add('$');
for i := 1 to thScriptFetches.Count do
l.Add(thScriptFetches[i -1]);
l.Add('$');
if (thProjectStruct.BuildLayout = 0) or (thProjectStruct.BuildLayout = 1) then
begin
if BuildFormEx then
l.Add('2')
else
l.Add(IntToStr(thProjectStruct.BuildLayout));
end
else
l.Add(IntToStr(thProjectStruct.BuildLayout));
for i := 1 to ComponentSpaces.Count do
l.Add(ComponentSpaces[i -1]);
l.Add('$');
l.Add(thProjectStruct.Revision);
for i := 1 to NewSourceListSource.Count do
l.Add(NewSourceListSource[i -1]);
l.Add('$');
l.Add(MyBoolToStr(thProjectStruct.MultiLang, True));
l.Add(thProjectStruct.Language);
for i := 1 to CommandHeaders.Count do
l.Add(CommandHeaders[i -1]);
l.Add('$');
for i := 1 to CompilerVariableDirect.Count do
l.Add(CompilerVariableDirect[i -1]);
l.Add('$');
l.Add(IntToStr(0));
for i := 1 to PullMapDirect.Count do
l.Add(PullMapDirect[i -1]);
l.Add('$');
l.Add(IntToStr(NativeTotal));
for i := 1 to NativeFileSourceStack.Count do
l.Add(NativeFileSourceStack[i -1]);
l.Add('$');
for i := 1 to IncludeDepthDirect.Count do
l.Add(IncludeDepthDirect[i -1]);
l.Add('$');
rX := '20210501';
l.Add(rX);
l.SaveToFile(EXEDIR + UlteriorTemp , TEncoding.UTF8);
inStream := TFileStream.Create(EXEDIR + UlteriorTemp ,
fmOpenRead or fmShareDenyWrite);
GetMem(b, inStream.Size);
inStream.Read(b^, inStream.Size);
outStream.Write(b^, inStream.Size);
if outStreamEx <> nil then
outStreamEx.Write(b^, inStream.Size);
FreeMem(b);
inStream.Free;
l.Free;
outStream.Free;
if outStreamEx <> nil then
outStreamEx.Free;
if AnsiCompareText(GetCompilerVariableValueDirect('KEEPSTUBDATA'), 'TRUE') <> 0 then
DeleteFile(PChar(EXEDIR + UlteriorTemp ));
UpdateString := SBuiltInstallationExecutable;
DisplayUpdateEx(UpdateString);
if Cancelled then
raise Exception.Create(SAbortedByUser);
{$IFNDEF WINDOWS}
LazShimSetExecutable(SetupEXE, EXEDIR + {$IFDEF DARWIN}'macos/miaxstub'{$ELSE}'linux/miaxstub'{$ENDIF});
if masterStubEx <> '' then
LazShimSetExecutable(SetupEXEEx, EXEDIR + {$IFDEF DARWIN}'macos/miaxstub'{$ELSE}'linux/miaxstub'{$ENDIF});
DisplayUpdateEx('Applied launch permissions upon setup');
if Cancelled then
raise Exception.Create(SAbortedByUser);
{$ENDIF}
{$IFDEF LINUX}
FileCopyFile(PChar( EXEDIR + 'linux/miax.lib'),
PChar(AssertDir(ExtractFilePath(SetupEXE)) + 'miax.lib'), false);
{$IFDEF LCLQT5}
FileCopyFile(PChar(EXEDIR + 'libQt5Pas.so.1'),
PChar(AssertDir(ExtractFilePath(SetupEXE)) + 'libQt5Pas.so.1'), false);
{$ENDIF}
{$ELSE}
{$IFDEF DARWIN}
FileCopyFile(PChar( EXEDIR + 'macos/miax.lib'),
PChar(AssertDir(ExtractFilePath(SetupEXE)) + 'miax.lib'), false);
{$ELSE}
CopyFile(PChar( EXEDIR + 'windows\miax.lib'),
PChar(AssertDir(ExtractFilePath(SetupEXE)) + 'miax.lib'), false);
{$ENDIF}
{$ENDIF}
{$IFNDEF WINDOWS}
LazShimSetExecutable(AssertDir(ExtractFilePath(SetupEXE)) + 'miax.lib', EXEDIR + {$IFDEF DARWIN}'macos/miaxstub'{$ELSE}'linux/miax.lib'{$ENDIF});
DisplayUpdateEx('Applied launch permissions upon library');
if Cancelled then
raise Exception.Create(SAbortedByUser);
{$ENDIF}
{$IFDEF WINDOWS}
if MyFileExists(EXEDIR + 'trans\translations.' + thProjectStruct.Language) then
begin
inStream := TFileStream.Create(AssertDir(ExtractFilePath(SetupEXE)) + 'miax.lib',
fmOpenRead or fmShareDenyWrite);
outStream := TFileStream.Create(AssertDir(ExtractFilePath(SetupEXE)) + 'miax.lib.inj', fmCreate or fmShareExclusive);
GetMem(b, inStream.Size);
inStream.Read(b^, inStream.Size);
outStream.Write(b^, inStream.Size);
FreeMem(b);
inStream.Free;
UlteriorTempLang := PrepTempLangFile(EXEDIR + 'trans\translations.' + thProjectStruct.Language);
inStream := TFileStream.Create(EXEDIR + 'trans\translations.' +
UlteriorTempLang + '.TempLangFile', fmOpenRead or fmShareDenyWrite);
GetMem(b, inStream.Size);
inStream.Read(b^, inStream.Size);
outStream.Write(b^, inStream.Size);
FreeMem(b);
inStream.Free;
outStream.Free;
DeleteFile(PChar(AssertDir(ExtractFilePath(SetupEXE)) + 'miax.lib'));
DeleteFile(PChar(EXEDIR + 'trans\translations.' + UlteriorTempLang + '.TempLangFile'));
RenameFile(AssertDir(ExtractFilePath(SetupEXE)) + 'miax.lib.inj',
AssertDir(ExtractFilePath(SetupEXE)) + 'miax.lib');
if AnsiCompareText(GetCompilerVariableValueDirect('NOEXE'), 'TRUE') = 0 then
DeleteFile(PChar(AssertDir(ExtractFilePath(SetupEXE)) + 'miax.lib'));
end;
DoGenericCodeSign(AssertDir(ExtractFilePath(SetupEXE)) + 'miax.lib');
UpdateString := SInjectedSetupLanguages;
DisplayUpdateEx(UpdateString);
if Cancelled then
raise Exception.Create(SAbortedByUser);
{$ENDIF}
l := TStringList.Create;
for i := 1 to thDialogFiles.Count do
l.Add(PROJDIR + thDialogFiles[i -1]);
if false then
PreparePippin(l);
for i := 1 to thSupportFiles.Count do
if AnsiPos('translations.', thSupportFiles[i -1]) = 1 then
begin
SetFileAttributes(PChar(PROJDIR + thSupportFiles[i -1] + '.shared'),
FILE_ATTRIBUTE_NORMAL);
FileCopyFile(PChar(EXEDIR + 'trans' + PathDelim + thSupportFiles[i -1]),
PChar(PROJDIR + 'shared.' + thSupportFiles[i -1]), false);
if MyFileExists(PROJDIR + 'shared.' + thSupportFiles[i -1]) then
l.Add(PROJDIR + 'shared.' + thSupportFiles[i -1]);
end;
for i := 1 to thSupportFiles.Count do
if ((AnsiLowerCase(thSupportFiles[i -1]) <> 'setup.bmp')
and (AnsiLowerCase(thSupportFiles[i -1]) <> 'setup.ico')) and
(AnsiLowerCase(thSupportFiles[i -1]) <> 'updates.ini') then
l.Add(PROJDIR + thSupportFiles[i -1])
else
if (AnsiLowerCase(thSupportFiles[i -1]) = 'setup.bmp') then
FileCopyFile(PChar(PROJDIR + 'setup.bmp'),
PChar(thBuildToFolder + 'setup.bmp'), false);
{$IFDEF LINUX}
if not MyFileExists(PROJDIR + 'icon.png') then
FileCopyFile(EXEDIR + 'miaxstub.png', PROJDIR + 'icon.png', false);
if l.IndexOf(PROJDIR + 'icon.png') = -1 then
begin
l.Add(PROJDIR + 'icon.png');
luxLinux := false;
end
else
luxLinux := True;
{$ENDIF}
for i := 1 to PlugDLLs.Count do
l.Add(PlugDLLs[i -1]);
for i := 1 to lXX.Count do
if l.IndexOf(PROJDIR + lXX[i -1]) = -1 then
l.Add(PROJDIR + lXX[i -1]);
PlugDLLs.Free;
lXX.Free;
if l.Count = 0 then
begin
AssignFile(t, thBuildToFolder + 'mia.tmp',cp_utf8);
ReWrite(t);
CloseFile(t);
l.Add(thBuildToFolder + 'mia.tmp');
end;
{$IFDEF WINDOWS}
if BuildForm = 2 then
begin
l.Add(EXEDIR + 'libeay32.dll');
l.Add(EXEDIR + 'ssleay32.dll');
end;
{$ENDIF}
{$IFDEF LINUX}
if BuildForm = 2 then
begin
l.Add(EXEDIR + 'libcrypto.so.1.1');
l.Add(EXEDIR + 'libssl.so.1.1');
end;
{$ENDIF}
{$IFDEF DARWIN}
l.Add(s + '.msi');
if thProjectStruct.aSign then
l.Add(EXEDIR + 'macos/miaxstub');
{$ENDIF}
szMode := SStoringSupportFiles;