protected override async Task AfterDetect(bool installed) { if (!installed) { return; } var runner = new BrewRunner(Context.Instance); if (InstalledButWrongVersion) { Log.DebugLine($"Unpinning {Name} as wrong version installed (may show warnings if package isn't pinned)"); await runner.UnPin(Name); return; } if (!Pin) { return; } Log.DebugLine($"Pinning {Name} to version {CurrentVersion}"); await runner.Pin(Name); }
public override async Task<bool> Install () { var runner = new BrewRunner (Context.Instance); if (!String.IsNullOrEmpty (HomebrewTapName)) { if (!await runner.Tap (HomebrewTapName)) return false; } bool install = !InstalledButWrongVersion; bool success; if (multipleVersionsPickle) { Log.InfoLine ($"{Name} has multiple versions installed, let's get out of this pickle"); // 1. unpin success = await runner.UnPin (Name); // 2. unlink success = await runner.Unlink (Name); // 3. uninstall --ignore-dependencies success = await runner.Uninstall (Name, ignoreDependencies: true, force: true); install = true; } string installName = HomebrewFormulaUrl != null ? HomebrewFormulaUrl.ToString () : Name; if (!install) { success = await runner.Upgrade (installName); } else success = await runner.Install (installName); if (!success || !Pin) return success; return await runner.Pin (Name); }
protected override async Task AfterDetect(bool installed) { if (!installed) { return; } var runner = new BrewRunner(Context.Instance); if (InstalledButWrongVersion) { Log.DebugLine($"Unpinning {Name} as wrong version installed (may show warnings if package isn't pinned)"); await runner.UnPin(Name); return; } // It may happen that the package is installed but not linked to the prefix that's in the user's PATH. // Detecting whether the package is linked would require requesting and parsing JSON for all the packages which // would be more trouble than it's worth. Let's just link the package await runner.Link(Name, echoOutput : false, echoError : false); if (!Pin) { return; } Log.DebugLine($"Pinning {Name} to version {CurrentVersion}"); await runner.Pin(Name); }
#pragma warning disable CS1998 protected override async Task <bool> Execute(Context context) { var runner = new BrewRunner(context); if (!runner.List("libzip", out List <string> lines) || lines == null || lines.Count == 0) { Log.ErrorLine("Failed to retrieve libzip package contents"); return(false); } string libZipPath = null; foreach (string line in lines) { Match match = libZipDylib.Match(line); if (!match.Success) { continue; } libZipPath = line; break; } if (String.IsNullOrEmpty(libZipPath)) { Log.ErrorLine("`libzip` package does not contain the dynamic library"); return(false); } if (!File.Exists(libZipPath)) { Log.ErrorLine($"`libzip` package lists the dynamic library at {libZipPath} but the file does not exist"); return(false); } Log.DebugLine($"`libzip` library found at {libZipPath}"); string destFile = Path.Combine(Configurables.Paths.InstallMSBuildDir, Path.GetFileName(libZipPath)); Log.Status("Installing "); Log.Status(Utilities.GetRelativePath(BuildPaths.XamarinAndroidSourceRoot, destFile), ConsoleColor.White); Log.StatusLine($" {context.Characters.LeftArrow} ", libZipPath, leadColor: ConsoleColor.Cyan, tailColor: ConsoleColor.White); Utilities.CopyFile(libZipPath, destFile); if (!File.Exists(destFile)) { Log.ErrorLine("Failed to copy the libzip dynamic library."); return(false); } return(true); }
public override async Task <bool> Install() { var runner = new BrewRunner(Context.Instance); if (!String.IsNullOrEmpty(HomebrewTapName)) { if (!await runner.Tap(HomebrewTapName)) { return(false); } } bool success; if (InstalledButWrongVersion) { if (HomebrewFormulaUrl != null) { success = await runner.Upgrade(HomebrewFormulaUrl.ToString()); } else { success = await runner.Upgrade(Name); } } else { success = await runner.Install(Name); } if (!success || !Pin) { return(success); } return(await runner.Pin(Name)); }