Skip to content

Commit eece777

Browse files
committed
Adding classic confinment support + refactor for later flathub
1 parent 3f36db5 commit eece777

File tree

3 files changed

+75
-49
lines changed

3 files changed

+75
-49
lines changed

.github/workflows/release-gradle.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ jobs:
153153
ORG_GRADLE_PROJECT_compose.desktop.mac.notarization.password: ${{ secrets.PROCESSING_APP_PASSWORD }}
154154
ORG_GRADLE_PROJECT_compose.desktop.mac.notarization.teamID: ${{ secrets.PROCESSING_TEAM_ID }}
155155
ORG_GRADLE_PROJECT_snapname: ${{ vars.SNAP_NAME }}
156+
ORG_GRADLE_PROJECT_snapconfinement: ${{ vars.SNAP_CONFINEMENT }}
156157

157158
- name: Sign files with Trusted Signing
158159
if: runner.os == 'Windows'

app/build.gradle.kts

Lines changed: 32 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -228,61 +228,44 @@ tasks.register<Exec>("packageCustomMsi"){
228228

229229

230230
tasks.register("generateSnapConfiguration"){
231-
val name = findProperty("snapname") ?: rootProject.name
231+
onlyIf { OperatingSystem.current().isLinux }
232+
233+
val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()
234+
dependsOn(distributable)
235+
236+
val name = findProperty("snapname") as String? ?: rootProject.name
232237
val arch = when (System.getProperty("os.arch")) {
233238
"amd64", "x86_64" -> "amd64"
234239
"aarch64" -> "arm64"
235240
else -> System.getProperty("os.arch")
236241
}
237-
238-
onlyIf { OperatingSystem.current().isLinux }
239-
val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()
240-
dependsOn(distributable)
241-
242+
val confinement = findProperty("snapconfinement") as String? ?: "strict"
242243
val dir = distributable.destinationDir.get()
243-
val content = """
244-
name: $name
245-
version: $version
246-
base: core22
247-
summary: A creative coding editor
248-
description: |
249-
Processing is a flexible software sketchbook and a programming language designed for learning how to code.
250-
confinement: strict
251-
252-
apps:
253-
processing:
254-
command: opt/processing/bin/Processing
255-
desktop: opt/processing/lib/processing-Processing.desktop
256-
environment:
257-
LD_LIBRARY_PATH: ${'$'}SNAP/opt/processing/lib/runtime/lib:${'$'}LD_LIBRARY_PATH
258-
LIBGL_DRIVERS_PATH: ${'$'}SNAP/usr/lib/${'$'}SNAPCRAFT_ARCH_TRIPLET/dri
259-
plugs:
260-
- desktop
261-
- desktop-legacy
262-
- wayland
263-
- x11
264-
- network
265-
- opengl
266-
- home
267-
- removable-media
268-
- audio-playback
269-
- audio-record
270-
- pulseaudio
271-
- gpio
272-
273-
parts:
274-
processing:
275-
plugin: dump
276-
source: deb/processing_$version-1_$arch.deb
277-
source-type: deb
278-
stage-packages:
279-
- openjdk-17-jre
280-
override-prime: |
281-
snapcraftctl prime
282-
rm -vf usr/lib/jvm/java-17-openjdk-*/lib/security/cacerts
283-
chmod -R +x opt/processing/lib/app/resources/jdk
284-
""".trimIndent()
285-
dir.file("../snapcraft.yaml").asFile.writeText(content)
244+
val base = layout.projectDirectory.file("linux/snapcraft.base.yml")
245+
246+
doFirst {
247+
248+
var content = base
249+
.asFile
250+
.readText()
251+
.replace("\$name", name)
252+
.replace("\$arch", arch)
253+
.replace("\$version", version as String)
254+
.replace("\$confinement", confinement)
255+
.let {
256+
if (confinement != "classic") return@let it
257+
// If confinement is not strict, remove the PLUGS section
258+
val start = it.indexOf("# PLUGS START")
259+
val end = it.indexOf("# PLUGS END")
260+
if (start != -1 && end != -1) {
261+
val before = it.substring(0, start)
262+
val after = it.substring(end + "# PLUGS END".length)
263+
return@let before + after
264+
}
265+
return@let it
266+
}
267+
dir.file("../snapcraft.yaml").asFile.writeText(content)
268+
}
286269
}
287270

288271
tasks.register<Exec>("packageSnap"){

app/linux/snapcraft.base.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: $name
2+
version: $version
3+
base: core22
4+
summary: A creative coding editor
5+
description: |
6+
Processing is a flexible software sketchbook and a programming language designed for learning how to code.
7+
confinement: $confinement
8+
9+
apps:
10+
processing:
11+
command: opt/processing/bin/Processing
12+
desktop: opt/processing/lib/processing-Processing.desktop
13+
environment:
14+
LD_LIBRARY_PATH: $SNAP/opt/processing/lib/runtime/lib:$LD_LIBRARY_PATH
15+
LIBGL_DRIVERS_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/dri
16+
# PLUGS START
17+
plugs:
18+
- desktop
19+
- desktop-legacy
20+
- wayland
21+
- x11
22+
- network
23+
- opengl
24+
- home
25+
- removable-media
26+
- audio-playback
27+
- audio-record
28+
- pulseaudio
29+
- gpio
30+
# PLUGS END
31+
32+
parts:
33+
processing:
34+
plugin: dump
35+
source: deb/processing_$version-1_$arch.deb
36+
source-type: deb
37+
stage-packages:
38+
- openjdk-17-jre
39+
override-prime: |
40+
snapcraftctl prime
41+
rm -vf usr/lib/jvm/java-17-openjdk-*/lib/security/cacerts
42+
chmod -R +x opt/processing/lib/app/resources/jdk

0 commit comments

Comments
 (0)