Skip to content

Commit

Permalink
Bundle drivers to windows installer #156
Browse files Browse the repository at this point in the history
  • Loading branch information
developersu committed Dec 26, 2023
1 parent 88ca081 commit c0bf247
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
9 changes: 8 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -91,4 +95,7 @@ volumes:
path: /home/www/builds
- name: jdk
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
2 changes: 2 additions & 0 deletions misc/windows/NSIS/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Section "NS-USBloader" Install

SetOutPath "$INSTDIR"
file /r jdk
file Drivers_set.exe
file NS-USBloader.exe
file logo.ico

Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2020 Dmitry Isaenko
Copyright 2019-2023 Dmitry Isaenko
This file is part of NS-USBloader.
Expand All @@ -25,8 +25,8 @@

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;

Expand All @@ -38,7 +38,7 @@ protected String call() {
}

private boolean isDriversDownloaded(){
return driversInstallerFile != null && driversInstallerFile.length() == driversFileSize;
return driversInstallerFile != null && driversInstallerFile.length() == DRIVERS_FILE_SIZE;
}

private boolean downloadDrivers(){
Expand All @@ -64,7 +64,7 @@ private boolean downloadDrivers(){
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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2020 Dmitry Isaenko
Copyright 2019-2023 Dmitry Isaenko
This file is part of NS-USBloader.
Expand Down Expand Up @@ -32,28 +32,44 @@
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;

DriversInstall.isRunning = true;

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);
Expand Down Expand Up @@ -90,7 +106,7 @@ public DriversInstall(ResourceBundle rb){

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"),
Expand All @@ -115,7 +131,7 @@ public DriversInstall(ResourceBundle rb){
stage.toFront();

downloadTask.setOnSucceeded(event -> {
cancelButton.setText(rb.getString("btn_Close"));
cancelButton.setText(resourceBundle.getString("btn_Close"));

String returnedValue = downloadTask.getValue();

Expand Down

0 comments on commit c0bf247

Please sign in to comment.