More accurate/pretty OS detection

This commit is contained in:
Hylke Bons 2018-03-14 16:11:49 +00:00
parent 62bcad5563
commit 1369ac07b4
7 changed files with 34 additions and 31 deletions

View file

@ -214,11 +214,7 @@ namespace SparkleShare {
Logger.LogInfo ("Environment", "SparkleShare " + version); Logger.LogInfo ("Environment", "SparkleShare " + version);
Logger.LogInfo ("Environment", "Git LFS " + Sparkles.Git.GitCommand.GitLFSVersion); Logger.LogInfo ("Environment", "Git LFS " + Sparkles.Git.GitCommand.GitLFSVersion);
Logger.LogInfo ("Environment", "Git " + Sparkles.Git.GitCommand.GitVersion); Logger.LogInfo ("Environment", "Git " + Sparkles.Git.GitCommand.GitVersion);
Logger.LogInfo ("Environment", InstallationInfo.OperatingSystem + " " + InstallationInfo.OperatingSystemVersion);
if (InstallationInfo.OperatingSystem == OS.Mac)
Logger.LogInfo ("Environment", InstallationInfo.MacOSVersion ());
else
Logger.LogInfo ("Environment", InstallationInfo.OperatingSystem + " (" + Environment.OSVersion + ")");
UserAuthenticationInfo = new SSHAuthenticationInfo (); UserAuthenticationInfo = new SSHAuthenticationInfo ();
SSHAuthenticationInfo.DefaultAuthenticationInfo = UserAuthenticationInfo; SSHAuthenticationInfo.DefaultAuthenticationInfo = UserAuthenticationInfo;

View file

@ -36,7 +36,7 @@ namespace SparkleShare {
public static void Main (string [] args) public static void Main (string [] args)
{ {
if (args.Length != 0 && (args [0].Equals ("help") || args [0].Equals ("version")) && if (args.Length != 0 && (args [0].Equals ("help") || args [0].Equals ("version")) &&
InstallationInfo.OperatingSystem != OS.Mac && InstallationInfo.OperatingSystem != OS.macOS &&
InstallationInfo.OperatingSystem != OS.Windows) { InstallationInfo.OperatingSystem != OS.Windows) {
string n = Environment.NewLine; string n = Environment.NewLine;

View file

@ -25,6 +25,7 @@ configure_file(
output: 'sparkleshare', output: 'sparkleshare',
configuration: configuration, install_dir: get_option('bindir')) configuration: configuration, install_dir: get_option('bindir'))
# .desktop and .appdata files # .desktop and .appdata files
apps_dir = join_paths(get_option('prefix'), 'share', 'applications') apps_dir = join_paths(get_option('prefix'), 'share', 'applications')
install_data(sources: 'org.sparkleshare.SparkleShare.desktop', install_dir: apps_dir) install_data(sources: 'org.sparkleshare.SparkleShare.desktop', install_dir: apps_dir)
@ -56,6 +57,6 @@ sparkleshare = executable('SparkleShare',
install: true, install: true,
install_dir: install_dir) install_dir: install_dir)
subdir('Images') subdir('Images')
subdir('Images/icons') subdir('Images/icons')

View file

@ -28,7 +28,7 @@ namespace Sparkles {
private static Lazy<Configuration> ConfigLazy = new Lazy<Configuration> (() => { private static Lazy<Configuration> ConfigLazy = new Lazy<Configuration> (() => {
string app_data_path = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData); string app_data_path = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
if (InstallationInfo.OperatingSystem != OS.Windows && InstallationInfo.OperatingSystem != OS.Mac) if (InstallationInfo.OperatingSystem != OS.Windows && InstallationInfo.OperatingSystem != OS.macOS)
app_data_path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".config"); app_data_path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".config");
string config_path = Path.Combine (app_data_path, "org.sparkleshare.SparkleShare"); string config_path = Path.Combine (app_data_path, "org.sparkleshare.SparkleShare");

View file

@ -420,7 +420,7 @@ namespace Sparkles.Git {
string smudge_command; string smudge_command;
string clean_command; string clean_command;
if (InstallationInfo.OperatingSystem == OS.Mac || InstallationInfo.OperatingSystem == OS.Windows) { if (InstallationInfo.OperatingSystem == OS.macOS || InstallationInfo.OperatingSystem == OS.Windows) {
smudge_command = "env GIT_SSH_COMMAND='" + GIT_SSH_COMMAND + "' " + smudge_command = "env GIT_SSH_COMMAND='" + GIT_SSH_COMMAND + "' " +
Path.Combine (Configuration.DefaultConfiguration.BinPath, "git-lfs").Replace ("\\", "/") + " smudge %f"; Path.Combine (Configuration.DefaultConfiguration.BinPath, "git-lfs").Replace ("\\", "/") + " smudge %f";

View file

@ -209,7 +209,7 @@ namespace Sparkles.Git {
string pre_push_hook_content; string pre_push_hook_content;
// The pre-push hook may have been changed by Git LFS, overwrite it to use our own configuration // The pre-push hook may have been changed by Git LFS, overwrite it to use our own configuration
if (InstallationInfo.OperatingSystem == OS.Mac || InstallationInfo.OperatingSystem == OS.Windows) { if (InstallationInfo.OperatingSystem == OS.macOS || InstallationInfo.OperatingSystem == OS.Windows) {
pre_push_hook_content = pre_push_hook_content =
"#!/bin/sh" + Environment.NewLine + "#!/bin/sh" + Environment.NewLine +
"env GIT_SSH_COMMAND='" + GitCommand.FormatGitSSHCommand (auth_info) + "' " + "env GIT_SSH_COMMAND='" + GitCommand.FormatGitSSHCommand (auth_info) + "' " +

View file

@ -22,7 +22,7 @@ namespace Sparkles {
public enum OS { public enum OS {
Unknown, Unknown,
Mac, macOS,
Windows, Windows,
Ubuntu, Ubuntu,
GNOME GNOME
@ -49,7 +49,7 @@ namespace Sparkles {
// Environment.OSVersion.Platform.PlatformID.MacOSX is broken in Mono // Environment.OSVersion.Platform.PlatformID.MacOSX is broken in Mono
// for historical reasons, so check manually // for historical reasons, so check manually
if (output.StartsWith ("Darwin", StringComparison.InvariantCulture)) { if (output.StartsWith ("Darwin", StringComparison.InvariantCulture)) {
operating_system = OS.Mac; operating_system = OS.macOS;
} else if (output.Contains ("Ubuntu")) { } else if (output.Contains ("Ubuntu")) {
operating_system = OS.Ubuntu; operating_system = OS.Ubuntu;
@ -63,8 +63,9 @@ namespace Sparkles {
} }
public static string MacOSVersion () public static string OperatingSystemVersion {
{ get {
if (OperatingSystem == OS.macOS) {
var uname = new Command ("sw_vers", "-productVersion", false); var uname = new Command ("sw_vers", "-productVersion", false);
string output = uname.StartAndReadStandardOutput (); string output = uname.StartAndReadStandardOutput ();
string version = output; string version = output;
@ -85,7 +86,12 @@ namespace Sparkles {
case 13: release = "High Sierra"; break; case 13: release = "High Sierra"; break;
} }
return string.Format ("macOS {0} ({1})", version, release); return string.Format ("{0} ({1})", version, release);
}
string os_version = Environment.OSVersion.ToString ();
return string.Format ("({0})", os_version.Replace ("Unix", "Linux"));
}
} }