Windows: Creating an installer with a custom data directory path

This commit is contained in:
Zoe Roux 2021-08-22 17:20:23 +02:00
parent f661457617
commit daedd60f3d
10 changed files with 74 additions and 18 deletions

View File

@ -1,5 +1,5 @@
name: Analysis name: Analysis
on: [push, pull_request] on: [push, pull_request, workflow_dispatch]
jobs: jobs:
analysis: analysis:

View File

@ -1,5 +1,5 @@
name: Build name: Build
on: [push, pull_request] on: [push, pull_request, workflow_dispatch]
jobs: jobs:
build: build:
@ -43,13 +43,16 @@ jobs:
if: matrix.artifact == 'windows' if: matrix.artifact == 'windows'
uses: ilammy/msvc-dev-cmd@v1 uses: ilammy/msvc-dev-cmd@v1
- name: Build the app - name: Build the app
shell: bash
env: env:
INCLUDE: ${{env.INCLUDE}};C:\Program Files\FFmpeg\include INCLUDE: ${{env.INCLUDE}};C:\Program Files\FFmpeg\include
LIB: ${{env.LIB}};C:\Program Files\FFmpeg\lib LIB: ${{env.LIB}};C:\Program Files\FFmpeg\lib
LIBPATH: ${{env.LIBPATH}};C:\Program Files\FFmpeg\lib LIBPATH: ${{env.LIBPATH}};C:\Program Files\FFmpeg\lib
CFLAGS: -I/usr/local/include CFLAGS: -I/usr/local/include
LDFLAGS: -L/usr/local/lib LDFLAGS: -L/usr/local/lib
run: dotnet publish -r ${{matrix.runtime}} -c Release -o dist Kyoo run: |
project=$([ "${{runner.os}}" == "Windows" ] && echo Kyoo.WindowsHost || echo Kyoo)
dotnet publish -r ${{matrix.runtime}} -c Release -o dist $project
- name: Compression output - name: Compression output
shell: bash shell: bash
run: | run: |
@ -71,7 +74,7 @@ jobs:
*.tar.gz *.tar.gz
release: release:
name: Create debian, rpm & arch releases name: Create windows, debian, rpm & arch releases
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build
if: github.ref == 'refs/heads/master' if: github.ref == 'refs/heads/master'
@ -80,12 +83,26 @@ jobs:
version: v0.0.1 #${{ github.ref }} version: v0.0.1 #${{ github.ref }}
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- uses: actions/download-artifact@v2 - name: Download linux build
uses: actions/download-artifact@v2
with: with:
name: kyoo_linux name: kyoo_linux
path: artifact path: artifact
- name: Unzip the published files. - name: Unzip the published files.
run: mkdir dist && tar -C dist -xzf artifact/kyoo_linux.tar.gz run: mkdir dist && tar -C dist -xzf artifact/kyoo_linux.tar.gz
- name: Download windows build
uses: actions/download-artifact@v2
with:
name: kyoo_windows
path: artifact
- name: Unzip windows files
run: mkdir dist_win && 7z e artifact/kyoo_windows.zip -o dist_win
- name: Install Inno Setup
run: |
curl -L https://jrsoftware.org/download.php/is.exe > innosetup.exe
./innosetup.exe /VERYSILENT /SUPPRESSMSGBOXES /Log=log.txt || (cat log.txt && exit 1)
- name: Create windows installer
run: iscc -Dkyoo=$(realpath dist_win) -O./ -Fkyoo-windows deployment/kyoo-windows.iss
- name: Create the package structure - name: Create the package structure
run: | run: |
sudo mkdir -p pkg/usr/lib/ sudo mkdir -p pkg/usr/lib/
@ -119,6 +136,10 @@ jobs:
with: with:
pkgdir: deployment pkgdir: deployment
namcapDisable: true namcapDisable: true
- uses: actions/upload-artifact@v2
with:
name: kyoo_windows
path: ./*.exe
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: kyoo_rpm name: kyoo_rpm

View File

@ -1,6 +1,5 @@
name: Docker name: Docker
on: [push, pull_request, workflow_dispatch]
on: [push, pull_request]
jobs: jobs:
build: build:

View File

@ -3,7 +3,6 @@
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework> <TargetFramework>net5.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<RootNamespace>Kyoo.Host.Windows</RootNamespace> <RootNamespace>Kyoo.Host.Windows</RootNamespace>
</PropertyGroup> </PropertyGroup>

View File

@ -1,6 +1,8 @@
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Autofac; using Autofac;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Win32;
namespace Kyoo.Host.Windows namespace Kyoo.Host.Windows
{ {
@ -13,6 +15,10 @@ namespace Kyoo.Host.Windows
/// </summary> /// </summary>
public static async Task Main(string[] args) public static async Task Main(string[] args)
{ {
object dataDir = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\SDG\Kyoo\Settings", "DataDir", null)
?? Registry.GetValue(@"HKEY_CURRENT_USER\Software\SDG\Kyoo\Settings", "DataDir", null);
if (dataDir is string data)
Environment.SetEnvironmentVariable("KYOO_DATA_DIR", data);
Kyoo.Program.SetupDataDir(args); Kyoo.Program.SetupDataDir(args);
IHost host = Kyoo.Program.CreateWebHostBuilder(args) IHost host = Kyoo.Program.CreateWebHostBuilder(args)

View File

@ -23,7 +23,7 @@ namespace Kyoo.Host.Windows
/// <summary> /// <summary>
/// The thread where the trait is running. /// The thread where the trait is running.
/// </summary> /// </summary>
private Thread? _thread; private Thread _thread;
/// <summary> /// <summary>

View File

@ -59,4 +59,8 @@
<Visible>false</Visible> <Visible>false</Visible>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="../LICENSE" CopyToOutputDirectory="Always" Visible="false" />
</ItemGroup>
</Project> </Project>

View File

@ -65,13 +65,13 @@ namespace Kyoo
{ {
try try
{ {
host.Services.GetRequiredService<ILogger<Application>>() Log.Information("Running as {Name}", System.Environment.UserName);
.LogInformation("Running as {Name}", System.Environment.UserName); Log.Information("Data directory: {DataDirectory}", System.Environment.CurrentDirectory);
await host.RunAsync(); await host.RunAsync();
} }
catch (Exception ex) catch (Exception ex)
{ {
host.Services.GetRequiredService<ILogger<Application>>().LogCritical(ex, "Unhandled exception"); Log.Fatal(ex, "Unhandled exception");
} }
} }

View File

@ -9,12 +9,12 @@ AppUpdatesURL=https://github.com/AnonymusRaccoon/Kyoo
DefaultDirName={commonpf}\Kyoo DefaultDirName={commonpf}\Kyoo
DisableProgramGroupPage=yes DisableProgramGroupPage=yes
LicenseFile={#kyoo}\LICENSE LicenseFile={#kyoo}\LICENSE
OutputBaseFilename=kyoo-windows
SetupIconFile={#kyoo}\wwwroot\favicon.ico SetupIconFile={#kyoo}\wwwroot\favicon.ico
Compression=lzma Compression=lzma
SolidCompression=yes SolidCompression=yes
WizardStyle=modern WizardStyle=modern
AppCopyright=GPL-3.0 AppCopyright=GPL-3.0
ArchitecturesInstallIn64BitMode=x64 arm64 ia64
[Languages] [Languages]
Name: "english"; MessagesFile: "compiler:Default.isl" Name: "english"; MessagesFile: "compiler:Default.isl"
@ -26,14 +26,41 @@ Name: "none"; Description: "Do not start automatically"; GroupDescription: "Star
[Files] [Files]
Source: "{#kyoo}\Kyoo.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "{#kyoo}\Kyoo.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#kyoo}\Kyoo.WindowsHost.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#kyoo}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "{#kyoo}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
[Registry]
Root: HKA; Subkey: "Software\SDG"; Flags: uninsdeletekeyifempty
Root: HKA; Subkey: "Software\SDG\Kyoo"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\SDG\Kyoo\Settings"; ValueType: string; ValueName: "DataDir"; ValueData: "{code:GetDataDir}"
[UninstallDelete] [UninstallDelete]
Type: filesandordirs; Name: "{commonappdata}\Kyoo" Type: filesandordirs; Name: "{code:GetDataDir}"
[Icons] [Icons]
Name: "{autoprograms}\Kyoo"; Filename: "{app}\Kyoo.exe" Name: "{autoprograms}\Kyoo"; Filename: "{app}\Kyoo.WindowsHost.exe"
Name: "{autodesktop}\Kyoo"; Filename: "{app}\Kyoo.exe"; Tasks: desktopicon Name: "{autoprograms}\Kyoo (Console)"; Filename: "{app}\Kyoo.exe"
Name: "{autodesktop}\Kyoo"; Filename: "{app}\Kyoo.WindowsHost.exe"; Tasks: desktopicon
[Run] [Run]
Filename: "{app}\Kyoo.exe"; Description: "{cm:LaunchProgram,Kyoo}"; Flags: nowait postinstall skipifsilent Filename: "{app}\Kyoo.WindowsHost.exe"; Description: "{cm:LaunchProgram,Kyoo}"; Flags: nowait postinstall skipifsilent
[Code]
var
DataDirPage: TInputDirWizardPage;
procedure InitializeWizard;
begin
DataDirPage := CreateInputDirPage(wpSelectDir,
'Choose Data Location', 'Choose the folder in which to install the Kyoo data',
'The installer will set the following folder for Kyoo. To install in a different folder, click Browse and select another folder.' +
'Please make sure the folder exists and is accessible. Do not choose the server install folder. Click Next to continue.',
False, '');
DataDirPage.Add('');
DataDirPage.Values[0] := GetPreviousData('DataDir', 'C:\ProgramData\Kyoo');
end;
function GetDataDir(Param: String): String;
begin
Result := DataDirPage.Values[0];
end;

View File

@ -5,7 +5,7 @@ After=network.target
[Service] [Service]
User=kyoo User=kyoo
WorkingDirectory=/var/lib/kyoo Environment=KYOO_DATA_DIR=/var/lib/kyoo
ExecStart=/usr/lib/kyoo/Kyoo ExecStart=/usr/lib/kyoo/Kyoo
Restart=on-abort Restart=on-abort
TimeoutSec=20 TimeoutSec=20