Merge pull request #658 from wolsen/snapcraft
Add snapcraft information for building snaps
This commit is contained in:
commit
43d6779e12
2
.gitignore
vendored
2
.gitignore
vendored
@ -89,3 +89,5 @@ crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
openrocket.log
|
||||
|
||||
*.snap
|
||||
|
@ -41,7 +41,24 @@ public class SystemInfo {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the OpenRocket is running a confined manner that may
|
||||
* require alternative behaviors and experiences.
|
||||
*
|
||||
* Note: future versions may return further confinement information and
|
||||
* this interface is subject to change.
|
||||
*
|
||||
* @return true if the system is running in a confined manner, false
|
||||
* otherwise
|
||||
*/
|
||||
public static boolean isConfined() {
|
||||
switch (getPlatform()) {
|
||||
case UNIX:
|
||||
return (System.getenv("SNAP_VERSION") != null);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
8
snap/gui/openrocket.desktop
Normal file
8
snap/gui/openrocket.desktop
Normal file
@ -0,0 +1,8 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=openrocket
|
||||
Comment=Design and simulate model rockets
|
||||
Icon=${SNAP}/meta/gui/openrocket.png
|
||||
Exec=openrocket
|
||||
Terminal=false
|
||||
Categories=Utility;
|
BIN
snap/gui/openrocket.png
Normal file
BIN
snap/gui/openrocket.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 63 KiB |
23
snap/local/launcher
Executable file
23
snap/local/launcher
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
JAVA_BIN="$JAVA_HOME/bin/java"
|
||||
|
||||
export DESKTOP_SESSION=gnome
|
||||
export XDG_SESSION_DESKTOP=gnome
|
||||
export XDG_CURRENT_DESKTOP=GNOME
|
||||
|
||||
JAVA_OPTS="-Dsun.java2d.xrender=true -Dprism.useFontConfig=false -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Djava.io.tmpdir=$SNAP_USER_COMMON"
|
||||
|
||||
if ! snapctl is-connected preferences; then
|
||||
JAVA_OPTS="$JAVA_OPTS -Djava.util.prefs.userRoot=$SNAP_USER_COMMON/"
|
||||
fi
|
||||
|
||||
if ! snapctl is-connected openrocket-db; then
|
||||
JAVA_OPTS="$JAVA_OPTS -Duser.home=$SNAP_USER_COMMON/"
|
||||
fi
|
||||
|
||||
export _JAVA_OPTIONS=$JAVA_OPTS
|
||||
# Fix font / theme
|
||||
export JAVA_FONTS=$SNAP/usr/share/fonts/truetype
|
||||
exec $JAVA_BIN -jar $SNAP/OpenRocket.jar "$@"
|
||||
|
94
snap/snapcraft.yaml
Normal file
94
snap/snapcraft.yaml
Normal file
@ -0,0 +1,94 @@
|
||||
name: openrocket
|
||||
adopt-info: openrocket
|
||||
grade: stable
|
||||
summary: A free, fully featured model rocket simulator.
|
||||
description: |
|
||||
OpenRocket is a free, fully featured model rocket simulator that allows you
|
||||
to design and simulate your rockets before actually building and flying them.
|
||||
|
||||
The main features include
|
||||
|
||||
* Six-degree-of-freedom flight simulation
|
||||
* Automatic design optimization
|
||||
* Realtime simulated altitude, velocity and acceleration display
|
||||
* Staging and clustering support
|
||||
* Cross-platform (Java-based)
|
||||
* Read more about it on the OpenRocket.info.
|
||||
license: GPL-3.0
|
||||
base: core18
|
||||
|
||||
grade: stable
|
||||
confinement: strict
|
||||
|
||||
plugs:
|
||||
preferences:
|
||||
interface: personal-files
|
||||
read:
|
||||
- $HOME/.java
|
||||
write:
|
||||
- $HOME/.java
|
||||
openrocket-db:
|
||||
interface: personal-files
|
||||
read:
|
||||
- $HOME/.openrocket
|
||||
write:
|
||||
- $HOME/.openrocket
|
||||
|
||||
apps:
|
||||
openrocket:
|
||||
extensions:
|
||||
- gnome-3-28
|
||||
command: bin/launcher
|
||||
plugs:
|
||||
- home
|
||||
- network
|
||||
- cups-control
|
||||
- opengl
|
||||
- preferences
|
||||
- openrocket-db
|
||||
environment:
|
||||
JAVA_HOME: "$SNAP/usr/lib/jvm/java-11-openjdk-amd64"
|
||||
|
||||
parts:
|
||||
openrocket:
|
||||
plugin: ant
|
||||
source: .
|
||||
ant-build-targets:
|
||||
- clean
|
||||
- check
|
||||
- unittest
|
||||
- jar
|
||||
override-pull: |
|
||||
# Override the pull in order to set the version and the grade.
|
||||
# In the future, the releases can be annotated tags and snapcraft
|
||||
# will use those for the version numbers.
|
||||
#
|
||||
# This can be extended to other parts of OpenRocket (to use the
|
||||
# git describe --tags command) but the build should be updated at
|
||||
# the same time so its consistent across all artifacts. Will defer
|
||||
# that to a later pull request.
|
||||
#
|
||||
# Until then, just use the build.version value
|
||||
snapcraftctl pull
|
||||
VERSION=$(cat core/resources/build.properties | awk -F'=' '/build\.version/ { print $2 }')
|
||||
snapcraftctl set-version "$VERSION"
|
||||
override-build: |
|
||||
snapcraftctl build
|
||||
mv swing/build/jar/OpenRocket.jar $SNAPCRAFT_PART_INSTALL/OpenRocket.jar
|
||||
build-packages:
|
||||
# Add gcc as a build package due to bug https://bugs.launchpad.net/snapcraft/+bug/1883392
|
||||
- gcc
|
||||
stage-packages:
|
||||
- openjdk-11-jre
|
||||
- ca-certificates
|
||||
- ca-certificates-java
|
||||
prime:
|
||||
- -usr/lib/jvm/java-*/lib/security/cacerts
|
||||
- -usr/lib/jvm/java-*/jre/lib/security/cacerts
|
||||
|
||||
launcher:
|
||||
plugin: dump
|
||||
source: snap/local
|
||||
organize:
|
||||
'launcher': 'bin/'
|
||||
|
@ -31,6 +31,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sf.openrocket.arch.SystemInfo;
|
||||
import net.sf.openrocket.arch.SystemInfo.Platform;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.gui.print.PrintController;
|
||||
import net.sf.openrocket.gui.print.PrintSettings;
|
||||
@ -321,7 +323,7 @@ public class PrintDialog extends JDialog implements TreeSelectionListener {
|
||||
// TODO: HIGH: Remove UIManager, and pass settings to the actual printing methods
|
||||
TemplateProperties.setColors(settings);
|
||||
File f = generateReport(settings);
|
||||
desktop.open(f);
|
||||
openPreviewHelper(f);
|
||||
} catch (IOException e) {
|
||||
log.error("Could not open preview.", e);
|
||||
JOptionPane.showMessageDialog(this, new String[] {
|
||||
@ -339,6 +341,20 @@ public class PrintDialog extends JDialog implements TreeSelectionListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void openPreviewHelper(final File f) throws IOException {
|
||||
if (SystemInfo.getPlatform() == Platform.UNIX && SystemInfo.isConfined()) {
|
||||
/* When installed via a snap package on Linux, the default option
|
||||
* to open PDF options using java.awt.Desktop.open() doesn't work
|
||||
* due to using . Instead, use the xdg-open command
|
||||
* which will work for URLs.
|
||||
*/
|
||||
String command = "xdg-open " + f.getAbsolutePath();
|
||||
Runtime.getRuntime().exec(command);
|
||||
} else {
|
||||
desktop.open(f);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for when the "Save as PDF" button is clicked.
|
||||
*
|
||||
|
@ -23,6 +23,8 @@ import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sf.openrocket.arch.SystemInfo;
|
||||
import net.sf.openrocket.arch.SystemInfo.Platform;
|
||||
import net.sf.openrocket.gui.adaptors.BooleanModel;
|
||||
import net.sf.openrocket.gui.components.StyledLabel;
|
||||
import net.sf.openrocket.gui.components.StyledLabel.Style;
|
||||
@ -37,7 +39,7 @@ public class GraphicsPreferencesPanel extends PreferencesPanel {
|
||||
public GraphicsPreferencesPanel(JDialog parent) {
|
||||
super(parent, new MigLayout("fillx"));
|
||||
|
||||
this.add(new JPanel(new MigLayout("fill, ins n n n")) {
|
||||
JPanel editorPrefPanel = new JPanel(new MigLayout("fill, ins n n n")) {
|
||||
{ //Editor Options
|
||||
TitledBorder border = BorderFactory.createTitledBorder(trans.get("pref.dlg.lbl.DecalEditor"));
|
||||
GUIUtil.changeFontStyle(border, Font.BOLD);
|
||||
@ -135,7 +137,16 @@ public class GraphicsPreferencesPanel extends PreferencesPanel {
|
||||
|
||||
});
|
||||
}
|
||||
}, "growx, span");
|
||||
};
|
||||
|
||||
/* Don't show the editor preferences panel when confined in a snap on Linux.
|
||||
* The snap confinement doesn't allow to run any edit commands, and instead
|
||||
* we will rely on using the xdg-open command which allows the user to pick
|
||||
* their preferred application.
|
||||
*/
|
||||
if (SystemInfo.getPlatform() != Platform.UNIX && !SystemInfo.isConfined()) {
|
||||
this.add(editorPrefPanel, "growx, span");
|
||||
}
|
||||
|
||||
this.add(new JPanel(new MigLayout("fill, ins n n n")) {
|
||||
{/////GL Options
|
||||
|
@ -74,15 +74,17 @@ public class EditDecalHelper {
|
||||
|
||||
boolean sysPrefSet = prefs.isDecalEditorPreferenceSet();
|
||||
int usageCount = doc.countDecalUsage(decal);
|
||||
boolean isSnapConfined = (SystemInfo.getPlatform() == Platform.UNIX && SystemInfo.isConfined());
|
||||
|
||||
//First Check preferences
|
||||
if (sysPrefSet && usageCount == 1) {
|
||||
|
||||
launchEditor(prefs.isDecalEditorPreferenceSystem(), prefs.getDecalEditorCommandLine(), decal);
|
||||
if (usageCount == 1 && (sysPrefSet || isSnapConfined)) {
|
||||
String commandLine = isSnapConfined ? "xdg-open %%" : prefs.getDecalEditorCommandLine();
|
||||
launchEditor(prefs.isDecalEditorPreferenceSystem(), commandLine, decal);
|
||||
return decal;
|
||||
}
|
||||
|
||||
EditDecalDialog dialog = new EditDecalDialog(parent, !sysPrefSet, usageCount);
|
||||
boolean promptForEditor = (!sysPrefSet && !isSnapConfined);
|
||||
EditDecalDialog dialog = new EditDecalDialog(parent, promptForEditor, usageCount);
|
||||
dialog.setVisible(true);
|
||||
|
||||
if (dialog.isCancel()) {
|
||||
@ -93,7 +95,10 @@ public class EditDecalHelper {
|
||||
boolean useSystemEditor = false;
|
||||
String commandLine = "";
|
||||
|
||||
if (sysPrefSet) {
|
||||
if (isSnapConfined) {
|
||||
useSystemEditor = false;
|
||||
commandLine = "xdg-open %%";
|
||||
} else if (sysPrefSet) {
|
||||
useSystemEditor = prefs.isDecalEditorPreferenceSystem();
|
||||
commandLine = prefs.getDecalEditorCommandLine();
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user