@@ -228,60 +228,36 @@ tasks.register<Exec>("packageCustomMsi"){
228228
229229
230230tasks.register("generateSnapConfiguration"){
231- val name = findProperty("snapname") ?: rootProject.name
231+ onlyIf { OperatingSystem.current().isLinux }
232+ val name = findProperty("snapname") as String? ?: rootProject.name
232233 val arch = when (System.getProperty("os.arch")) {
233234 "amd64", "x86_64" -> "amd64"
234235 "aarch64" -> "arm64"
235236 else -> System.getProperty("os.arch")
236237 }
237-
238- onlyIf { OperatingSystem.current().isLinux }
238+ val confinement = findProperty("snapconfinement") as String? ?: "strict"
239239 val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()
240240 dependsOn(distributable)
241241
242242 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()
243+ var content = layout.projectDirectory.file("linux/snapcraft.base.yml")
244+ .asFile.readText()
245+ .replace("\$name", name)
246+ .replace("\$arch", arch)
247+ .replace("\$version", version as String)
248+ .replace("\$confinement", confinement)
249+ .let {
250+ if (confinement != "classic") return@let it
251+ // If confinement is not strict, remove the PLUGS section
252+ val start = it.indexOf("# PLUGS START")
253+ val end = it.indexOf("# PLUGS END")
254+ if (start != -1 && end != -1) {
255+ val before = it.substring(0, start)
256+ val after = it.substring(end + "# PLUGS END".length)
257+ return@let before + after
258+ }
259+ return@let it
260+ }
285261 dir.file("../snapcraft.yaml").asFile.writeText(content)
286262}
287263
0 commit comments