@@ -228,61 +228,44 @@ tasks.register<Exec>("packageCustomMsi"){
228228
229229
230230tasks.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
288271tasks.register<Exec >(" packageSnap" ){
0 commit comments