build: added linux deb and rpm package support

This commit is contained in:
Alex Andres 2024-02-19 20:19:51 +01:00
parent 86ab20e1d9
commit e59c76f00d
No known key found for this signature in database
GPG key ID: 340764C7851D7041
8 changed files with 128 additions and 68 deletions

View file

@ -1,41 +1,79 @@
#!/bin/bash
# lecturePresenter is the main launcher and lectureEditor is the secondary
# launcher which parameters are defined in the separate properties file.
# Both applications are packaged together and share one runtime.
JAVA_VERSION=${package.java.version}
PRODUCT_NAME="${package.full.name}"
PRESENTER_NAME="${package.presenter.name}"
PRESENTER_CLASS="${package.presenter.class}"
PRESENTER_JAR="${package.presenter.jar}"
PRESENTER_ICON="${package.presenter.icon}"
EDITOR_NAME="${package.editor.name}"
EDITOR_JAR="${package.editor.jar}"
VERSION="${package.version}"
VENDOR="${package.vendor}"
DESCRIPTION="${package.description}"
ABOUT_URL="${package.about.url}"
LICENSE="${package.license}"
LICENSE_TYPE="${package.license.type}"
COPYRIGHT="${package.copyright}"
INPUT_DIR="${package.input.dir}"
OUTPUT_DIR="${package.output.dir}"
LIBRARY_PATH=\$APPDIR/lib/native
app[0]=lecturePresenter
app[1]=lectureEditor
COMMON_PARAMS=(--java-options -Xmx4096m \
--java-options -Djava.library.path="$LIBRARY_PATH" \
--java-options -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager \
--description "$DESCRIPTION" \
--app-version "$VERSION" \
--vendor "$VENDOR" \
--copyright "$COPYRIGHT" \
--name "$PRESENTER_NAME" \
--main-class "$PRESENTER_CLASS" \
--main-jar "$PRESENTER_JAR" \
--icon "$PRESENTER_ICON" \
--add-launcher lectureEditor=resources/lectureEditor.properties)
class[0]=org.lecturestudio.presenter.swing.PresenterApplication
class[1]=org.lecturestudio.editor.javafx.EditorFxApplication
icon[0]=${project.parent.parent.basedir}/lect-presenter-swing/src/main/resources/gfx/app-icon/128.png
icon[1]=${project.parent.parent.basedir}/lect-editor-fx/src/main/resources/gfx/app-icon/128.png
jar[0]=lect-presenter-swing.jar
jar[1]=lect-editor-fx.jar
LINUX_PARAMS=("${COMMON_PARAMS[@]}" \
--input "$INPUT_DIR" \
--dest "$OUTPUT_DIR" \
--about-url "$ABOUT_URL" \
--file-associations "resources/lectureEditor-File-Association.properties" \
--runtime-image "runtime" \
--linux-package-name "lecturestudio" \
--linux-menu-group "Education" \
--linux-app-category "education" \
--linux-app-release "linux" \
--linux-shortcut \
--license-file "$LICENSE" \
--resource-dir resources)
mkdir "$PRODUCT_NAME"
# Start with modules not discovered with jdeps.
MODULES="jdk.localedata,java.security.jgss,java.security.sasl,jdk.crypto.cryptoki,jdk.crypto.ec,jdk.zipfs"
# Retrieve modules.
for value in {0..1}
do
echo "Get ${app[$value]} modules"
# Retrieve the required modules by the applications.
# $1: Application name
# $2: Application jar file
getAppModules() {
app=${1?:"Need an application."}
appJar=${2?:"Need an application jar file."}
echo "Get $app Modules"
modules=$(jdeps \
--class-path "${package.input.dir}/lib/*" \
--multi-release 15 \
--class-path "$INPUT_DIR/lib/*" \
--multi-release $JAVA_VERSION \
--ignore-missing-deps \
--print-module-deps \
-R -q \
"${package.input.dir}/${jar[$value]}")
"$INPUT_DIR/$appJar")
echo "$modules"
@ -45,13 +83,15 @@ do
else
MODULES="$MODULES,$modules"
fi
done
}
# Create the Runtime.
getAppModules $PRESENTER_NAME $PRESENTER_JAR
getAppModules $EDITOR_NAME $EDITOR_JAR
# Create runtime with modules required by the applications.
echo "Create Runtime"
jlink \
--no-header-files --no-man-pages \
jlink --no-header-files --no-man-pages \
--compress=1 \
--strip-debug \
--strip-native-commands \
@ -59,55 +99,39 @@ jlink \
--add-modules="$MODULES" \
--output "runtime"
for value in {0..1}
do
app_name=${app[$value]}
# Create the self-contained Java application package. Used only for the ZIP archive.
echo "Create Application Image"
echo "Packaging $app_name";
jpackage "${COMMON_PARAMS[@]}" \
--type app-image \
--input "$INPUT_DIR" \
--runtime-image "runtime"
if [ -n "${icon[$value]}" ]; then
app_icon="--icon ${icon[$value]}"
fi
# Copy all files of the generated application package to the common bundle folder.
cp -npR "$PRESENTER_NAME"/* "$PRODUCT_NAME/"
# Create the self-contained Java application package.
jpackage \
--type app-image \
--input "${package.input.dir}" \
--runtime-image "runtime" \
--java-options -Xmx4096m \
--java-options -Djava.library.path="$LIBRARY_PATH" \
--java-options -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager \
--app-version "$VERSION" \
--name $app_name \
--main-jar ${jar[$value]} \
--main-class ${class[$value]} \
--vendor "$VENDOR" \
--copyright "$COPYRIGHT" \
${app_icon}
# Copy all files of the generated application package to the common bundle folder.
cp -npR $app_name/* "$PRODUCT_NAME/"
# Remove the individual application package.
rm -Rf $app_name
unset app_icon
done
# Remove the individual application package.
rm -Rf "$PRESENTER_NAME"
# Create a manually installable ZIP package.
chmod +x "$PRODUCT_NAME"/lib/app/lib/native/ffmpeg
zip -r -q "${package.output.dir}/$PRODUCT_NAME".zip "$PRODUCT_NAME"
echo "Create ZIP Archive"
zip -r -q "$OUTPUT_DIR/$PRODUCT_NAME".zip "$PRODUCT_NAME"
# Create installable DEB package.
echo "Create DEB Package"
jpackage "${LINUX_PARAMS[@]}" \
--type deb \
--temp temp_deb
# Create installable RPM package.
echo "Create RPM Package"
jpackage "${LINUX_PARAMS[@]}" \
--type rpm \
--linux-rpm-license-type "$LICENSE_TYPE" \
--temp temp_rpm
# Create installable DEB package
jpackage \
--type deb \
--name "${package.name}" \
--app-version "$VERSION" \
--app-image "$PRODUCT_NAME" \
--vendor "$VENDOR" \
--copyright "$COPYRIGHT" \
--linux-shortcut \
--linux-menu-group "Education" \
--linux-app-category "education" \
--license-file "$LICENSE" \
--linux-app-release "1"

View file

@ -0,0 +1,4 @@
extension=presenter
mime-type=application/presenter
description=Presenter Recording File
icon=resources/presenter-file-icon.png

View file

@ -0,0 +1,9 @@
[Desktop Entry]
Name=lectureEditor
Comment=An integrated tool for presenting lectures
Exec=/opt/lecturestudio/bin/lectureEditor
Icon=/opt/lecturestudio/lib/lectureEditor.png
Terminal=false
Type=Application
Categories=Education
MimeType=application/presenter

View file

@ -0,0 +1,3 @@
main-jar = ${package.editor.jar}
main-class = ${package.editor.class}
icon = ${package.editor.icon}

View file

@ -0,0 +1,9 @@
[Desktop Entry]
Name=lecturePresenter
Comment=An integrated tool for presenting lectures
Exec=/opt/lecturestudio/bin/lecturePresenter
Icon=/opt/lecturestudio/lib/lecturePresenter.png
Terminal=false
Type=Application
Categories=Education
MimeType=

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -15,7 +15,17 @@
<packaging>pom</packaging>
<properties>
<package.java.version>17</package.java.version>
<package.presenter.name>lecturePresenter</package.presenter.name>
<package.presenter.class>org.lecturestudio.presenter.swing.PresenterApplication</package.presenter.class>
<package.presenter.jar>lect-presenter-swing.jar</package.presenter.jar>
<package.presenter.icon>${project.parent.parent.basedir}/lect-presenter-swing/src/main/resources/gfx/app-icon/128.png</package.presenter.icon>
<package.editor.name>lectureEditor</package.editor.name>
<package.editor.class>org.lecturestudio.editor.javafx.EditorFxApplication</package.editor.class>
<package.editor.jar>lect-editor-fx.jar</package.editor.jar>
<package.editor.icon>${project.parent.parent.basedir}/lect-editor-fx/src/main/resources/gfx/app-icon/128.png</package.editor.icon>
<package.license>${project.parent.parent.basedir}/LICENSE</package.license>
<package.license.type>GPLv3</package.license.type>
<package.input.dir>${project.parent.parent.build.directory}/${build.output.dir}</package.input.dir>
<package.output.dir>${project.parent.parent.build.directory}</package.output.dir>
</properties>
@ -122,4 +132,4 @@
</properties>
</profile>
</profiles>
</project>
</project>

View file

@ -17,6 +17,7 @@
<package.copyright>Copyright © 2024 TU Darmstadt</package.copyright>
<package.description>An integrated tool for presenting lectures</package.description>
<package.vendor>TU Darmstadt</package.vendor>
<package.about.url>https://www.lecturestudio.org</package.about.url>
</properties>
<modules>
@ -37,4 +38,4 @@
</modules>
</profile>
</profiles>
</project>
</project>