Skip to content

Adding snap classic confinement support #1200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release-gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
81 changes: 32 additions & 49 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -228,61 +228,44 @@ tasks.register<Exec>("packageCustomMsi"){


tasks.register("generateSnapConfiguration"){
val name = findProperty("snapname") ?: rootProject.name
onlyIf { OperatingSystem.current().isLinux }

val distributable = tasks.named<AbstractJPackageTask>("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<AbstractJPackageTask>("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
Comment on lines +256 to +265
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be moved into a helper function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but it is only being used once, which means it would clutter up the file and be less clear where it is being used

}
dir.file("../snapcraft.yaml").asFile.writeText(content)
}
}

tasks.register<Exec>("packageSnap"){
Expand Down
42 changes: 42 additions & 0 deletions app/linux/snapcraft.base.yml
Original file line number Diff line number Diff line change
@@ -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
Loading