4using System.Threading.Tasks;
6using Microsoft.Extensions.Logging;
7using Microsoft.Extensions.Options;
98 ILogger<OpenDreamInstaller> logger,
104 IOptions<GeneralConfiguration> generalConfigurationOptions,
105 IOptions<SessionConfiguration> sessionConfigurationOptions)
106 : base(ioManager, logger)
109 ProcessExecutor = processExecutor ??
throw new ArgumentNullException(nameof(processExecutor));
113 GeneralConfiguration = generalConfigurationOptions?.Value ??
throw new ArgumentNullException(nameof(generalConfigurationOptions));
114 SessionConfiguration = sessionConfigurationOptions?.Value ??
throw new ArgumentNullException(nameof(sessionConfigurationOptions));
118 public override Task
CleanCache(CancellationToken cancellationToken) => Task.CompletedTask;
139 ArgumentNullException.ThrowIfNull(jobProgressReporter);
142 Logger.LogTrace(
"Cloning OD repo...");
144 var progressSection1 = jobProgressReporter.
CreateSection(
"Updating OpenDream git repository", 0.5f);
159 progressSection1.Dispose();
167 Logger.LogTrace(
"OD repo seems to already exist, attempting load and fetch...");
170 throw new JobException(
"Can't load OpenDream repository! Please delete cache from disk!");
180 progressSection1.Dispose();
181 progressSection1 =
null;
183 using (var progressSection2 = jobProgressReporter.
CreateSection(
"Checking out OpenDream version", 0.5f))
185 var committish = version.SourceSHA
186 ?? $
"{GeneralConfiguration.OpenDreamGitTagPrefix}{version.Version!.Semver()}";
210 progressSection1?.Dispose();
215 public override async ValueTask
Install(
EngineVersion version,
string installPath,
bool deploymentPipelineProcesses, CancellationToken cancellationToken)
218 ArgumentNullException.ThrowIfNull(installPath);
225 Logger.LogDebug(
"Correcting extraction location...");
230 await Task.WhenAll(dirsTask, filesTask, dirCreateTask);
232 var dirsMoveTasks = dirsTask
241 var filesMoveTask = filesTask
251 await Task.WhenAll(dirsMoveTasks.Concat(filesMoveTask));
256 const string DeployDir =
"tgs_deploy";
257 int? buildExitCode =
null;
259 async shortenedPath =>
265 $
"run -c Release --project OpenDreamPackageTool -- --tgs -o {shortenedDeployPath}",
273 buildProcess.AdjustPriority(
false);
275 using (cancellationToken.Register(() => buildProcess.Terminate()))
276 buildExitCode = await buildProcess.Lifetime;
281 var buildOutputTask = buildProcess.GetCombinedOutput(cancellationToken);
282 if (!buildOutputTask.IsCompleted)
283 Logger.LogTrace(
"OD build complete, waiting for output...");
284 output = await buildOutputTask;
287 output =
"<Build output suppressed by configuration due to not being immediately available>";
290 "OpenDream build exited with code {exitCode}:{newLine}{output}",
298 if (buildExitCode != 0)
302 async ValueTask MoveDirs()
312 cancellationToken)));
315 async ValueTask MoveFiles()
325 cancellationToken)));
328 var dirsMoveTask = MoveDirs();
329 var outputFilesMoveTask = MoveFiles();
338 ArgumentNullException.ThrowIfNull(path);
339 return ValueTask.CompletedTask;
345 ArgumentNullException.ThrowIfNull(engineVersion);
346 ArgumentNullException.ThrowIfNull(fullDmbPath);
348 Logger.LogTrace(
"TrustDmbPath is a no-op: {path}", fullDmbPath);
349 return ValueTask.CompletedTask;
360 Func<string, ValueTask> shortenedPathOperation,
362 CancellationToken cancellationToken)
363 => shortenedPathOperation(originalPath);
371 protected void GetExecutablePaths(
string installationPath, out
string serverExePath, out
string compilerExePath)
373 var exeExtension = platformIdentifier.IsWindows
381 $
"Robust.Server{exeExtension}");
387 $
"DMCompiler{exeExtension}");
Information about an engine installation.
Extension methods for the ValueTask and ValueTask<TResult> classes.
static async ValueTask WhenAll(IEnumerable< ValueTask > tasks)
Fully await a given list of tasks .
void CheckVersionValidity(EngineVersion version)
Check that a given version is of type EngineType.Byond.
IIOManager IOManager
Gets the IIOManager for the EngineInstallerBase.
ILogger< EngineInstallerBase > Logger
Gets the ILogger for the EngineInstallerBase.
Implementation of IEngineInstallation for EngineType.OpenDream.
Implementation of IEngineInstaller for EngineType.OpenDream.
void GetExecutablePaths(string installationPath, out string serverExePath, out string compilerExePath)
Gets the paths to the server and client executables.
readonly IAbstractHttpClientFactory httpClientFactory
The IAbstractHttpClientFactory for the OpenDreamInstaller.
override EngineType TargetEngineType
readonly IPlatformIdentifier platformIdentifier
The IPlatformIdentifier for the OpenDreamInstaller.
readonly IRepositoryManager repositoryManager
The IRepositoryManager for the OpenDream repository.
override async ValueTask Install(EngineVersion version, string installPath, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
Does actions necessary to get an extracted installation working.A ValueTask representing the running ...
override ValueTask TrustDmbPath(EngineVersion engineVersion, string fullDmbPath, CancellationToken cancellationToken)
Add a given fullDmbPath to the trusted DMBs list in BYOND's config.A ValueTask representing the runn...
const string ServerDir
The OD server directory name.
override async ValueTask< IEngineInstallationData > DownloadVersion(EngineVersion version, JobProgressReporter jobProgressReporter, CancellationToken cancellationToken)
Download a given engine version .A ValueTask<TResult> resulting in the IEngineInstallationData for th...
override IEngineInstallation CreateInstallation(EngineVersion version, string path, Task installationTask)
Creates an IEngineInstallation for a given version .The IEngineInstallation.
override Task CleanCache(CancellationToken cancellationToken)
Attempts to cleans the engine's cache folder for the system.A Task representing the running operation...
OpenDreamInstaller(IIOManager ioManager, ILogger< OpenDreamInstaller > logger, IPlatformIdentifier platformIdentifier, IProcessExecutor processExecutor, IRepositoryManager repositoryManager, IAsyncDelayer asyncDelayer, IAbstractHttpClientFactory httpClientFactory, IOptions< GeneralConfiguration > generalConfigurationOptions, IOptions< SessionConfiguration > sessionConfigurationOptions)
Initializes a new instance of the OpenDreamInstaller class.
const string InstallationCompilerDirectory
The name of the subdirectory in an installation's BinDir used to store the compiler binaries.
const string InstallationSourceSubDirectory
The name of the subdirectory used for the RepositoryEngineInstallationData's copy.
override ValueTask UpgradeInstallation(EngineVersion version, string path, CancellationToken cancellationToken)
Does actions necessary to get upgrade a version installed by a previous version of TGS....
readonly IAsyncDelayer asyncDelayer
The IAsyncDelayer for the OpenDreamInstaller.
virtual ValueTask HandleExtremelyLongPathOperation(Func< string, ValueTask > shortenedPathOperation, string originalPath, CancellationToken cancellationToken)
Perform an operation on a very long path.
const string BinDir
The bin directory name.
Implementation of IEngineInstallationData using a IRepository.
General configuration options.
bool OpenDreamSuppressInstallOutput
If the dotnet output of creating an OpenDream installation should be suppressed. Known to cause issue...
Uri OpenDreamGitUrl
Location of a publically accessible OpenDream repository.
Configuration options for the game sessions.
bool LowPriorityDeploymentProcesses
If the deployment DreamMaker and DreamDaemon instances are set to be below normal priority processes.
An IIOManager that resolve relative paths from another IIOManager to a subdirectory of that.
Operation exceptions thrown from the context of a Models.Job.
Progress reporter for a Job.
JobProgressReporter CreateSection(string? newStageName, double percentage)
Create a subsection of the JobProgressReporter with its optional own stage name.
Helper methods for working with the dotnet executable.
static async ValueTask< string?> GetDotnetPath(IPlatformIdentifier platformIdentifier, IIOManager ioManager, CancellationToken cancellationToken)
Locate a dotnet executable to use.
async ValueTask< IProcess > LaunchProcess(string fileName, string workingDirectory, string arguments, CancellationToken cancellationToken, IReadOnlyDictionary< string, string >? environment, string? fileRedirect, bool readStandardHandles, bool noShellExecute)
Launch a IProcess.A ValueTask<TResult> resulting in the new IProcess.
Represents a BYOND installation.
Represents an on-disk git repository.
Task< bool > CommittishIsParent(string committish, CancellationToken cancellationToken)
Check if a given committish is a parent of the current Head.
ValueTask CheckoutObject(string committish, string? username, string? password, bool updateSubmodules, bool moveCurrentReference, JobProgressReporter progressReporter, CancellationToken cancellationToken)
Checks out a given committish .
ValueTask FetchOrigin(JobProgressReporter progressReporter, string? username, string? password, bool deploymentPipeline, CancellationToken cancellationToken)
Fetch commits from the origin repository.
Factory for creating and loading IRepositorys.
ValueTask< IRepository?> CloneRepository(Uri url, string? initialBranch, string? username, string? password, JobProgressReporter progressReporter, bool recurseSubmodules, CancellationToken cancellationToken)
Clone the repository at url .
ValueTask< IRepository?> LoadRepository(CancellationToken cancellationToken)
Attempt to load the IRepository from the default location.
Interface for using filesystems.
Task< IReadOnlyList< string > > GetFiles(string path, CancellationToken cancellationToken)
Returns full file names in a given path .
string GetFileName(string path)
Gets the file name portion of a path .
string ConcatPath(params string[] paths)
Combines an array of strings into a path.
Task MoveFile(string source, string destination, CancellationToken cancellationToken)
Moves a file at source to destination .
Task< IReadOnlyList< string > > GetDirectories(string path, CancellationToken cancellationToken)
Returns full directory names in a given path .
Task CreateDirectory(string path, CancellationToken cancellationToken)
Create a directory at path .
Task DeleteDirectory(string path, CancellationToken cancellationToken)
Recursively delete a directory, removes and does not enter any symlinks encounterd.
Task MoveDirectory(string source, string destination, CancellationToken cancellationToken)
Moves a directory at source to destination .
Task< bool > DirectoryExists(string path, CancellationToken cancellationToken)
Check that the directory at path exists.
For waiting asynchronously.
ErrorCode
Types of Response.ErrorMessageResponses that the API may return.
EngineType
The type of engine the codebase is using.