From eece777e285563d51d68d9afd999bbb320594f46 Mon Sep 17 00:00:00 2001 From: Stef Tervelde Date: Tue, 12 Aug 2025 14:11:35 +0200 Subject: [PATCH] Adding classic confinment support + refactor for later flathub --- .github/workflows/release-gradle.yml | 1 + app/build.gradle.kts | 81 +++++++++++----------------- app/linux/snapcraft.base.yml | 42 +++++++++++++++ 3 files changed, 75 insertions(+), 49 deletions(-) create mode 100644 app/linux/snapcraft.base.yml diff --git a/.github/workflows/release-gradle.yml b/.github/workflows/release-gradle.yml index 16e8984e3b..8ec45cad0b 100644 --- a/.github/workflows/release-gradle.yml +++ b/.github/workflows/release-gradle.yml @@ -153,6 +153,7 @@ jobs: ORG_GRADLE_PROJECT_compose.desktop.mac.notarization.password: ${{ secrets.PROCESSING_APP_PASSWORD }} ORG_GRADLE_PROJECT_compose.desktop.mac.notarization.teamID: ${{ secrets.PROCESSING_TEAM_ID }} ORG_GRADLE_PROJECT_snapname: ${{ vars.SNAP_NAME }} + ORG_GRADLE_PROJECT_snapconfinement: ${{ vars.SNAP_CONFINEMENT }} - name: Sign files with Trusted Signing if: runner.os == 'Windows' diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5323a1a829..b536208583 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -228,61 +228,44 @@ tasks.register("packageCustomMsi"){ tasks.register("generateSnapConfiguration"){ - val name = findProperty("snapname") ?: rootProject.name + onlyIf { OperatingSystem.current().isLinux } + + val distributable = tasks.named("createDistributable").get() + dependsOn(distributable) + + val name = findProperty("snapname") as String? ?: rootProject.name val arch = when (System.getProperty("os.arch")) { "amd64", "x86_64" -> "amd64" "aarch64" -> "arm64" else -> System.getProperty("os.arch") } - - onlyIf { OperatingSystem.current().isLinux } - val distributable = tasks.named("createDistributable").get() - dependsOn(distributable) - + val confinement = findProperty("snapconfinement") as String? ?: "strict" val dir = distributable.destinationDir.get() - val content = """ - name: $name - version: $version - base: core22 - summary: A creative coding editor - description: | - Processing is a flexible software sketchbook and a programming language designed for learning how to code. - confinement: strict - - apps: - processing: - command: opt/processing/bin/Processing - desktop: opt/processing/lib/processing-Processing.desktop - environment: - LD_LIBRARY_PATH: ${'$'}SNAP/opt/processing/lib/runtime/lib:${'$'}LD_LIBRARY_PATH - LIBGL_DRIVERS_PATH: ${'$'}SNAP/usr/lib/${'$'}SNAPCRAFT_ARCH_TRIPLET/dri - plugs: - - desktop - - desktop-legacy - - wayland - - x11 - - network - - opengl - - home - - removable-media - - audio-playback - - audio-record - - pulseaudio - - gpio - - parts: - processing: - plugin: dump - source: deb/processing_$version-1_$arch.deb - source-type: deb - stage-packages: - - openjdk-17-jre - override-prime: | - snapcraftctl prime - rm -vf usr/lib/jvm/java-17-openjdk-*/lib/security/cacerts - chmod -R +x opt/processing/lib/app/resources/jdk - """.trimIndent() - dir.file("../snapcraft.yaml").asFile.writeText(content) + val base = layout.projectDirectory.file("linux/snapcraft.base.yml") + + doFirst { + + var content = base + .asFile + .readText() + .replace("\$name", name) + .replace("\$arch", arch) + .replace("\$version", version as String) + .replace("\$confinement", confinement) + .let { + if (confinement != "classic") return@let it + // If confinement is not strict, remove the PLUGS section + val start = it.indexOf("# PLUGS START") + val end = it.indexOf("# PLUGS END") + if (start != -1 && end != -1) { + val before = it.substring(0, start) + val after = it.substring(end + "# PLUGS END".length) + return@let before + after + } + return@let it + } + dir.file("../snapcraft.yaml").asFile.writeText(content) + } } tasks.register("packageSnap"){ diff --git a/app/linux/snapcraft.base.yml b/app/linux/snapcraft.base.yml new file mode 100644 index 0000000000..4847f0a7c8 --- /dev/null +++ b/app/linux/snapcraft.base.yml @@ -0,0 +1,42 @@ +name: $name +version: $version +base: core22 +summary: A creative coding editor +description: | + Processing is a flexible software sketchbook and a programming language designed for learning how to code. +confinement: $confinement + +apps: + processing: + command: opt/processing/bin/Processing + desktop: opt/processing/lib/processing-Processing.desktop + environment: + LD_LIBRARY_PATH: $SNAP/opt/processing/lib/runtime/lib:$LD_LIBRARY_PATH + LIBGL_DRIVERS_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/dri + # PLUGS START + plugs: + - desktop + - desktop-legacy + - wayland + - x11 + - network + - opengl + - home + - removable-media + - audio-playback + - audio-record + - pulseaudio + - gpio + # PLUGS END + +parts: + processing: + plugin: dump + source: deb/processing_$version-1_$arch.deb + source-type: deb + stage-packages: + - openjdk-17-jre + override-prime: | + snapcraftctl prime + rm -vf usr/lib/jvm/java-17-openjdk-*/lib/security/cacerts + chmod -R +x opt/processing/lib/app/resources/jdk \ No newline at end of file