mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Fixes for mac
This commit is contained in:
parent
6439f7b754
commit
27732bec35
7 changed files with 42 additions and 58 deletions
|
@ -131,7 +131,7 @@ public final class XPipeApiConnection extends BeaconConnection {
|
|||
}
|
||||
|
||||
private void start() throws Exception {
|
||||
var installation = XPipeInstallation.getLocalDefaultInstallationBasePath();
|
||||
var installation = XPipeInstallation.getLocalDefaultInstallationBasePath(true);
|
||||
BeaconServer.start(installation);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class BeaconDaemonController {
|
|||
if ((process = BeaconServer.tryStartCustom()) != null) {
|
||||
custom = true;
|
||||
} else {
|
||||
var defaultBase = XPipeInstallation.getLocalDefaultInstallationBasePath();
|
||||
var defaultBase = XPipeInstallation.getLocalDefaultInstallationBasePath(true);
|
||||
process = BeaconServer.start(defaultBase);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package io.xpipe.core.process;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface OsType {
|
||||
|
||||
|
@ -34,10 +32,6 @@ public interface OsType {
|
|||
}
|
||||
}
|
||||
|
||||
Path getBaseInstallPath();
|
||||
|
||||
UUID getSystemUUID(ShellProcessControl pc) throws Exception;
|
||||
|
||||
static class Windows implements OsType {
|
||||
|
||||
@Override
|
||||
|
@ -70,20 +64,6 @@ public interface OsType {
|
|||
return properties.get("OS Name") + " "
|
||||
+ properties.get("OS Version").split(" ")[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getBaseInstallPath() {
|
||||
return Path.of(System.getenv("LOCALAPPDATA"), "X-Pipe");
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSystemUUID(ShellProcessControl pc) throws Exception {
|
||||
try (CommandProcessControl c = pc.command(
|
||||
"reg query \"Computer\\\\HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Cryptography\" /v MachineGuid")) {
|
||||
var output = c.readOnlyStdout();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class Linux implements OsType {
|
||||
|
@ -110,16 +90,14 @@ public interface OsType {
|
|||
|
||||
@Override
|
||||
public String determineOperatingSystemName(ShellProcessControl pc) throws Exception {
|
||||
try (CommandProcessControl c =
|
||||
pc.command("lsb_release -a").start()) {
|
||||
try (CommandProcessControl c = pc.command("lsb_release -a").start()) {
|
||||
var text = c.readOnlyStdout();
|
||||
if (c.getExitCode() == 0) {
|
||||
return PropertiesFormatsParser.parse(text, ":").getOrDefault("Description", null);
|
||||
}
|
||||
}
|
||||
|
||||
try (CommandProcessControl c =
|
||||
pc.command("cat /etc/*release").start()) {
|
||||
try (CommandProcessControl c = pc.command("cat /etc/*release").start()) {
|
||||
var text = c.readOnlyStdout();
|
||||
if (c.getExitCode() == 0) {
|
||||
return PropertiesFormatsParser.parse(text, "=").getOrDefault("PRETTY_NAME", null);
|
||||
|
@ -144,23 +122,13 @@ public interface OsType {
|
|||
|
||||
return type + " " + version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getBaseInstallPath() {
|
||||
return Path.of("/opt/xpipe");
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSystemUUID(ShellProcessControl pc) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static class Mac implements OsType {
|
||||
|
||||
@Override
|
||||
public String getTempDirectory(ShellProcessControl pc) throws Exception {
|
||||
return pc.executeStringSimpleCommand(pc.getShellType().getPrintVariableCommand("TEMP"));
|
||||
return pc.executeStringSimpleCommand(pc.getShellType().getPrintVariableCommand("TMPDIR"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -175,22 +143,21 @@ public interface OsType {
|
|||
|
||||
@Override
|
||||
public Map<String, String> getProperties(ShellProcessControl pc) throws Exception {
|
||||
return null;
|
||||
try (CommandProcessControl c =
|
||||
pc.subShell(ShellTypes.BASH).command("sw_vers").start()) {
|
||||
var text = c.readOrThrow();
|
||||
return PropertiesFormatsParser.parse(text, ":");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String determineOperatingSystemName(ShellProcessControl pc) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getBaseInstallPath() {
|
||||
return Path.of(System.getProperty("user.home"), "Application Support", "X-Pipe");
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSystemUUID(ShellProcessControl pc) throws Exception {
|
||||
return null;
|
||||
var properties = getProperties(pc);
|
||||
var name = pc.executeStringSimpleCommand(
|
||||
"awk '/SOFTWARE LICENSE AGREEMENT FOR macOS/' '/System/Library/CoreServices/Setup " +
|
||||
"Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf' | " +
|
||||
"awk -F 'macOS ' '{print $NF}' | awk '{print substr($0, 0, length($0)-1)}'");
|
||||
return properties.get("ProductName") + " " + name + " " + properties.get("ProductVersion");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.xpipe.core.store;
|
||||
|
||||
import io.xpipe.core.charsetter.Charsetter;
|
||||
import io.xpipe.core.impl.LocalStore;
|
||||
import io.xpipe.core.process.ShellProcessControl;
|
||||
import io.xpipe.core.process.ShellType;
|
||||
|
@ -10,6 +11,12 @@ public interface ShellStore extends DataStore {
|
|||
return new LocalStore();
|
||||
}
|
||||
|
||||
static void withLocal(Charsetter.FailableConsumer<ShellProcessControl, Exception> c) throws Exception {
|
||||
try (var l = local().create().start()) {
|
||||
c.accept(l);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isLocal(ShellStore s) {
|
||||
return s instanceof LocalStore;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class Deobfuscator {
|
|||
file.toString())
|
||||
.redirectErrorStream(true);
|
||||
var active = proc.start();
|
||||
var out = new String(active.getInputStream().readAllBytes()).replaceAll("\\r\\n", NewLine.LF.getNewLineString());
|
||||
var out = new String(active.getInputStream().readAllBytes()).replaceAll("\r\n", NewLine.LF.getNewLineString());
|
||||
var code = active.waitFor();
|
||||
if (code == 0) {
|
||||
return out;
|
||||
|
|
|
@ -64,9 +64,9 @@ public class XPipeInstallation {
|
|||
}
|
||||
}
|
||||
|
||||
public static String getLocalDefaultInstallationBasePath() {
|
||||
public static String getLocalDefaultInstallationBasePath(boolean acceptCustomHome) {
|
||||
var customHome = System.getenv("XPIPE_HOME");
|
||||
if (!customHome.isEmpty()) {
|
||||
if (!customHome.isEmpty() && acceptCustomHome) {
|
||||
return customHome;
|
||||
}
|
||||
|
||||
|
@ -74,8 +74,10 @@ public class XPipeInstallation {
|
|||
if (OsType.getLocal().equals(OsType.WINDOWS)) {
|
||||
var base = System.getenv("LOCALAPPDATA");
|
||||
path = FileNames.join(base, "X-Pipe");
|
||||
} else {
|
||||
} else if (OsType.getLocal().equals(OsType.LINUX)) {
|
||||
path = "/opt/xpipe";
|
||||
} else {
|
||||
path = "~/Applications/X-Pipe.app";
|
||||
}
|
||||
|
||||
return path;
|
||||
|
@ -93,8 +95,10 @@ public class XPipeInstallation {
|
|||
if (p.getOsType().equals(OsType.WINDOWS)) {
|
||||
var base = p.executeStringSimpleCommand(p.getShellType().getPrintVariableCommand("LOCALAPPDATA"));
|
||||
path = FileNames.join(base, "X-Pipe");
|
||||
} else {
|
||||
} else if (p.getOsType().equals(OsType.LINUX)) {
|
||||
path = "/opt/xpipe";
|
||||
} else {
|
||||
path = "~/Applications/X-Pipe.app";
|
||||
}
|
||||
|
||||
return path;
|
||||
|
@ -103,24 +107,30 @@ public class XPipeInstallation {
|
|||
public static String getDaemonDebugScriptPath(OsType type) {
|
||||
if (type.equals(OsType.WINDOWS)) {
|
||||
return FileNames.join("app", "scripts", "xpiped_debug.bat");
|
||||
} else {
|
||||
} else if (type.equals(OsType.LINUX)) {
|
||||
return FileNames.join("app", "scripts", "xpiped_debug.sh");
|
||||
} else {
|
||||
return FileNames.join("Content", "scripts", "xpiped_debug.sh");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDaemonDebugAttachScriptPath(OsType type) {
|
||||
if (type.equals(OsType.WINDOWS)) {
|
||||
return FileNames.join("app", "scripts", "xpiped_debug_attach.bat");
|
||||
} else {
|
||||
} else if (type.equals(OsType.LINUX)) {
|
||||
return FileNames.join("app", "scripts", "xpiped_debug_attach.sh");
|
||||
} else {
|
||||
return FileNames.join("Content", "scripts", "xpiped_debug_attach.sh");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDaemonExecutablePath(OsType type) {
|
||||
if (type.equals(OsType.WINDOWS)) {
|
||||
return FileNames.join("app", "xpiped.exe");
|
||||
} else {
|
||||
} else if (type.equals(OsType.LINUX)) {
|
||||
return FileNames.join("app", "bin", "xpiped");
|
||||
} else {
|
||||
return FileNames.join("Content", "MacOS", "xpiped");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class XPipeTempDirectory {
|
|||
throw new IOException("Unable to access or create temporary directory " + dir);
|
||||
}
|
||||
|
||||
if (proc.getOsType().equals(OsType.LINUX)) {
|
||||
if (proc.getOsType().equals(OsType.LINUX) || proc.getOsType().equals(OsType.MAC)) {
|
||||
proc.executeSimpleCommand("(chmod -f 777 \"" + dir + "\" || true)");
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue