Skip to content

Commit

Permalink
Set execute permissions for bin Zip entries (#204)
Browse files Browse the repository at this point in the history
* Set execute permissions for bin Zip entries

* Minor syntax fix

Co-authored-by: Taro L. Saito <leo@xerial.org>
  • Loading branch information
soeren and xerial authored Apr 27, 2020
1 parent 001314d commit 128cd43
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/scala/xerial/sbt/pack/PackArchive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ trait PackArchive {
tos
}

private def createZipEntry(file: File, fileName: String, binDir: File) = {
val archiveEntry = new ZipArchiveEntry(file, fileName)
if (file.getAbsolutePath.startsWith(binDir.getAbsolutePath)) {
archiveEntry.setUnixMode(Integer.parseInt("0755", 8))
}
archiveEntry
}

lazy val packArchiveSettings = Seq[Def.Setting[_]](
packArchivePrefix := name.value,
packArchiveName := s"${packArchivePrefix.value}-${version.value}",
Expand All @@ -77,7 +85,7 @@ trait PackArchive {
packArchiveTgz := createArchive("tar.gz", (fos) => createTarArchiveOutputStream(new GzipCompressorOutputStream(fos)), createTarEntry).value,
packArchiveTbz := createArchive("tar.bz2", (fos) => createTarArchiveOutputStream(new BZip2CompressorOutputStream(fos)), createTarEntry).value,
packArchiveTxz := createArchive("tar.xz", (fos) => createTarArchiveOutputStream(new XZCompressorOutputStream(fos)), createTarEntry).value,
packArchiveZip := createArchive("zip", new ZipArchiveOutputStream(_), (file, fileName, _) => new ZipArchiveEntry(file, fileName)).value,
packArchiveZip := createArchive("zip", new ZipArchiveOutputStream(_), createZipEntry).value,
packArchive := Seq(packArchiveTgz.value, packArchiveZip.value)
)

Expand Down

0 comments on commit 128cd43

Please sign in to comment.