Skip to content
This repository was archived by the owner on Jan 8, 2022. It is now read-only.

Commit 71f7bf5

Browse files
committed
Suave suavesito
1 parent 98e9950 commit 71f7bf5

File tree

4 files changed

+53
-4
lines changed

4 files changed

+53
-4
lines changed

Source/Deployer.Raspberry.NetFx/ContainerConfigurator.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Deployer.Execution;
77
using Deployer.Filesystem.FullFx;
88
using Deployer.FileSystem;
9+
using Deployer.Raspberry;
910
using Deployer.Services;
1011
using Deployer.Tasks;
1112
using Grace.DependencyInjection;
@@ -33,13 +34,13 @@ where type.GetTypeInfo().ImplementedInterfaces.Contains(typeof(IDeploymentTask))
3334
block.ExportFactory(Tokenizer.Create).As<Tokenizer<LangToken>>();
3435
block.Export<ScriptParser>().As<IScriptParser>();
3536
block.ExportFactory(() => installOptionsProvider).As<IWindowsOptionsProvider>();
36-
37+
block.Export<WoaDeployer>().As<IWoaDeployer>();
3738
block.Export<BootCreator>().As<IBootCreator>();
3839
block.Export<LowLevelApi>().As<ILowLevelApi>();
3940
block.ExportInstance(taskTypes).As<IEnumerable<Type>>();
4041
block.Export<ScriptRunner>().As<IScriptRunner>();
4142
block.Export<InstanceBuilder>().As<IInstanceBuilder>();
42-
43+
block.Export<RaspberryPathBuilder>().As<IPathBuilder>();
4344
block.Export<FileSystemOperations>().As<IFileSystemOperations>();
4445
block.Export<BcdInvokerFactory>().As<IBcdInvokerFactory>();
4546
block.Export<WindowsDeployer>().As<IWindowsDeployer>();
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text.RegularExpressions;
5+
using System.Threading.Tasks;
6+
7+
namespace Deployer.Raspberry
8+
{
9+
public class RaspberryPathBuilder : IPathBuilder
10+
{
11+
private readonly IDevice device;
12+
13+
public RaspberryPathBuilder(IDevice device)
14+
{
15+
this.device = device;
16+
}
17+
18+
public async Task<string> Replace(string str)
19+
{
20+
IDictionary<string, Func<Task<string>>> mappings = new Dictionary<string, Func<Task<string>>>()
21+
{
22+
{ "WindowsARM", async () => (await device.GetWindowsVolume()).RootDir.Name },
23+
};
24+
25+
var matching = mappings.Keys.FirstOrDefault(s => str.StartsWith(s, StringComparison.OrdinalIgnoreCase));
26+
if (matching !=null)
27+
{
28+
var replacement = await mappings[matching]();
29+
var replaced = Regex.Replace(str, $"^{matching}", replacement, RegexOptions.IgnoreCase);
30+
return Regex.Replace(replaced, $@"\\+", @"\", RegexOptions.IgnoreCase);
31+
}
32+
33+
return str;
34+
}
35+
36+
private async Task<string> Replace(string str, string identifier, Func<Task<string>> func)
37+
{
38+
var matching = str.StartsWith(identifier, StringComparison.OrdinalIgnoreCase);
39+
if (matching)
40+
{
41+
var replacement = await func();
42+
return Regex.Replace(str, $"^{identifier}", replacement, RegexOptions.IgnoreCase);
43+
}
44+
45+
return str;
46+
}
47+
}
48+
}

Source/Deployer/ISpaceAllocator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Threading.Tasks;
22
using ByteSizeLib;
33

4-
namespace Deployer.Lumia
4+
namespace Deployer
55
{
66
public interface ISpaceAllocator<in TDev> where TDev : IDevice
77
{

Source/Deployer/ITooling.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Threading.Tasks;
22

3-
namespace Deployer.Lumia
3+
namespace Deployer
44
{
55
public interface ITooling
66
{

0 commit comments

Comments
 (0)