diff options
author | Nan Zhang <nanzhang@google.com> | 2017-09-13 13:17:43 -0700 |
---|---|---|
committer | Nan Zhang <nanzhang@google.com> | 2017-09-13 23:01:49 -0700 |
commit | d5998cce7dee2c7e4200c3e8e7285095e5ba1a85 (patch) | |
tree | 7169a26931667dc1f4d054bc2bc973d8de41a576 /cmd | |
parent | 58aebd40d414abfa926c0a70548b4f2c51c034c8 (diff) | |
download | build_soong-d5998cce7dee2c7e4200c3e8e7285095e5ba1a85.tar.gz build_soong-d5998cce7dee2c7e4200c3e8e7285095e5ba1a85.tar.bz2 build_soong-d5998cce7dee2c7e4200c3e8e7285095e5ba1a85.zip |
Don't add data_descripters when merging uncompress zip entries for merge_zips.
Also filter out META-INF/TRANSITIVE dir, and report warnings when
merge_zips see duplicates entries with different CRC hash.
Bug: b/65455145
Test: m clean && m -j java (locally)
Change-Id: I47172ffa27df71f3280f35f6b540a7b5a0c14550
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/merge_zips/merge_zips.go | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/cmd/merge_zips/merge_zips.go b/cmd/merge_zips/merge_zips.go index 7874a41b..3c1cb9a1 100644 --- a/cmd/merge_zips/merge_zips.go +++ b/cmd/merge_zips/merge_zips.go @@ -26,11 +26,28 @@ import ( "android/soong/third_party/zip" ) +type strip struct{} + +func (s *strip) String() string { + return `""` +} + +func (s *strip) Set(path_prefix string) error { + strippings = append(strippings, path_prefix) + + return nil +} + var ( sortEntries = flag.Bool("s", false, "sort entries (defaults to the order from the input zip files)") emulateJar = flag.Bool("j", false, "sort zip entries using jar ordering (META-INF first)") + strippings []string ) +func init() { + flag.Var(&strip{}, "strip", "the prefix of file path to be excluded from the output zip") +} + func main() { flag.Usage = func() { fmt.Fprintln(os.Stderr, "usage: merge_zips [-j] output [inputs...]") @@ -115,7 +132,13 @@ func mergeZips(readers []namedZipReader, writer *zip.Writer, sortEntries bool, e orderedMappings := []fileMapping{} for _, namedReader := range readers { + FileLoop: for _, file := range namedReader.reader.File { + for _, path_prefix := range strippings { + if strings.HasPrefix(file.Name, path_prefix) { + continue FileLoop + } + } // check for other files or directories destined for the same path dest := file.Name mapKey := dest @@ -142,8 +165,15 @@ func mergeZips(readers []namedZipReader, writer *zip.Writer, sortEntries bool, e continue } if !isDir { - return fmt.Errorf("Duplicate path %v found in %v and %v\n", - dest, existingMapping.source.path, newMapping.source.path) + if emulateJar { + if existingMapping.source.content.CRC32 != newMapping.source.content.CRC32 { + fmt.Fprintf(os.Stdout, "WARNING: Duplicate path %v found in %v and %v\n", + dest, existingMapping.source.path, newMapping.source.path) + } + } else { + return fmt.Errorf("Duplicate path %v found in %v and %v\n", + dest, existingMapping.source.path, newMapping.source.path) + } } } else { // save entry @@ -151,7 +181,6 @@ func mergeZips(readers []namedZipReader, writer *zip.Writer, sortEntries bool, e orderedMappings = append(orderedMappings, newMapping) } } - } if emulateJar { |