Skip to content

Commit b729882

Browse files
committed
make permissions changes at end
1 parent 0041f1f commit b729882

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎app/build.gradle.kts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,37 @@ tasks.register("setExecutablePermissions") {
667667
}
668668
}
669669

670+
tasks.register("fixDebPermissions") {
671+
description = "Rebuilds the .deb so binaries under opt/processing/lib/app/resources keep their executable bit " +
672+
"(jpackage's own deb assembly does not reliably preserve it for arbitrary resource files)"
673+
group = "compose desktop"
674+
onlyIf { OperatingSystem.current().isLinux }
675+
676+
val execOps = objects.newInstance<ExecOps>().execOps
677+
678+
doLast {
679+
val debDir = layout.buildDirectory.dir("compose/binaries/main/deb").get().asFile
680+
val deb = debDir.listFiles { f -> f.name.startsWith("processing") && f.name.endsWith(".deb") }
681+
?.singleOrNull()
682+
?: throw GradleException("Expected exactly one processing*.deb in $debDir")
683+
684+
val extractDir = debDir.resolve("${deb.nameWithoutExtension}-fixperms")
685+
extractDir.deleteRecursively()
686+
687+
execOps.exec {
688+
commandLine(
689+
"fakeroot", "bash", "-c",
690+
"dpkg-deb -R '${deb.absolutePath}' '${extractDir.absolutePath}' && " +
691+
"find '${extractDir.absolutePath}/opt/processing/lib/app/resources' " +
692+
"-path '*/bin/*' -type f -exec chmod +x {} + && " +
693+
"dpkg-deb -b '${extractDir.absolutePath}' '${deb.absolutePath}'"
694+
)
695+
}
696+
697+
extractDir.deleteRecursively()
698+
}
699+
}
700+
670701
afterEvaluate {
671702
tasks.named("prepareAppResources").configure {
672703
dependsOn("includeProcessingResources")
@@ -681,5 +712,9 @@ afterEvaluate {
681712
// app image before permissions are restored on it.
682713
tasks.named("packageDeb").configure {
683714
dependsOn("setExecutablePermissions")
715+
// jpackage's own --type deb assembly doesn't reliably preserve the
716+
// executable bit on arbitrary resource binaries (java, windres, ...);
717+
// rebuild the .deb afterward via dpkg-deb to force it back on.
718+
finalizedBy("fixDebPermissions")
684719
}
685720
}

0 commit comments

Comments
 (0)