From f05a164538171f7cf6d9bcd90f7db65fae476859 Mon Sep 17 00:00:00 2001 From: Slawek Mikula Date: Sun, 21 Feb 2021 09:45:42 +0100 Subject: [PATCH] - preliminary support for downloading fgdata via web (sourceforge) --- FlightGear-files.iss | 16 +++++++ FlightGear-i18n.iss | 8 ++++ FlightGear.iss | 112 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 131 insertions(+), 5 deletions(-) diff --git a/FlightGear-files.iss b/FlightGear-files.iss index 802ff61..d4f34ca 100644 --- a/FlightGear-files.iss +++ b/FlightGear-files.iss @@ -34,6 +34,22 @@ Source: "{#ThirdPartyDir}\3rdParty.x64\bin\liblzma.dll"; DestDir: "{app}\bin"; C Source: "{#FgHarnessPath}\fgdata\*.*"; DestDir: "{app}\data"; Excludes: "{#FGDataExcludes}"; Flags: ignoreversion recursesubdirs skipifsourcedoesntexist #endif +; Web installer for the base package +#if IncludeWeb == "TRUE" +; bzip2 +Source: "{#DecompressDir}\\bunzip2.exe"; Flags: dontcopy +Source: "{#DecompressDir}\\bzip2.dll"; Flags: dontcopy +; tar +Source: "{#DecompressDir}\\tar.exe"; Flags: dontcopy +Source: "{#DecompressDir}\\libiconv-2.dll"; Flags: dontcopy +Source: "{#DecompressDir}\\libintl-2.dll"; Flags: dontcopy +; txz +Source: "{#DecompressDir}\\xzdec.exe"; Flags: dontcopy +Source: "{#DecompressDir}\\liblzma.dll"; Flags: dontcopy +; full code +Source: "{tmp}\\fgdata-extracted\\fgdata\\*.*"; DestDir: "{app}\data"; Flags: external recursesubdirs +#endif + ; 32 bits install Source: "{#OSGInstallDir}\bin\osg{#OSGSoNumber}-osg.dll"; DestDir: "{app}\bin"; Check: not Is64BitInstallMode Source: "{#OSGInstallDir}\bin\osg{#OSGSoNumber}-osgDB.dll"; DestDir: "{app}\bin"; Check: not Is64BitInstallMode diff --git a/FlightGear-i18n.iss b/FlightGear-i18n.iss index 9d4aec4..a5c3a88 100644 --- a/FlightGear-i18n.iss +++ b/FlightGear-i18n.iss @@ -13,6 +13,10 @@ RemoveAllSettings=Remove all settings, downloaded scenery and aircraft RemoveAllSettingsDescription=FlightGear stores some settings in your user folder. In addition, scenery or aircraft data may have been downloaded to the download directory. To completely remove all these files, select this option. FirewallFgException=Allows FlightGear to send and receive data over the multiplayer network and to get METARs. FirewallFgcomException=Allows FGCom to establish a connection to FlightGear and the VoIP server for voice ATC communication. +ExtractingDownloadContentTitle=Extracting downloaded content +ExtractingDownloadContentMessage=This step will perform extraction of the downloaded content +ExtractingDownloadedFile=Extracting file +UntarringDownloadedFile=Untarring file pl.CreateDesktopIcon=Utwórz ikony na pulpicie pl.CreateDesktopIconGroup=Dodatkowe ikony: @@ -20,6 +24,10 @@ pl.RemoveAllSettings=Usuń wszystkie ustawienia, pobraną scenerię i samoloty pl.RemoveAllSettingsDescription=FlightGear zapisuje niektóre ustawienia w katalogach użytkownika. Dodatkowo, sceneria lub dane statków powietrznych mogą być pobierane do katalogu pobrań. Aby całkowicie usunąć te ustawienia, wybierz tą opcję. pl.FirewallFgException=Pozwala aplikacji FlightGear na wysyłanie i pobieranie danych przez sieć multiplayer oraz aby pobrać dane pogodowe METAR. pl.FirewallFgcomException=Pozwala aplikacji FGCom na ustanowienie połączenia do aplikacji FlightGear i do serwerów VoIP dla komunikacji głosowej z ATC (kontrolerem lotów). +pl.ExtractingDownloadContentTitle=Rozpakowywanie pobranej dodatkowej treści +pl.ExtractingDownloadContentMessage=Ten krok rozpakuje pobraną dodatkową treść +pl.ExtractingDownloadedFile=Rozpakowywanie pliku +pl.UntarringDownloadedFile=Roztarowanie pliku es.CreateDesktopIcon=Crear icono en el escritorio es.RemoveAllSettings=Borrar todos los ajustes, escenarios y aviones descargados diff --git a/FlightGear.iss b/FlightGear.iss index 0fe7b1f..3c94e3c 100644 --- a/FlightGear.iss +++ b/FlightGear.iss @@ -56,6 +56,7 @@ #define OSG64PluginsDir OSG64InstallDir + "\bin\osgPlugins-" + OSGVersion #define ThirdPartyDir FgHarnessPath + "\windows-3rd-party\msvc140" +#define DecompressDir FgHarnessPath + "\windows-3rd-party\decompress" ; we copy everything in install//bin except these, which aren't ; useful to the end-user to ship @@ -142,6 +143,30 @@ const NET_FW_PROFILE2_PRIVATE = 2; NET_FW_PROFILE2_PUBLIC = 4; +var + UninstallCheckCleanPage: TNewNotebookPage; + UninstallBackButton: TNewButton; + UninstallNextButton: TNewButton; + DoCleanCheckbox : TNewCheckBox; + CleanHelp : TNewStaticText; + DownloadPage: TDownloadWizardPage; + ExtractDownload: TOutputProgressWizardPage; + + ResultCode: Integer; + +function OnDownloadProgress(const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean; +begin + if Progress = ProgressMax then + Log(Format('Successfully downloaded file to {tmp}: %s', [FileName])); + Result := True; +end; + +procedure InitializeWizard; +begin + DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), @OnDownloadProgress); + ExtractDownload := CreateOutputProgressPage(ExpandConstant('{cm:ExtractingDownloadContentTitle}'), ExpandConstant('{cm:ExtractingDownloadContentMessage}')); +end; + procedure URLLabelOnClick(Sender: TObject); var ErrorCode: Integer; @@ -245,12 +270,82 @@ begin end; end; +function NextButtonClick(CurPageID: Integer): Boolean; var - UninstallCheckCleanPage: TNewNotebookPage; - UninstallBackButton: TNewButton; - UninstallNextButton: TNewButton; - DoCleanCheckbox : TNewCheckBox; - CleanHelp : TNewStaticText; + fgDataInstalled: Cardinal; +begin + if CurPageID = wpReady then begin + DownloadPage.Clear; + + fgDataInstalled := 0; + + // checking registry entry, if fgdata was installed + if RegKeyExists(HKEY_LOCAL_MACHINE, ExpandConstant('Software\FlightGear\{#FGVersionGroup}')) then + begin + if RegQueryDWordValue(HKEY_LOCAL_MACHINE, ExpandConstant('Software\FlightGear\{#FGVersionGroup}'), 'fgdata-installed', fgDataInstalled) then + begin + Log('Previous fgdata installed. Downloading delta package'); + end; + end; + + // selecting fgdata installation packages + if (fgDataInstalled = 1) then + begin + DownloadPage.Add('https://sourceforge.net/projects/flightgear/files/release-{#FGVersionGroup}/FlightGear-{#FGVersion}-data-delta.tar.bz2/download', 'fgdata-downloaded.tar.bz2', ''); + end + else + begin + DownloadPage.Add('https://sourceforge.net/projects/flightgear/files/release-{#FGVersionGroup}/FlightGear-{#FGVersion}-data.tar.bz2/download', 'fgdata-downloaded.tar.bz2', ''); + end; + + DownloadPage.Show; + try + try + DownloadPage.Download; + // show extract progress page + try + ExtractDownload.Show; + ExtractDownload.SetText(ExpandConstant('{cm:ExtractingDownloadedFile}'), 'fgdata-downloaded.tar.bz2'); + ExtractTemporaryFile('bunzip2.exe'); + ExtractTemporaryFile('bzip2.dll'); + if Exec(ExpandConstant('{tmp}\bunzip2.exe'), ExpandConstant('{tmp}\fgdata-downloaded.tar.bz2'), ExpandConstant('{tmp}'), SW_HIDE, ewWaitUntilTerminated, ResultCode) then + begin + Log(Format('Successfully bunzipped file: %s', [ExpandConstant('{tmp}\fgdata-downloaded.tar.bz2')])); + ExtractDownload.SetText(ExpandConstant('{cm:UntarringDownloadedFile}'), ExpandConstant('fgdata-downloaded.tar')); + ExtractTemporaryFile('tar.exe'); + ExtractTemporaryFile('libiconv-2.dll'); + ExtractTemporaryFile('libintl-2.dll'); + CreateDir(ExpandConstant('{tmp}\fgdata-extracted')); + if Exec(ExpandConstant('{tmp}\tar.exe'), ExpandConstant('-xf fgdata-downloaded.tar -C fgdata-extracted'), ExpandConstant('{tmp}'), SW_HIDE, ewWaitUntilTerminated, ResultCode) then + begin + Log(Format('Successfully untarred file: %s', [ExpandConstant('{tmp}\fgdata-downloaded.tar')])); + end + else begin + Log(Format('ERROR untarring file: %s', [ExpandConstant('{tmp}\fgdata-downloaded.tar')])); + end; + end + else begin + Log(Format('ERROR bunzipping file: %s', [ExpandConstant('{tmp}\fgdata-downloaded.tar.bz2')])); + end; + finally + ExtractDownload.Hide; + end; + Result := True; + except + // FIXME - available in IS 6.1.3-dev + //if DownloadPage.AbortedByUser then + // Log('Aborted by user.') + //else + SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK); + Result := False; + end; + finally + DownloadPage.Hide; + end; + end + else + Result := True; +end; procedure InitializeUninstallProgressForm(); begin @@ -307,6 +402,7 @@ var begin if CurStep = ssPostInstall then begin + // firewall rules GetWindowsVersionEx(Version); if (Version.Major >= 6) then begin @@ -322,6 +418,9 @@ begin AddBasicFirewallException('FlightGear', ExpandConstant('{app}') + '\bin\fgfs.exe'); AddBasicFirewallException('FlightGear FGCom', ExpandConstant('{app}') + '\bin\fgcom.exe'); end; + + // registry entries + RegWriteDWordValue(HKEY_LOCAL_MACHINE, ExpandConstant('Software\FlightGear\{#FGVersionGroup}'), 'fgdata-installed', 1); end; end; @@ -342,5 +441,8 @@ begin begin RemoveFirewallException('FlightGear', ExpandConstant('{app}') + '\bin\fgfs.exe'); RemoveFirewallException('FlightGear FGCom', ExpandConstant('{app}') + '\bin\fgcom.exe'); + + // registry entries + RegDeleteValue(HKEY_LOCAL_MACHINE, ExpandConstant('Software\FlightGear\{#FGVersionGroup}'), 'fgdata-installed'); end; end;