From 65eaa6b4ef7d9e3dd787bc9d0b000893d771f59a Mon Sep 17 00:00:00 2001 From: Martin Goellnitz Date: Mon, 25 Mar 2024 11:34:45 +0100 Subject: [PATCH] Fix hardcoded Path in XDG Intgration and add DEB/RPM Packages --- build.gradle | 49 +++++++++++++++++++++++++++++++++++-- xdg/JFileSync3.desktop | 4 +-- xdg/prepare_desktop_file.sh | 17 +++++++++++++ 3 files changed, 66 insertions(+), 4 deletions(-) create mode 100755 xdg/prepare_desktop_file.sh diff --git a/build.gradle b/build.gradle index c73acf8..e38aabc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2023 Martin Goellnitz + * Copyright (C) 2013-2024 Martin Goellnitz * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ plugins { id "edu.sc.seis.launch4j" version "2.5.4" id "net.ossindex.audit" version "0.4.11" + id "com.netflix.nebula.ospackage" version "11.8.1" } def l4j = true @@ -148,7 +149,50 @@ startScripts { } } -distZip.dependsOn startScripts +ospackage { + packageName = 'jfilesync' + version = '3.0-SNAPSHOT' + maintainer = 'Martin Goellnitz' + url = 'https://mgoellnitz.github.io/JFileSync3' + into("/usr/share/applications") { + from 'xdg' + include '*.desktop' + } + into("/usr/share/icons/hicolor/64x64") { + from 'xdg' + include '*.png' + } + into("/usr/share/$project.name") { + from '.' + include 'legal/*.*' + include 'profiles/*.*' + include 'README.md' + } + into("/usr/lib/$packageName/lib") { + from "build/install/$project.name/lib" + include '*.jar' + } + into("/usr/lib/$packageName/script") { + from "build/install/$project.name/bin" + include "$project.name" + } +} + +installDist.dependsOn startScripts + +buildDeb.dependsOn installDist + +buildDeb { + link("/usr/bin/$project.name", "/usr/lib/$packageName/script/$project.name") +} + +buildRpm.dependsOn buildDeb + +buildRpm { + link("/usr/bin/$project.name", "/usr/lib/$packageName/script/$project.name") +} + +distZip.dependsOn buildRpm distZip { // TODO: later... @@ -175,6 +219,7 @@ distZip { from 'xdg' include '*.desktop' include '*.png' + include 'prepare*.sh' } // legal stuff, examples, and documentation into(project.name) { diff --git a/xdg/JFileSync3.desktop b/xdg/JFileSync3.desktop index 7c7dc43..2c7371d 100755 --- a/xdg/JFileSync3.desktop +++ b/xdg/JFileSync3.desktop @@ -2,8 +2,8 @@ Encoding=UTF-8 Name=JFileSync3 - 3.0-SNAPSHOT Comment=Syncing and Encryption -Exec=/opt/JFileSync3/bin/JFileSync3 -Icon=/opt/JFileSync3/bin/JFileSync3.png +Exec=JFileSync3 +Icon=JFileSync3.png Categories=Application;Java Version=1.0 Type=Application diff --git a/xdg/prepare_desktop_file.sh b/xdg/prepare_desktop_file.sh new file mode 100755 index 0000000..2cb8a4a --- /dev/null +++ b/xdg/prepare_desktop_file.sh @@ -0,0 +1,17 @@ +#!/bin/bash +DIR=$(dirname $(readlink -f $0)) +if [ -f $DIR/../lib/JFileSync3.jar ] ; then + if [ -f ~/.config/user-dirs.dirs ] ; then + DESKTOP_DIR=~/$(cat ~/.config/user-dirs.dirs |grep XDG_DESKTOP_DIR|sed -e 's/^.*HOME.\(.*\)./\1/g') + else + if [ -f ~/.config/user-dirs.dirs ] ; then + DESKTOP_DIR=~/$(cat /etc/xdg/user-dirs.defaults |grep DESKTOP|sed -e 's/^.*=\(.*\)$/\1/g') + else + DESKTOP_DIR=~/Desktop + fi + fi + PATTERN=$(echo $DIR|sed -e 's/\//\\\//g')\\/ + sed -i.bak -e "s/^Exec=.*/Exec=${PATTERN}JFileSync3/" $DIR/JFileSync3.desktop + sed -i.bak -e "s/^Icon=.*/Icon=${PATTERN}JFileSync3.png/" $DIR/JFileSync3.desktop + rm $DIR/JFileSync3.desktop.bak +fi