Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Fix minor issues in linux packaging #172

Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added client/icons/LighthouseProject.icns
Binary file not shown.
Binary file added client/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/icons/mac.icns
Binary file not shown.
19 changes: 13 additions & 6 deletions client/src/main/java/lighthouse/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import javafx.fxml.*;
import javafx.geometry.*;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.effect.*;
import javafx.scene.image.*;
import javafx.scene.input.*;
Expand Down Expand Up @@ -52,14 +51,17 @@
public class Main extends Application {
public static final Logger log = LoggerFactory.getLogger(Main.class);

public static final String APP_NAME = "Crowdfunding App";
public static final String APP_NAME = "Lighthouse";

// UpdateFX stuff. Version is incremented monotonically after a new version is released.
public static final int VERSION = 27;

// No online updates URL for "Crowdfunding App".
@Nullable public static final String UPDATES_BASE_URL = null;
public static final String UPDATES_BASE_URL = "https://www.vinumeris.com/lighthouse/updates";
public static final List<ECPoint> UPDATE_SIGNING_KEYS = Crypto.decode(
// Two keys during temporary transition from a key that was not password protected to one that is.
// At release the old key will be removed.
"02A3CDE5D0EDC281637C67AA67C0CB009EA6573E0F101C6E018ACB91393C08C129", // old
"02AA4D7E966BFA942D3BEABD2049A49DB6AE92C417D8837C328BC02F8B50411A97" // new
);
public static final int UPDATE_SIGNING_THRESHOLD = 1;

Expand Down Expand Up @@ -150,7 +152,7 @@ public void start(Stage stage) throws Exception {
log.info("We are running on: {} with Java {}", System.getProperty("os.name"), System.getProperty("java.version"));

// Show the crash dialog for any exceptions that we don't handle and that hit the main loop.
CrashFX.setup();
CrashFX.setup("Lighthouse/" + Main.VERSION, AppDirectory.dir().resolve("crashes"), URI.create("https://www.vinumeris.com/crashfx/upload"));
// Set up the basic window with an empty UI stack, and put a quick splash there.
reached("JFX initialised");
prefs = new UserPrefs();
Expand Down Expand Up @@ -284,6 +286,7 @@ private void initGUI(Stage stage) throws IOException {
log.warn("Prism is using software rendering");
log.info("Primary screen scale factor is {}", GuiUtils.getPixelScale());
mainStage = stage;
stage.getIcons().add(new Image(Main.class.getResourceAsStream("icon.png")));
Font.loadFont(Main.class.getResource("nanlight-webfont.ttf").toString(), 10);
Font.loadFont(Main.class.getResource("nanlightbold-webfont.ttf").toString(), 10);
// Create the scene with a StackPane so we can overlay things on top of the main UI.
Expand All @@ -309,7 +312,11 @@ private void initGUI(Stage stage) throws IOException {
}

private Node createLoadingUI() {
StackPane pane = new StackPane(new Label("Crowdfunding app"));
ImageView lighthouseLogo = new ImageView(getResource("Logo.jpg").toString());
lighthouseLogo.setFitWidth(500);
lighthouseLogo.setPreserveRatio(true);
StackPane.setAlignment(lighthouseLogo, Pos.CENTER);
StackPane pane = new StackPane(lighthouseLogo);
pane.setPadding(new Insets(20));
pane.setStyle("-fx-background-color: white");
return pane;
Expand Down
6 changes: 6 additions & 0 deletions client/src/main/java/lighthouse/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,12 @@ public void tellUserToSendSomeMoney() {
});
}

@FXML
public void onRedditAdClicked(MouseEvent event) {
log.info("reddit ad clicked");
Main.instance.getHostServices().showDocument("https://www.reddit.com/r/LighthouseProjects");
}

//region Generic Bitcoin wallet related code
@FXML
public void emptyWallet(ActionEvent event) {
Expand Down
14 changes: 14 additions & 0 deletions client/src/main/resources/lighthouse/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

.gradient-pane {
-fx-background-color: #3c777b;
-fx-background-image: url("low-point-lighthouse-darkgreen.jpg");
-fx-background-position: bottom right;
-fx-background-repeat: no-repeat;
}
Expand Down Expand Up @@ -264,4 +265,17 @@

.edit-project-grid .link-label {
-fx-font-weight: normal;
}

.reddit-ad {
-fx-border-color: #ffffff;
-fx-border-radius: 6;
-fx-border-style: dashed;
-fx-background-radius: 6;
-fx-background-color: #ffffff33;
-fx-padding: 30px;
-fx-cursor: hand;
}
.reddit-ad:hover {
-fx-background-color: #ffffffcc;
}
17 changes: 10 additions & 7 deletions client/src/main/resources/lighthouse/main.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import lighthouse.controls.ClickableBitcoinAddress?>
<?import lighthouse.controls.ProjectView?>
<?import lighthouse.controls.*?>
<VBox id="root" fx:id="root" alignment="CENTER" styleClass="cc-root" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="lighthouse.MainWindow">
<children>
<HBox fx:id="topBox" minHeight="100" alignment="CENTER" styleClass="topbox">
Expand All @@ -16,9 +14,9 @@
<Button fx:id="backButton" mnemonicParsing="false" onAction="#backToOverview" styleClass="back-button" text="">
<padding><Insets right="15"/></padding>
</Button>
<!--<ImageView fitWidth="80.0" pickOnBounds="true" preserveRatio="true">
<ImageView fitWidth="80.0" pickOnBounds="true" preserveRatio="true">
<Image url="@icon.jpg"/>
</ImageView>-->
</ImageView>
<VBox alignment="CENTER_LEFT" prefHeight="80.0">
<children>
<HBox spacing="15">
Expand Down Expand Up @@ -93,6 +91,11 @@
<Label text="You can also drop an existing project file here."/>
</children>
</VBox>
<VBox alignment="CENTER" maxWidth="650" styleClass="reddit-ad" onMouseClicked="#onRedditAdClicked">
<ImageView fitWidth="290" fitHeight="90">
<Image url="@reddit-ad.png"/>
</ImageView>
</VBox>
</children>
<padding>
<Insets bottom="320.0" left="15.0" right="15.0"/>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions linux-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -e

# Extract the version number.
ver=$( sed -n 's/^.*final int VERSION = //p' client/src/main/java/lighthouse/Main.java )
ver="${ver:0:${#ver}-1}"
build=updates/builds/processed/$ver.jar

if [ ! -e "$build" ]; then
echo "Must run package.sh first to generate build"
exit 1
fi

javapackager -deploy \
-BappVersion=$ver \
-Bcategory=Office,Finance \
-BlicenseType=Apache \
-BlicenseFile=LICENSE \
[email protected] \
-Bicon=client/icons/icon.png \
-native deb \
-name lighthouse \
-title "Lighthouse: a peer to peer crowdfunding app that uses Bitcoin" \
-vendor Vinumeris \
-outdir deploy \
-appclass lighthouse.Main \
-srcdir updates/builds/processed \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change really correct? This looks like it might try and package every single JAR in that directory instead of only the one that corresponds to the right version number.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, only one JAR will be packaged, along with license file and postinst / prerm scripts. The directory contents are erased before build in package.sh.

An alternative solution is to keep old updates in the processed folder, and use -srcfiles to specify only $build, postinst, prerm and LICENSE. Would you prefer this solution? I can add another commit, it's a small change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so that's why my attempts to make LICENSE work failed - it has to be listed in the source files.

I've been meaning to improve the UpdateFX workflow I use as the current one is prone to mistakes. Your approach of emptying the processed directory might work, I need to check that the UpdateFX tool is OK with that. I'll get back to you soon. The current commit looks OK assuming it doesn't mess with the updates system. Thanks for fixing this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're welcome. I've tested the .deb package installation on Ubuntu 14.04 LTS using DPKG, but I didn't do any testing with UpdateFX.

-outfile lighthouse
35 changes: 35 additions & 0 deletions mac-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -e

# Extract the version number.
ver=$( sed -n 's/^.*final int VERSION = //p' client/src/main/java/lighthouse/Main.java )
ver="${ver:0:${#ver}-1}"
build=updates/builds/processed/$ver.jar

# Generate the plist from the template
sed "s|JAR_NAME_STRING_GOES_HERE|<string>$ver.jar</string>|" package/macosx/Info.template.plist >package/macosx/Info.plist

if [ ! -e "$build" ]; then
echo "Must run package.sh first to generate build"
exit 1
fi

jh=$(/usr/libexec/java_home -v 1.8)
if [ -e ../min-jdk ]; then
jh=`pwd`/../min-jdk/Contents/Home
fi
$jh/bin/javapackager -deploy \
-BappVersion=$ver \
-Bmac.CFBundleIdentifier=com.vinumeris.lighthouse \
-Bmac.CFBundleName=Lighthouse \
-Bicon=client/icons/mac.icns \
-Bruntime="$jh/../../" \
-native dmg \
-name Lighthouse \
-title Lighthouse \
-vendor Vinumeris \
-outdir deploy \
-appclass lighthouse.Main \
-srcfiles $build \
-outfile Lighthouse
45 changes: 45 additions & 0 deletions package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

set -e

if grep 'String UPDATES_BASE_URL = null' client/src/main/java/lighthouse/Main.java >/dev/null; then
echo "Don't use this for Crowdfunding App"
exit 1
fi
# Extract the version number.
ver=$( sed -n 's/^.*final int VERSION = //p' client/src/main/java/lighthouse/Main.java )
ver="${ver:0:${#ver}-1}"

echo "Building version $ver..."
rm -f updates/builds/processed/*
mvn -q -U clean package -DskipTests
[ ! -e updates ] && mkdir -p updates/builds

dest=updates/builds/$ver.jar

echo "Running ProGuard to delete dead code and shrink JAR ..."
java -jar ~/.m2/repository/net/sf/proguard/proguard-base/5.0/proguard-base-5.0.jar @client/proguard.pro

du -h client/target/shaded.jar client/target/lighthouse.jar

cp client/target/lighthouse.jar $dest
echo "Copied build as version $ver to $dest"

echo "Generating Windows build script"
sed "s/__VERSION__/$ver/g" package/windows/Lighthouse.iss.template >package/windows/Lighthouse.iss
echo "& 'C:\Program Files\Java\stripped8u31-64\bin\javapackager.exe' -deploy -BappVersion=$ver -native exe -name Lighthouse -title Lighthouse -vendor Vinumeris -outdir deploy -appclass lighthouse.Main -srcfiles .\\updates\\builds\\processed\\$ver.jar -outfile Lighthouse -Bruntime='c:\Program Files\Java\stripped8u31-64\jre'" >win-build.ps1
echo "& 'C:\Program Files (x86)\Java\jdk1.8.0_31\bin\javapackager.exe' -deploy -BappVersion=$ver -native exe -name Lighthouse -title Lighthouse -vendor Vinumeris -outdir deploy -appclass lighthouse.Main -srcfiles .\\updates\\builds\\processed\\$ver.jar -outfile Lighthouse -Bruntime='c:\Program Files (x86)\Java\jdk1.8.0_31\jre'" >>win-build.ps1

if [[ "$1" != "--nosign" ]]; then
echo "Generating online update site"
rm updates/site/* || true
java -jar tools/updatefx.jar --url=https://s3-eu-west-1.amazonaws.com/vinumeris/lighthouse/updates --gzip-from=7 updates
fi

if [[ $1 == "--package" ]]; then
if [ -e /Library ]; then
./mac-package.sh
elif [ -e /proc ]; then
./linux-package.sh
fi
fi
Loading