[portability] Support unknown operating systems in gclient.

Detect the name of unknown operating systems using uname, if available,
since it doesn't append the operating system version.

Change-Id: Idab7bd0db65a8d424ec2fd48f06247405b6649e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4169240
Auto-Submit: Jonas Termansen <sortie@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
diff --git a/gclient_utils.py b/gclient_utils.py
index 84d9679..6a1659d 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -634,7 +634,7 @@
     # If our stdout is a terminal, then pass in a psuedo-tty pipe to our
     # subprocess when filtering its output. This makes the subproc believe
     # it was launched from a terminal, which will preserve ANSI color codes.
-    os_type = GetMacWinAixOrLinux()
+    os_type = GetOperatingSystem()
     if sys.stdout.isatty() and os_type != 'win' and os_type != 'aix':
       pipe_reader, pipe_writer = os.openpty()
     else:
@@ -780,8 +780,8 @@
     path = new_path
 
 
-def GetMacWinAixOrLinux():
-  """Returns 'mac', 'win', or 'linux', matching the current platform."""
+def GetOperatingSystem():
+  """Returns 'mac', 'win', 'linux', or the name of the current platform."""
   if sys.platform.startswith(('cygwin', 'win')):
     return 'win'
 
@@ -794,7 +794,10 @@
   if sys.platform.startswith('aix'):
     return 'aix'
 
-  raise Error('Unknown platform: ' + sys.platform)
+  try:
+    return os.uname().sysname.lower()
+  except AttributeError:
+    return sys.platform
 
 
 def GetGClientRootAndEntries(path=None):