You've already forked lazarus-ccr
updatehm Companion to Lazautoupdate component (see wiki page)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5327 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
BIN
components/lazautoupdate/updatehmcompiled/linux32/updatehm
Normal file
BIN
components/lazautoupdate/updatehmcompiled/linux32/updatehm
Normal file
Binary file not shown.
BIN
components/lazautoupdate/updatehmcompiled/linux64/updatehm
Normal file
BIN
components/lazautoupdate/updatehmcompiled/linux64/updatehm
Normal file
Binary file not shown.
BIN
components/lazautoupdate/updatehmcompiled/win32/updatehm.exe
Normal file
BIN
components/lazautoupdate/updatehmcompiled/win32/updatehm.exe
Normal file
Binary file not shown.
BIN
components/lazautoupdate/updatehmcompiled/win64/updatehm.exe
Normal file
BIN
components/lazautoupdate/updatehmcompiled/win64/updatehm.exe
Normal file
Binary file not shown.
233
components/lazautoupdate/updatehmsource/updatehm.lpi
Normal file
233
components/lazautoupdate/updatehmsource/updatehm.lpi
Normal file
@ -0,0 +1,233 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<CONFIG>
|
||||||
|
<ProjectOptions>
|
||||||
|
<Version Value="9"/>
|
||||||
|
<General>
|
||||||
|
<Flags>
|
||||||
|
<MainUnitHasCreateFormStatements Value="False"/>
|
||||||
|
<MainUnitHasTitleStatement Value="False"/>
|
||||||
|
</Flags>
|
||||||
|
<SessionStorage Value="InProjectDir"/>
|
||||||
|
<MainUnit Value="0"/>
|
||||||
|
<Title Value="LazUpdate Updater"/>
|
||||||
|
<UseAppBundle Value="False"/>
|
||||||
|
<ResourceType Value="res"/>
|
||||||
|
<XPManifest>
|
||||||
|
<ExecutionLevel Value="1"/>
|
||||||
|
<UIAccess Value="True"/>
|
||||||
|
</XPManifest>
|
||||||
|
</General>
|
||||||
|
<i18n>
|
||||||
|
<EnableI18N LFM="False"/>
|
||||||
|
</i18n>
|
||||||
|
<VersionInfo>
|
||||||
|
<UseVersionInfo Value="True"/>
|
||||||
|
<RevisionNr Value="13"/>
|
||||||
|
<StringTable Comments="updatehm -h for list of parameters" CompanyName="minesadorada@charcodelvalle.com" FileDescription="Console updater for LazAutoUpdate component" InternalName="updatehm" LegalCopyright="LGPLv2" OriginalFilename="updatehm.exe" ProductName="LazAutoUpdate"/>
|
||||||
|
</VersionInfo>
|
||||||
|
<BuildModes Count="6">
|
||||||
|
<Item1 Name="Default" Default="True"/>
|
||||||
|
<Item2 Name="Debug">
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="updates\updatehm"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<Parsing>
|
||||||
|
<SyntaxOptions>
|
||||||
|
<IncludeAssertionCode Value="True"/>
|
||||||
|
</SyntaxOptions>
|
||||||
|
</Parsing>
|
||||||
|
<CodeGeneration>
|
||||||
|
<Checks>
|
||||||
|
<IOChecks Value="True"/>
|
||||||
|
<RangeChecks Value="True"/>
|
||||||
|
<OverflowChecks Value="True"/>
|
||||||
|
<StackChecks Value="True"/>
|
||||||
|
</Checks>
|
||||||
|
</CodeGeneration>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<DebugInfoType Value="dsDwarf2Set"/>
|
||||||
|
<UseHeaptrc Value="True"/>
|
||||||
|
<UseExternalDbgSyms Value="True"/>
|
||||||
|
</Debugging>
|
||||||
|
</Linking>
|
||||||
|
</CompilerOptions>
|
||||||
|
</Item2>
|
||||||
|
<Item3 Name="Win32 Release">
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="..\updatehmcompiled\win32\updatehm"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<CodeGeneration>
|
||||||
|
<SmartLinkUnit Value="True"/>
|
||||||
|
<TargetCPU Value="i386"/>
|
||||||
|
<TargetOS Value="win32"/>
|
||||||
|
<Optimizations>
|
||||||
|
<OptimizationLevel Value="3"/>
|
||||||
|
</Optimizations>
|
||||||
|
<SmallerCode Value="True"/>
|
||||||
|
</CodeGeneration>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<GenerateDebugInfo Value="False"/>
|
||||||
|
</Debugging>
|
||||||
|
<LinkSmart Value="True"/>
|
||||||
|
</Linking>
|
||||||
|
</CompilerOptions>
|
||||||
|
</Item3>
|
||||||
|
<Item4 Name="Win64 Release">
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="..\updatehmcompiled\win64\updatehm"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<CodeGeneration>
|
||||||
|
<SmartLinkUnit Value="True"/>
|
||||||
|
<TargetCPU Value="x86_64"/>
|
||||||
|
<TargetOS Value="win64"/>
|
||||||
|
<Optimizations>
|
||||||
|
<OptimizationLevel Value="3"/>
|
||||||
|
</Optimizations>
|
||||||
|
<SmallerCode Value="True"/>
|
||||||
|
</CodeGeneration>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<GenerateDebugInfo Value="False"/>
|
||||||
|
</Debugging>
|
||||||
|
<LinkSmart Value="True"/>
|
||||||
|
</Linking>
|
||||||
|
</CompilerOptions>
|
||||||
|
</Item4>
|
||||||
|
<Item5 Name="Linux32 Release">
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="..\updatehmcompiled\linux32\updatehm"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<CodeGeneration>
|
||||||
|
<SmartLinkUnit Value="True"/>
|
||||||
|
<TargetCPU Value="i386"/>
|
||||||
|
<TargetOS Value="linux"/>
|
||||||
|
<Optimizations>
|
||||||
|
<OptimizationLevel Value="3"/>
|
||||||
|
</Optimizations>
|
||||||
|
<SmallerCode Value="True"/>
|
||||||
|
</CodeGeneration>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<GenerateDebugInfo Value="False"/>
|
||||||
|
</Debugging>
|
||||||
|
<LinkSmart Value="True"/>
|
||||||
|
</Linking>
|
||||||
|
<Other>
|
||||||
|
<CustomOptions Value="-FLC:\NewPascal\cross\lib\i386-linux\ld-linux.so.2"/>
|
||||||
|
</Other>
|
||||||
|
</CompilerOptions>
|
||||||
|
</Item5>
|
||||||
|
<Item6 Name="Linux64 Release">
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="..\updatehmcompiled\linux64\updatehm"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<Libraries Value="C:\codetyphon\linux\x86_64-linux\"/>
|
||||||
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<CodeGeneration>
|
||||||
|
<SmartLinkUnit Value="True"/>
|
||||||
|
<TargetCPU Value="x86_64"/>
|
||||||
|
<TargetOS Value="linux"/>
|
||||||
|
<Optimizations>
|
||||||
|
<OptimizationLevel Value="3"/>
|
||||||
|
</Optimizations>
|
||||||
|
<SmallerCode Value="True"/>
|
||||||
|
</CodeGeneration>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<GenerateDebugInfo Value="False"/>
|
||||||
|
</Debugging>
|
||||||
|
<LinkSmart Value="True"/>
|
||||||
|
</Linking>
|
||||||
|
</CompilerOptions>
|
||||||
|
</Item6>
|
||||||
|
</BuildModes>
|
||||||
|
<PublishOptions>
|
||||||
|
<Version Value="2"/>
|
||||||
|
</PublishOptions>
|
||||||
|
<RunParams>
|
||||||
|
<local>
|
||||||
|
<FormatVersion Value="1"/>
|
||||||
|
<CommandLineParams Value="healthmonitor32sqlite3.exe"/>
|
||||||
|
</local>
|
||||||
|
</RunParams>
|
||||||
|
<RequiredPackages Count="2">
|
||||||
|
<Item1>
|
||||||
|
<PackageName Value="LCLBase"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<PackageName Value="LazUtils"/>
|
||||||
|
</Item2>
|
||||||
|
</RequiredPackages>
|
||||||
|
<Units Count="1">
|
||||||
|
<Unit0>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
</Unit0>
|
||||||
|
</Units>
|
||||||
|
</ProjectOptions>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="updatehm"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<GenerateDebugInfo Value="False"/>
|
||||||
|
</Debugging>
|
||||||
|
</Linking>
|
||||||
|
</CompilerOptions>
|
||||||
|
<Debugging>
|
||||||
|
<Exceptions Count="3">
|
||||||
|
<Item1>
|
||||||
|
<Name Value="EAbort"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<Name Value="ECodetoolError"/>
|
||||||
|
</Item2>
|
||||||
|
<Item3>
|
||||||
|
<Name Value="EFOpenError"/>
|
||||||
|
</Item3>
|
||||||
|
</Exceptions>
|
||||||
|
</Debugging>
|
||||||
|
</CONFIG>
|
329
components/lazautoupdate/updatehmsource/updatehm.lpr
Normal file
329
components/lazautoupdate/updatehmsource/updatehm.lpr
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
program updatehm;
|
||||||
|
{$ifdef Linux}
|
||||||
|
|
||||||
|
{$ifdef FPC_CROSSCOMPILING}
|
||||||
|
|
||||||
|
{$ifdef CPUARM}
|
||||||
|
//if GUI, then uncomment
|
||||||
|
|
||||||
|
//{$linklib GLESv2}
|
||||||
|
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
{$linklib libc_nonshared.a}
|
||||||
|
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
{ LazAutoUpdate companion application
|
||||||
|
This application should be deployed in the same directory
|
||||||
|
as any application that uses the LazAutoUpdate component.
|
||||||
|
Actions:
|
||||||
|
1. Checks for correct parameters
|
||||||
|
2. Copies a whatsnew.txt file from the updates directory to the ProgramDirectory
|
||||||
|
3. Waits for 2 seconds whilst the calling app shuts itself down
|
||||||
|
4. If present, copies TrayNotifier info to the common data directory
|
||||||
|
and adds a new entry: Location=<ProgramDirectory>
|
||||||
|
5(a) If CopyTree=TRUE, copies the whole directory tree from
|
||||||
|
the updates folder to the ProgramDirectory
|
||||||
|
5(b) If CopyTree=FALSE, copies the new executable from the
|
||||||
|
updates folder to the ProgramDirectory
|
||||||
|
6. Uses TProcess to start up the new executable
|
||||||
|
7. Closes.
|
||||||
|
|
||||||
|
Note that an application log (C_LogFileName) is written anew, and
|
||||||
|
can be checked for error information
|
||||||
|
|
||||||
|
Copyright (C)2014 Gordon Bamber (minesadorada@charcodelvalle.com)
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU Library General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public License
|
||||||
|
along with this library; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Takes 5 parameters
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils,
|
||||||
|
LazUTF8,LazFileUtils,FileUtil,
|
||||||
|
process,
|
||||||
|
eventlog,
|
||||||
|
DateUtils,
|
||||||
|
inifiles,
|
||||||
|
Classes;
|
||||||
|
|
||||||
|
{$R *.res}
|
||||||
|
const
|
||||||
|
C_AppPrettyName = 'Lazarus Auto-Updater';
|
||||||
|
C_WhatsNewFileName = 'whatsnew.txt';
|
||||||
|
C_Version = '0.0.14';
|
||||||
|
C_UpdatesDirectory = 'updates';
|
||||||
|
C_LogFileName = 'updatehmlog.txt';
|
||||||
|
C_LAUTRayINI = 'lauimport.ini';
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
C_OS = 'win';
|
||||||
|
{$ELSE}
|
||||||
|
C_OS = 'linux';
|
||||||
|
{$ENDIF}
|
||||||
|
{$IFDEF CPU32}
|
||||||
|
C_BITNESS = '32';
|
||||||
|
{$ELSE}
|
||||||
|
C_BITNESS = '64';
|
||||||
|
{$ENDIF}
|
||||||
|
C_PFX = C_OS + C_BITNESS;
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
C_Appname = 'lazautoupdateexample' + C_PFX + '.exe';
|
||||||
|
C_LAUTrayApp = 'lautraynotify' + C_PFX + '.exe';
|
||||||
|
{$ELSE}
|
||||||
|
C_Appname = 'lazautoupdateexample' + C_PFX;
|
||||||
|
C_LAUTrayApp = 'lautraynotify' + C_PFX;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
var
|
||||||
|
szAppName, szUpdatesFolder, szWhatsNewName, szPrettyName: string;
|
||||||
|
szUpdatedEXEPath, szOldEXEPath: string;
|
||||||
|
szUpdatedWNPath, szOldWNPath: string;
|
||||||
|
szUpdatesFullPath: string;
|
||||||
|
AppProcess: TProcess;
|
||||||
|
Logger: TEventLog;
|
||||||
|
bCopyTreeSuccess: boolean;
|
||||||
|
szLAUTrayAppPath: string;
|
||||||
|
INI: TINIFile;
|
||||||
|
SectionStringList: TStrings;
|
||||||
|
|
||||||
|
procedure WaitFor(const MillisecondDelay: longword);
|
||||||
|
// Linux - this proc is intentionally thread-blocking
|
||||||
|
var
|
||||||
|
ThisSecond: longword;
|
||||||
|
begin
|
||||||
|
ThisSecond := MilliSecondOfTheDay(Now);
|
||||||
|
while MilliSecondOfTheDay(Now) < (ThisSecond + MillisecondDelay) do ;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure WriteAndLog(szText: string);
|
||||||
|
begin
|
||||||
|
Logger.Info(szText);
|
||||||
|
writeln(szText);
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if ParamCount = 0 then
|
||||||
|
begin
|
||||||
|
Writeln(LineEnding + '==== updatehm v' + C_Version +
|
||||||
|
' - an lazautoupdate application ====');
|
||||||
|
Writeln('Usage: updatehm exename.exe [updatesfoldername] [whatnewfilename] [exePrettyName] [copytree]');
|
||||||
|
Halt;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (ParamStrUTF8(1) = '-h') or (ParamStrUTF8(1) = '/h') then
|
||||||
|
begin
|
||||||
|
WriteLn('==========================================================');
|
||||||
|
Writeln('Normal usage: updatehm exename.exe [updatesfoldername] [whatnewfilename] [exePrettyName] [copytree]');
|
||||||
|
WriteLn('- where exename.exe is a single application to be updated');
|
||||||
|
WriteLn(LineEnding);
|
||||||
|
WriteLn('optional parameters are');
|
||||||
|
WriteLn('-h or /h - this screen');
|
||||||
|
WriteLn('==========================================================');
|
||||||
|
Halt;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Logger := TEventLog.Create(nil);
|
||||||
|
Logger.LogType := ltFile;
|
||||||
|
Logger.FileName := C_LogFileName;
|
||||||
|
if FileExistsUTF8(C_LogFileName) then
|
||||||
|
DeleteFile(C_LogFileName);
|
||||||
|
Logger.Active := True;
|
||||||
|
Logger.Info('Start of Log');
|
||||||
|
|
||||||
|
bCopyTreeSuccess := False;
|
||||||
|
|
||||||
|
szAppName := ParamStrUTF8(1);
|
||||||
|
if szAppName = '' then
|
||||||
|
szAppname := C_Appname;
|
||||||
|
|
||||||
|
szUpdatesFolder := ParamStrUTF8(2);
|
||||||
|
if szUpdatesFolder = '' then
|
||||||
|
szUpdatesFolder := C_UpdatesDirectory;
|
||||||
|
|
||||||
|
szWhatsNewName := ParamStrUTF8(3);
|
||||||
|
if szWhatsNewName = '' then
|
||||||
|
szWhatsNewName := C_WhatsNewFileName;
|
||||||
|
|
||||||
|
szPrettyName := ParamStrUTF8(4);
|
||||||
|
if szPrettyName = '' then
|
||||||
|
szPrettyName := C_AppPrettyName;
|
||||||
|
|
||||||
|
WriteAndLog('updatehm version ' + C_Version);
|
||||||
|
Logger.Info('Given parameters follow:');
|
||||||
|
Logger.Info('App name = ' + szAppName);
|
||||||
|
Logger.Info('Updates folder = ' + szUpdatesFolder);
|
||||||
|
Logger.Info('WhatsNew filename = ' + szWhatsNewName);
|
||||||
|
Logger.Info('Pretty Name = ' + szPrettyName);
|
||||||
|
if ParamStrUTF8(5) = 'copytree' then
|
||||||
|
Logger.Info('CopyTree = TRUE')
|
||||||
|
else
|
||||||
|
Logger.Info('CopyTree = FALSE');
|
||||||
|
WriteAndLog('Please wait. Updating ' + szPrettyName + '....');
|
||||||
|
// Set up paths
|
||||||
|
|
||||||
|
szOldEXEPath := CleanAndExpandFilename(ProgramDirectory + PathDelim + szAppName);
|
||||||
|
Logger.Info('Application path = ' + szOldEXEPath);
|
||||||
|
szUpdatedEXEPath := CleanAndExpandFilename(ProgramDirectory +
|
||||||
|
szUpdatesFolder + PathDelim + szAppName);
|
||||||
|
Logger.Info('Updated application path = ' + szUpdatedEXEPath);
|
||||||
|
szOldWNPath := CleanAndExpandFilename(ProgramDirectory + PathDelim + szWhatsNewName);
|
||||||
|
Logger.Info('WhatsNew path = ' + szOldWNPath);
|
||||||
|
szUpdatedWNPath := CleanAndExpandFilename(ProgramDirectory +
|
||||||
|
szUpdatesFolder + PathDelim + szWhatsNewName);
|
||||||
|
Logger.Info('Updated whatsNew path = ' + szUpdatedWNPath);
|
||||||
|
|
||||||
|
if not FileExistsUTF8(szUpdatedEXEPath) then
|
||||||
|
begin
|
||||||
|
WriteAndLog('Couldn''t find szUpdatedEXEPath');
|
||||||
|
Logger.Active := False;
|
||||||
|
FreeAndNil(Logger);
|
||||||
|
Halt(1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
if FileExistsUTF8(szUpdatedWNPath) then
|
||||||
|
begin
|
||||||
|
// Write a file to disk that the app keeps checking for.
|
||||||
|
try
|
||||||
|
Fileutil.CopyFile(szUpdatedWNPath, szOldWNPath, [cffOverWriteFile]);
|
||||||
|
WriteAndLog('Writing.. ' + szWhatsNewName);
|
||||||
|
except
|
||||||
|
On E: Exception do
|
||||||
|
begin
|
||||||
|
WriteAndLog(Format('There was a problem writing %s. Reason: %s',
|
||||||
|
[szWhatsNewName, E.Message]));
|
||||||
|
Logger.Active := False;
|
||||||
|
FreeAndNil(Logger);
|
||||||
|
Halt(1);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// The calling app is in a loop - waiting to detect
|
||||||
|
// a Whatsnew file in it's home directory
|
||||||
|
// As soon as the call: If FileExists(WhatsNew) returns TRUE
|
||||||
|
// then the app will close itself
|
||||||
|
// The following code is to give the App time to do all this..
|
||||||
|
{$IFDEF HAS_SLEEP}
|
||||||
|
WriteAndLog('Sleeping...');
|
||||||
|
Sleep(2000); // give time for calling app to close
|
||||||
|
{$ELSE}
|
||||||
|
WriteAndLog('Waiting 2 seconds...');
|
||||||
|
WaitFor(2000);
|
||||||
|
{$ENDIF}
|
||||||
|
// App should now be closed. OK to overwrite it.
|
||||||
|
|
||||||
|
// Define Updates directory
|
||||||
|
szUpdatesFullPath := CleanAndExpandDirectory(ProgramDirectory + szUpdatesFolder);
|
||||||
|
|
||||||
|
// Deal with C_LAUTRayINI
|
||||||
|
// Copied to the global application data folder
|
||||||
|
// Add entry 'Location'
|
||||||
|
if FileExistsUTF8(szUpdatesFullPath + C_LAUTRayINI) then
|
||||||
|
begin
|
||||||
|
szLAUTrayAppPath := GetAppConfigDirUTF8(False, True);;
|
||||||
|
try
|
||||||
|
ForceDirectory(szLAUTrayAppPath);
|
||||||
|
Fileutil.CopyFile(szUpdatesFullPath + C_LAUTRayINI, szLAUTrayAppPath +
|
||||||
|
C_LAUTRayINI, [cffOverWriteFile]);
|
||||||
|
WriteAndLog(Format('Successfully copied %s to %s ',
|
||||||
|
[C_LAUTRayINI, szLAUTrayAppPath]));
|
||||||
|
if FileExistsUTF8(szLAUTrayAppPath + C_LAUTRayINI) then
|
||||||
|
begin
|
||||||
|
INI := TINIFile.Create(szLAUTrayAppPath + C_LAUTRayINI);
|
||||||
|
SectionStringList := TStringList.Create;
|
||||||
|
try
|
||||||
|
INI.ReadSections(SectionStringList);
|
||||||
|
if SectionStringList.Count > 0 then
|
||||||
|
begin
|
||||||
|
INI.WriteString(SectionStringList[0], 'Location', ProgramDirectory);
|
||||||
|
WriteAndLog(Format('Wrote new entry in section %s. Location=%s',
|
||||||
|
[SectionStringList[0], ProgramDirectory]));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
WriteAndLog('Failed to find a valid section in ' + C_LAUTRayINI);
|
||||||
|
finally
|
||||||
|
FreeAndNil(SectionStringList);
|
||||||
|
FreeAndNil(INI);
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
WriteAndLog('Failed to copy ' + C_LAUTRayINI + ' to ' + szLAUTrayAppPath);
|
||||||
|
except
|
||||||
|
On E: Exception do
|
||||||
|
WriteAndLog(Format('Could not copy %s. Error: %s ', [C_LAUTrayApp, E.Message]));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
// If CopyTree, then just copy the whole of the /updates folder (inc directories) to the App Directory
|
||||||
|
try
|
||||||
|
if ParamStrUTF8(5) = 'copytree' then
|
||||||
|
// Copy a whole directory tree?
|
||||||
|
bCopyTreeSuccess := CopyDirTree(szUpdatesFullPath, ProgramDirectory,
|
||||||
|
[cffOverwriteFile, cffCreateDestDirectory]);
|
||||||
|
except
|
||||||
|
On E: Exception do
|
||||||
|
WriteAndLog('Copytree error: ' + E.Message);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// CopyTree not specified, or operation failed
|
||||||
|
// Just copy the updated app over the old one
|
||||||
|
if FileExistsUTF8(szUpdatedEXEPath) then
|
||||||
|
begin
|
||||||
|
if (bCopyTreeSuccess = False) then
|
||||||
|
// Copy over exe file
|
||||||
|
if Fileutil.CopyFile(szUpdatedEXEPath, szOldEXEPath, [cffOverWriteFile]) then
|
||||||
|
begin
|
||||||
|
WriteAndLog('Copying over executeable, then sleeping...');
|
||||||
|
{$IFDEF HAS_SLEEP}
|
||||||
|
WriteAndLog('Sleeping...');
|
||||||
|
Sleep(1000); // give more time for calling app to close
|
||||||
|
{$ELSE}
|
||||||
|
WriteAndLog('Waiting 1 second...');
|
||||||
|
WaitFor(1000);
|
||||||
|
{$ENDIF}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
WriteAndLog('Copy to ' + szUpdatedEXEPath + ' failed');
|
||||||
|
|
||||||
|
// Restart updated app
|
||||||
|
if FileExistsUTF8(szOldEXEPath) then
|
||||||
|
begin
|
||||||
|
WriteAndLog('Restarting ' + szPrettyName + '...');
|
||||||
|
AppProcess := TProcess.Create(nil);
|
||||||
|
try
|
||||||
|
AppProcess.CurrentDirectory := ExtractFileDir(szOldEXEPath);
|
||||||
|
AppProcess.Executable := szOldEXEPath;
|
||||||
|
AppProcess.StartupOptions := [suoUseShowWindow];
|
||||||
|
AppProcess.Execute;
|
||||||
|
finally
|
||||||
|
AppProcess.Free;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
WriteAndLog('Failure. Couldn''t find ' + szOldEXEPath);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
WriteAndLog('Failure. Couldn''t find ' + szUpdatedEXEPath);
|
||||||
|
|
||||||
|
Logger.Info('End of Log');
|
||||||
|
Logger.Active := False;
|
||||||
|
FreeAndNil(Logger);
|
||||||
|
end.
|
274
components/lazautoupdate/updatehmsource/updatehm.lps
Normal file
274
components/lazautoupdate/updatehmsource/updatehm.lps
Normal file
@ -0,0 +1,274 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<CONFIG>
|
||||||
|
<ProjectSession>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<Version Value="9"/>
|
||||||
|
<BuildModes Active="Win64 Release"/>
|
||||||
|
<Units Count="25">
|
||||||
|
<Unit0>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<IsVisibleTab Value="True"/>
|
||||||
|
<TopLine Value="114"/>
|
||||||
|
<CursorPos X="36" Y="292"/>
|
||||||
|
<UsageCount Value="76"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit0>
|
||||||
|
<Unit1>
|
||||||
|
<Filename Value="copydir.pas"/>
|
||||||
|
<TopLine Value="333"/>
|
||||||
|
<CursorPos X="22" Y="333"/>
|
||||||
|
<UsageCount Value="32"/>
|
||||||
|
</Unit1>
|
||||||
|
<Unit2>
|
||||||
|
<Filename Value="upoweredby.pas"/>
|
||||||
|
<TopLine Value="6"/>
|
||||||
|
<CursorPos X="47" Y="27"/>
|
||||||
|
<UsageCount Value="6"/>
|
||||||
|
</Unit2>
|
||||||
|
<Unit3>
|
||||||
|
<Filename Value="D:\Lazarus32_production\components\splashabout\usplashabout.pas"/>
|
||||||
|
<TopLine Value="65"/>
|
||||||
|
<CursorPos X="79" Y="86"/>
|
||||||
|
<UsageCount Value="6"/>
|
||||||
|
</Unit3>
|
||||||
|
<Unit4>
|
||||||
|
<Filename Value="ulazautoupdate.pas"/>
|
||||||
|
<TopLine Value="112"/>
|
||||||
|
<CursorPos X="43" Y="24"/>
|
||||||
|
<UsageCount Value="7"/>
|
||||||
|
</Unit4>
|
||||||
|
<Unit5>
|
||||||
|
<Filename Value="..\..\..\healthmonitor\svn\trunk\updatefromsourceforge.pas"/>
|
||||||
|
<TopLine Value="22"/>
|
||||||
|
<CursorPos X="44" Y="49"/>
|
||||||
|
<UsageCount Value="7"/>
|
||||||
|
</Unit5>
|
||||||
|
<Unit6>
|
||||||
|
<Filename Value="D:\Lazarus32_production\components\ideintf\propedits.pp"/>
|
||||||
|
<TopLine Value="619"/>
|
||||||
|
<UsageCount Value="7"/>
|
||||||
|
</Unit6>
|
||||||
|
<Unit7>
|
||||||
|
<Filename Value="D:\Lazarus32_production\components\lazutils\fileutil.pas"/>
|
||||||
|
<TopLine Value="76"/>
|
||||||
|
<CursorPos X="9" Y="77"/>
|
||||||
|
<UsageCount Value="11"/>
|
||||||
|
</Unit7>
|
||||||
|
<Unit8>
|
||||||
|
<Filename Value="..\..\..\copydir.pas"/>
|
||||||
|
<TopLine Value="94"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit8>
|
||||||
|
<Unit9>
|
||||||
|
<Filename Value="D:\development\fpc\rtl\objpas\sysutils\osutilsh.inc"/>
|
||||||
|
<CursorPos Y="27"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit9>
|
||||||
|
<Unit10>
|
||||||
|
<Filename Value="D:\development\lazarus\lcl\extctrls.pp"/>
|
||||||
|
<TopLine Value="165"/>
|
||||||
|
<CursorPos X="47" Y="198"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit10>
|
||||||
|
<Unit11>
|
||||||
|
<Filename Value="D:\development\lazarus\lcl\customtimer.pas"/>
|
||||||
|
<TopLine Value="91"/>
|
||||||
|
<CursorPos X="30" Y="129"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit11>
|
||||||
|
<Unit12>
|
||||||
|
<Filename Value="D:\development\lazarus\lcl\interfacebase.pp"/>
|
||||||
|
<CursorPos X="19" Y="18"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit12>
|
||||||
|
<Unit13>
|
||||||
|
<Filename Value="D:\development\fpc\rtl\linux\linux.pp"/>
|
||||||
|
<CursorPos X="45" Y="28"/>
|
||||||
|
<UsageCount Value="11"/>
|
||||||
|
</Unit13>
|
||||||
|
<Unit14>
|
||||||
|
<Filename Value="D:\development\fpc\packages\fcl-base\src\eventlog.pp"/>
|
||||||
|
<TopLine Value="70"/>
|
||||||
|
<CursorPos X="30" Y="26"/>
|
||||||
|
<UsageCount Value="11"/>
|
||||||
|
</Unit14>
|
||||||
|
<Unit15>
|
||||||
|
<Filename Value="D:\development\lazarus\components\lazutils\fileutil.pas"/>
|
||||||
|
<TopLine Value="194"/>
|
||||||
|
<CursorPos X="21" Y="218"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit15>
|
||||||
|
<Unit16>
|
||||||
|
<Filename Value="D:\development\lazarus\components\lazutils\fileutil.inc"/>
|
||||||
|
<TopLine Value="680"/>
|
||||||
|
<CursorPos X="3" Y="714"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit16>
|
||||||
|
<Unit17>
|
||||||
|
<Filename Value="D:\development\fpc\rtl\objpas\dateutils.pp"/>
|
||||||
|
<CursorPos X="13"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit17>
|
||||||
|
<Unit18>
|
||||||
|
<Filename Value="D:\development\fpc\rtl\objpas\dateutil.inc"/>
|
||||||
|
<TopLine Value="196"/>
|
||||||
|
<CursorPos X="29" Y="214"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit18>
|
||||||
|
<Unit19>
|
||||||
|
<Filename Value="D:\development\fpc\rtl\objpas\dateutil.pp"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit19>
|
||||||
|
<Unit20>
|
||||||
|
<Filename Value="trayicon\umainform.pas"/>
|
||||||
|
<EditorIndex Value="-1"/>
|
||||||
|
<TopLine Value="103"/>
|
||||||
|
<CursorPos X="43" Y="126"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit20>
|
||||||
|
<Unit21>
|
||||||
|
<Filename Value="updatepack\updatepack.lpr"/>
|
||||||
|
<EditorIndex Value="-1"/>
|
||||||
|
<CursorPos X="89" Y="24"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit21>
|
||||||
|
<Unit22>
|
||||||
|
<Filename Value="..\..\..\..\..\lazarus\components\lazutils\lazutf8.pas"/>
|
||||||
|
<UnitName Value="LazUTF8"/>
|
||||||
|
<EditorIndex Value="3"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit22>
|
||||||
|
<Unit23>
|
||||||
|
<Filename Value="..\..\..\..\..\lazarus\components\lazutils\lazfileutils.pas"/>
|
||||||
|
<UnitName Value="LazFileUtils"/>
|
||||||
|
<EditorIndex Value="2"/>
|
||||||
|
<TopLine Value="61"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit23>
|
||||||
|
<Unit24>
|
||||||
|
<Filename Value="..\..\..\..\..\fpc\packages\fcl-process\src\process.pp"/>
|
||||||
|
<EditorIndex Value="1"/>
|
||||||
|
<TopLine Value="76"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit24>
|
||||||
|
</Units>
|
||||||
|
<JumpHistory Count="28" HistoryIndex="27">
|
||||||
|
<Position1>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="47" Column="92" TopLine="19"/>
|
||||||
|
</Position1>
|
||||||
|
<Position2>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="34" Column="6" TopLine="13"/>
|
||||||
|
</Position2>
|
||||||
|
<Position3>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="55" Column="65" TopLine="9"/>
|
||||||
|
</Position3>
|
||||||
|
<Position4>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="81" Column="53" TopLine="27"/>
|
||||||
|
</Position4>
|
||||||
|
<Position5>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="101" Column="52" TopLine="69"/>
|
||||||
|
</Position5>
|
||||||
|
<Position6>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="8"/>
|
||||||
|
</Position6>
|
||||||
|
<Position7>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="90" Column="6" TopLine="67"/>
|
||||||
|
</Position7>
|
||||||
|
<Position8>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="30" Column="5" TopLine="13"/>
|
||||||
|
</Position8>
|
||||||
|
<Position9>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="27" Column="15" TopLine="4"/>
|
||||||
|
</Position9>
|
||||||
|
<Position10>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="98" Column="49" TopLine="58"/>
|
||||||
|
</Position10>
|
||||||
|
<Position11>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="8" Column="22" TopLine="2"/>
|
||||||
|
</Position11>
|
||||||
|
<Position12>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="98" Column="44" TopLine="74"/>
|
||||||
|
</Position12>
|
||||||
|
<Position13>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="57" Column="29" TopLine="13"/>
|
||||||
|
</Position13>
|
||||||
|
<Position14>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="30" Column="23"/>
|
||||||
|
</Position14>
|
||||||
|
<Position15>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="113" Column="14" TopLine="94"/>
|
||||||
|
</Position15>
|
||||||
|
<Position16>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="158" Column="28" TopLine="134"/>
|
||||||
|
</Position16>
|
||||||
|
<Position17>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="164" Column="21" TopLine="146"/>
|
||||||
|
</Position17>
|
||||||
|
<Position18>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="169" Column="50" TopLine="148"/>
|
||||||
|
</Position18>
|
||||||
|
<Position19>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="181" Column="90" TopLine="148"/>
|
||||||
|
</Position19>
|
||||||
|
<Position20>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="237" Column="84" TopLine="196"/>
|
||||||
|
</Position20>
|
||||||
|
<Position21>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="73" Column="29" TopLine="53"/>
|
||||||
|
</Position21>
|
||||||
|
<Position22>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="47" Column="10" TopLine="23"/>
|
||||||
|
</Position22>
|
||||||
|
<Position23>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="2" Column="9"/>
|
||||||
|
</Position23>
|
||||||
|
<Position24>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="213" Column="46" TopLine="170"/>
|
||||||
|
</Position24>
|
||||||
|
<Position25>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="52" Column="77" TopLine="34"/>
|
||||||
|
</Position25>
|
||||||
|
<Position26>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="55" Column="38" TopLine="45"/>
|
||||||
|
</Position26>
|
||||||
|
<Position27>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="60" Column="14" TopLine="31"/>
|
||||||
|
</Position27>
|
||||||
|
<Position28>
|
||||||
|
<Filename Value="updatehm.lpr"/>
|
||||||
|
<Caret Line="312" Column="58" TopLine="279"/>
|
||||||
|
</Position28>
|
||||||
|
</JumpHistory>
|
||||||
|
</ProjectSession>
|
||||||
|
</CONFIG>
|
BIN
components/lazautoupdate/updatehmsource/updatehm.res
Normal file
BIN
components/lazautoupdate/updatehmsource/updatehm.res
Normal file
Binary file not shown.
Reference in New Issue
Block a user