@@ -229,61 +229,44 @@ tasks.register<Exec>("packageCustomMsi"){
229
229
230
230
231
231
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
233
238
val arch = when (System .getProperty(" os.arch" )) {
234
239
" amd64" , " x86_64" -> " amd64"
235
240
" aarch64" -> " arm64"
236
241
else -> System .getProperty(" os.arch" )
237
242
}
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"
243
244
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
+ }
287
270
}
288
271
289
272
tasks.register<Exec >(" packageSnap" ){
0 commit comments