#pragma warning restore CS1998 protected override bool DeterminePackageVersion() { var output = Utilities.GetStringFromStdout("pacman", "-Q", PackageName).Split(' '); CurrentVersion = output.Length == 2 ? output[1] : null; return(!String.IsNullOrEmpty(CurrentVersion)); }
string GetPackageVersion() { return(Utilities.GetStringFromStdout( Context.Instance.Tools.BrewPath, false, // throwOnErrors true, // trimTrailingWhitespace true, // quietErrors "ls", "--versions", "-1", Name )); }
public static Linux DetectAndCreate(Context context) { string name; string release; string codeName; string progPath; if (Directory.Exists("/app")) { name = "Flatpak"; release = GetFlatpakRelease(); codeName = String.Empty; } else { if (File.Exists(DefaultLsbReleasePath)) { progPath = DefaultLsbReleasePath; } else { progPath = FindProgram("lsb_release", GetPathDirectories()); } if (String.IsNullOrEmpty(progPath) || !IsExecutable(progPath, true)) { throw new InvalidOperationException("Your Linux distribution lacks a working `lsb_release` command"); } name = Utilities.GetStringFromStdout(progPath, "-is"); release = Utilities.GetStringFromStdout(progPath, "-rs"); codeName = Utilities.GetStringFromStdout(progPath, "-cs"); } Func <Context, Linux> creator; if (!distroMap.TryGetValue(name, out creator)) { throw new InvalidOperationException($"Your Linux distribution ({name} {release}) is not supported at this time."); } Linux linux = creator(context); linux.Name = name; linux.Release = release; linux.warnBinFmt = ShouldWarnAboutBinfmt(); linux.codeName = codeName; Log.Instance.Todo("Check Mono version and error out if not the required minimum version"); return(linux); }
protected override bool DeterminePackageVersion() { string currentVersion = Utilities.GetStringFromStdout("pacman", "-Q", "--", PackageName); int index = currentVersion.IndexOf(' '); if (index < 0) { Log.Error($"Could not determine version of {PackageName}"); return(false); } CurrentVersion = currentVersion.Substring(PackageName.Length + 1).Trim(); return(true); }
string GetPackageVersion () { string output = Utilities.GetStringFromStdout ( Context.Instance.Tools.BrewPath, false, // throwOnErrors true, // trimTrailingWhitespace true, // quietErrors "ls", "--versions", Name ); if (String.IsNullOrEmpty (output)) return output; string[] lines = output.Split (lineSplit, StringSplitOptions.RemoveEmptyEntries); if (lines.Length == 0) return String.Empty; return lines [0]; }
protected override bool InitOS() { if (!base.InitOS()) { return(false); } string brewPath = Which("brew", false); if (String.IsNullOrEmpty(brewPath)) { Log.ErrorLine("Could not find Homebrew on this system, please install it from https://brew.sh/"); return(false); } Context.MonoOptions.Add("--arch=64"); Context.Instance.Tools.BrewPath = brewPath; HomebrewPrefix = Utilities.GetStringFromStdout(brewPath, "--prefix"); (bool success, string bv) = Utilities.GetProgramVersion(brewPath); if (!success || !Version.TryParse(bv, out Version brewVersion)) { Log.ErrorLine("Failed to obtain Homebrew version"); return(false); } HomebrewVersion = brewVersion; // This is a hack since we have a chicken-and-egg problem. On mac, Configuration.props uses the // `HostHomebrewPrefix` property which is defined in `Configuration.OperatingSystem.props` but we're here to // *generate* the latter file, so when the bootstrapper is built `HostHomebrewPrefix` is empty and we can't // access mingw utilities. So, we need to cheat here. string mxePath = Context.Instance.Properties.GetValue(KnownProperties.AndroidMxeFullPath); if (String.IsNullOrEmpty(mxePath)) { Context.Instance.Properties.Set(KnownProperties.AndroidMxeFullPath, HomebrewPrefix); } AntDirectory = HomebrewPrefix; return(true); }
public virtual string GetVersion(Context context, string fullProgramPath) { if (context == null) { throw new ArgumentNullException(nameof(context)); } string programPath = String.IsNullOrEmpty(fullProgramPath) ? ProgramName : fullProgramPath; if (Path.IsPathRooted(ProgramName)) { programPath = ProgramName; } else if (ProgramName.IndexOf(Path.DirectorySeparatorChar) >= 0) { if (ProgramName [0] == Path.DirectorySeparatorChar) // Might be the case on Windows { programPath = Path.GetFullPath(ProgramName); } else { programPath = Path.Combine(BuildPaths.XamarinAndroidSourceRoot, ProgramName); } } else { programPath = context.OS.Which(ProgramName, required: false); } if (!Utilities.FileExists(programPath)) { Log.DebugLine("File {fullProgramPath} does not exist, unable to obtain version"); return(DefaultVersionString); } string versionOutput = Utilities.GetStringFromStdout(programPath, VersionArguments); Log.DebugLine($"{programPath} {VersionArguments} returned: {versionOutput}"); return(ParseVersion(versionOutput)); }
public MacOS(Context context) : base(context) { Flavor = "macOS"; string progPath = FindProgram("sw_vers", GetPathDirectories()); if (!String.IsNullOrEmpty(progPath)) { Name = Utilities.GetStringFromStdout(progPath, "-productName"); string release = Utilities.GetStringFromStdout(progPath, "-productVersion"); string build = Utilities.GetStringFromStdout(progPath, "-buildVersion"); Build = build; Release = $"{release} ({build})"; if (!Version.TryParse(release, out Version ver)) { Log.WarningLine($"Unable to parse macOS version: {release}"); Version = new Version(0, 0, 0); } else { Version = ver; } } else { Name = "macOS"; Release = "0.0.0"; Build = "Unknown"; Version = new Version(0, 0, 0); } processIsTranslated = GetProcessIsTranslated(); Dependencies = new List <Program> (); }
public async Task <Version> GetPackageVersion(string packageId, bool echoOutput = false, bool echoError = true) { if (String.IsNullOrEmpty(packageId)) { throw new ArgumentException("must not be null or empty", nameof(packageId)); } string output = Utilities.GetStringFromStdout(GetRunner(echoOutput, echoError, "--pkg-info", packageId))?.Trim(); if (String.IsNullOrEmpty(output)) { return(null); } string v = null; foreach (string l in output.Split('\n')) { if (GetFieldValue(l.Trim(), "version:", out v)) { break; } } if (String.IsNullOrEmpty(v)) { Log.WarningLine($"Package info for {packageId} is empty"); return(null); } if (!Version.TryParse(v, out Version pkgVer)) { Log.ErrorLine($"Failed to parse package {packageId} version from '{v}'"); return(null); } return(pkgVer); }
static bool DetectLsbRelease(ref string name, ref string release, ref string codeName, ref string idLike, ref string id) { string progPath; if (File.Exists(DefaultLsbReleasePath)) { progPath = DefaultLsbReleasePath; } else { progPath = FindProgram("lsb_release", GetPathDirectories()); } if (String.IsNullOrEmpty(progPath) || !IsExecutable(progPath, true)) { return(false); } id = name = Utilities.GetStringFromStdout(progPath, "-is"); release = Utilities.GetStringFromStdout(progPath, "-rs"); codeName = Utilities.GetStringFromStdout(progPath, "-cs"); return(true); }
string CaptureBrewOutput(params string[] parameters) { return(Utilities.GetStringFromStdout(GetBrewRunner(false, true, parameters))); }
protected override bool DeterminePackageVersion() { CurrentVersion = Utilities.GetStringFromStdout("dpkg-query", "-f", "${Version}", "-W", PackageName); return(!String.IsNullOrEmpty(CurrentVersion)); }
protected override void DetectCompilers() { string ccVersion = Utilities.GetStringFromStdout(Configurables.Defaults.DefaultCompiler, "--version"); if (String.IsNullOrEmpty(ccVersion)) { throw new InvalidOperationException($"Failed to obtain version information from the {Configurables.Defaults.DefaultCompiler} compiler"); } Log.DebugLine($"Default compiler {Configurables.Defaults.DefaultCompiler} identifies as:"); Log.DebugLine(ccVersion); bool clang = false; if (ccVersion.IndexOf("Free Software Foundation", StringComparison.OrdinalIgnoreCase) >= 0) { CC = "gcc"; CXX = "g++"; } else if (ccVersion.IndexOf("clang", StringComparison.OrdinalIgnoreCase) >= 0) { CC = "clang"; CXX = "clang++"; clang = true; } else { CC = "cc"; CXX = "c++"; } VerifyCompilersExist(); Triple = Utilities.GetStringFromStdout(CC, "-dumpmachine"); if (String.IsNullOrEmpty(Triple)) { throw new InvalidOperationException($"Failed to determine default target triple for compiler {CC}"); } if (Is64Bit) { CC64 = CC; CXX64 = CXX; CC32 = $"{CC} -m32"; CXX32 = $"{CXX} -m32"; if (clang) { Triple32 = Utilities.GetStringFromStdout(CC, "-m32", "-dumpmachine"); } else { if (!Triple.StartsWith("x86_64-", StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException($"Unexpected 64-bit triple '{Triple}'"); } Triple32 = Triple.Replace("x86_64-", "i686-"); } Triple64 = Triple; } else { CC64 = null; CXX64 = null; CC32 = CC; CXX32 = CXX; Triple32 = Triple; Triple64 = null; } LogCompilerDetails(); }
protected override bool CheckWhetherInstalled() { string status = Utilities.GetStringFromStdout("dpkg-query", "-f", "${db:Status-Abbrev}", "-W", PackageName); return(!String.IsNullOrEmpty(status) && status.Length >= 2 && status[1] == 'i'); }
protected Unix(Context context) : base(context) { Architecture = Utilities.GetStringFromStdout("uname", "-m")?.Trim(); }
protected override bool DeterminePackageVersion() { CurrentVersion = Utilities.GetStringFromStdout("rpm", "-q", PackageName, "--qf", "%{version}"); return(!String.IsNullOrEmpty(CurrentVersion)); }
string CaptureBrewOutput(List <string> arguments) { return(Utilities.GetStringFromStdout(GetBrewRunner(false, true, arguments))); }
protected override void DetectCompilers() { string cc = Environment.GetEnvironmentVariable("CC")?.Trim() ?? String.Empty; string cxx = Environment.GetEnvironmentVariable("CXX")?.Trim() ?? String.Empty; string defaultCompiler = String.Empty; if (!String.IsNullOrEmpty(cc)) { Log.DebugLine($"Unix C compiler read from environment variable CC: {cc}"); defaultCompiler = cc; } if (!String.IsNullOrEmpty(cxx)) { Log.DebugLine($"Unix C++ compiler read from environment variable CXX: {cxx}"); if (String.IsNullOrEmpty(defaultCompiler)) { defaultCompiler = cxx; } } if (String.IsNullOrEmpty(defaultCompiler)) { defaultCompiler = Configurables.Defaults.DefaultCompiler; if (String.IsNullOrEmpty(defaultCompiler)) { throw new InvalidOperationException("Default compiler not specified"); } } string ccVersion = Utilities.GetStringFromStdout(defaultCompiler, "--version"); if (String.IsNullOrEmpty(ccVersion)) { throw new InvalidOperationException($"Failed to obtain version information from the {defaultCompiler} compiler"); } Log.DebugLine($"Compiler {defaultCompiler} identifies as:"); Log.DebugLine(ccVersion); bool clang = false; if (ccVersion.IndexOf("Free Software Foundation", StringComparison.OrdinalIgnoreCase) >= 0) { CC = GetCompiler(cc, "gcc"); CXX = GetCompiler(cxx, "g++"); } else if (ccVersion.IndexOf("clang", StringComparison.OrdinalIgnoreCase) >= 0) { CC = GetCompiler(cc, "clang"); CXX = GetCompiler(cxx, "clang++"); clang = true; } else { CC = GetCompiler(cc, "cc"); CXX = GetCompiler(cxx, "c++"); } VerifyCompilersExist(); Triple = Utilities.GetStringFromStdout(CC, "-dumpmachine"); if (String.IsNullOrEmpty(Triple)) { throw new InvalidOperationException($"Failed to determine default target triple for compiler {CC}"); } if (Is64Bit) { CC64 = CC; CXX64 = CXX; CC32 = $"{CC} -m32"; CXX32 = $"{CXX} -m32"; if (clang) { Triple32 = Utilities.GetStringFromStdout(CC, "-m32", "-dumpmachine"); } else { if (!Triple.StartsWith("x86_64-", StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException($"Unexpected 64-bit triple '{Triple}'"); } Triple32 = Triple.Replace("x86_64-", "i686-"); } Triple64 = Triple; } else { CC64 = String.Empty; CXX64 = String.Empty; CC32 = CC; CXX32 = CXX; Triple32 = Triple; Triple64 = String.Empty; } LogCompilerDetails(); }
#pragma warning disable CS1998 public async Task <bool> LogPackagesInstalled() { Log.StatusLine("Installed packages:"); Log.StatusLine(Utilities.GetStringFromStdout(GetRunner(true, true, "--pkgs"))); return(true); }