Bundle drivers to windows installer #156

This commit is contained in:
Dmitry Isaenko 2023-12-26 14:39:05 +03:00
parent 88ca0815ed
commit c0bf247666
4 changed files with 35 additions and 10 deletions

View file

@ -39,6 +39,8 @@ steps:
path: /builds
- name: jdk
path: /drone/src/misc/windows/NSIS/jdk
- name: drivers
path: /drone/src/misc/windows/NSIS/Drivers_set.exe
- name: emerge-legacy-artifact
image: maven:3-openjdk-17
@ -68,6 +70,8 @@ steps:
path: /builds
- name: jdk
path: /drone/src/misc/windows/NSIS/jdk
- name: drivers
path: /drone/src/misc/windows/NSIS/Drivers_set.exe
- name: emerge-mac-m1-artifact
image: maven:3-openjdk-17
@ -92,3 +96,6 @@ volumes:
- name: jdk
host:
path: /home/docker/drone/files/assembly/openjdk-19.0.2
- name: drivers
host:
path: /home/docker/drone/files/assembly/Drivers_set.exe

View file

@ -92,6 +92,7 @@ Section "NS-USBloader" Install
SetOutPath "$INSTDIR"
file /r jdk
file Drivers_set.exe
file NS-USBloader.exe
file logo.ico
@ -143,6 +144,7 @@ Section "Uninstall"
;Delete installed files
RMDir /r "$INSTDIR\jdk\*"
Delete "$INSTDIR\Drivers_set.exe"
Delete "$INSTDIR\NS-USBloader.exe"
Delete "$INSTDIR\logo.ico"
Delete "$SMPROGRAMS\Uninstall.exe"

View file

@ -1,5 +1,5 @@
/*
Copyright 2019-2020 Dmitry Isaenko
Copyright 2019-2023 Dmitry Isaenko
This file is part of NS-USBloader.
@ -25,8 +25,8 @@ import java.net.URL;
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 long driversFileSize = 3857375;
private static File driversInstallerFile;
@ -38,7 +38,7 @@ public class DownloadDriversTask extends Task<String> {
}
private boolean isDriversDownloaded(){
return driversInstallerFile != null && driversInstallerFile.length() == driversFileSize;
return driversInstallerFile != null && driversInstallerFile.length() == DRIVERS_FILE_SIZE;
}
private boolean downloadDrivers(){
@ -64,7 +64,7 @@ public class DownloadDriversTask extends Task<String> {
while ((bytesRead = bis.read(dataBuffer, 0, 1024)) != -1) {
fos.write(dataBuffer, 0, bytesRead);
totalRead += bytesRead;
updateProgress(totalRead, driversFileSize);
updateProgress(totalRead, DRIVERS_FILE_SIZE);
if (this.isCancelled()) {
bis.close();
fos.close();

View file

@ -1,5 +1,5 @@
/*
Copyright 2019-2020 Dmitry Isaenko
Copyright 2019-2023 Dmitry Isaenko
This file is part of NS-USBloader.
@ -32,16 +32,32 @@ import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import nsusbloader.AppPreferences;
import java.io.File;
import java.util.ResourceBundle;
public class DriversInstall {
private static volatile boolean isRunning;
private final ResourceBundle resourceBundle;
private Label runInstallerStatusLabel;
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)
return;
@ -49,11 +65,11 @@ public class DriversInstall {
DownloadDriversTask downloadTask = new DownloadDriversTask();
Button cancelButton = new Button(rb.getString("btn_Cancel"));
Button cancelButton = new Button(resourceBundle.getString("btn_Cancel"));
HBox hBoxInformation = new HBox();
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.setPrefWidth(Double.MAX_VALUE);
@ -90,7 +106,7 @@ public class DriversInstall {
Stage stage = new Stage();
stage.setTitle(rb.getString("windowTitleDownloadDrivers"));
stage.setTitle(resourceBundle.getString("windowTitleDownloadDrivers"));
stage.getIcons().addAll(
new Image("/res/dwnload_ico32x32.png"), //TODO: REDRAW
new Image("/res/dwnload_ico48x48.png"),
@ -115,7 +131,7 @@ public class DriversInstall {
stage.toFront();
downloadTask.setOnSucceeded(event -> {
cancelButton.setText(rb.getString("btn_Close"));
cancelButton.setText(resourceBundle.getString("btn_Close"));
String returnedValue = downloadTask.getValue();