mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-10-01 17:47:30 +13:00
Shell fixes
This commit is contained in:
parent
294c9459a2
commit
f2bf943d56
6 changed files with 17 additions and 17 deletions
|
@ -43,17 +43,9 @@ public class AppInstaller {
|
||||||
} else {
|
} else {
|
||||||
targetFile = FileNames.join(
|
targetFile = FileNames.join(
|
||||||
s.getTemporaryDirectory(), localFile.getFileName().toString());
|
s.getTemporaryDirectory(), localFile.getFileName().toString());
|
||||||
try (CommandControl c = s.getShellDialect().getStreamFileWriteCommand(s, targetFile)
|
try (InputStream in = Files.newInputStream(localFile)) {
|
||||||
.start()) {
|
in.transferTo(s.getShellDialect().createStreamFileWriteCommand(s, targetFile).startExternalStdin());
|
||||||
c.discardOut();
|
|
||||||
c.discardErr();
|
|
||||||
try (InputStream in = Files.newInputStream(localFile)) {
|
|
||||||
in.transferTo(c.getStdin());
|
|
||||||
}
|
|
||||||
c.closeStdin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s.restart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
asset.installRemote(s, targetFile);
|
asset.installRemote(s, targetFile);
|
||||||
|
|
|
@ -60,10 +60,10 @@ public class DesktopShortcuts {
|
||||||
pc.getShellDialect().flatten(pc.getShellDialect().getMkdirsCommand(base + "/Contents/Resources")));
|
pc.getShellDialect().flatten(pc.getShellDialect().getMkdirsCommand(base + "/Contents/Resources")));
|
||||||
|
|
||||||
var executable = base + "/Contents/MacOS/" + name;
|
var executable = base + "/Contents/MacOS/" + name;
|
||||||
pc.executeSimpleCommand(pc.getShellDialect().getTextFileWriteCommand(content, executable));
|
pc.getShellDialect().createTextFileWriteCommand(pc, content, executable).execute();
|
||||||
pc.executeSimpleCommand("chmod ugo+x \"" + executable + "\"");
|
pc.executeSimpleCommand("chmod ugo+x \"" + executable + "\"");
|
||||||
|
|
||||||
pc.executeSimpleCommand(pc.getShellDialect().getTextFileWriteCommand("APPL????", base + "/PkgInfo"));
|
pc.getShellDialect().createTextFileWriteCommand(pc, "APPL????", base + "/PkgInfo").execute();
|
||||||
pc.executeSimpleCommand("cp \"" + icon + "\" \"" + base + "/Contents/Resources/" + name + ".icns\"");
|
pc.executeSimpleCommand("cp \"" + icon + "\" \"" + base + "/Contents/Resources/" + name + ".icns\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,7 @@ public class ScriptHelper {
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
// processControl.executeSimpleCommand(type.getFileTouchCommand(file), "Failed to create script " + file);
|
// processControl.executeSimpleCommand(type.getFileTouchCommand(file), "Failed to create script " + file);
|
||||||
processControl.executeSimpleCommand(type.getTextFileWriteCommand(content, file));
|
processControl.getShellDialect().createTextFileWriteCommand(processControl, content, file).execute();
|
||||||
processControl.executeSimpleCommand(
|
processControl.executeSimpleCommand(
|
||||||
type.getMakeExecutableCommand(file), "Failed to make script " + file + " executable");
|
type.getMakeExecutableCommand(file), "Failed to make script " + file + " executable");
|
||||||
return file;
|
return file;
|
||||||
|
|
|
@ -26,8 +26,16 @@ public interface CommandControl extends ProcessControl {
|
||||||
|
|
||||||
CommandControl complex();
|
CommandControl complex();
|
||||||
|
|
||||||
|
CommandControl notComplex();
|
||||||
|
|
||||||
CommandControl workingDirectory(String directory);
|
CommandControl workingDirectory(String directory);
|
||||||
|
|
||||||
|
default void execute() throws Exception {
|
||||||
|
try (var c = start()) {
|
||||||
|
c.discardOrThrow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ShellControl getParent();
|
ShellControl getParent();
|
||||||
|
|
||||||
InputStream startExternalStdout() throws Exception;
|
InputStream startExternalStdout() throws Exception;
|
||||||
|
|
|
@ -13,6 +13,8 @@ import java.util.stream.Stream;
|
||||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
|
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
|
||||||
public interface ShellDialect {
|
public interface ShellDialect {
|
||||||
|
|
||||||
|
CommandControl createStreamFileWriteCommand(ShellControl shellControl, String file);
|
||||||
|
|
||||||
default String getCdCommand(String directory){
|
default String getCdCommand(String directory){
|
||||||
return "cd \"" + directory + "\"";
|
return "cd \"" + directory + "\"";
|
||||||
}
|
}
|
||||||
|
@ -101,9 +103,7 @@ public interface ShellDialect {
|
||||||
|
|
||||||
String getFileMoveCommand(String oldFile, String newFile);
|
String getFileMoveCommand(String oldFile, String newFile);
|
||||||
|
|
||||||
CommandControl getStreamFileWriteCommand(ShellControl processControl, String file);
|
CommandControl createTextFileWriteCommand(ShellControl parent, String content, String file);
|
||||||
|
|
||||||
String getTextFileWriteCommand(String content, String file);
|
|
||||||
|
|
||||||
String getFileDeleteCommand(String file);
|
String getFileDeleteCommand(String file);
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class ConnectionFileSystem implements FileSystem {
|
||||||
@Override
|
@Override
|
||||||
public OutputStream openOutput(String file) throws Exception {
|
public OutputStream openOutput(String file) throws Exception {
|
||||||
return shellControl.getShellDialect()
|
return shellControl.getShellDialect()
|
||||||
.getStreamFileWriteCommand(shellControl, shellControl.getOsType().normalizeFileName(file))
|
.createStreamFileWriteCommand(shellControl, shellControl.getOsType().normalizeFileName(file))
|
||||||
.startExternalStdin();
|
.startExternalStdin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue