Rework jna handling and add sid check

This commit is contained in:
crschnick 2024-03-25 08:15:31 +00:00
parent e90c6f36d3
commit db94d2d74b
8 changed files with 58 additions and 15 deletions

View file

@ -10,10 +10,12 @@ repositories {
apply from: "$rootDir/gradle/gradle_scripts/java.gradle"
apply from: "$rootDir/gradle/gradle_scripts/javafx.gradle"
apply from: "$rootDir/gradle/gradle_scripts/jna.gradle"
apply from: "$rootDir/gradle/gradle_scripts/lombok.gradle"
configurations {
implementation.extendsFrom(javafx)
api.extendsFrom(jna)
}
dependencies {
@ -42,8 +44,6 @@ dependencies {
api 'io.sentry:sentry:7.6.0'
api 'org.ocpsoft.prettytime:prettytime:5.0.7.Final'
api 'commons-io:commons-io:2.15.1'
api 'net.java.dev.jna:jna-jpms:5.14.0'
api 'net.java.dev.jna:jna-platform-jpms:5.14.0'
api group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "2.17.0"
api group: 'com.fasterxml.jackson.module', name: 'jackson-module-parameter-names', version: "2.17.0"
api group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: "2.17.0"
@ -54,6 +54,7 @@ dependencies {
api group: 'org.kordamp.ikonli', name: 'ikonli-material-pack', version: "12.2.0"
api group: 'org.kordamp.ikonli', name: 'ikonli-feather-pack', version: "12.2.0"
api group: 'org.slf4j', name: 'slf4j-api', version: '2.0.12'
api group: 'org.slf4j', name: 'slf4j-jdk-platform-logging', version: '2.0.12'
api 'io.xpipe:modulefs:0.1.5'
api 'net.synedra:validatorfx:0.4.2'
api ('io.github.mkpaz:atlantafx-base:2.0.1') {
@ -79,7 +80,7 @@ application {
run {
systemProperty 'io.xpipe.app.useVirtualThreads', 'false'
systemProperty 'io.xpipe.app.mode', 'gui'
systemProperty 'io.xpipe.app.dataDir', "$projectDir/local_git8/"
systemProperty 'io.xpipe.app.dataDir', "$projectDir/local_git23/"
systemProperty 'io.xpipe.app.writeLogs', "true"
systemProperty 'io.xpipe.app.writeSysOut', "true"
systemProperty 'io.xpipe.app.developerMode', "true"

View file

@ -6,7 +6,6 @@ import io.xpipe.app.util.XPipeSession;
import io.xpipe.core.util.Deobfuscator;
import lombok.Getter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.ILoggerFactory;
import org.slf4j.IMarkerFactory;
import org.slf4j.Logger;
@ -315,17 +314,16 @@ public class AppLogs {
private final Map<String, Logger> loggers = new ConcurrentHashMap<>();
public Logger getLogger(String name) {
if (AppLogs.get() == null) {
return NOPLogger.NOP_LOGGER;
}
// Only change this when debugging the logs of other libraries
return NOPLogger.NOP_LOGGER;
// Don't use fully qualified class names
var normalizedName = FilenameUtils.getExtension(name);
if (normalizedName == null || normalizedName.isEmpty()) {
normalizedName = name;
}
return loggers.computeIfAbsent(normalizedName, s -> new Slf4jLogger());
// // Don't use fully qualified class names
// var normalizedName = FilenameUtils.getExtension(name);
// if (normalizedName == null || normalizedName.isEmpty()) {
// normalizedName = name;
// }
//
// return loggers.computeIfAbsent(normalizedName, s -> new Slf4jLogger());
}
};

View file

@ -0,0 +1,21 @@
package io.xpipe.app.core.check;
import com.sun.jna.Function;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.core.process.OsType;
public class AppSidCheck {
public static void check() {
if (OsType.getLocal().equals(OsType.WINDOWS)) {
return;
}
try {
var func = Function.getFunction("c", "setsid");
func.invoke(new Object[0]);
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).omit().handle();
}
}
}

View file

@ -6,6 +6,7 @@ import io.xpipe.app.core.*;
import io.xpipe.app.core.check.AppAvCheck;
import io.xpipe.app.core.check.AppCertutilCheck;
import io.xpipe.app.core.check.AppShellCheck;
import io.xpipe.app.core.check.AppSidCheck;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
@ -49,6 +50,7 @@ public class BaseMode extends OperationMode {
AppPrefs.initLocal();
AppCertutilCheck.check();
AppAvCheck.check();
AppSidCheck.check();
LocalShell.init();
AppShellCheck.check();
XPipeDistributionType.init();

View file

@ -46,6 +46,7 @@ open module io.xpipe.app {
requires com.sun.jna;
requires com.sun.jna.platform;
requires org.slf4j;
requires org.slf4j.jdk.platform.logging;
requires atlantafx.base;
requires org.ocpsoft.prettytime;
requires com.vladsch.flexmark;

View file

@ -92,6 +92,7 @@ project.ext {
"-Dapple.awt.application.appearance=system"
]
useBundledJavaFx = fullVersion
useBundledJna = fullVersion
announce = System.getenv('SKIP_ANNOUNCEMENT') == null || !Boolean.parseBoolean(System.getenv('SKIP_ANNOUNCEMENT'))
changelogFile = file("$rootDir/dist/changelogs/${versionString}.md").exists() ?
file("$rootDir/dist/changelogs/${versionString}.md") :

13
dist/jpackage.gradle vendored
View file

@ -1,4 +1,5 @@
apply from: "$rootDir/gradle/gradle_scripts/javafx.gradle"
apply from: "$rootDir/gradle/gradle_scripts/jna.gradle"
def distDir = "${project.layout.buildDirectory.get()}/dist"
@ -10,7 +11,9 @@ def releaseArguments = distJvmArgs + [
"-Dio.xpipe.app.buildId=$rootProject.buildId",
"-Dio.xpipe.app.fullVersion=$rootProject.fullVersion",
"-Dio.xpipe.app.staging=$rootProject.isStage",
'-Dio.xpipe.app.sentryUrl=https://fd5f67ff10764b7e8a704bec9558c8fe@o1084459.ingest.sentry.io/6094279'
'-Dio.xpipe.app.sentryUrl=https://fd5f67ff10764b7e8a704bec9558c8fe@o1084459.ingest.sentry.io/6094279',
'-Djna.nosys=false',
'-Djna.nounpack=true'
]
if (org.gradle.internal.os.OperatingSystem.current().isMacOsX()) {
@ -30,6 +33,11 @@ dependencies {
implementation files(it)
}
}
if (!useBundledJavaFx) {
configurations.jna.getAsFileTree().getFiles().forEach {
implementation files(it)
}
}
}
// Mac does not like a zero major version
@ -51,6 +59,9 @@ jlink {
if (useBundledJavaFx) {
addExtraModulePath(layout.projectDirectory.dir("javafx/${platformName}/${arch}").toString())
}
if (useBundledJna) {
addExtraModulePath(layout.projectDirectory.dir("jna/${platformName}/${arch}").toString())
}
launcher {
moduleName = 'io.xpipe.app'

View file

@ -0,0 +1,8 @@
configurations {
jna
}
dependencies {
jna 'net.java.dev.jna:jna-jpms:5.14.0'
jna 'net.java.dev.jna:jna-platform-jpms:5.14.0'
}