From e28e2271b9c22cd53a82424186641986ac70a37b Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Tue, 5 Jan 2021 21:01:49 +0100 Subject: [PATCH] [Linux] Properly parse single-digit Ubuntu version Fixes: https://github.com/xamarin/xamarin-android/issues/4929 Some releases of Ubuntu use only a single digit for their version, which the `Version` class is not able to parse properly. Add a special case to handle it. Additionally, don't hardcode `Ubuntu` into error message, use the actual (derived) distro name instead. --- build-tools/xaprepare/xaprepare/Application/Context.cs | 1 + .../xaprepare/ConfigAndData/Dependencies/Linux.Ubuntu.cs | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/build-tools/xaprepare/xaprepare/Application/Context.cs b/build-tools/xaprepare/xaprepare/Application/Context.cs index fe1cd05cfb8..65fd29ede71 100644 --- a/build-tools/xaprepare/xaprepare/Application/Context.cs +++ b/build-tools/xaprepare/xaprepare/Application/Context.cs @@ -749,6 +749,7 @@ public async Task Init (string? scenarioName = null) Log.StatusLine (); Log.StatusLine (" OS type: ", OS.Type, tailColor: Log.InfoColor); + Log.StatusLine (" OS flavor: ", OS.Flavor, tailColor: Log.InfoColor); Log.StatusLine (" OS name: ", OS.Name, tailColor: Log.InfoColor); Log.StatusLine ("OS release: ", OS.Release, tailColor: Log.InfoColor); Log.StatusLine (" OS bits: ", OS.Architecture, tailColor: Log.InfoColor); diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Ubuntu.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Ubuntu.cs index bffb8f07c72..4ffa86a0318 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Ubuntu.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Ubuntu.cs @@ -42,8 +42,12 @@ protected override bool InitOS () { Version ubuntuRelease; if (!Version.TryParse (Release, out ubuntuRelease)) { - Log.ErrorLine ($"Unable to parse string '{Release}' as a valid Ubuntu release version"); - return false; + if (Int32.TryParse (Release, out int singleNumberVersion)) { + ubuntuRelease = new Version (singleNumberVersion, 0); + } else { + Log.ErrorLine ($"Unable to parse string '{Release}' as a valid {Name} release version"); + return false; + } } UbuntuRelease = ubuntuRelease;