diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index e3e4ac11459..95313d59df0 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -81,7 +81,7 @@ jobs: id: android-build continue-on-error: true run: | - make jenkins PREPARE_CI=1 PREPARE_AUTOPROVISION=1 CONFIGURATION=Debug + make jenkins PREPARE_CI=1 CONFIGURATION=Debug timeout-minutes: 60 - name: Log disk space (after android build) diff --git a/Configuration.props b/Configuration.props index 1539d0aeb42..870a4620286 100644 --- a/Configuration.props +++ b/Configuration.props @@ -56,8 +56,6 @@ $(BuildOutputDirectory)lib\packs\ - False - False <_XABinRelativeInstallPrefix>lib\xamarin.android $(MSBuildThisFileDirectory)bin\$(Configuration)\$(_XABinRelativeInstallPrefix)\ <_MonoAndroidNETOutputRoot>$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\ diff --git a/Documentation/building/configuration.md b/Documentation/building/configuration.md index 75d278b2bd0..1a535cc50e2 100644 --- a/Documentation/building/configuration.md +++ b/Documentation/building/configuration.md @@ -29,11 +29,6 @@ and will override any default values specified in `Configuration.props`. Overridable MSBuild properties include: - * `$(AutoProvision)`: Automatically install required dependencies, if possible. - Only supported on macOS and certain Linux distros. - - * `$(AutoProvisionUsesSudo)`: Use `sudo` when installing dependencies. - * `$(AndroidApiLevel)`: The Android API level to bind in `src/Mono.Android`. This is an integer value, e.g. `15` for [API-15 (Android 4.0.3)](http://developer.android.com/about/versions/android-4.0.3.html). diff --git a/Documentation/building/unix/dependencies.md b/Documentation/building/unix/dependencies.md index 67c3fcfbc9e..a9904e640b3 100644 --- a/Documentation/building/unix/dependencies.md +++ b/Documentation/building/unix/dependencies.md @@ -15,19 +15,17 @@ Building .NET for Android requires: [dotnetsdk]: https://docs.microsoft.com/de-de/dotnet/core/install/sdk The `make prepare` build step (or `/t:Prepare` on Windows) will -check that all required dependencies are present. -If you would like `make prepare` to automatically install -required dependencies, set the `$(AutoProvision)` MSBuild property to True -and (if necessary) set the `$(AutoProvisionUsesSudo)` property to True. -(This is not supported on all operating systems; -see [configuration.md](../configuration.md) for details.) - -If `$(AutoProvision)` is False (the default) and a dependency is missing, -then the build will fail and an error message will be displayed attempting -to provide install instructions to obtain the missing dependency, e.g.: +check that all required dependencies are present. If a dependency is +missing, the build will fail and an error message will be displayed +attempting to provide install instructions to obtain the missing +dependency, e.g.: error : Could not find required program '7za'. Please run: brew install 'p7zip'. +Install any missing dependencies using your platform's package manager +(e.g. `brew install p7zip` on macOS, `sudo apt-get install p7zip-full` +on Debian/Ubuntu). + ## Homebrew diff --git a/Makefile b/Makefile index ca6ed31fc9f..a90eb79a841 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,6 @@ PREPARE_MSBUILD_FLAGS = $(PREPARE_MSBUILD_ARGS) $(MSBUILD_ARGS) PREPARE_SCENARIO = PREPARE_CI_PR ?= 0 PREPARE_CI ?= 0 -PREPARE_AUTOPROVISION ?= 0 LOCALIZE_TEMPLATES ?= 0 _PREPARE_CI_MODE_PR_ARGS = --no-emoji --run-mode=CI @@ -31,12 +30,6 @@ ifeq ($(OS_ARCH),) export OS_ARCH := $(shell uname -m) endif -export NO_SUDO ?= false - -ifneq ($(NO_SUDO),false) -_PREPARE_ARGS += --auto-provisioning-uses-sudo=false -endif - ifneq ($(V),0) MONO_OPTIONS += --debug NUGET_VERBOSITY = -Verbosity Detailed @@ -51,10 +44,6 @@ ifneq ($(PREPARE_CI),0) _PREPARE_ARGS += $(_PREPARE_CI_MODE_ARGS) endif -ifneq ($(PREPARE_AUTOPROVISION),0) -_PREPARE_ARGS += --auto-provision=yes --auto-provision-uses-sudo=yes -endif - ifneq ($(PREPARE_SCENARIO),) _PREPARE_ARGS += -s:"$(PREPARE_SCENARIO)" endif diff --git a/build-tools/automation/azure-pipelines-apidocs.yaml b/build-tools/automation/azure-pipelines-apidocs.yaml index 37adcf90628..a71ca76ea5c 100644 --- a/build-tools/automation/azure-pipelines-apidocs.yaml +++ b/build-tools/automation/azure-pipelines-apidocs.yaml @@ -136,7 +136,7 @@ extends: - script: boots https://download.mono-project.com/archive/6.12.0/macos-10-universal/MonoFramework-MDK-6.12.0.188.macos10.xamarin.universal.pkg displayName: Install Mono - - script: make prepare CONFIGURATION=$(XA.Build.Configuration) PREPARE_CI=1 PREPARE_AUTOPROVISION=1 + - script: make prepare CONFIGURATION=$(XA.Build.Configuration) PREPARE_CI=1 workingDirectory: $(Build.SourcesDirectory) displayName: make prepare diff --git a/build-tools/automation/yaml-templates/build-linux-steps.yaml b/build-tools/automation/yaml-templates/build-linux-steps.yaml index cc5b4ac56d4..c85d5d7d021 100644 --- a/build-tools/automation/yaml-templates/build-linux-steps.yaml +++ b/build-tools/automation/yaml-templates/build-linux-steps.yaml @@ -11,6 +11,13 @@ parameters: steps: - template: /build-tools/automation/yaml-templates/log-disk-space.yaml +- ${{ if ne(parameters.use1ESTemplate, true) }}: + - bash: | + set -e + sudo apt-get update + sudo apt-get install -y p7zip-full cmake ninja-build ccache + displayName: Install build dependencies on Linux + - template: /build-tools/automation/yaml-templates/setup-jdk-variables.yaml parameters: useAgentJdkPath: false @@ -35,7 +42,7 @@ steps: parameters: xaSourcePath: ${{ parameters.xaSourcePath }} -- script: make jenkins PREPARE_CI=1 PREPARE_AUTOPROVISION=1 CONFIGURATION=$(XA.Build.Configuration) MSBUILD_ARGS='${{ parameters.makeMSBuildArgs }}' +- script: make jenkins PREPARE_CI=1 CONFIGURATION=$(XA.Build.Configuration) MSBUILD_ARGS='${{ parameters.makeMSBuildArgs }}' workingDirectory: ${{ parameters.xaSourcePath }} displayName: make jenkins retryCountOnTaskFailure: 1 diff --git a/build-tools/automation/yaml-templates/build-macos-steps.yaml b/build-tools/automation/yaml-templates/build-macos-steps.yaml index 6b441020bb6..edcaffbee53 100644 --- a/build-tools/automation/yaml-templates/build-macos-steps.yaml +++ b/build-tools/automation/yaml-templates/build-macos-steps.yaml @@ -17,8 +17,8 @@ steps: - ${{ if ne(parameters.use1ESTemplate, true) }}: - bash: | set -e - brew install p7zip - displayName: Install p7zip on macOS + brew install p7zip cmake ninja ccache + displayName: Install build dependencies on macOS - template: /build-tools/automation/yaml-templates/setup-jdk-variables.yaml parameters: @@ -45,7 +45,7 @@ steps: xaSourcePath: ${{ parameters.xaSourcePath }} # Prepare and Build everything -- script: make jenkins CONFIGURATION=$(XA.Build.Configuration) PREPARE_CI=1 PREPARE_AUTOPROVISION=1 MSBUILD_ARGS='${{ parameters.makeMSBuildArgs }}' +- script: make jenkins CONFIGURATION=$(XA.Build.Configuration) PREPARE_CI=1 MSBUILD_ARGS='${{ parameters.makeMSBuildArgs }}' workingDirectory: ${{ parameters.xaSourcePath }} displayName: make jenkins retryCountOnTaskFailure: 1 diff --git a/build-tools/automation/yaml-templates/build-windows-steps.yaml b/build-tools/automation/yaml-templates/build-windows-steps.yaml index 7fc987b2bd0..e3b83ed4de8 100644 --- a/build-tools/automation/yaml-templates/build-windows-steps.yaml +++ b/build-tools/automation/yaml-templates/build-windows-steps.yaml @@ -36,7 +36,7 @@ steps: retryCountOnTaskFailure: 1 inputs: projects: Xamarin.Android.sln - arguments: '-c $(XA.Build.Configuration) -t:Prepare --no-restore -p:AutoProvision=true -bl:$(System.DefaultWorkingDirectory)\bin\Build$(XA.Build.Configuration)\dotnet-build-prepare.binlog' + arguments: '-c $(XA.Build.Configuration) -t:Prepare --no-restore -bl:$(System.DefaultWorkingDirectory)\bin\Build$(XA.Build.Configuration)\dotnet-build-prepare.binlog' # Build Xamarin.Android and configure local workloads to test improved local build loop - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml diff --git a/build-tools/automation/yaml-templates/commercial-build.yaml b/build-tools/automation/yaml-templates/commercial-build.yaml index 35af92b8d57..94ccd2ff676 100644 --- a/build-tools/automation/yaml-templates/commercial-build.yaml +++ b/build-tools/automation/yaml-templates/commercial-build.yaml @@ -31,7 +31,7 @@ steps: condition: and(succeeded(), eq(variables['Codeql.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main')) # Prepare and Build everything -- script: make jenkins CONFIGURATION=$(XA.Build.Configuration) PREPARE_CI=1 PREPARE_AUTOPROVISION=1 MSBUILD_ARGS='${{ parameters.makeMSBuildArgs }}' +- script: make jenkins CONFIGURATION=$(XA.Build.Configuration) PREPARE_CI=1 MSBUILD_ARGS='${{ parameters.makeMSBuildArgs }}' workingDirectory: ${{ parameters.xaSourcePath }} displayName: make jenkins diff --git a/build-tools/xaprepare/README.md b/build-tools/xaprepare/README.md index 1e792f7ab88..53be76c2522 100644 --- a/build-tools/xaprepare/README.md +++ b/build-tools/xaprepare/README.md @@ -150,10 +150,6 @@ You can append the following parameters to the command line: All and any command line parameters accepted by the utility - `PREPARE_SCENARIO=""` Name of the "scenario" to run - - `PREPARE_AUTOPROVISION=0|1` - If set to `0` (the default), the utility will take notice of missing/outdated software the build depends on and exit with an error - should any such condition is detected. Setting the property to `1` will let the utility install the software (installation **may** - use `sudo` on Unix so you will need administrator/root credentials for it to work) - `V=1` Causes the run to output much more information (making output much more messy in the process) to the console. Normally this additional information is placed only in the log files generated by the utility. diff --git a/build-tools/xaprepare/xaprepare/Application/Context.cs b/build-tools/xaprepare/xaprepare/Application/Context.cs index b112f5f5864..c4ec9a63d52 100644 --- a/build-tools/xaprepare/xaprepare/Application/Context.cs +++ b/build-tools/xaprepare/xaprepare/Application/Context.cs @@ -126,16 +126,6 @@ partial class Context : AppObject /// public bool NoEmoji { get; set; } = !Configurables.Defaults.UseEmoji; - /// - /// Automatically provision all the missing programs - /// - public bool AutoProvision { get; set; } - - /// - /// If a program being provisioned automatically requires administrative rights to install, use sudo - /// - public bool AutoProvisionUsesSudo { get; set; } - /// /// Current session execution mode. See /// diff --git a/build-tools/xaprepare/xaprepare/Application/HomebrewProgram.MacOS.cs b/build-tools/xaprepare/xaprepare/Application/HomebrewProgram.MacOS.cs deleted file mode 100644 index 2b6cdd1bde9..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/HomebrewProgram.MacOS.cs +++ /dev/null @@ -1,242 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - class HomebrewProgram : Program, IBuildInventoryItem - { - static readonly char[] lineSplit = new [] { '\n' }; - - string? cachedVersionOutput; - bool brewNeedsSudo = false; - bool multipleVersionsPickle = false; - - public override bool NeedsSudoToInstall => brewNeedsSudo; - public string HomebrewTapName { get; } = String.Empty; - public Uri? HomebrewFormulaUrl { get; } - public bool Pin { get; set; } - - public string BuildToolName => Name; - - public string BuildToolVersion => CurrentVersion; - - public HomebrewProgram (string homebrewPackageName, string? executableName = null) - : this (homebrewPackageName, homebrewTap: null, executableName: executableName) - {} - - public HomebrewProgram (string homebrewPackageName, Uri homebrewFormulaUrl, string? executableName = null) - : this (homebrewPackageName, homebrewTap: null, executableName: executableName) - { - HomebrewFormulaUrl = homebrewFormulaUrl ?? throw new ArgumentNullException (nameof (homebrewFormulaUrl)); - } - - public HomebrewProgram (string homebrewPackageName, string? homebrewTap, string? executableName) - { - if (String.IsNullOrEmpty (homebrewPackageName)) - throw new ArgumentException ("must not be null or empty", nameof (homebrewPackageName)); - Name = homebrewPackageName; - HomebrewTapName = homebrewTap?.Trim () ?? String.Empty; - ExecutableName = executableName?.Trim () ?? String.Empty; - } - - public override async Task 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); - - await DetermineCurrentVersion (); - AddToInventory (); - - if (!success || !Pin) - return success; - - return await runner.Pin (Name); - } - - protected override bool CheckWhetherInstalled () - { - if (String.IsNullOrEmpty (Name)) { - Log.DebugLine ("Homebrew package name not specified, unable to check installation state"); - return false; - } - - cachedVersionOutput = GetPackageVersion (); - return !String.IsNullOrEmpty (cachedVersionOutput); - } - - protected override bool ForceReinstall () - { - Log.DebugLine ($"ForceReinstall called, pickle? {multipleVersionsPickle}"); - return multipleVersionsPickle; - } - - protected override bool ParseVersion (string? version, out Version? ver) - { - if (base.ParseVersion (version, out ver)) - return true; - - ver = null; - if (String.IsNullOrEmpty (version)) - return false; - - // It is sometimes possible (if one tries hard) to have two versions of the same package installed. - // In such instances brew will report *all* the versions in a single line, e.g.: - // - // $ brew ls --versions -1 mingw-w64 - // mingw-w64 7.0.0_1 6.0.0_1 - // - // We need to handle it here *and* on install time (see Install above) - - int pos = version!.IndexOf (' '); - if (pos > 0) { - Log.DebugLine ($"Brew reported more than one version of {Name} is installed: {version}"); - multipleVersionsPickle = true; - var versions = new List (); - foreach (string v in version.Split (' ')) { - string cvs = GetCleanedUpVersion (v); - if (Version.TryParse (cvs, out Version? tempVer) && tempVer != null) { - versions.Add (tempVer); - } - } - - if (versions.Count == 0) { - Log.DebugLine ($"Failed to parse any valid versions for {Name} from {version}"); - return false; - } - - versions.Sort (); - ver = versions [0]; - Log.DebugLine ($"Will use version {ver}"); - return true; - } - - string cv = GetCleanedUpVersion (version); - if (Version.TryParse (cv, out ver)) - return true; - - Log.DebugLine ($"Failed to parse {Name} version {version}"); - return false; - - string GetCleanedUpVersion (string inVer) - { - // Some brew packages (e.g. mingw-w64) have "weird" version formats, we'll handle them here on the - // case-by-case basis. First we should try some general rules to handle the weird versions, checking package - // name should be the very last resort. - pos = inVer.IndexOf ('_'); - if (pos < 0) - return inVer; - return inVer.Replace ('_', '.'); - } - } - - protected override async Task DetermineCurrentVersion () - { - bool result = await base.DetermineCurrentVersion (); - if (result) - return true; - - if (String.IsNullOrEmpty (cachedVersionOutput)) { - cachedVersionOutput = GetPackageVersion (); - if (String.IsNullOrEmpty (cachedVersionOutput)) - return false; - } - - string[] parts = cachedVersionOutput!.Split (new [] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); - if (parts.Length != 2) { - Log.DebugLine ($"Unable to parse {Name} version from Homebrew output: '{cachedVersionOutput}'"); - return false; - } - - string currentVersion = parts [1]; - if (String.IsNullOrEmpty (currentVersion)) { - Log.DebugLine ($"Missing Homebrew version info for package {Name}"); - return false; - } - - CurrentVersion = currentVersion; - if (multipleVersionsPickle) { - Log.DebugLine ($"Multiple versions of {Name} are installed, forcing reinstallation"); - return false; - } - - return true; - } - - protected override async Task AfterDetect (bool installed) - { - if (!installed) - return; - - AddToInventory (); - - 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); - } - - 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]; - } - - public void AddToInventory () - { - if (!string.IsNullOrEmpty (BuildToolName) && !string.IsNullOrEmpty (BuildToolVersion) && !Context.Instance.BuildToolsInventory.ContainsKey (BuildToolName)) { - Context.Instance.BuildToolsInventory.Add (BuildToolName, BuildToolVersion); - } - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/IBuildInventoryItem.cs b/build-tools/xaprepare/xaprepare/Application/IBuildInventoryItem.cs deleted file mode 100644 index d57998539e0..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/IBuildInventoryItem.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace Xamarin.Android.Prepare -{ - interface IBuildInventoryItem - { - string BuildToolName { get; } - string BuildToolVersion { get; } - void AddToInventory (); - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs b/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs index e80df2d8537..620d9a4b7d8 100644 --- a/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs +++ b/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs @@ -13,8 +13,6 @@ static class KnownProperties public const string AndroidSupportedTargetJitAbis = "AndroidSupportedTargetJitAbis"; public const string AndroidToolchainCacheDirectory = "AndroidToolchainCacheDirectory"; public const string AndroidToolchainDirectory = "AndroidToolchainDirectory"; - public const string AutoProvision = "AutoProvision"; - public const string AutoProvisionUsesSudo = "AutoProvisionUsesSudo"; public const string CLRRuntimeFlavorDirName = "_CLRRuntimeFlavorDirName"; public const string CMakePath = "CmakePath"; public const string Configuration = "Configuration"; diff --git a/build-tools/xaprepare/xaprepare/Application/PkgProgram.MacOS.cs b/build-tools/xaprepare/xaprepare/Application/PkgProgram.MacOS.cs deleted file mode 100644 index 42c65ec0d2d..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/PkgProgram.MacOS.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.IO; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - class PkgProgram : Program - { - public override bool NeedsSudoToInstall => false; - public string PackageId { get; } - public Uri? PackageUrl { get; set; } - protected bool SkipPkgUtilVersionCheck { get; set; } - - public PkgProgram (string name, string packageId, Uri? packageUrl = null) - { - if (String.IsNullOrEmpty (name)) - throw new ArgumentException ("must not be null or empty", nameof (name)); - - if (String.IsNullOrEmpty(packageId)) - throw new ArgumentException ("must not be null or empty", nameof (packageId)); - - Name = name; - PackageId = packageId; - PackageUrl = packageUrl; - } - - public override async Task Install () - { - Context context = Context.Instance; - - if (!context.AutoProvisionUsesSudo) { - Log.ErrorLine ("Installation of macOS packages requires sudo to be enabled (pass `--auto-provision-uses-sudo=yes` to the bootstrapper)"); - return false; - } - - if (PackageUrl == null) { - Log.ErrorLine ($"{Name} is not installed but no URL is provided to download it from. Please make sure to install it before continuing"); - return false; - } - - (bool success, ulong size) = await Utilities.GetDownloadSize (PackageUrl); - if (!success) { - Log.ErrorLine ($"Failed to get download size of {PackageUrl}"); - return false; - } - - DownloadStatus downloadStatus = Utilities.SetupDownloadStatus (context, size, context.InteractiveSession); - Log.StatusLine ($" {context.Characters.Link} {PackageUrl}", ConsoleColor.White); - - string localPath = Path.Combine (context.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory), Path.GetFileName (PackageUrl.LocalPath)); - success = await Utilities.Download (PackageUrl, localPath, downloadStatus); - if (!success) { - Log.ErrorLine ($"Failed to download {PackageUrl}"); - return false; - } - - var runner = new ProcessRunner ("sudo") { - EchoStandardError = true, - EchoStandardOutput = true, - ProcessTimeout = TimeSpan.FromMinutes (10) - }; - - runner.AddArgument ("/usr/sbin/installer"); - runner.AddArgument ("-verbose"); - runner.AddArgument ("-pkg"); - runner.AddQuotedArgument (localPath); - runner.AddArgument ("-target"); - runner.AddArgument ("/"); - - return await Task.Run (() => runner.Run ()); - } - - protected override bool CheckWhetherInstalled () - { - return GetVersion (echoError: false).Result != null; - } - - protected override async Task DetermineCurrentVersion () - { - if (SkipPkgUtilVersionCheck) - return await base.DetermineCurrentVersion (); - - var runner = new PkgutilRunner (Context.Instance); - - Version? ver = await GetVersion (echoError: true); - if (ver == null) - return false; - - CurrentVersion = ver.ToString (); - return true; - } - - async Task GetVersion (bool echoError) - { - var runner = new PkgutilRunner (Context.Instance); - return await runner.GetPackageVersion (PackageId, echoError: echoError); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/Program.ArchLinux.cs b/build-tools/xaprepare/xaprepare/Application/Program.ArchLinux.cs deleted file mode 100644 index e93058c11f1..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/Program.ArchLinux.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - class ArchLinuxProgram : LinuxProgram - { - public ArchLinuxProgram (string packageName, string? executableName = null) - : base (packageName, executableName) - {} - - protected override bool CheckWhetherInstalled () - { - return Utilities.RunCommand ("pacman", "-Q", PackageName); - } - -#pragma warning disable CS1998 - public override async Task Install () - { - var runner = new ProcessRunner ("sudo", "pacman", "-S", "--noconfirm", PackageName) { - EchoStandardOutput = true, - EchoStandardError = true, - ProcessTimeout = TimeSpan.FromMinutes (30), - }; - - bool failed = await Task.Run (() => !runner.Run ()); - if (failed) { - Log.Error ($"Installation of {PackageName} timed out"); - failed = true; - } - - if (runner.ExitCode != 0) { - Log.Error ($"Installation failed with error code {runner.ExitCode}"); - failed = true; - } - - return !failed; - } -#pragma warning restore CS1998 - - protected override bool DeterminePackageVersion() - { - var output = Utilities.GetStringFromStdout ("pacman", "-Q", PackageName).Split(' '); - if (output.Length == 2) { - CurrentVersion = output[1]; - return true; - } - - return false; - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/Program.DebianLinux.cs b/build-tools/xaprepare/xaprepare/Application/Program.DebianLinux.cs deleted file mode 100644 index ea72489ce7d..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/Program.DebianLinux.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - class DebianLinuxProgram : LinuxProgram - { - class AptGetStandardStreamWrapper : ProcessStandardStreamWrapper - { - bool interactive = Context.Instance.InteractiveSession; - - public AptGetStandardStreamWrapper () - { - LoggingLevel = ProcessStandardStreamWrapper.LogLevel.Message; - } - - protected override string? PreprocessMessage (string? message, ref bool writeLine, out bool ignoreLine) - { - ignoreLine = false; - // apt-get calls `dpkg` which can't be persuaded to not show any progress and it shows the progress by - // writing a line which ends with `0x0D` that is supposed to move the caret to the beginning of the line - // which doesn't work with System.Diagnostics.Process because it strips 0x0D and 0x0A before passing the - // line to us... So in order to keep the display straight we need to reset the cursor position blindly - // here. - Console.CursorLeft = 1; - return message?.TrimEnd (); - } - } - - public DebianLinuxProgram (string packageName, string? executableName = null) - : base (packageName, executableName) - {} - - 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'; - } - - public override async Task Install () - { - var runner = new ProcessRunner ("sudo", "apt-get", "-y", "-f", "-u", "install", PackageName) { - EchoStandardOutput = true, - EchoStandardError = true, - ProcessTimeout = TimeSpan.FromMinutes (30), - StandardOutputEchoWrapper = new AptGetStandardStreamWrapper (), - }; - - bool failed = await Task.Run (() => !runner.Run ()); - if (failed) { - Log.Error ($"Installation of {PackageName} timed out"); - failed = true; - } - - if (runner.ExitCode != 0) { - Log.Error ($"Installation failed with error code {runner.ExitCode}"); - failed = true; - } - - return !failed; - } - - protected override bool DeterminePackageVersion () - { - CurrentVersion = Utilities.GetStringFromStdout ("dpkg-query", "-f", "${Version}", "-W", PackageName); - return !String.IsNullOrEmpty (CurrentVersion); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/Program.FedoraLinux.cs b/build-tools/xaprepare/xaprepare/Application/Program.FedoraLinux.cs deleted file mode 100644 index 856a6487290..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/Program.FedoraLinux.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - class FedoraLinuxProgram : LinuxProgram - { - public FedoraLinuxProgram (string packageName, string? executableName = null) - : base (packageName, executableName) - {} - - protected override bool CheckWhetherInstalled () - { - return Utilities.RunCommand ("rpm", "-q", PackageName); - } - - public override async Task Install () - { - var runner = new ProcessRunner ("sudo", "dnf", "-y", "install", PackageName) { - EchoStandardOutput = true, - EchoStandardError = true, - ProcessTimeout = TimeSpan.FromMinutes (30), - }; - - bool failed = await Task.Run (() => !runner.Run ()); - if (failed) { - Log.Error ($"Installation of {PackageName} timed out"); - failed = true; - } - - if (runner.ExitCode != 0) { - Log.Error ($"Installation failed with error code {runner.ExitCode}"); - failed = true; - } - - return !failed; - } - - protected override bool DeterminePackageVersion() - { - CurrentVersion = Utilities.GetStringFromStdout ("rpm", "-q", PackageName, "--qf", "%{version}"); - return !String.IsNullOrEmpty (CurrentVersion); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/Program.GentooLinux.cs b/build-tools/xaprepare/xaprepare/Application/Program.GentooLinux.cs deleted file mode 100644 index 2b32b5dea20..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/Program.GentooLinux.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - class GentooLinuxProgram : LinuxProgram - { - public GentooLinuxProgram (string packageName, string? executableName = null) - : base (packageName, executableName) - {} - - protected override bool CheckWhetherInstalled () - { - var output = Utilities.GetStringFromStdout ("equery", "--quiet", "list", PackageName).Replace ($"{PackageName.Split (':') [0]}-", "").Split ('-', '_'); - if (output.Length >= 1 && !String.IsNullOrEmpty (output [0])) { - CurrentVersion = output [0]; - return true; - } - - return false; - } - -#pragma warning disable CS1998 - public override async Task Install () - { - ProcessRunner runner; - if (NeedsSudoToInstall) { - runner = new ProcessRunner ("sudo", "emerge", "--oneshot", PackageName) { - EchoStandardOutput = true, - EchoStandardError = true, - ProcessTimeout = TimeSpan.FromMinutes (60), // gcc most probably will not compile in 60 minutes... - }; - } - else - { - runner = new ProcessRunner ("emerge", "--oneshot", PackageName) { - EchoStandardOutput = true, - EchoStandardError = true, - ProcessTimeout = TimeSpan.FromMinutes (60), // gcc most probably will not compile in 60 minutes... - }; - } - - bool failed = await Task.Run (() => !runner.Run ()); - if (failed) { - Log.Error ($"Installation of {PackageName} timed out"); - failed = true; - } - - if (runner.ExitCode != 0) { - Log.Error ($"Installation failed with error code {runner.ExitCode}"); - failed = true; - } - - return !failed; - } -#pragma warning restore CS1998 - - protected override bool DeterminePackageVersion() - { - return true; - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/Program.Linux.cs b/build-tools/xaprepare/xaprepare/Application/Program.Linux.cs deleted file mode 100644 index d16155dbc00..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/Program.Linux.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - abstract class LinuxProgram : Program - { - public override bool NeedsSudoToInstall => true; - - public string PackageName { get; } - - public LinuxProgram (string packageName, string? executableName) - { - if (String.IsNullOrEmpty (packageName)) - throw new ArgumentException ("must not be null or empty", nameof (packageName)); - PackageName = packageName; - Name = packageName; - ExecutableName = executableName; - } - - protected override async Task DetermineCurrentVersion () - { - bool ret = await base.DetermineCurrentVersion (); - if (ret) - return true; - - Log.DebugLine ($"Getting {Name} version from package manager"); - return DeterminePackageVersion (); - } - - protected abstract bool DeterminePackageVersion (); - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in b/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in index 83ce47017ab..94ce58595c5 100644 --- a/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in +++ b/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in @@ -17,8 +17,6 @@ namespace Xamarin.Android.Prepare properties.Add (KnownProperties.AndroidSupportedTargetJitAbis, StripQuotes ("@AndroidSupportedTargetJitAbis@")); properties.Add (KnownProperties.AndroidToolchainCacheDirectory, StripQuotes (@"@AndroidToolchainCacheDirectory@")); properties.Add (KnownProperties.AndroidToolchainDirectory, StripQuotes (@"@AndroidToolchainDirectory@")); - properties.Add (KnownProperties.AutoProvision, StripQuotes ("@AutoProvision@")); - properties.Add (KnownProperties.AutoProvisionUsesSudo, StripQuotes ("@AutoProvisionUsesSudo@")); properties.Add (KnownProperties.CLRRuntimeFlavorDirName, StripQuotes ("@_CLRRuntimeFlavorDirName@")); properties.Add (KnownProperties.CMakePath, StripQuotes (@"@CmakePath@")); properties.Add (KnownProperties.Configuration, StripQuotes ("@Configuration@")); diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Arch.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Arch.cs index 8a99cc04638..caa4371fe1e 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Arch.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Arch.cs @@ -1,57 +1,12 @@ -using System.Collections.Generic; - namespace Xamarin.Android.Prepare { class LinuxArch : Linux { - static readonly List packages = new List { - new ArchLinuxProgram ("autoconf"), - new ArchLinuxProgram ("automake"), - new ArchLinuxProgram ("binutils"), - new ArchLinuxProgram ("bison"), - new ArchLinuxProgram ("curl"), - new ArchLinuxProgram ("fakeroot"), - new ArchLinuxProgram ("file"), - new ArchLinuxProgram ("findutils"), - new ArchLinuxProgram ("flex"), - new ArchLinuxProgram ("gawk"), - new ArchLinuxProgram ("gcc"), - new ArchLinuxProgram ("gettext"), - new ArchLinuxProgram ("git"), - new ArchLinuxProgram ("grep"), - new ArchLinuxProgram ("groff"), - new ArchLinuxProgram ("gtk-sharp-2"), - new ArchLinuxProgram ("gzip"), - new ArchLinuxProgram ("jdk8-openjdk"), - new ArchLinuxProgram ("libtool"), - new ArchLinuxProgram ("libzip"), - new ArchLinuxProgram ("m4"), - new ArchLinuxProgram ("make"), - new ArchLinuxProgram ("patch"), - new ArchLinuxProgram ("pkg-config"), - new ArchLinuxProgram ("sed"), - new ArchLinuxProgram ("texinfo"), - new ArchLinuxProgram ("unzip"), - new ArchLinuxProgram ("which"), - new ArchLinuxProgram ("zip"), - new ArchLinuxProgram ("p7zip"), - }; - public LinuxArch (Context context) : base (context) - { - Dependencies.AddRange (packages); - } + {} protected override void InitializeDependencies () {} - - protected override bool InitOS () - { - if (!base.InitOS ()) - return false; - - return true; - } }; } diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Debian.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Debian.cs index af397d531ff..b1e2ab42bb3 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Debian.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Debian.cs @@ -1,6 +1,6 @@ using System; -using System.IO; using System.Collections.Generic; +using System.IO; namespace Xamarin.Android.Prepare { @@ -8,28 +8,6 @@ class LinuxDebian : LinuxDebianCommon { const string DebianVersionPath = "/etc/debian_version"; - static readonly List packages = new List { - new DebianLinuxProgram ("libtool-bin", "libtool"), - }; - - static readonly List packagesPre10 = new List { - new DebianLinuxProgram ("openjdk-8-jdk"), - }; - - static readonly List packagesPreTrixie = new List { - new DebianLinuxProgram ("libncurses5-dev"), - }; - - static readonly List packagesTrixieAndLater = new List { - new DebianLinuxProgram ("libncurses-dev"), - }; - - // zulu-8 does NOT exist as official Debian package! We need it for our bots, but we have to figure out what to - // do with Debian 10+ in general, as it does not contain OpenJDK 8 anymore and we require it to work. - static readonly List packages10AndNewerBuildBots = new List { - new DebianLinuxProgram ("zulu-8"), - }; - static readonly Dictionary DebianUnstableVersionMap = new Dictionary (StringComparer.OrdinalIgnoreCase) { { "bookworm", "12" }, { "bookworm/sid", "12" }, @@ -43,38 +21,7 @@ class LinuxDebian : LinuxDebianCommon public LinuxDebian (Context context) : base (context) - { - Dependencies.AddRange (packages); - } - - protected override void InitializeDependencies () - { - base.InitializeDependencies (); - - if (DebianRelease.Major >= 10 || (IsTesting && String.Compare ("buster", CodeName, StringComparison.OrdinalIgnoreCase) == 0)) { - if (Context.IsRunningOnHostedAzureAgent) - Dependencies.AddRange (packages10AndNewerBuildBots); - if (DebianRelease.Major >= 13 || (String.Compare ("SparkyLinux", Name, StringComparison.OrdinalIgnoreCase) == 0 && DebianRelease.Major >= 7)) { - Dependencies.AddRange (packagesTrixieAndLater); - } else { - Dependencies.AddRange (packagesPreTrixie); - } - } else { - Dependencies.AddRange (packagesPre10); - Dependencies.AddRange (packagesPreTrixie); - } - } - - static bool IsDebian13OrNewer (string? version) - { - if (String.IsNullOrEmpty (version)) { - return false; - } - - return - version.IndexOf ("trixie", StringComparison.OrdinalIgnoreCase) >= 0 || - version.IndexOf ("sid", StringComparison.OrdinalIgnoreCase) >= 0; - } + {} static bool IsDebian10OrNewer (string? version) { diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.DebianCommon.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.DebianCommon.cs index 8ae39063597..8cddc22ecb5 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.DebianCommon.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.DebianCommon.cs @@ -1,43 +1,9 @@ -using System.Collections.Generic; - namespace Xamarin.Android.Prepare { abstract class LinuxDebianCommon : Linux { - static readonly List commonPackages = new List { - new DebianLinuxProgram ("autoconf"), - new DebianLinuxProgram ("autotools-dev"), - new DebianLinuxProgram ("automake"), - new DebianLinuxProgram ("ccache"), - new DebianLinuxProgram ("cmake"), - new DebianLinuxProgram ("build-essential"), - new DebianLinuxProgram ("cli-common-dev"), - new DebianLinuxProgram ("curl"), - new DebianLinuxProgram ("devscripts"), - new DebianLinuxProgram ("gcc"), - new DebianLinuxProgram ("g++"), - new DebianLinuxProgram ("git"), - new DebianLinuxProgram ("libtool"), - new DebianLinuxProgram ("linux-libc-dev"), - new DebianLinuxProgram ("make"), - new DebianLinuxProgram ("ninja-build", "ninja"), - new DebianLinuxProgram ("p7zip-full", "7z"), - new DebianLinuxProgram ("sqlite3"), - new DebianLinuxProgram ("vim-common"), - new DebianLinuxProgram ("zlib1g-dev"), - }; - - static readonly List commonPackages64bit = new List { - new DebianLinuxProgram ("lib32stdc++6"), - new DebianLinuxProgram ("lib32z1"), - }; - protected override void InitializeDependencies () - { - Dependencies.AddRange (commonPackages); - if (!Is64Bit) - Dependencies.AddRange (commonPackages64bit); - } + {} protected LinuxDebianCommon (Context context) : base (context) diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Fedora.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Fedora.cs index 1727890f9c6..1ba55f1321e 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Fedora.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Fedora.cs @@ -1,56 +1,12 @@ -using System.Collections.Generic; - namespace Xamarin.Android.Prepare { class LinuxFedora : Linux { - static readonly List packages = new List { - new FedoraLinuxProgram ("autoconf"), - new FedoraLinuxProgram ("automake"), - new FedoraLinuxProgram ("binutils"), - new FedoraLinuxProgram ("bison"), - new FedoraLinuxProgram ("curl"), - new FedoraLinuxProgram ("fakeroot"), - new FedoraLinuxProgram ("file"), - new FedoraLinuxProgram ("findutils"), - new FedoraLinuxProgram ("flex"), - new FedoraLinuxProgram ("gawk"), - new FedoraLinuxProgram ("gcc"), - new FedoraLinuxProgram ("gettext"), - new FedoraLinuxProgram ("git"), - new FedoraLinuxProgram ("grep"), - new FedoraLinuxProgram ("groff"), - new FedoraLinuxProgram ("gtk-sharp2"), - new FedoraLinuxProgram ("gzip"), - new FedoraLinuxProgram ("java-1.8.0-openjdk"), - new FedoraLinuxProgram ("libtool"), - new FedoraLinuxProgram ("libzip"), - new FedoraLinuxProgram ("m4"), - new FedoraLinuxProgram ("make"), - new FedoraLinuxProgram ("patch"), - new FedoraLinuxProgram ("pkgconf"), - new FedoraLinuxProgram ("sed"), - new FedoraLinuxProgram ("texinfo"), - new FedoraLinuxProgram ("unzip"), - new FedoraLinuxProgram ("which"), - new FedoraLinuxProgram ("zip"), - new FedoraLinuxProgram ("p7zip"), - }; - public LinuxFedora (Context context) : base (context) - { - Dependencies.AddRange (packages); - } + {} protected override void InitializeDependencies () {} - - protected override bool InitOS () - { - if (!base.InitOS ()) - return false; - return true; - } } } diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Gentoo.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Gentoo.cs index d335db6edb6..04c11352aa1 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Gentoo.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Gentoo.cs @@ -1,58 +1,12 @@ -using System.Collections.Generic; - namespace Xamarin.Android.Prepare { class LinuxGentoo : Linux { - static readonly List packages = new List { - new GentooLinuxProgram ("sys-devel/autoconf"), - new GentooLinuxProgram ("sys-devel/automake"), - new GentooLinuxProgram ("sys-devel/binutils"), - new GentooLinuxProgram ("sys-devel/bison"), - new GentooLinuxProgram ("net-misc/curl"), - new GentooLinuxProgram ("sys-apps/fakeroot"), - new GentooLinuxProgram ("sys-apps/file"), - new GentooLinuxProgram ("sys-apps/findutils"), - new GentooLinuxProgram ("sys-devel/flex"), - new GentooLinuxProgram ("sys-apps/gawk"), - new GentooLinuxProgram ("sys-devel/gcc"), - new GentooLinuxProgram ("sys-devel/gettext"), - new GentooLinuxProgram ("dev-vcs/git"), - new GentooLinuxProgram ("sys-apps/grep"), - new GentooLinuxProgram ("sys-apps/groff"), - //new GentooLinuxProgram ("gtk-sharp-2"), - new GentooLinuxProgram ("app-arch/gzip"), - new GentooLinuxProgram ("dev-java/openjdk-bin:8"), - new GentooLinuxProgram ("sys-devel/libtool"), - new GentooLinuxProgram ("dev-libs/libzip"), - new GentooLinuxProgram ("sys-devel/m4"), - new GentooLinuxProgram ("sys-devel/make"), - new GentooLinuxProgram ("sys-devel/patch"), - new GentooLinuxProgram ("dev-util/pkgconf"), - //new GentooLinuxProgram ("referenceassemblies-pcl"), - new GentooLinuxProgram ("sys-apps/sed"), - new GentooLinuxProgram ("sys-apps/texinfo"), - new GentooLinuxProgram ("app-arch/unzip"), - new GentooLinuxProgram ("sys-apps/which"), - new GentooLinuxProgram ("app-arch/zip"), - new GentooLinuxProgram ("app-arch/p7zip"), - }; - public LinuxGentoo (Context context) : base (context) - { - Dependencies.AddRange (packages); - } + {} protected override void InitializeDependencies () {} - - protected override bool InitOS () - { - if (!base.InitOS ()) - return false; - - return true; - } }; } diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Mint.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Mint.cs index 8614a588312..b23fa3fff0e 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Mint.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Mint.cs @@ -2,8 +2,6 @@ namespace Xamarin.Android.Prepare { class LinuxMint : LinuxUbuntu { - protected override bool NeedLibtool => UbuntuRelease.Major == 19; - public LinuxMint (Context context) : base (context) {} }; diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Ubuntu.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Ubuntu.cs index 793341225be..32413e05f90 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Ubuntu.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Ubuntu.cs @@ -1,43 +1,14 @@ using System; -using System.Collections.Generic; namespace Xamarin.Android.Prepare { class LinuxUbuntu : LinuxUbuntuCommon { - static readonly List preCosmicPackages = new List { - new DebianLinuxProgram ("libx32tinfo-dev"), - }; - - static readonly List cosmicPackages = new List { - new DebianLinuxProgram ("libx32ncurses6-dev"), - }; - - static readonly List preDiscoPackages = new List { - new DebianLinuxProgram ("openjdk-8-jdk"), - }; - protected Version UbuntuRelease { get; private set; } = new Version (0, 0); - protected override bool NeedLibtool => (UbuntuRelease.Major == 17 && UbuntuRelease.Minor == 10) | UbuntuRelease.Major >= 18; - public LinuxUbuntu (Context context) : base (context) {} - protected override void InitializeDependencies () - { - base.InitializeDependencies (); - - if (UbuntuRelease.Major < 18 || (UbuntuRelease.Major == 18 && UbuntuRelease.Minor < 10)) - Dependencies.AddRange (preCosmicPackages); - else { - if (UbuntuRelease.Major < 20) - Dependencies.AddRange (cosmicPackages); - if (UbuntuRelease.Major < 19) - Dependencies.AddRange (preDiscoPackages); - } - } - protected override bool EnsureVersionInformation (Context context) { if (!Version.TryParse (Release, out Version? ubuntuRelease) || ubuntuRelease == null) { diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.UbuntuCommon.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.UbuntuCommon.cs index 2fb35695b6e..79bfe0823b4 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.UbuntuCommon.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.UbuntuCommon.cs @@ -1,29 +1,9 @@ -using System; -using System.Collections.Generic; - namespace Xamarin.Android.Prepare { abstract partial class LinuxUbuntuCommon : LinuxDebianCommon { - static readonly List libtoolPackages = new List { - new DebianLinuxProgram ("libtool-bin", "libtool"), - }; - - protected virtual bool NeedLibtool { get; } = false; - protected LinuxUbuntuCommon (Context context) : base (context) {} - - protected override bool InitOS () - { - if (!base.InitOS ()) - return false; - - if (NeedLibtool) - Dependencies.AddRange (libtoolPackages); - - return true; - } }; } diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/MacOS.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/MacOS.cs index e92fac0645d..b486ff03da8 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/MacOS.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/MacOS.cs @@ -1,38 +1,10 @@ -using System; -using System.Collections.Generic; - namespace Xamarin.Android.Prepare { partial class MacOS { - static readonly List programs = new List { - new HomebrewProgram ("autoconf"), - new HomebrewProgram ("automake"), - new HomebrewProgram ("ccache"), - new HomebrewProgram ("cmake"), - new HomebrewProgram ("make"), - new HomebrewProgram ("ninja"), - new HomebrewProgram ("p7zip", "7za"), - }; - - static readonly HomebrewProgram git = new HomebrewProgram ("git") { - MinimumVersion = "2.20.0", - }; - protected override void InitializeDependencies () { - Dependencies.AddRange (programs); - - // Allow using git from $PATH if it has the right version - (bool success, string bv) = Utilities.GetProgramVersion (git.Name); - if (success && Version.TryParse (bv, out Version? gitVersion) && - Version.TryParse (git.MinimumVersion, out Version? gitMinVersion)) { - if (gitVersion < gitMinVersion) - Dependencies.Add (git); - - } else { - Dependencies.Add (git); - } + // No-op: per-OS dependency provisioning has been removed. } } } diff --git a/build-tools/xaprepare/xaprepare/Main.cs b/build-tools/xaprepare/xaprepare/Main.cs index 4a65478c8be..59a06992fb2 100644 --- a/build-tools/xaprepare/xaprepare/Main.cs +++ b/build-tools/xaprepare/xaprepare/Main.cs @@ -25,8 +25,6 @@ sealed class ParsedOptions public bool ListScenarios { get; set; } = false; public string CompressionFormat { get; set; } = Configurables.Defaults.DefaultCompressionFormat.Name; public string? Configuration { get; set; } - public bool AutoProvision { get; set; } - public bool AutoProvisionUsesSudo { get; set; } } public static int Main (string[] args) @@ -73,10 +71,7 @@ static async Task Run (string[] args) Encoding.RegisterProvider (CodePagesEncodingProvider.Instance); var optionErrors = new List (); - ParsedOptions parsedOptions = new ParsedOptions { - AutoProvision = ParseBoolean (Context.Instance.Properties.GetValue (KnownProperties.AutoProvision)), - AutoProvisionUsesSudo = ParseBoolean (Context.Instance.Properties.GetValue (KnownProperties.AutoProvisionUsesSudo)), - }; + ParsedOptions parsedOptions = new ParsedOptions (); var opts = new OptionSet { "Usage: xaprepare [OPTIONS]", @@ -95,9 +90,6 @@ static async Task Run (string[] args) {"cf=", $"{{NAME}} of the compression format to use for some archives (e.g. the XA bundle). One of: {GetCompressionFormatNames ()}; Default: {parsedOptions.CompressionFormat}", v => parsedOptions.CompressionFormat = v?.Trim () ?? String.Empty}, {"c|configuration=", $"Build {{CONFIGURATION}}. Default: {Context.Instance.Configuration}", v => parsedOptions.Configuration = v?.Trim ()}, "", - {"auto-provision=", $"Automatically install software required by .NET for Android", v => parsedOptions.AutoProvision = ParseBoolean (v)}, - {"auto-provision-uses-sudo=", $"Allow use of sudo(1) when provisioning", v => parsedOptions.AutoProvisionUsesSudo = ParseBoolean (v)}, - "", {"h|help", "Show this help message", v => parsedOptions.ShowHelp = true }, }; @@ -124,8 +116,6 @@ static async Task Run (string[] args) Context.Instance.ExecutionMode = parsedOptions.ExecutionMode; Context.Instance.LoggingVerbosity = parsedOptions.Verbosity; Context.Instance.DebugFileExtension = parsedOptions.DebugFileExtension; - Context.Instance.AutoProvision = parsedOptions.AutoProvision; - Context.Instance.AutoProvisionUsesSudo = parsedOptions.AutoProvisionUsesSudo; if (!String.IsNullOrEmpty (parsedOptions.Configuration)) Context.Instance.Configuration = parsedOptions.Configuration!; diff --git a/build-tools/xaprepare/xaprepare/OperatingSystems/OS.cs b/build-tools/xaprepare/xaprepare/OperatingSystems/OS.cs index 91c4247851f..c891417dd6e 100644 --- a/build-tools/xaprepare/xaprepare/OperatingSystems/OS.cs +++ b/build-tools/xaprepare/xaprepare/OperatingSystems/OS.cs @@ -175,12 +175,10 @@ public virtual void ShowFinalNotices () /// /// Initialize OS support. Initializes basic OS properties (by calling ), dependencies (by /// calling ) as well as makes sure that all the dependencies are - /// installed and initializes the environment. + /// present and initializes the environment. /// /// - /// Missing dependencies are installed only if - /// condition is set and and is true. If the two conditions aren't - /// met and missing programs are found, the initialization fails unless the is set to true in which case only a warning is /// printed regarding the missing dependencies. /// @@ -206,8 +204,6 @@ async Task EnsureDependencies () if (Dependencies == null) throw new InvalidOperationException ("Dependencies not set"); - Log.Todo ("Implement 'package refresh' mode where we reinstall packages/programs forcibly"); - int maxNameLength = GetMaxNameLength (Dependencies); var missing = new List (); foreach (Program p in Dependencies) { @@ -236,53 +232,14 @@ async Task EnsureDependencies () return true; bool ignoreMissing = Context.Instance.CheckCondition (KnownConditions.IgnoreMissingPrograms); - if (!Context.Instance.AutoProvision) { - string message = "Some programs are missing or have invalid versions, but automatic provisioning is disabled"; - if (ignoreMissing) { - Log.WarningLine ($"{message}. Ignoring missing programs."); - return true; - } - - Log.ErrorLine (message); - return false; - } - - maxNameLength = GetMaxNameLength (missing); - Context.Banner ("Installing programs"); - if (missing.Any (p => p.NeedsSudoToInstall)) - Log.StatusLine ("You might be prompted for your sudo password"); - - bool someFailed = false; - foreach (Program p in missing) { - if (p.NeedsSudoToInstall && !Context.AutoProvisionUsesSudo) { - Log.ErrorLine ($"Program '{p.Name}' requires sudo to install but sudo is disabled"); - someFailed = true; - continue; - } - - if (!p.CanInstall ()) { - if (!ignoreMissing) - someFailed = true; - Log.Status ("Installation disabled for "); - Log.StatusLine (p.Name.PadRight (maxNameLength), ConsoleColor.Cyan); - continue; - } - - Log.Status ("Installing "); - Log.StatusLine (p.Name.PadRight (maxNameLength), ConsoleColor.White); - bool success = await p.Install (); - Log.StatusLine (); - if (success) - continue; - - someFailed = true; - Log.ErrorLine ($"Installation of {p.Name} failed"); + string message = "Some programs are missing or have invalid versions"; + if (ignoreMissing) { + Log.WarningLine ($"{message}. Ignoring missing programs."); + return true; } - if (someFailed) - throw new InvalidOperationException ("Failed to install some required programs."); - - return true; + Log.ErrorLine (message); + return false; int GetMaxNameLength (List list) { diff --git a/build-tools/xaprepare/xaprepare/OperatingSystems/Unix.cs b/build-tools/xaprepare/xaprepare/OperatingSystems/Unix.cs index 3e56688fda4..5b4c56a7c5e 100644 --- a/build-tools/xaprepare/xaprepare/OperatingSystems/Unix.cs +++ b/build-tools/xaprepare/xaprepare/OperatingSystems/Unix.cs @@ -61,7 +61,6 @@ protected static bool IsExecutable (string fullPath, bool throwOnErrors = false) protected override void PopulateEnvironmentVariables () { base.PopulateEnvironmentVariables (); - EnvironmentVariables ["NO_SUDO"] = Context.AutoProvisionUsesSudo ? "false" : "true"; List monoOptions = Context.MonoOptions; if (monoOptions != null && monoOptions.Count > 0) diff --git a/build-tools/xaprepare/xaprepare/ToolRunners/BrewRunner.MacOS.cs b/build-tools/xaprepare/xaprepare/ToolRunners/BrewRunner.MacOS.cs deleted file mode 100644 index d8a6dc35202..00000000000 --- a/build-tools/xaprepare/xaprepare/ToolRunners/BrewRunner.MacOS.cs +++ /dev/null @@ -1,200 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - partial class BrewRunner : ToolRunner - { - static readonly Version sudoVersion = new Version (1, 1); - static readonly char[] lineSplit = new [] { '\n' }; - - bool? needSudo; - bool? needArch; - - protected override string DefaultToolExecutableName => GetDefaultExecutableName (); - protected override string ToolName => "Homebrew"; - - string BrewPath => Context.Instance?.Tools?.BrewPath ?? "brew"; - - public BrewRunner (Context context, Log? log = null, string? toolPath = null) - : base (context, log, toolPath) - { - ProcessTimeout = TimeSpan.FromMinutes (30); - EchoStandardError = true; - EchoStandardOutput = true; - } - - string GetDefaultExecutableName () - { - if (!needSudo.HasValue) { - // MUST use Context.Instance as the `Context` property might be null here - var os = Context.Instance.OS as MacOS; - if (os == null) - throw new InvalidOperationException ($"BrewRunner does not suppport {Context.Instance.OS.Name}"); - - needSudo = os.HomebrewVersion != null && os.HomebrewVersion < sudoVersion; - needArch = os.ProcessIsTranslated; - } - - if (needSudo ?? false) - return "sudo"; - if (needArch ?? false) - return "arch"; - - return BrewPath; - } - - public async Task Tap (string tapName, bool echoOutput = true, bool echoError = true) - { - if (String.IsNullOrEmpty (tapName)) - throw new ArgumentException ("must not be null or empty", nameof (tapName)); - - return await RunBrew (echoOutput, echoError, "tap", tapName); - } - - public async Task Install (string packageName, bool echoOutput = true, bool echoError = true) - { - if (String.IsNullOrEmpty (packageName)) - throw new ArgumentException ("must not be null or empty", nameof (packageName)); - - return await RunBrew (echoOutput, echoError, "install", packageName); - } - - public async Task Uninstall (string packageName, bool ignoreDependencies = false, bool force = false, bool echoOutput = true, bool echoError = true) - { - if (String.IsNullOrEmpty (packageName)) - throw new ArgumentException ("must not be null or empty", nameof (packageName)); - - var arguments = new List { - "uninstall" - }; - - - if (ignoreDependencies) - arguments.Add ("--ignore-dependencies"); - if (force) - arguments.Add ("--force"); - arguments.Add (packageName); - - return await RunBrew (echoOutput, echoError, arguments); - } - - public async Task Unlink (string packageName, bool echoOutput = true, bool echoError = true) - { - if (String.IsNullOrEmpty (packageName)) - throw new ArgumentException ("must not be null or empty", nameof (packageName)); - - return await RunBrew (echoOutput, echoError, "unlink", packageName); - } - - public async Task Link (string packageName, bool echoOutput = true, bool echoError = true) - { - if (String.IsNullOrEmpty (packageName)) - throw new ArgumentException ("must not be null or empty", nameof (packageName)); - - return await RunBrew (echoOutput, echoError, "link", packageName); - } - - public async Task Upgrade (string packageName, bool echoOutput = true, bool echoError = true) - { - if (String.IsNullOrEmpty (packageName)) - throw new ArgumentException ("must not be null or empty", nameof (packageName)); - - return await RunBrew (echoOutput, echoError, "upgrade", packageName); - } - - public async Task Pin (string packageName, bool echoOutput = false, bool echoError = false) - { - if (String.IsNullOrEmpty (packageName)) - throw new ArgumentException ("must not be null or empty", nameof (packageName)); - - return await RunBrew (echoOutput, echoError, "pin", packageName); - } - - public async Task UnPin (string packageName, bool echoOutput = false, bool echoError = false) - { - if (String.IsNullOrEmpty (packageName)) - throw new ArgumentException ("must not be null or empty", nameof (packageName)); - - return await RunBrew (echoOutput, echoError, "unpin", packageName);; - } - - public bool List (string packageName, out List? lines) - { - if (String.IsNullOrEmpty (packageName)) - throw new ArgumentException ("must not be null or empty", nameof (packageName)); - - lines = null; - string? listing = CaptureBrewOutput ("ls", packageName)?.Trim (); - if (String.IsNullOrEmpty (listing)) - return false; - - lines = new List (listing!.Split (lineSplit, StringSplitOptions.RemoveEmptyEntries)); - return true; - } - - string CaptureBrewOutput (string command, string packageName) - { - return CaptureBrewOutput (new List { command, packageName }); - } - - string CaptureBrewOutput (List arguments) - { - return Utilities.GetStringFromStdout (GetBrewRunner (false, true, arguments)); - } - - async Task RunBrew (bool echoOutput, bool echoError, string command, string packageName) - { - return await RunBrew (echoOutput, echoError, new List { command, packageName }); - } - - async Task RunBrew (bool echoOutput, bool echoError, List arguments) - { - ProcessRunner runner = GetBrewRunner (echoOutput, echoError, arguments); - bool success = await RunTool (() => runner.Run ()); - if (!success) { - var os = Context.Instance.OS as MacOS; - if (os == null) { - throw new InvalidOperationException ("Context.Instance.OS is not MacOS!"); - } - os.HomebrewErrors = true; - } - - return success; - } - - ProcessRunner GetBrewRunner (bool echoOutput, bool echoError, List arguments) - { - ProcessRunner runner = CreateProcessRunner (); - - if ((needSudo ?? false) && (needArch ?? false)) { - // So we run `sudo arch -arch x86_64 brew …` - runner.AddArgument ("arch"); - } - - if (needArch ?? false) { - runner.AddArgument ("-arch"); - runner.AddArgument ("x86_64"); - } - - if ((needSudo ?? false) || (needArch ?? false)) { - runner.AddArgument (BrewPath); - } - - AddArguments (runner, arguments); - - if (!echoOutput) { - runner.EchoStandardOutputLevel = ProcessStandardStreamWrapper.LogLevel.Debug; - } - - if (!echoError) { - runner.EchoStandardErrorLevel = ProcessStandardStreamWrapper.LogLevel.Debug; - } - - return runner; - } - - } -} diff --git a/build-tools/xaprepare/xaprepare/ToolRunners/PkgutilRunner.MacOS.cs b/build-tools/xaprepare/xaprepare/ToolRunners/PkgutilRunner.MacOS.cs deleted file mode 100644 index b0788221541..00000000000 --- a/build-tools/xaprepare/xaprepare/ToolRunners/PkgutilRunner.MacOS.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - partial class PkgutilRunner : ToolRunner - { - protected override string DefaultToolExecutableName => GetToolExecutableName (); - protected override string ToolName => "PkgUtil"; - - public PkgutilRunner (Context context, Log? log = null, string? toolPath = null) - : base (context, log, toolPath) - {} - -#pragma warning disable CS1998 - public async Task LogPackagesInstalled () - { - Log.StatusLine ("Installed packages:"); - Log.StatusLine (Utilities.GetStringFromStdout (GetRunner (true, true, "--pkgs"))); - return true; - } - - public async Task 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) || pkgVer == null) { - Log.ErrorLine ($"Failed to parse package {packageId} version from '{v}'"); - return null; - } - - return pkgVer; - } -#pragma warning restore CS1998 - - bool GetFieldValue (string line, string name, out string? v) - { - v = null; - if (String.IsNullOrEmpty (line)) - return false; - - if (!line.StartsWith (name, StringComparison.Ordinal)) - return false; - - v = line.Substring (name.Length).Trim (); - return true; - } - - ProcessRunner GetRunner (bool echoOutput, bool echoError, params string[] parameters) - { - ProcessRunner runner = CreateProcessRunner (); - - AddArguments (runner, parameters); - - if (!echoOutput) { - runner.EchoStandardOutputLevel = ProcessStandardStreamWrapper.LogLevel.Debug; - } - - if (!echoError) { - runner.EchoStandardErrorLevel = ProcessStandardStreamWrapper.LogLevel.Debug; - } - - return runner; - } - - string GetToolExecutableName () - { - EssentialTools? tools = Context.Instance?.Tools; - - if (tools != null && tools.IsInitialized) - return tools.PkgutilPath; - - return "pkgutil"; - } - } -} diff --git a/build-tools/xaprepare/xaprepare/xaprepare.targets b/build-tools/xaprepare/xaprepare/xaprepare.targets index 50f9c290493..5350014f8e8 100644 --- a/build-tools/xaprepare/xaprepare/xaprepare.targets +++ b/build-tools/xaprepare/xaprepare/xaprepare.targets @@ -53,8 +53,6 @@ - -