Skip to content

Commit c57bbb8

Browse files
committed
Fix executable POSIX permission in archive files
The PR apache#2819 accidentally _removed_ the executable POSIX file permission, assuming that not explicity setting the attributes via `filePermissions` retains the file-system 'x' permission. This change updates the logic to explicitly check the owner-executable bit and uses `755` or `644` respectively for each individual file in the archive.
1 parent 5d6b61e commit c57bbb8

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

build-logic/src/main/kotlin/polaris-reproducible.gradle.kts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717
* under the License.
1818
*/
1919

20+
import java.nio.file.Files
21+
import java.nio.file.attribute.PosixFilePermission
22+
2023
// ensure jars conform to reproducible builds
2124
// (https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives)
2225
tasks.withType<AbstractArchiveTask>().configureEach {
2326
isPreserveFileTimestamps = false
2427
isReproducibleFileOrder = true
2528

26-
dirPermissions { unix("755") }
27-
filePermissions {
28-
// do not force the "execute" bit in case the file _is_ executable
29-
user.read = true
30-
user.write = true
31-
group.read = true
32-
group.write = false
33-
other.read = true
34-
other.write = false
29+
eachFile {
30+
permissions {
31+
val isExec = Files.getPosixFilePermissions(file.toPath()).contains(PosixFilePermission.OWNER_EXECUTE)
32+
unix(if (isExec) "755" else "644")
33+
}
3534
}
35+
dirPermissions { unix("755") }
3636
}

0 commit comments

Comments
 (0)