Skip to content

Commit

Permalink
Refactor for Windows installation.
Browse files Browse the repository at this point in the history
  • Loading branch information
CartBlanche committed Jun 27, 2024
1 parent e1cee70 commit 33353f5
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions Source/v2/Meadow.Dfu/DfuUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public static class DfuUtils
{
private static readonly int _osAddress = 0x08000000;

private const string DFU_UTIL_AMD64_URL = "http://ftp.de.debian.org/debian/pool/main/d/dfu-util/dfu-util_0.11-1_amd64.deb";
private const string DFU_UTIL_ARM64_URL = "http://ftp.de.debian.org/debian/pool/main/d/dfu-util/dfu-util_0.11-1_arm64.deb";
private const string DFU_UTIL_UBUNTU_AMD64_URL = "http://ftp.de.debian.org/debian/pool/main/d/dfu-util/dfu-util_0.11-1_amd64.deb";
private const string DFU_UTIL_UBUNTU_ARM64_URL = "http://ftp.de.debian.org/debian/pool/main/d/dfu-util/dfu-util_0.11-1_arm64.deb";
private const string DFU_UTIL_WINDOWS_URL = $"https://s3-us-west-2.amazonaws.com/downloads.wildernesslabs.co/public/dfu-util-{DEFAULT_DFU_VERSION}-binaries.zip";
private const string DFU_UTIL = "dfu-util";

public const string DEFAULT_DFU_VERSION = "0.11";
Expand Down Expand Up @@ -240,14 +241,12 @@ private static async Task<bool> InstallDfuUtilOnWindows(string tempFolder, strin

Directory.CreateDirectory(tempFolder);

var downloadUrl = $"https://s3-us-west-2.amazonaws.com/downloads.wildernesslabs.co/public/dfu-util-{dfuUtilVersion}-binaries.zip";

var downloadedFileName = downloadUrl.Substring(downloadUrl.LastIndexOf("/", StringComparison.Ordinal) + 1);

await DownloadFile(downloadUrl, downloadedFileName, cancellationToken);
var downloadedFileName = Path.GetFileName(new Uri(DFU_UTIL_WINDOWS_URL).LocalPath);
var downloadedFilePath = Path.Combine(tempFolder, downloadedFileName);
await DownloadFile(DFU_UTIL_WINDOWS_URL, downloadedFilePath, cancellationToken);

ZipFile.ExtractToDirectory(
Path.Combine(tempFolder, downloadedFileName),
downloadedFilePath,
tempFolder);

var is64Bit = Environment.Is64BitOperatingSystem;
Expand Down Expand Up @@ -452,8 +451,8 @@ private static async Task<bool> InstallPackageOnLinux(string package)
{
var dfuPackageUrl = RuntimeInformation.OSArchitecture switch
{
Architecture.Arm64 => DFU_UTIL_ARM64_URL,
Architecture.X64 => DFU_UTIL_AMD64_URL,
Architecture.Arm64 => DFU_UTIL_UBUNTU_ARM64_URL,
Architecture.X64 => DFU_UTIL_UBUNTU_AMD64_URL,
_ => throw new PlatformNotSupportedException("Unsupported architecture")
};
var fileName = Path.GetFileName(new Uri(dfuPackageUrl).LocalPath);
Expand Down

0 comments on commit 33353f5

Please sign in to comment.