V0.2.3.0: WIP

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5655 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
gbamber 2017-01-15 19:00:32 +00:00
parent fe451a5fc9
commit f092ed6dd7
11 changed files with 197 additions and 82 deletions

View File

@ -55,8 +55,8 @@ More information in the Wiki Home Page http://wiki.freepascal.org/LazAutoUpdater
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"/>
<Version Minor="2" Release="2"/>
<Files Count="5">
<Version Minor="2" Release="3"/>
<Files Count="6">
<Item1>
<Filename Value="ulazautoupdate.pas"/>
<HasRegisterProc Value="True"/>
@ -79,6 +79,10 @@ More information in the Wiki Home Page http://wiki.freepascal.org/LazAutoUpdater
<Filename Value="lazautoupdate_httpclient.pas"/>
<UnitName Value="lazautoupdate_httpclient"/>
</Item5>
<Item6>
<Filename Value="open_ssl.pas"/>
<UnitName Value="open_ssl"/>
</Item6>
</Files>
<i18n>
<EnableI18N Value="True"/>

View File

@ -4,11 +4,12 @@
unit lazupdate;
{$warn 5023 off : no warning about unused units}
interface
uses
ulazautoupdate, aboutlazautoupdateunit, VersionSupport, uappisrunning,
lazautoupdate_httpclient, LazarusPackageIntf;
lazautoupdate_httpclient, open_ssl, LazarusPackageIntf;
implementation

View File

@ -0,0 +1,82 @@
unit open_ssl;
{$mode objfpc}{$H+}
interface
uses
// Built-in: fphttpclient
Classes, SysUtils,lazautoupdate_httpclient,LazFileUtils,FileUtil,zipper;
function CheckForOpenSSL:Boolean;
function OpenSSLInstalled:Boolean;
implementation
const
{$ifdef win64}
cOpenSSLURL = 'http://packages.lazarus-ide.org/openssl-1.0.2j-x64_86-win64.zip';
{$endif}
{$ifdef win32}
cOpenSSLURL = 'http://packages.lazarus-ide.org/openssl-1.0.2j-i386-win32.zip';
{$endif}
Var FHTTPClient:TFPHttpClient;
function OpenSSLInstalled:Boolean;
begin
{$IFDEF MSWINDOWS}
Result:= FileExistsUTF8(ExtractFilePath(ParamStr(0)) + 'libeay32.dll') and
FileExistsUTF8(ExtractFilePath(ParamStr(0)) + 'ssleay32.dll');
// Look in Windows system dir?
{$ELSE}
Result:=True;
{$ENDIF}
end;
Function CheckForOpenSSL:Boolean;
var
ZipFile: String;
UnZipper: TUnZipper;
begin
{$IFDEF MSWINDOWS}
Result:=FALSE;
if not OpenSSLInstalled then
begin
ZipFile := ExtractFilePath(ParamStr(0)) + ExtractFileName(cOpenSSLURL);
try
FHTTPClient.Get(cOpenSSLURL, ZipFile);
except
end;
if FileExistsUTF8(ZipFile) then
begin
UnZipper := TUnZipper.Create;
try
try
UnZipper.FileName := ZipFile;
UnZipper.Examine;
UnZipper.UnZipAllFiles;
except
end;
finally
UnZipper.Free;
end;
DeleteFileUTF8(ZipFile);
Result:=OpenSSLInstalled;
end;
end
else
Result:=True;
{$ELSE}
Result:=True;
{$ENDIF}
end;
initialization
begin
FHTTPClient:=TFPHttpClient.Create(nil);
end;
finalization
begin
FreeAndNil(FHTTPClient);
end;
end.

View File

@ -0,0 +1,2 @@
http://indy.fulgan.com/SSL/openssl-1.0.2j-i386-win32.zip
http://indy.fulgan.com/SSL/openssl-1.0.2j-x64_86-win64.zip

View File

@ -33,6 +33,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value=".."/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>
@ -165,7 +166,7 @@
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="2">
<Units Count="3">
<Unit0>
<Filename Value="testapp.lpr"/>
<IsPartOfProject Value="True"/>
@ -177,6 +178,10 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
<Unit2>
<Filename Value="..\open_ssl.pas"/>
<IsPartOfProject Value="True"/>
</Unit2>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -35,7 +35,7 @@ uses
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, umainform
Forms, umainform, open_ssl
{ you can add units after this };
{$R *.res}

View File

@ -4,13 +4,13 @@
<PathDelim Value="\"/>
<Version Value="10"/>
<BuildModes Active="Win32"/>
<Units Count="12">
<Units Count="13">
<Unit0>
<Filename Value="testapp.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="5"/>
<CursorPos X="33" Y="27"/>
<UsageCount Value="36"/>
<UsageCount Value="38"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -19,32 +19,31 @@
<ComponentName Value="mainform"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<TopLine Value="74"/>
<CursorPos X="3" Y="76"/>
<UsageCount Value="36"/>
<TopLine Value="12"/>
<CursorPos X="43" Y="13"/>
<UsageCount Value="38"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="..\lazautoupdate_httpclient.pas"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/>
<TopLine Value="251"/>
<CursorPos X="27" Y="282"/>
<UsageCount Value="17"/>
<CursorPos X="28" Y="15"/>
<UsageCount Value="18"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="..\ulazautoupdate.pas"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
<TopLine Value="1210"/>
<CursorPos X="23" Y="1029"/>
<WindowIndex Value="1"/>
<TopLine Value="28"/>
<CursorPos X="3" Y="746"/>
<ExtraEditorCount Value="2"/>
<ExtraEditor1>
<IsVisibleTab Value="True"/>
<WindowIndex Value="1"/>
<TopLine Value="903"/>
<CursorPos X="6" Y="922"/>
<EditorIndex Value="3"/>
<TopLine Value="1135"/>
<CursorPos X="11" Y="1225"/>
</ExtraEditor1>
<ExtraEditor2>
<EditorIndex Value="-1"/>
@ -52,7 +51,7 @@
<TopLine Value="-1"/>
<CursorPos X="-1" Y="-1"/>
</ExtraEditor2>
<UsageCount Value="17"/>
<UsageCount Value="18"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
@ -96,7 +95,7 @@
<EditorIndex Value="1"/>
<TopLine Value="25"/>
<CursorPos X="25" Y="55"/>
<UsageCount Value="15"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
</Unit9>
<Unit10>
@ -111,130 +110,140 @@
<EditorIndex Value="4"/>
<TopLine Value="25"/>
<CursorPos X="71" Y="44"/>
<UsageCount Value="12"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit11>
<Unit12>
<Filename Value="..\open_ssl.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<WindowIndex Value="1"/>
<TopLine Value="22"/>
<CursorPos X="25" Y="35"/>
<UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit12>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="910" Column="37" TopLine="872"/>
<Caret Line="182" Column="58" TopLine="154"/>
</Position1>
<Position2>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1062" Column="3" TopLine="1021"/>
<Caret Line="913" Column="35" TopLine="875"/>
</Position2>
<Position3>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="51" Column="9" TopLine="25"/>
<Caret Line="123" Column="52" TopLine="115"/>
</Position3>
<Position4>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="900" Column="21" TopLine="894"/>
<Caret Line="56" Column="3" TopLine="33"/>
</Position4>
<Position5>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="371" TopLine="351"/>
<Caret Line="165" Column="36" TopLine="147"/>
</Position5>
<Position6>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="909" Column="37" TopLine="891"/>
<Caret Line="913" Column="38" TopLine="891"/>
</Position6>
<Position7>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1071" Column="38" TopLine="1039"/>
<Caret Line="1074" Column="38" TopLine="1053"/>
</Position7>
<Position8>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="48" Column="19" TopLine="25"/>
<Caret Line="182" Column="51" TopLine="159"/>
</Position8>
<Position9>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="923" TopLine="887"/>
<Caret Line="935" TopLine="900"/>
</Position9>
<Position10>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1075" TopLine="1040"/>
<Caret Line="1059" TopLine="1037"/>
</Position10>
<Position11>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="48" Column="19" TopLine="25"/>
<Caret Line="1974" TopLine="1945"/>
</Position11>
<Position12>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="929" TopLine="890"/>
<Caret Line="54" Column="18" TopLine="44"/>
</Position12>
<Position13>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="182" Column="58" TopLine="154"/>
<Caret Line="935" Column="89" TopLine="901"/>
</Position13>
<Position14>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="913" Column="35" TopLine="875"/>
<Filename Value="umainform.pas"/>
<Caret Line="108" Column="43" TopLine="88"/>
</Position14>
<Position15>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="123" Column="52" TopLine="115"/>
<Caret Line="51" Column="20" TopLine="35"/>
</Position15>
<Position16>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="56" Column="3" TopLine="33"/>
<Caret Line="914" TopLine="893"/>
</Position16>
<Position17>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="165" Column="36" TopLine="147"/>
<Caret Line="1076" TopLine="1039"/>
</Position17>
<Position18>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="913" Column="38" TopLine="891"/>
<Caret Line="180" Column="33" TopLine="157"/>
</Position18>
<Position19>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1074" Column="38" TopLine="1053"/>
<Filename Value="umainform.pas"/>
<Caret Line="76" Column="3" TopLine="74"/>
</Position19>
<Position20>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="182" Column="51" TopLine="159"/>
<Filename Value="umainform.pas"/>
<Caret Line="129" Column="3" TopLine="92"/>
</Position20>
<Position21>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="935" TopLine="900"/>
<Filename Value="umainform.pas"/>
<Caret Line="122" Column="3" TopLine="92"/>
</Position21>
<Position22>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1059" TopLine="1037"/>
<Filename Value="..\open_ssl.pas"/>
<Caret Line="8" Column="25"/>
</Position22>
<Position23>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1974" TopLine="1945"/>
<Filename Value="..\open_ssl.pas"/>
<Caret Line="6" Column="43"/>
</Position23>
<Position24>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="54" Column="18" TopLine="44"/>
<Filename Value="..\open_ssl.pas"/>
<Caret Line="8" Column="37"/>
</Position24>
<Position25>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="935" Column="89" TopLine="901"/>
<Filename Value="..\open_ssl.pas"/>
<Caret Line="25" Column="26" TopLine="5"/>
</Position25>
<Position26>
<Filename Value="umainform.pas"/>
<Caret Line="108" Column="43" TopLine="88"/>
<Filename Value="..\open_ssl.pas"/>
<Caret Line="8" Column="47"/>
</Position26>
<Position27>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="51" Column="20" TopLine="35"/>
<Filename Value="..\open_ssl.pas"/>
<Caret Line="71" Column="23" TopLine="32"/>
</Position27>
<Position28>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="914" TopLine="893"/>
<Filename Value="..\open_ssl.pas"/>
<Caret Line="68" Column="27" TopLine="34"/>
</Position28>
<Position29>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1076" TopLine="1039"/>
<Filename Value="..\open_ssl.pas"/>
<Caret Line="48" Column="6" TopLine="25"/>
</Position29>
<Position30>
<Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="180" Column="33" TopLine="157"/>
<Filename Value="..\open_ssl.pas"/>
<Caret Line="29" Column="18"/>
</Position30>
</JumpHistory>
</ProjectSession>

View File

@ -1,7 +1,7 @@
object mainform: Tmainform
Left = 716
Left = 682
Height = 209
Top = 296
Top = 277
Width = 335
BorderIcons = [biSystemMenu]
Caption = 'mainform'
@ -112,7 +112,7 @@ object mainform: Tmainform
OnDownloaded = LazAutoUpdate1Downloaded
OnDebugEvent = LazAutoUpdate1DebugEvent
SFProjectName = 'lazautoupdate'
auOtherSourceURL = '<not applicable>'
auOtherSourceURL = '<not applicable>/'
auOtherSourceFilename = '<not applicable>'
CopyTree = False
UpdatesFolder = 'updates'

View File

@ -39,7 +39,7 @@ uses
LazUTF8, FileUtil, LazFileUtils, Dialogs, StdCtrls,
Buttons, DateUtils, asyncprocess, zipper, LResources,
VersionSupport, inifiles, aboutlazautoupdateunit, uappisrunning, LCLProc,
fileinfo, winpeimagereader {need this for reading exe info}
fileinfo,open_ssl, winpeimagereader {need this for reading exe info}
, elfreader {needed for reading ELF executables}
, machoreader {needed for reading MACH-O executables}
{$IFDEF WINDOWS}, Windows, ShellAPI{$ENDIF}; // Thanks to Windows 10 and 704 error
@ -48,10 +48,12 @@ const
C_SOURCEFORGEURL =
'https://sourceforge.net/projects/%s/files/%s/%s/download';
// [updatepath,projectname,filename]
C_GITHUBFILEURL = 'https://raw.github.com/%s/%s/master/%s/%s';
// C_GITHUBFILE_URL = 'https://raw.github.com/%s/%s/master/%s/%s';
C_GITHUBFILE_URL = 'https://raw.github.com/%s/%s/%s/%s/%s';
C_GITHUBFILE_URL_UPDATES = 'https://raw.github.com/%s/%s/%s/%s/%s/%s';
// https://raw.github.com/<username>/<repo>/<branch>/some_directory/file
// GitHubUserName,GitHubProjectName,updatepath,filename
C_TLazAutoUpdateComponentVersion = '0.2.2';
C_TLazAutoUpdateComponentVersion = '0.2.3';
C_LAUTRayINI = 'lauimport.ini';
{
@ -116,6 +118,7 @@ const
C_INISection = 'versions';
C_GUIEntry = 'GUI';
C_ModuleEntry = 'Module';
C_MASTER = 'master';
{$IFDEF WINDOWS}
{$IFDEF CPU32}C_UPDATER = 'updatehmwin32.exe';
C_LOCALUPDATER = 'lauupdatewin32.exe';{$ENDIF}
@ -177,7 +180,7 @@ type
type
TProjectType = (auSourceForge,auGitHubUpdateZip, auOther);
TProjectType = (auSourceForge,auGitHubReleaseZip,auOther);
// Array of these records used for multiple updates
UpdateListRecord = record
PrettyName: string;
@ -199,6 +202,7 @@ type
fSourceForgeProjectName: string;
fGitHubUsername:String;
fGitHubProjectName:String;
fGitHubBranch:String;
fApplicationVersionString: string;
fApplicationVersionQuad: TVersionQuad;
fGuiQuad: TVersionQuad;
@ -367,7 +371,7 @@ type
property UpdateExeSilent:String read fUpdateSilentExe;
property GitHubUsername:String read fGitHubUsername write fGitHubUsername;
Property GitHubProjectName:String read fGitHubProjectName write fGitHubProjectName;
Property GitHubBranch:String read fGitHubBranch write fGitHubBranch;
end;
{TThreadedDownload }
@ -882,7 +886,6 @@ var
szOldCaption: string;
begin
Result := False;
// read the VMT once
if Assigned(fOndebugEvent) then
fFireDebugEvent := True;
@ -908,7 +911,7 @@ begin
szURL := Format(C_SOURCEFORGEURL, [fSourceForgeProjectName,
fUpdatesFolder, fVersionsININame]);
end;
if fProjectType = auGitHubUpdateZip then
if fProjectType = auGitHubReleaseZip then
begin
if ((fGitHubUserName = '') or (fGitHubProjectName = '')) then
begin
@ -918,8 +921,8 @@ begin
fOndebugEvent(Self, 'NewVersionAvailable', C_PropIsEmpty);
Exit;
end;
szURL := Format(C_GITHUBFILEURL,
[fGitHubUserName,fGitHubProjectName,fUpdatesFolder,fVersionsININame]);
szURL := Format(C_GITHUBFILE_URL,
[fGitHubUserName,fGitHubProjectName,fGitHubBranch,fVersionsININame]);
end;
if fProjectType = auOther then
// fauOtherSourceURL ends with '/'
@ -967,6 +970,7 @@ begin
fDownloadInprogress := True;
if not fSilentMode then
fParentForm.Caption := C_Checking;
CheckForOpenSSL;
// Start the thread
ThreadDownloadHTTP;
if fFireDebugEvent then
@ -1070,8 +1074,11 @@ begin
if fProjectType = auSourceForge then
szURL := Format(C_SOURCEFORGEURL, [fSourceForgeProjectName, fUpdatesFolder,
ExtractFileName(szTargetPath)]);
if fProjectType = auGitHubUpdateZip then
szURL := Format(C_GITHUBFILEURL, [fGitHubUserName,fGitHubProjectName,fUpdatesFolder,fZipfileName]);
if fProjectType = auGitHubReleaseZip then
If ((fUpdatesFolder=C_NotApplicable) or (fUpdatesFolder='')) then
szURL := Format(C_GITHUBFILE_URL, [fGitHubUserName,fGitHubProjectName,fGitHubBranch,fZipfileName])
else
szURL := Format(C_GITHUBFILE_URL_UPDATES, [fGitHubUserName,fGitHubProjectName,fGitHubBranch,fUpdatesFolder,fZipfileName]);
if fProjectType = auOther then
// fauOtherSourceURL ends with '/'
begin
@ -1152,6 +1159,7 @@ begin
end;
fDownloadInprogress := True;
CheckForOpenSSL;
// Do the download
with fThreadDownload do
begin
@ -1931,6 +1939,7 @@ begin
fSourceForgeProjectName := C_NotApplicable;
fGitHubProjectName := C_NotApplicable;
fGitHubUserName := C_NotApplicable;
fGitHubBranch:=C_NotApplicable;
fauOtherSourceFilename:='';
fauOtherSourceURL:='';
end;
@ -1942,16 +1951,19 @@ begin
fauOtherSourceURL := C_NotApplicable;
fGitHubProjectName := C_NotApplicable;
fGitHubUserName := C_NotApplicable;
fGitHubBranch:=C_NotApplicable;
end;
if fProjectType = auGitHubUpdateZip then
if fProjectType = auGitHubReleaseZip then
begin
fZipFileName:=ChangeFileExt(fVersionsININame,'.zip');
fUpdatesFolder := C_UpdatesFolder;
fSourceForgeProjectName := C_NotApplicable;
fauOtherSourceFilename := C_NotApplicable;
fauOtherSourceURL := C_NotApplicable;
fGitHubBranch:= C_MASTER;
fGitHubProjectName := '';
fGitHubUserName := '';
fUpdatesFolder:=C_NotApplicable;
end;

View File

@ -9,7 +9,7 @@
"ForceNotify" : true,
"InternalVersion" : 2,
"Name" : "lazupdate.lpk",
"Version" : "0.2.2.0"
"Version" : "0.2.3.0"
}
]
}