Skip to content

Commit 15aba90

Browse files
authored
Merge pull request #1200 from Stefterv/snap-classic-support
Adding snap classic confinement support
2 parents 02f7975 + eece777 commit 15aba90

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
@@ -229,61 +229,44 @@ tasks.register<Exec>("packageCustomMsi"){
229229

230230

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

289272
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)