Skip to content

Commit cc23933

Browse files
authored
Add permissions check in CI; expand scope of permissions fix (#1571)
* Add permissions check in CI; expand scope of permissions fix in snapcraft.yml and flathub.yml * make permissions changes at end
1 parent 247638a commit cc23933

4 files changed

Lines changed: 52 additions & 2 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ jobs:
7777
- name: Package Processing with Gradle
7878
run: ./gradlew packageDistributionForCurrentOS
7979

80+
- name: Verify binary permissions in .deb
81+
if: matrix.os_prefix == 'linux'
82+
run: |
83+
DEB=$(ls app/build/compose/binaries/main/deb/processing*.deb)
84+
dpkg-deb -x "$DEB" /tmp/debcheck
85+
test -x /tmp/debcheck/opt/processing/lib/app/resources/jdk/bin/java
86+
test -x /tmp/debcheck/opt/processing/lib/app/resources/modes/java/application/launch4j/bin/windres
87+
8088
- name: Add artifact
8189
uses: actions/upload-artifact@v4
8290
if: ${{ github.event_name != 'pull_request' }}

‎app/build.gradle.kts‎

Lines changed: 42 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")
@@ -675,4 +706,15 @@ afterEvaluate {
675706
dependsOn("includeJdk")
676707
finalizedBy("setExecutablePermissions")
677708
}
709+
// finalizedBy above only guarantees setExecutablePermissions runs after
710+
// createDistributable, not before packageDeb, which merely depends on
711+
// createDistributable transitively - without this, jpackage can read the
712+
// app image before permissions are restored on it.
713+
tasks.named("packageDeb").configure {
714+
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")
719+
}
678720
}

‎app/linux/flathub.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ modules:
1919
- ar x processing.deb
2020
- tar --zstd -xf data.tar.zst
2121
- mv opt/processing/* /app/
22-
- find /app/lib/app/resources/jdk/bin -type f -exec chmod +x {} +
22+
- find /app/lib/app/resources -path "*/bin/*" -type f -exec chmod +x {} +
2323

2424
# Install the desktop file and icon
2525
- install -D /app/lib/processing-Processing.desktop /app/share/applications/$identifier.desktop

‎app/linux/snapcraft.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ parts:
3939
override-prime: |
4040
snapcraftctl prime
4141
rm -vf usr/lib/jvm/java-17-openjdk-*/lib/security/cacerts
42-
chmod -R +x opt/processing/lib/app/resources/jdk
42+
find opt/processing/lib/app/resources -path "*/bin/*" -type f -exec chmod +x {} +

0 commit comments

Comments
 (0)