aboutsummaryrefslogtreecommitdiffstats
path: root/zip
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2018-06-22 16:37:47 -0700
committerColin Cross <ccross@android.com>2018-06-22 23:16:16 -0700
commit297d9bcedaa14670a84c3dc4d4bf90b9ea033bea (patch)
treea0d8d32d8cf724bf21c5a5f80db68eae6716c529 /zip
parent87d1af0134ab9d818b892294b551de3a5d6ad332 (diff)
downloadbuild_soong-297d9bcedaa14670a84c3dc4d4bf90b9ea033bea.tar.gz
build_soong-297d9bcedaa14670a84c3dc4d4bf90b9ea033bea.tar.bz2
build_soong-297d9bcedaa14670a84c3dc4d4bf90b9ea033bea.zip
soong_zip: set local header crc and size for symlinks
Getting a crc and size into the local header requires setting it before writing the payload, or using a streaming data header after the payload with the crc and size. Stored (uncompressed) entries are not allowed to use a streaming data header. Symlinks are always stored uncompressed, so set the crc and size in the file header before writing the payload. Also set the mode to 0777 to match the behavior of zip. This relands I66c5d41f0a5b23b828d6a03a3790afedc5a97625 with fixes for the size and mode. Test: m checkbuild Test: zipdetails on zip with symlink created with soong_zip has same crc in local header and central header. Test: Compare zipdetails output of zip containing symlink created by soong_zip and by zip --symlinks -X. Bug: 110716403 Change-Id: Iec0bc9056a0d9cdab76f015844aca9c711e72e5b
Diffstat (limited to 'zip')
-rw-r--r--zip/zip.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/zip/zip.go b/zip/zip.go
index b7e37646..a89fa9f2 100644
--- a/zip/zip.go
+++ b/zip/zip.go
@@ -788,13 +788,16 @@ func (z *ZipWriter) writeSymlink(rel, file string) error {
Name: rel,
}
fileHeader.SetModTime(z.time)
- fileHeader.SetMode(0700 | os.ModeSymlink)
+ fileHeader.SetMode(0777 | os.ModeSymlink)
dest, err := os.Readlink(file)
if err != nil {
return err
}
+ fileHeader.UncompressedSize64 = uint64(len(dest))
+ fileHeader.CRC32 = crc32.ChecksumIEEE([]byte(dest))
+
ze := make(chan *zipEntry, 1)
futureReaders := make(chan chan io.Reader, 1)
futureReader := make(chan io.Reader, 1)