Skip to content

Commit d5958cf

Browse files
committed
Cargo will use cargo-binstall to install and upgrade packages, added some more install & update options (fix marticliment#2884)
1 parent f03eb8f commit d5958cf

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

src/UniGetUI.PackageEngine.Managers.Cargo/Cargo.cs

+17-4
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,29 @@ public partial class Cargo : PackageManager
2626
public Cargo()
2727
{
2828
Dependencies = [
29-
// cargo-update is required to check for and update installed packages
29+
// cargo-update is required to check for installed and upgradable packages
3030
new ManagerDependency(
3131
"cargo-update",
3232
Path.Join(Environment.SystemDirectory, "windowspowershell\\v1.0\\powershell.exe"),
3333
"-ExecutionPolicy Bypass -NoLogo -NoProfile -Command \"& {cargo install cargo-update; if ($error.count -ne 0){pause}}\"",
3434
"cargo install cargo-update",
3535
async () => (await CoreTools.WhichAsync("cargo-install-update.exe")).Item1),
36+
// Cargo-binstall is required to install and update cargo binaries
37+
new ManagerDependency(
38+
"cargo-binstall",
39+
Path.Join(Environment.SystemDirectory, "windowspowershell\\v1.0\\powershell.exe"),
40+
"-ExecutionPolicy Bypass -NoLogo -NoProfile -Command \"& {Set-ExecutionPolicy Unrestricted -Scope Process; iex (iwr \\\"https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1\\\").Content; if ($error.count -ne 0){pause}}\"",
41+
"Set-ExecutionPolicy Unrestricted -Scope Process; iex (iwr \"https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1\").Content",
42+
async () => (await CoreTools.WhichAsync("cargo-binstall.exe")).Item1)
3643
];
3744

38-
Capabilities = new ManagerCapabilities { };
45+
Capabilities = new ManagerCapabilities
46+
{
47+
CanRunAsAdmin = true,
48+
CanSkipIntegrityChecks = true,
49+
SupportsCustomVersions = true,
50+
SupportsCustomLocations = true,
51+
};
3952

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

@@ -46,9 +59,9 @@ public Cargo()
4659
IconId = IconType.Rust,
4760
ColorIconId = "cargo_color",
4861
ExecutableFriendlyName = "cargo.exe",
49-
InstallVerb = "install",
62+
InstallVerb = "binstall",
5063
UninstallVerb = "uninstall",
51-
UpdateVerb = "install-update",
64+
UpdateVerb = "binstall",
5265
ExecutableCallArgs = "",
5366
DefaultSource = cratesIo,
5467
KnownSources = [cratesIo]

src/UniGetUI.PackageEngine.Managers.Cargo/Helpers/CargoPkgOperationHelper.cs

+12
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ protected override IEnumerable<string> _getOperationParameters(IPackage package,
1717
_ => throw new InvalidDataException("Invalid package operation"),
1818
};
1919

20+
if (operation is OperationType.Install or OperationType.Update)
21+
{
22+
parameters.Add("--no-confirm");
23+
24+
if(options.SkipHashCheck)
25+
parameters.Add("--skip-signatures");
26+
27+
if(options.CustomInstallLocation != "")
28+
parameters.AddRange(["--install-path", options.CustomInstallLocation]);
29+
}
30+
31+
parameters.AddRange(options.CustomParameters);
2032
return parameters;
2133
}
2234

0 commit comments

Comments
 (0)