Skip to content

Commit

Permalink
MP1-5218: DeployTools: Transferring program installation to a separat…
Browse files Browse the repository at this point in the history
…e thread
  • Loading branch information
andrewjswan committed May 1, 2024
1 parent affd227 commit 96977e9
Show file tree
Hide file tree
Showing 15 changed files with 260 additions and 438 deletions.
36 changes: 11 additions & 25 deletions Tools/MediaPortal.DeployTool/InstallationChecks/DirectX9Checker.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Copyright (C) 2005-2023 Team MediaPortal
#region Copyright (C) 2005-2024 Team MediaPortal

// Copyright (C) 2005-2023 Team MediaPortal
// Copyright (C) 2005-2024 Team MediaPortal
// http://www.team-mediaportal.com
//
// MediaPortal is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -55,35 +55,21 @@ public bool Download()
public bool Install()
{
// Extract package
Process setup = Process.Start(_fileName, "/q /t:\"" + Path.GetTempPath() + "\\directx9c\"");
if (setup != null)
{
setup.WaitForExit();
}
Utils.RunCommandWait(_fileName, "/q /t:\"" + Path.GetTempPath() + "\\directx9c\"");

// Install package
string exe = Path.GetTempPath() + "\\directx9c\\DXSetup.exe";
int exitCode = Utils.RunCommandWait(exe, "/silent");
// Return codes:
// 0 = success, no reboot required
// 3010 = success, reboot required
// any other value = failure

setup = Process.Start(exe, "/silent");
if (setup != null)
if (exitCode == 3010 || File.Exists("c:\\deploy_force_reboot"))
{
setup.WaitForExit();
// Return codes:
// 0 = success, no reboot required
// 3010 = success, reboot required
// any other value = failure

if (setup.ExitCode == 3010 || File.Exists("c:\\deploy_force_reboot"))
{
Utils.NotifyReboot(GetDisplayName());
}

if (setup.ExitCode == 0)
{
return true;
}
Utils.NotifyReboot(GetDisplayName());
}
return false;
return exitCode == 0;
}

public bool UnInstall()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,50 +58,34 @@ public bool Install()
// .Net 3.5
if (!dotNet35)
{
Process setup = Process.Start("DISM.EXE", "/Online /Enable-Feature /FeatureName:NetFx3 /All /Quiet /NoRestart");
if (setup != null)
{
setup.WaitForExit();
// Return codes:
// 0 = success, no reboot required
// 3010 = success, reboot required
// any other value = failure

if (setup.ExitCode == 3010 || File.Exists("c:\\deploy_force_reboot"))
{
Utils.NotifyReboot(GetDisplayName());
}
int exitCode = Utils.RunCommandWait("DISM.EXE", "/Online /Enable-Feature /FeatureName:NetFx3 /All /Quiet /NoRestart");
// Return codes:
// 0 = success, no reboot required
// 3010 = success, reboot required
// any other value = failure

if (setup.ExitCode == 0)
{
result = result || true;
}
if (exitCode == 3010 || File.Exists("c:\\deploy_force_reboot"))
{
Utils.NotifyReboot(GetDisplayName());
}
result = result || (exitCode == 0);
}

// .Net 4.0
if (!dotNet40)
{
Process setup = Process.Start(_fileName, "/q /norestart");
if (setup != null)
int exitCode = Utils.RunCommandWait(_fileName, "/q /norestart");
// Return codes:
// 0 = success, no reboot required
// 1638 = success, another version of this product is already installed.
// 3010 = success, reboot required
// any other value = failure

if (exitCode == 3010 || File.Exists("c:\\deploy_force_reboot"))
{
setup.WaitForExit();
// Return codes:
// 0 = success, no reboot required
// 1638 = success, another version of this product is already installed.
// 3010 = success, reboot required
// any other value = failure

if (setup.ExitCode == 3010 || File.Exists("c:\\deploy_force_reboot"))
{
Utils.NotifyReboot(GetDisplayName());
}

if (setup.ExitCode == 0 || setup.ExitCode == 1638)
{
result = result || true;
}
Utils.NotifyReboot(GetDisplayName());
}
result = result || (exitCode == 0 || exitCode == 1638);
}
return result;
}
Expand Down
26 changes: 6 additions & 20 deletions Tools/MediaPortal.DeployTool/InstallationChecks/MPEInstall.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Copyright (C) 2005-2023 Team MediaPortal
#region Copyright (C) 2005-2024 Team MediaPortal

// Copyright (C) 2005-2023 Team MediaPortal
// Copyright (C) 2005-2024 Team MediaPortal
// http://www.team-mediaportal.com
//
// MediaPortal is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -62,15 +62,8 @@ public bool Install()
string mpeExePath = Path.Combine(InstallationProperties.Instance["MPDir"], "MpeInstaller.exe");
if (File.Exists(mpeExePath))
{
Process setup = Process.Start(mpeExePath, String.Format(@"/S ""{0}""", FileName));
if (setup != null)
{
setup.WaitForExit();
if (setup.ExitCode == 0)
{
return true;
}
}
int exitCode = Utils.RunCommandWait(mpeExePath, String.Format(@"/S ""{0}""", FileName));
return exitCode == 0;
}
}
return false;
Expand All @@ -81,15 +74,8 @@ public bool UnInstall()
string mpeExePath = Path.Combine(InstallationProperties.Instance["MPDir"], "MpeInstaller.exe");
if (File.Exists(mpeExePath))
{
Process setup = Process.Start(mpeExePath, String.Format(@"/Uninstall={0}", MpeId));
if (setup != null)
{
setup.WaitForExit();
if (setup.ExitCode == 0)
{
return true;
}
}
int exitCode = Utils.RunCommandWait(mpeExePath, String.Format(@"/Uninstall={0}", MpeId));
return exitCode == 0;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Copyright (C) 2005-2023 Team MediaPortal
#region Copyright (C) 2005-2024 Team MediaPortal

// Copyright (C) 2005-2023 Team MediaPortal
// Copyright (C) 2005-2024 Team MediaPortal
// http://www.team-mediaportal.com
//
// MediaPortal is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -128,43 +128,29 @@ public bool Install()
{
string tmpPath = Path.GetTempPath() + "\\SQLEXPRESS";
//Extract all files
Process extract = Process.Start(_fileName, "/X:\"" + tmpPath + "\" /Q");
try
{
if (extract != null)
{
extract.WaitForExit();
}
}
catch
int exitCode = Utils.RunCommandWait(_fileName, "/X:\"" + tmpPath + "\" /Q");
if (exitCode == -1)
{
return false;
}

//Prepare the unattended ini file
PrepareTemplateINI(tmpPath + "\\template.ini");

try
exitCode = Utils.RunCommandWait(tmpPath + "\\setup.exe", "/wait /settings \"" + tmpPath + "\\template.ini\" /qn");
if (exitCode == 0)
{
//run the setup
Process setup = Process.Start(tmpPath + "\\setup.exe", "/wait /settings \"" + tmpPath + "\\template.ini\" /qn");
if (setup != null)
try
{
setup.WaitForExit();
if (setup.ExitCode == 0)
{
Directory.Delete(tmpPath, true);
StartStopService(false);
FixTcpPort();
StartStopService(true);
return true;
}
return false;
Directory.Delete(tmpPath, true);
StartStopService(false);
FixTcpPort();
StartStopService(true);
return true;
}
catch {}
}
catch
{
return false;
}

return false;
}

Expand Down

0 comments on commit 96977e9

Please sign in to comment.