fix broken hwi installs

This commit is contained in:
Craig Raw 2020-06-05 16:05:13 +02:00
parent f5a857317d
commit c5bcefd331
5 changed files with 54 additions and 4 deletions

View file

@ -56,7 +56,15 @@ compileJava {
} }
run { run {
applicationDefaultJvmArgs = ["-Xdock:name=Sparrow", "-Xdock:icon=/Users/scy/git/sparrow/src/main/resources/sparrow.png", "--add-opens=javafx.graphics/com.sun.javafx.css=org.controlsfx.controls", "--add-opens=javafx.graphics/javafx.scene=org.controlsfx.controls", "--add-opens=javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls", "--add-opens=javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls", "--add-opens=javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls", "--add-opens=javafx.base/com.sun.javafx.event=org.controlsfx.controls", "--add-opens=javafx.controls/javafx.scene.control.cell=com.sparrowwallet.sparrow", "--add-opens=org.controlsfx.controls/impl.org.controlsfx.skin=com.sparrowwallet.sparrow"] applicationDefaultJvmArgs = ["-Xdock:name=Sparrow", "-Xdock:icon=/Users/scy/git/sparrow/src/main/resources/sparrow.png",
"--add-opens=javafx.graphics/com.sun.javafx.css=org.controlsfx.controls",
"--add-opens=javafx.graphics/javafx.scene=org.controlsfx.controls",
"--add-opens=javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls",
"--add-opens=javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls",
"--add-opens=javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls",
"--add-opens=javafx.base/com.sun.javafx.event=org.controlsfx.controls",
"--add-opens=javafx.controls/javafx.scene.control.cell=com.sparrowwallet.sparrow",
"--add-opens=org.controlsfx.controls/impl.org.controlsfx.skin=com.sparrowwallet.sparrow"]
} }
jlink { jlink {
@ -66,12 +74,20 @@ jlink {
requires 'java.xml'; requires 'java.xml';
requires 'java.logging' requires 'java.logging'
requires 'javafx.base'; requires 'javafx.base';
requires 'com.fasterxml.jackson.databind';
} }
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages', '--ignore-signing-information', '--exclude-files', '**.png'] options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages', '--ignore-signing-information', '--exclude-files', '**.png']
launcher { launcher {
name = 'sparrow' name = 'sparrow'
jvmArgs = ["--add-opens=javafx.graphics/com.sun.javafx.css=org.controlsfx.controls", "--add-opens=javafx.graphics/javafx.scene=org.controlsfx.controls", "--add-opens=javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls", "--add-opens=javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls", "--add-opens=javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls", "--add-opens=javafx.base/com.sun.javafx.event=org.controlsfx.controls", "--add-opens=javafx.controls/javafx.scene.control.cell=com.sparrowwallet.sparrow", "--add-opens=org.controlsfx.controls/impl.org.controlsfx.skin=com.sparrowwallet.sparrow"] jvmArgs = ["--add-opens=javafx.graphics/com.sun.javafx.css=org.controlsfx.controls",
"--add-opens=javafx.graphics/javafx.scene=org.controlsfx.controls",
"--add-opens=javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls",
"--add-opens=javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls",
"--add-opens=javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls",
"--add-opens=javafx.base/com.sun.javafx.event=org.controlsfx.controls",
"--add-opens=javafx.controls/javafx.scene.control.cell=com.sparrowwallet.sparrow",
"--add-opens=org.controlsfx.controls/impl.org.controlsfx.skin=com.sparrowwallet.sparrow"]
} }
addExtraDependencies("javafx") addExtraDependencies("javafx")
jpackage { jpackage {

View file

@ -607,7 +607,7 @@ public class AppController implements Initializable {
} else { } else {
if(usbStatus == null) { if(usbStatus == null) {
usbStatus = new UsbStatusButton(); usbStatus = new UsbStatusButton();
statusBar.getRightItems().add(usbStatus); statusBar.getRightItems().add(0, usbStatus);
} else { } else {
usbStatus.getItems().remove(0, usbStatus.getItems().size()); usbStatus.getItems().remove(0, usbStatus.getItems().size());
} }

View file

@ -24,7 +24,7 @@ public class MainApp extends Application {
GlyphFontRegistry.register(new FontAwesome5Brands()); GlyphFontRegistry.register(new FontAwesome5Brands());
Mode mode = Config.get().getMode(); Mode mode = Config.get().getMode();
if(true || mode == null) { if(mode == null) {
WelcomeDialog welcomeDialog = new WelcomeDialog(getHostServices()); WelcomeDialog welcomeDialog = new WelcomeDialog(getHostServices());
Optional<Mode> optionalMode = welcomeDialog.showAndWait(); Optional<Mode> optionalMode = welcomeDialog.showAndWait();
if(optionalMode.isPresent()) { if(optionalMode.isPresent()) {

View file

@ -87,6 +87,16 @@ public class Hwi {
private synchronized File getHwiExecutable() { private synchronized File getHwiExecutable() {
File hwiExecutable = Config.get().getHwi(); File hwiExecutable = Config.get().getHwi();
if(hwiExecutable != null && hwiExecutable.exists()) {
if(!testHwi(hwiExecutable)) {
if(Platform.getCurrent().getPlatformId().toLowerCase().equals("mac")) {
deleteDirectory(hwiExecutable.getParentFile());
} else {
hwiExecutable.delete();
}
}
}
if(hwiExecutable == null || !hwiExecutable.exists()) { if(hwiExecutable == null || !hwiExecutable.exists()) {
try { try {
Platform platform = Platform.getCurrent(); Platform platform = Platform.getCurrent();
@ -147,6 +157,29 @@ public class Hwi {
return hwiExecutable; return hwiExecutable;
} }
private boolean testHwi(File hwiExecutable) {
try {
List<String> command = List.of(hwiExecutable.getAbsolutePath(), "enumerate");
ProcessBuilder processBuilder = new ProcessBuilder(command);
Process process = processBuilder.start();
int exitValue = process.waitFor();
return exitValue == 0;
} catch (Exception e) {
return false;
}
}
private boolean deleteDirectory(File directoryToBeDeleted) {
File[] allContents = directoryToBeDeleted.listFiles();
if (allContents != null) {
for (File file : allContents) {
deleteDirectory(file);
}
}
return directoryToBeDeleted.delete();
}
public static File newFile(File destinationDir, ZipEntry zipEntry, Set<PosixFilePermission> setFilePermissions) throws IOException { public static File newFile(File destinationDir, ZipEntry zipEntry, Set<PosixFilePermission> setFilePermissions) throws IOException {
String destDirPath = destinationDir.getCanonicalPath(); String destDirPath = destinationDir.getCanonicalPath();

View file

@ -27,4 +27,5 @@
.status-bar .right-items { .status-bar .right-items {
-fx-alignment: center-right; -fx-alignment: center-right;
-fx-padding: 0 0 0 8; -fx-padding: 0 0 0 8;
-fx-spacing: 10;
} }