Skip to content

Commit

Permalink
Better handling of module install and removal.
Browse files Browse the repository at this point in the history
  • Loading branch information
LongDirtyAnimAlf committed Mar 16, 2023
1 parent eeaad17 commit 7a22f41
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 59 deletions.
5 changes: 5 additions & 0 deletions sources/gitclient.pas
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ procedure TGitClient.Update;
begin
// Just do a simple pull
Command := ' pull';
end
else
begin
// First do a fetch to get all the current commits
if (NOT ExportOnly) then TInstaller(Parent).ExecuteCommandInDir(DoubleQuoteIfNeeded(FRepoExecutable) + ' fetch', LocalRepository, Output, Verbose);
end;

FReturnCode := TInstaller(Parent).ExecuteCommandInDir(DoubleQuoteIfNeeded(FRepoExecutable) + command, LocalRepository, Output, Verbose);
Expand Down
11 changes: 8 additions & 3 deletions sources/installercore.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,6 @@ function TInstaller.DownloadFromBase(aClient:TRepoClient; aModuleName: string; v
//aClient.Verbose := FVerbose;
aClient.LocalRepository := FSourceDirectory;
aClient.Repository := FURL;
aClient.ExportOnly := FExportOnly;
aClient.ModuleName := aModuleName;

//aBeforeRevision:=aClient.LocalRevision;
Expand Down Expand Up @@ -1791,6 +1790,10 @@ function TInstaller.DownloadFromBase(aClient:TRepoClient; aModuleName: string; v
aClient.DesiredBranch := FBranch; //We want to update to this specific branch
aClient.DesiredTag := FTAG; //We want to update to this specific tag

// Setting a DesiredTag also set ExportOnly when using GIT.
// Override this setting if false with global setting
if (NOT aClient.ExportOnly) then aClient.ExportOnly:=FExportOnly;

Output:=localinfotext+'Running '+UpperCase(aClient.RepoExecutableName)+' checkout or update';
ReturnCode:=Length(aClient.DesiredRevision);
if (ReturnCode>0) then Output:=Output+' of revision '+aClient.DesiredRevision;
Expand Down Expand Up @@ -3260,7 +3263,6 @@ function TInstaller.CheckModule(ModuleName: string): boolean;
Infoln(infotext+'Entering ...',etDebug);

if NOT DirectoryExists(FSourceDirectory) then exit;
if FExportOnly then exit;

aRepoClient:=GetSuitableRepoClient;

Expand All @@ -3284,14 +3286,17 @@ function TInstaller.CheckModule(ModuleName: string): boolean;
Infoln(infotext+'Checking ' + ModuleName + ' sources with '+TrimLeft(Copy(UnCamel(aRepoClient.ClassName),2,MaxInt)),etInfo);

aRepoClient.Verbose := FVerbose;
aRepoClient.ExportOnly := FExportOnly;
aRepoClient.ModuleName := ModuleName;
aRepoClient.LocalRepository := FSourceDirectory;
aRepoClient.Repository := FURL;
aRepoClient.DesiredTag := FTAG;
aRepoClient.DesiredBranch := FBranch;
aRepoClient.DesiredRevision := FDesiredRevision;

// Setting a DesiredTag also set ExportOnly when using GIT.
// Override this setting if false with global setting
if (NOT aRepoClient.ExportOnly) then aRepoClient.ExportOnly := FExportOnly;

if (NOT DirectoryExists(aRepoClient.LocalRepository)) OR (DirectoryIsEmpty(aRepoClient.LocalRepository)) then
begin
result:=true;
Expand Down
6 changes: 4 additions & 2 deletions sources/installeruniversal.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1924,8 +1924,8 @@ function TUniversalInstaller.GetModule(ModuleName: string): boolean;
UpdateWarnings:=TStringList.Create;
try
URL:=RemoteURL;
GitClient.ModuleName:=ModuleName;
GitClient.ExportOnly:=FExportOnly;
GitClient.ModuleName := ModuleName;
GitClient.ExportOnly := FExportOnly;
result:=DownloadFromGit(ModuleName,BeforeRevision,AfterRevision,UpdateWarnings);
SourceOK:=(result) AND (DirectoryExists(IncludeTrailingPathDelimiter(SourceDirectory)+'.git') OR FExportOnly);
if UpdateWarnings.Count>0 then
Expand All @@ -1949,6 +1949,8 @@ function TUniversalInstaller.GetModule(ModuleName: string): boolean;
UpdateWarnings:=TStringList.Create;
try
URL:=RemoteURL;
SVNClient.ModuleName := ModuleName;
SVNClient.ExportOnly := FExportOnly;
SVNClient.UserName := GetValueFromKey('UserName',PackageSettings);
SVNClient.Password := GetValueFromKey('Password',PackageSettings);
result:=DownloadFromSVN(ModuleName,BeforeRevision,AfterRevision,UpdateWarnings);
Expand Down
6 changes: 3 additions & 3 deletions sources/updeluxe/fpcupdeluxemainform.lfm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Form1: TForm1
Left = 32
Left = 36
Height = 832
Top = 78
Top = 27
Width = 1226
Anchors = []
Caption = 'FPCUPdeluxe'
Expand Down Expand Up @@ -2388,7 +2388,7 @@ object Form1: TForm1
F203ECE8E4010000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000
}
OnClick = QuickBtnClick
OnClick = btnInstallModuleClick
ParentFont = False
ParentShowHint = False
ShowHint = True
Expand Down
83 changes: 35 additions & 48 deletions sources/updeluxe/fpcupdeluxemainform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ TForm1 = class(TForm)
function PrepareRun(Sender: TObject):boolean;
function RealRun:boolean;
procedure GetSystemInfo;
procedure InstallModule(aModule:string; UnInstall:boolean);
function GetFPCUPSettings(IniDirectory:string):boolean;
function SetFPCUPSettings(IniDirectory:string):boolean;
procedure FillSourceListboxes;
Expand Down Expand Up @@ -2335,13 +2336,6 @@ procedure TForm1.QuickBtnClick(Sender: TObject);
aLazarusTarget:='trunk'+GITLABEXTENSION;
end;

if Sender=mORMotBtn then
begin
s:=Format(upInstallConfimationSimple,['mORMot2']);
aModule:='mORMot2';
//aModule:='mORMot,zeos';
end;

if Sender=UltiboBtn then
begin
s:=Format(upInstallConfimationSimple,['Ultibo']);
Expand Down Expand Up @@ -2403,6 +2397,9 @@ procedure TForm1.QuickBtnClick(Sender: TObject);
FPCupManager.IncludeModules:=FPCupManager.IncludeModules+_LHELP;
end;




{$ifdef RemoteLog}
if ((Length(aFPCTarget)>0) OR (Length(aLazarusTarget)>0)) then
begin
Expand Down Expand Up @@ -2569,43 +2566,36 @@ procedure TForm1.QuickBtnClick(Sender: TObject);
end;

procedure TForm1.btnInstallModuleClick(Sender: TObject);
var
//i:integer;
modules:string;
s:string;
begin
if listModules.SelCount=0 then
begin
AddMessage('Please select a module / package.');
exit;
end;

modules:='';

//No multi-select for now
(*
for i:=0 to listModules.Count-1 do
if (Sender=btnInstallModule) OR (Sender=btnUninstallModule) then
begin
if listModules.Selected[i] then
if ((listModules.SelCount=0) OR (listModules.ItemIndex=-1)) then
begin
modules:=modules+listModules.Items[i];
if Sender=btnUninstallModule then modules:=modules+_UNINSTALL else
begin
if Form2.UpdateOnly then modules:=modules+_BUILD+_ONLY;
end;
modules:=modules+',';
AddMessage('Please select a module / package.');
exit;
end;
end;
*)
DisEnable(Sender,False);
try
if (Sender=mORMotBtn) then
InstallModule('mORMot2',false)
else
InstallModule(listModules.Items.Strings[listModules.ItemIndex],(Sender=btnUninstallModule));
finally
DisEnable(Sender,True);
end;
end;

//Single select
if (listModules.ItemIndex<>-1) then
procedure TForm1.InstallModule(aModule:string; UnInstall:boolean);
var
modules:string;
s:string;
begin
modules:=aModule;

if UnInstall then modules:=modules+_UNINSTALL else
begin
modules:=listModules.Items.Strings[listModules.ItemIndex];
if Sender=btnUninstallModule then modules:=modules+_UNINSTALL else
begin
if Form2.UpdateOnly then modules:=modules+_BUILD+_ONLY;
end;
if Form2.UpdateOnly then modules:=modules+_BUILD+_ONLY;
end;

if Length(modules)>0 then
Expand All @@ -2616,8 +2606,8 @@ procedure TForm1.btnInstallModuleClick(Sender: TObject);
s:=modules;
s:=StringReplace(s,_UNINSTALL,'',[rfReplaceAll]);
s:=StringReplace(s,_BUILD+_ONLY,'',[rfReplaceAll]);
if Sender=btnInstallModule then s:=upInstallModule+': '+s;
if Sender=btnUninstallModule then s:=upRemoveModule+': '+s;
if (NOT UnInstall) then s:=upInstallModule+': '+s;
if UnInstall then s:=upRemoveModule+': '+s;
s:=s+'.'+sLineBreak;
s:=s+upInstallDirectory+': '+Self.sInstallDir;
s:=s+sLineBreak;
Expand All @@ -2626,7 +2616,7 @@ procedure TForm1.btnInstallModuleClick(Sender: TObject);
if (MessageDlgEx(s,mtConfirmation,[mbYes, mbNo],Self)<>mrYes) then
exit;

if Sender=btnInstallModule then
if (NOT UnInstall) then
begin
AddMessage('Limiting installation/update to '+FPCupManager.OnlyModules);
AddMessage('');
Expand All @@ -2639,31 +2629,28 @@ procedure TForm1.btnInstallModuleClick(Sender: TObject);
sStatus:='Going to remove selected modules.';
end;

DisEnable(Sender,False);
try
if (NOT PrepareRun(Sender)) then exit;
if (NOT PrepareRun(nil)) then exit;

FPCupManager.ExportOnly:=(NOT Form2.PackageRepo);
FPCupManager.ExportOnly:=(NOT Form2.PackageRepo);
try
FPCupManager.OnlyModules:=modules;

{$ifdef RemoteLog}
s:=modules;
s:=StringReplace(s,_UNINSTALL,'',[rfReplaceAll]);
s:=StringReplace(s,_BUILD+_ONLY,'',[rfReplaceAll]);
aDataClient.AddExtraData('module[s]:',s);
if Sender=btnInstallModule then aDataClient.UpInfo.UpFunction:=ufInstallModule;
if Sender=btnUninstallModule then aDataClient.UpInfo.UpFunction:=ufUninstallModule;
if (NOT UnInstall) then aDataClient.UpInfo.UpFunction:=ufInstallModule;
if UnInstall then aDataClient.UpInfo.UpFunction:=ufUninstallModule;
{$endif}

RealRun;

finally
FPCupManager.ExportOnly:=(NOT Form2.Repo);
DisEnable(Sender,True);
end;

end;

end;

procedure TForm1.btnInstallDirSelectClick(Sender: TObject);
Expand Down
6 changes: 3 additions & 3 deletions sources/zipper.pp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
File_Comment_Length : Word;
Starting_Disk_Num : Word;
Internal_Attributes : Word;
External_Attributes : LongWord;
External_Attributes : Longint;
Local_Header_Offset : LongWord; // if zip64: 0xFFFFFFFF
End;

Expand Down Expand Up @@ -355,7 +355,7 @@
FArchiveFileName: String; //Name of the file as it appears in the zip file list
FUTF8FileName : UTF8String;
FUTF8DiskFileName : UTF8String;
FAttributes: LongWord;
FAttributes: Longint;
FDateTime: TDateTime;
FDiskFileName: String; {Name of the file on disk (i.e. uncompressed. Can be empty if based on a stream.);
uses local OS/filesystem directory separators}
Expand Down Expand Up @@ -390,7 +390,7 @@
Property Size : Int64 Read FSize Write FSize;
Property DateTime : TDateTime Read FDateTime Write FDateTime;
property OS: Byte read FOS write FOS;
property Attributes: LongWord read FAttributes write FAttributes;
property Attributes: Longint read FAttributes write FAttributes;
Property CompressionLevel: TCompressionlevel read FCompressionLevel write FCompressionLevel;
end;

Expand Down

0 comments on commit 7a22f41

Please sign in to comment.