Skip to content

Commit

Permalink
Implemented installer for embedded tools by Michael.
Browse files Browse the repository at this point in the history
  • Loading branch information
LongDirtyAnimAlf committed Feb 23, 2021
1 parent ec96943 commit 6fc08a2
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Temporary Items
*.pot

logger/secrets.inc
secrets.inc
secrets/

*.log
libfpcup/
Expand Down
11 changes: 10 additions & 1 deletion fpcup.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
; ... and you can define your own, like below:

[fpcupinfo]
inifileversion=1.1.8.21
inifileversion=1.1.8.22

[ALIASfpcURL]
stable=https://svn.freepascal.org/svn/fpc/tags/release_3_2_0
Expand Down Expand Up @@ -2498,3 +2498,12 @@ ArchiveURL=https://services.gradle.org/distributions/gradle-6.5-bin.zip
UninstallExecute=$(terminal) $(Installdir)/bin/gradle --stop
UnInstall=rm -Rf $(Installdir)

[HiddenModule14]
Name=develtools4fpc
Description="Microcontroller Tools."
Category=development,embedded
Installdir=$(basedir)/ccr/$(name)
Enabled=0
GITURL=https://github.com/michael-ring/develtools4fpc
UnInstall=rm -Rf $(Installdir)

Binary file modified fpcupdeluxe.res
Binary file not shown.
17 changes: 7 additions & 10 deletions fpcupdeluxemainform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1936,23 +1936,20 @@ procedure TForm1.QuickBtnClick(Sender: TObject);
end;
}

if Sender=PicoBtn then
if (Sender=WioBtn) OR (Sender=PicoBtn) then
begin
s:='Going to install FPC and Lazarus for Raspberry Pico.';
if Sender=PicoBtn then
s:='Going to install FPC and Lazarus for Raspberry Pico.';
if Sender=WioBtn then
s:='Going to install FPC and Lazarus for Wio Terminal.';
aFPCTarget:='embedded-mir';
aLazarusTarget:='embedded';
aModule:='develtools4fpc';
//aModule:='mbf-freertos';
//aModule:='mbf,pxl';
//aModule:='mbf';
end;

if Sender=WioBtn then
begin
s:='Going to install FPC and Lazarus for Wio Terminal.';
aFPCTarget:='embedded-mir';
aLazarusTarget:='embedded';
//aModule:='mbf-freertos';
end;

if Sender=mORMotBtn then
begin
s:='Going to install the mORMot.';
Expand Down
9 changes: 5 additions & 4 deletions installermanager.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1528,10 +1528,11 @@ function TSequencer.GetInstaller(ModuleName: string): boolean;
end;

case ModuleName of
'awgg' : FInstaller:=TAWGGInstaller.Create;
'mORMotPXL' : FInstaller:=TmORMotPXLInstaller.Create;
'internettools' : FInstaller:=TInternetToolsInstaller.Create;
'pas2js-rtl' :FInstaller:=TPas2jsInstaller.Create;
'awgg' : FInstaller:=TAWGGInstaller.Create;
'mORMotPXL' : FInstaller:=TmORMotPXLInstaller.Create;
'internettools' : FInstaller:=TInternetToolsInstaller.Create;
'develtools4fpc' : FInstaller:=TDeveltools4FPCInstaller.Create;
'pas2js-rtl' : FInstaller:=TPas2jsInstaller.Create;
else
FInstaller:=TUniversalInstaller.Create;
end;
Expand Down
91 changes: 91 additions & 0 deletions installeruniversal.pas
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ TInternetToolsInstaller = class(TUniversalInstaller)
function GetModule(ModuleName: string): boolean; override;
end;

{ TDeveltools4FPCInstaller }
TDeveltools4FPCInstaller = class(TUniversalInstaller)
public
function GetModule(ModuleName: string): boolean; override;
end;


// Gets the list of modules enabled in ConfigFile. Appends to existing TStringList
function GetModuleEnabledList(var ModuleList:TStringList):boolean;
Expand Down Expand Up @@ -1802,6 +1808,7 @@ function TUniversalInstaller.GetModule(ModuleName: string): boolean;
WritelnLog(infotext+'Going to download '+RemoteURL+' into '+aFile,false);
try
result:=Download(FUseWget, RemoteURL, aFile);
if result then result:=FileExists(aFile);
except
on E: Exception do
begin
Expand Down Expand Up @@ -2407,6 +2414,90 @@ function TInternetToolsInstaller.GetModule(ModuleName: string): boolean;
end;
end;

function TDeveltools4FPCInstaller.GetModule(ModuleName: string): boolean;
var
idx:integer;
PackageSettings:TStringList;
RemoteURL:string;
aName,aFile:string;
ResultCode: longint;
begin
result:=InitModule;
if not result then exit;

ResultCode:=-1;

idx:=UniModuleList.IndexOf(ModuleName);
if idx>=0 then
begin
WritelnLog(infotext+'Getting module '+ModuleName,True);

PackageSettings:=TStringList(UniModuleList.Objects[idx]);
FSourceDirectory:=GetValueFromKey('InstallDir',PackageSettings);
FSourceDirectory:=FixPath(FSourceDirectory);
FSourceDirectory:=ExcludeTrailingPathDelimiter(FSourceDirectory);

if (FSourceDirectory<>'') then
begin

ForceDirectoriesSafe(FSourceDirectory);

RemoteURL:=GetValueFromKey('GITURL',PackageSettings);
if (RemoteURL<>'') then
begin
RemoteURL:=RemoteURL+'/releases/download/v1.0.0-1/develtools4fpc-'+GetTargetCPUOS+'.zip';
Infoln(infotext+'Going to download from archive '+RemoteURL,etInfo);
aName:=FileNameFromURL(RemoteURL);
if Length(aName)>0 then
begin
aName:=SysUtils.ExtractFileExt(aName);
if Length(aName)>0 then
begin
if aName[1]='.' then Delete(aName,1,1);
end;
end;
//If no extension, assume zip
if Length(aName)=0 then aName:='zip';
aFile := GetTempFileNameExt('FPCUPTMP',aName);
WritelnLog(infotext+'Going to download '+RemoteURL+' into '+aFile,false);
try
result:=Download(FUseWget, RemoteURL, aFile);
if result then result:=FileExists(aFile);
except
on E: Exception do
begin
result:=false;
end;
end;

if result then
begin
ResultCode:=-1;
WritelnLog(infotext+'Download ok',True);

if DirectoryExists(FSourceDirectory) then DeleteDirectoryEx(FSourceDirectory);

with TNormalUnzipper.Create do
begin
try
ResultCode:=Ord(NOT DoUnZip(aFile,IncludeTrailingPathDelimiter(FSourceDirectory),[]));
finally
Free;
end;
end;
if (ResultCode<>0) then
begin
result := False;
Infoln(infotext+'Unpack of '+aFile+' failed with resultcode: '+IntToStr(ResultCode),etwarning);
end;
end;

SysUtils.Deletefile(aFile); //Get rid of temp file.
end;
end;
end;
end;

procedure ClearUniModuleList;
var
i:integer;
Expand Down

0 comments on commit 6fc08a2

Please sign in to comment.