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

Commit 28ef155

Browse files
committed
Absurd changes
1 parent 71f7bf5 commit 28ef155

File tree

34 files changed

+164
-54
lines changed

34 files changed

+164
-54
lines changed

Source/Deployer.Lumia/Phone.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public override async Task RemoveExistingWindowsPartitions()
137137
Log.Verbose("Cleanup of possible previous Windows 10 ARM64 installation...");
138138

139139
await RemovePartition("Reserved", await (await GetDeviceDisk()).GetReservedPartition());
140-
await RemovePartition("WoA ESP", await DeviceMixin.GetBootPartition(this));
140+
await RemovePartition("WoA ESP", await this.GetBootPartition());
141141
var winVol = await GetWindowsVolume();
142142
await RemovePartition("WoA", winVol?.Partition);
143143
}

Source/Deployer.NetFx/ImageFlasher.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ public class ImageFlasher : IImageFlasher
1717
{
1818
private readonly Regex percentRegex = new Regex(@"(\d*.\d*)%");
1919

20+
public string EtcherPath
21+
{
22+
get
23+
{
24+
var platformSuffix = Environment.Is64BitProcess ? "x64" : "x86";
25+
var etcherPath = Path.Combine("Core", "Tools", "Etcher-Cli", platformSuffix, "Etcher");
26+
return etcherPath;
27+
}
28+
}
29+
2030
public async Task Flash(Disk disk, string imagePath, IObserver<double> progressObserver = null)
2131
{
2232
ISubject<string> outputSubject = new Subject<string>();
@@ -29,7 +39,7 @@ public async Task Flash(Disk disk, string imagePath, IObserver<double> progressO
2939
{
3040
if (!isValidating && CultureInfo.CurrentCulture.CompareInfo.IndexOf(s, "validating", 0, CompareOptions.IgnoreCase) != -1)
3141
{
32-
Log.Verbose("Validating flashed image...");
42+
Log.Information("Validating flashed image...");
3343
isValidating = true;
3444
}
3545
})
@@ -38,14 +48,9 @@ public async Task Flash(Disk disk, string imagePath, IObserver<double> progressO
3848
.Subscribe(progressObserver);
3949
}
4050

41-
//etcher.exe -d \\.\PHYSICALDRIVE3 "..\Tutorial Googulator\gpt.zip" --yes
42-
var gptSchemeImagePath = Path.Combine("Files", "Core", "Gpt.zip");
43-
44-
var platformSuffix = Environment.Is64BitProcess ? "x64" : "x86";
45-
var etcherPath = Path.Combine("Files", "Tools", "Etcher-Cli", platformSuffix, "Etcher");
46-
var args = $@"-d \\.\PHYSICALDRIVE{disk.Number} ""{gptSchemeImagePath}"" --yes --no-unmount";
47-
Log.Verbose("We are about to run Etcher: {ExecName} {Parameters}", etcherPath, args);
48-
var resultCode = await ProcessUtils.RunProcessAsync(etcherPath, args, outputObserver: outputSubject);
51+
var args = $@"-d \\.\PHYSICALDRIVE{disk.Number} ""{imagePath}"" --yes --no-unmount";
52+
Log.Verbose("We are about to run Etcher: {ExecName} {Parameters}", EtcherPath, args);
53+
var resultCode = await ProcessUtils.RunProcessAsync(EtcherPath, args, outputObserver: outputSubject);
4954
if (resultCode != 0)
5055
{
5156
throw new DeploymentException($"There has been a problem during deployment: Etcher exited with code {resultCode}.");
@@ -54,6 +59,7 @@ public async Task Flash(Disk disk, string imagePath, IObserver<double> progressO
5459
progressObserver?.OnNext(double.NaN);
5560

5661
stdOutputSubscription?.Dispose();
62+
await disk.LowLevelApi.UpdateStorageCache();
5763
}
5864

5965
private double GetPercentage(string output)

Source/Deployer.NetFx/LowLevelApi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public async Task<IList<Volume>> GetVolumes(Disk disk)
8282
return await volumes;
8383
}
8484

85-
private Task UpdateStorageCache()
85+
public Task UpdateStorageCache()
8686
{
8787
ps.Commands.Clear();
8888
ps.AddCommand($@"Update-HostStorageCache");

Source/Deployer.Raspberry.Gui/Deployer.Raspberry.Gui.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
<ItemGroup>
301301
<None Include="..\Deployer.Raspberry\Core\Tools\Etcher-Cli\x64\etcher.exe">
302302
<Link>Core\Tools\Etcher-Cli\x64\etcher.exe</Link>
303+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
303304
</None>
304305
</ItemGroup>
305306
<ItemGroup>
@@ -323,6 +324,7 @@
323324
<ItemGroup>
324325
<None Include="..\Deployer.Raspberry\Core\Tools\Etcher-Cli\x86\etcher.exe">
325326
<Link>Core\Tools\Etcher-Cli\x86\etcher.exe</Link>
327+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
326328
</None>
327329
</ItemGroup>
328330
<ItemGroup>

Source/Deployer.Raspberry.Gui/Locator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
using System;
2+
using System.Linq;
23
using System.Reactive.Subjects;
4+
using System.Reflection;
5+
using Deployer.Execution;
6+
using Deployer.Filesystem.FullFx;
37
using Deployer.Gui.Common;
48
using Deployer.Gui.Common.Services;
59
using Deployer.Gui.Core;
Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
2-
using System.Reactive;
3-
using System.Threading.Tasks;
2+
using System.Reactive.Linq;
43
using ByteSizeLib;
54
using Deployer.Gui.Common;
65
using Deployer.Gui.Core;
@@ -10,25 +9,20 @@ namespace Deployer.Raspberry.Gui.ViewModels
109
{
1110
public class AdvancedViewModel : ReactiveObject, IBusy
1211
{
13-
private readonly UIServices uiServices;
1412
private readonly ISettingsService settingsService;
15-
private readonly IWoaDeployer autoDeployer;
16-
public CommandWrapper<Unit, Unit> InstallGpuWrapper { get; set; }
1713

1814
private readonly ObservableAsPropertyHelper<ByteSize> sizeReservedForWindows;
1915

20-
public AdvancedViewModel(UIServices uiServices, ISettingsService settingsService, IWoaDeployer autoDeployer)
16+
public AdvancedViewModel(ISettingsService settingsService)
2117
{
22-
this.uiServices = uiServices;
2318
this.settingsService = settingsService;
24-
this.autoDeployer = autoDeployer;
25-
19+
2620

2721
sizeReservedForWindows =
2822
this.WhenAnyValue(x => x.GbsReservedForWindows, ByteSize.FromGigaBytes)
2923
.ToProperty(this, x => x.SizeReservedForWindows);
3024

31-
IsBusyObservable = InstallGpuWrapper.Command.IsExecuting;
25+
IsBusyObservable = Observable.Return(false);
3226
}
3327

3428
public ByteSize SizeReservedForWindows => sizeReservedForWindows.Value;
@@ -44,10 +38,6 @@ public double GbsReservedForWindows
4438
}
4539
}
4640

47-
48-
49-
public IObservable<bool> IsBusyObservable { get; }
50-
5141
public bool UseCompactDeployment
5242
{
5343
get => settingsService.UseCompactDeployment;
@@ -58,5 +48,7 @@ public bool UseCompactDeployment
5848
this.RaisePropertyChanged(nameof(UseCompactDeployment));
5949
}
6050
}
51+
52+
public IObservable<bool> IsBusyObservable { get; }
6153
}
6254
}

Source/Deployer.Raspberry.Gui/ViewModels/DeploymentViewModel.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public class DeploymentViewModel : ReactiveObject, IBusy
2121
private DiskViewModel selectedDisk;
2222
private readonly ObservableAsPropertyHelper<IEnumerable<DiskViewModel>> disks;
2323

24-
public DeploymentViewModel(
24+
public DeploymentViewModel(IDeviceProvider deviceProvider,
2525
IWindowsOptionsProvider optionsProvider,
2626
IWoaDeployer deployer, UIServices uiServices, AdvancedViewModel advancedViewModel,
27-
WimPickViewModel wimPickViewModel, ILowLevelApi lowLevel)
27+
WimPickViewModel wimPickViewModel, ILowLevelApi lowLevelApi)
2828
{
2929
this.optionsProvider = optionsProvider;
3030
this.deployer = deployer;
@@ -41,12 +41,14 @@ public DeploymentViewModel(
4141
isBusy = IsBusyObservable.ToProperty(this, model => model.IsBusy);
4242

4343
RefreshDisksCommandWrapper = new CommandWrapper<Unit, ICollection<Disk>>(this,
44-
ReactiveCommand.CreateFromTask(lowLevel.GetDisks), uiServices.DialogService);
44+
ReactiveCommand.CreateFromTask(lowLevelApi.GetDisks), uiServices.DialogService);
4545
disks = RefreshDisksCommandWrapper.Command
4646
.Select(x => x
4747
.Where(y => !y.IsBoot && !y.IsSystem && !y.IsOffline)
4848
.Select(disk => new DiskViewModel(disk)))
4949
.ToProperty(this, x => x.Disks);
50+
51+
this.WhenAnyValue(x => x.SelectedDisk).Where(x => x != null).Subscribe(x => deviceProvider.Device = new RaspberryPi(lowLevelApi, x.Disk));
5052
}
5153

5254
public IEnumerable<DiskViewModel> Disks => disks.Value;
@@ -81,5 +83,5 @@ await uiServices.DialogService.ShowAlert(this, Resources.Finished,
8183

8284
public CommandWrapper<Unit, Unit> FullInstallWrapper { get; set; }
8385
public IObservable<bool> IsBusyObservable { get; }
84-
}
86+
}
8587
}

Source/Deployer.Raspberry.Gui/Views/MarkdownViewerWindow.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<DockPanel>
1616
<Button DockPanel.Dock="Bottom" Margin="15" HorizontalAlignment="Center" Content="Close" Click="OnClick" />
1717
<FlowDocumentScrollViewer Margin="10"
18+
FontFamily="Arial"
19+
FontSize="20"
1820
Document="{Binding Text, Converter={StaticResource TextToFlowDocumentConverter}}" />
1921
</DockPanel>
2022
</mah:MetroWindow>

Source/Deployer.Raspberry.NetFx/ContainerConfigurator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ where type.GetTypeInfo().ImplementedInterfaces.Contains(typeof(IDeploymentTask))
4545
block.Export<BcdInvokerFactory>().As<IBcdInvokerFactory>();
4646
block.Export<WindowsDeployer>().As<IWindowsDeployer>();
4747
block.Export<GitHubDownloader>().As<IGitHubDownloader>();
48+
block.Export<DeviceProvider>().As<IDeviceProvider>().Lifestyle.Singleton();
49+
block.Export<RaspberryDisklayoutPreparer>().As<IDisklayoutPreparer>();
50+
block.Export<ImageFlasher>().As<IImageFlasher>();
51+
block.Export<DismImageService>().As<IWindowsImageService>();
4852

4953
block.ExportFactory(() => AzureDevOpsClient.Create(new Uri("https://dev.azure.com"))).As<IAzureDevOpsBuildClient>();
5054

0 commit comments

Comments
 (0)