Bundle drivers to windows installer #156
This commit is contained in:
parent
88ca0815ed
commit
c0bf247666
4 changed files with 35 additions and 10 deletions
|
@ -39,6 +39,8 @@ steps:
|
||||||
path: /builds
|
path: /builds
|
||||||
- name: jdk
|
- name: jdk
|
||||||
path: /drone/src/misc/windows/NSIS/jdk
|
path: /drone/src/misc/windows/NSIS/jdk
|
||||||
|
- name: drivers
|
||||||
|
path: /drone/src/misc/windows/NSIS/Drivers_set.exe
|
||||||
|
|
||||||
- name: emerge-legacy-artifact
|
- name: emerge-legacy-artifact
|
||||||
image: maven:3-openjdk-17
|
image: maven:3-openjdk-17
|
||||||
|
@ -68,6 +70,8 @@ steps:
|
||||||
path: /builds
|
path: /builds
|
||||||
- name: jdk
|
- name: jdk
|
||||||
path: /drone/src/misc/windows/NSIS/jdk
|
path: /drone/src/misc/windows/NSIS/jdk
|
||||||
|
- name: drivers
|
||||||
|
path: /drone/src/misc/windows/NSIS/Drivers_set.exe
|
||||||
|
|
||||||
- name: emerge-mac-m1-artifact
|
- name: emerge-mac-m1-artifact
|
||||||
image: maven:3-openjdk-17
|
image: maven:3-openjdk-17
|
||||||
|
@ -91,4 +95,7 @@ volumes:
|
||||||
path: /home/www/builds
|
path: /home/www/builds
|
||||||
- name: jdk
|
- name: jdk
|
||||||
host:
|
host:
|
||||||
path: /home/docker/drone/files/assembly/openjdk-19.0.2
|
path: /home/docker/drone/files/assembly/openjdk-19.0.2
|
||||||
|
- name: drivers
|
||||||
|
host:
|
||||||
|
path: /home/docker/drone/files/assembly/Drivers_set.exe
|
|
@ -92,6 +92,7 @@ Section "NS-USBloader" Install
|
||||||
|
|
||||||
SetOutPath "$INSTDIR"
|
SetOutPath "$INSTDIR"
|
||||||
file /r jdk
|
file /r jdk
|
||||||
|
file Drivers_set.exe
|
||||||
file NS-USBloader.exe
|
file NS-USBloader.exe
|
||||||
file logo.ico
|
file logo.ico
|
||||||
|
|
||||||
|
@ -143,6 +144,7 @@ Section "Uninstall"
|
||||||
|
|
||||||
;Delete installed files
|
;Delete installed files
|
||||||
RMDir /r "$INSTDIR\jdk\*"
|
RMDir /r "$INSTDIR\jdk\*"
|
||||||
|
Delete "$INSTDIR\Drivers_set.exe"
|
||||||
Delete "$INSTDIR\NS-USBloader.exe"
|
Delete "$INSTDIR\NS-USBloader.exe"
|
||||||
Delete "$INSTDIR\logo.ico"
|
Delete "$INSTDIR\logo.ico"
|
||||||
Delete "$SMPROGRAMS\Uninstall.exe"
|
Delete "$SMPROGRAMS\Uninstall.exe"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2019-2020 Dmitry Isaenko
|
Copyright 2019-2023 Dmitry Isaenko
|
||||||
|
|
||||||
This file is part of NS-USBloader.
|
This file is part of NS-USBloader.
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ import java.net.URL;
|
||||||
|
|
||||||
public class DownloadDriversTask extends Task<String> {
|
public class DownloadDriversTask extends Task<String> {
|
||||||
|
|
||||||
|
public static final long DRIVERS_FILE_SIZE = 3857375;
|
||||||
private static final String driverFileLocationURL = "https://github.com/developersu/NS-Drivers/releases/download/v1.0/Drivers_set.exe";
|
private static final String driverFileLocationURL = "https://github.com/developersu/NS-Drivers/releases/download/v1.0/Drivers_set.exe";
|
||||||
private static final long driversFileSize = 3857375;
|
|
||||||
|
|
||||||
private static File driversInstallerFile;
|
private static File driversInstallerFile;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class DownloadDriversTask extends Task<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDriversDownloaded(){
|
private boolean isDriversDownloaded(){
|
||||||
return driversInstallerFile != null && driversInstallerFile.length() == driversFileSize;
|
return driversInstallerFile != null && driversInstallerFile.length() == DRIVERS_FILE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean downloadDrivers(){
|
private boolean downloadDrivers(){
|
||||||
|
@ -64,7 +64,7 @@ public class DownloadDriversTask extends Task<String> {
|
||||||
while ((bytesRead = bis.read(dataBuffer, 0, 1024)) != -1) {
|
while ((bytesRead = bis.read(dataBuffer, 0, 1024)) != -1) {
|
||||||
fos.write(dataBuffer, 0, bytesRead);
|
fos.write(dataBuffer, 0, bytesRead);
|
||||||
totalRead += bytesRead;
|
totalRead += bytesRead;
|
||||||
updateProgress(totalRead, driversFileSize);
|
updateProgress(totalRead, DRIVERS_FILE_SIZE);
|
||||||
if (this.isCancelled()) {
|
if (this.isCancelled()) {
|
||||||
bis.close();
|
bis.close();
|
||||||
fos.close();
|
fos.close();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2019-2020 Dmitry Isaenko
|
Copyright 2019-2023 Dmitry Isaenko
|
||||||
|
|
||||||
This file is part of NS-USBloader.
|
This file is part of NS-USBloader.
|
||||||
|
|
||||||
|
@ -32,16 +32,32 @@ import javafx.scene.layout.VBox;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import nsusbloader.AppPreferences;
|
import nsusbloader.AppPreferences;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class DriversInstall {
|
public class DriversInstall {
|
||||||
|
|
||||||
private static volatile boolean isRunning;
|
private static volatile boolean isRunning;
|
||||||
|
|
||||||
|
private final ResourceBundle resourceBundle;
|
||||||
private Label runInstallerStatusLabel;
|
private Label runInstallerStatusLabel;
|
||||||
|
|
||||||
public DriversInstall(ResourceBundle rb){
|
public DriversInstall(ResourceBundle rb){
|
||||||
|
this.resourceBundle = rb;
|
||||||
|
|
||||||
|
if (isDriversDistributesWithExecutable())
|
||||||
|
runInstaller("Drivers_set.exe");
|
||||||
|
else
|
||||||
|
runDownloadProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isDriversDistributesWithExecutable(){
|
||||||
|
final File drivers = new File("Drivers_set.exe");
|
||||||
|
|
||||||
|
return drivers.length() == DownloadDriversTask.DRIVERS_FILE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runDownloadProcess(){
|
||||||
if (DriversInstall.isRunning)
|
if (DriversInstall.isRunning)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -49,11 +65,11 @@ public class DriversInstall {
|
||||||
|
|
||||||
DownloadDriversTask downloadTask = new DownloadDriversTask();
|
DownloadDriversTask downloadTask = new DownloadDriversTask();
|
||||||
|
|
||||||
Button cancelButton = new Button(rb.getString("btn_Cancel"));
|
Button cancelButton = new Button(resourceBundle.getString("btn_Cancel"));
|
||||||
|
|
||||||
HBox hBoxInformation = new HBox();
|
HBox hBoxInformation = new HBox();
|
||||||
hBoxInformation.setAlignment(Pos.TOP_LEFT);
|
hBoxInformation.setAlignment(Pos.TOP_LEFT);
|
||||||
hBoxInformation.getChildren().add(new Label(rb.getString("windowBodyDownloadDrivers")));
|
hBoxInformation.getChildren().add(new Label(resourceBundle.getString("windowBodyDownloadDrivers")));
|
||||||
|
|
||||||
ProgressBar progressBar = new ProgressBar();
|
ProgressBar progressBar = new ProgressBar();
|
||||||
progressBar.setPrefWidth(Double.MAX_VALUE);
|
progressBar.setPrefWidth(Double.MAX_VALUE);
|
||||||
|
@ -90,7 +106,7 @@ public class DriversInstall {
|
||||||
|
|
||||||
Stage stage = new Stage();
|
Stage stage = new Stage();
|
||||||
|
|
||||||
stage.setTitle(rb.getString("windowTitleDownloadDrivers"));
|
stage.setTitle(resourceBundle.getString("windowTitleDownloadDrivers"));
|
||||||
stage.getIcons().addAll(
|
stage.getIcons().addAll(
|
||||||
new Image("/res/dwnload_ico32x32.png"), //TODO: REDRAW
|
new Image("/res/dwnload_ico32x32.png"), //TODO: REDRAW
|
||||||
new Image("/res/dwnload_ico48x48.png"),
|
new Image("/res/dwnload_ico48x48.png"),
|
||||||
|
@ -115,7 +131,7 @@ public class DriversInstall {
|
||||||
stage.toFront();
|
stage.toFront();
|
||||||
|
|
||||||
downloadTask.setOnSucceeded(event -> {
|
downloadTask.setOnSucceeded(event -> {
|
||||||
cancelButton.setText(rb.getString("btn_Close"));
|
cancelButton.setText(resourceBundle.getString("btn_Close"));
|
||||||
|
|
||||||
String returnedValue = downloadTask.getValue();
|
String returnedValue = downloadTask.getValue();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue