aboutsummaryrefslogtreecommitdiffstats
path: root/zip
diff options
context:
space:
mode:
authorColin Cross2018-09-26 16:36:44 -0500
committerColin Cross2018-09-26 16:36:44 -0500
commitc7feeff1e91db814a38701fe89e473f0c0dda535 (patch)
tree1c001d1aa0e8a5c60c8ce67f842ee8fc448b7d4f /zip
parentd59dab94c4897f504ca7a3a2b227ca6b000bfaa4 (diff)
downloadplatform-build-soong-c7feeff1e91db814a38701fe89e473f0c0dda535.tar.gz
platform-build-soong-c7feeff1e91db814a38701fe89e473f0c0dda535.tar.xz
platform-build-soong-c7feeff1e91db814a38701fe89e473f0c0dda535.zip
Revert "Add a --symlinks argument to soong_zip"
This reverts commit d59dab94c4897f504ca7a3a2b227ca6b000bfaa4. Bug: 112843624 Change-Id: I3d0f1b61e899b162e65c18662f9d27dd794a9a30
Diffstat (limited to 'zip')
-rw-r--r--zip/cmd/main.go5
-rw-r--r--zip/zip.go30
2 files changed, 9 insertions, 26 deletions
diff --git a/zip/cmd/main.go b/zip/cmd/main.go
index c4e1196d..f49105a6 100644
--- a/zip/cmd/main.go
+++ b/zip/cmd/main.go
@@ -186,8 +186,6 @@ func main() {
186 emulateJar := flags.Bool("jar", false, "modify the resultant .zip to emulate the output of 'jar'") 186 emulateJar := flags.Bool("jar", false, "modify the resultant .zip to emulate the output of 'jar'")
187 writeIfChanged := flags.Bool("write_if_changed", false, "only update resultant .zip if it has changed") 187 writeIfChanged := flags.Bool("write_if_changed", false, "only update resultant .zip if it has changed")
188 188
189 symlinks := flags.Bool("symlinks", true, "store symbolic links in zip instead of following them")
190
191 parallelJobs := flags.Int("parallel", runtime.NumCPU(), "number of parallel threads to use") 189 parallelJobs := flags.Int("parallel", runtime.NumCPU(), "number of parallel threads to use")
192 cpuProfile := flags.String("cpuprofile", "", "write cpu profile to file") 190 cpuProfile := flags.String("cpuprofile", "", "write cpu profile to file")
193 traceFile := flags.String("trace", "", "write trace to file") 191 traceFile := flags.String("trace", "", "write trace to file")
@@ -218,10 +216,9 @@ func main() {
218 NumParallelJobs: *parallelJobs, 216 NumParallelJobs: *parallelJobs,
219 NonDeflatedFiles: nonDeflatedFiles, 217 NonDeflatedFiles: nonDeflatedFiles,
220 WriteIfChanged: *writeIfChanged, 218 WriteIfChanged: *writeIfChanged,
221 StoreSymlinks: *symlinks,
222 }) 219 })
223 if err != nil { 220 if err != nil {
224 fmt.Fprintln(os.Stderr, "error:", err.Error()) 221 fmt.Fprintln(os.Stderr, err.Error())
225 os.Exit(1) 222 os.Exit(1)
226 } 223 }
227} 224}
diff --git a/zip/zip.go b/zip/zip.go
index d9645b84..4a02531e 100644
--- a/zip/zip.go
+++ b/zip/zip.go
@@ -107,7 +107,6 @@ type ZipWriter struct {
107 107
108 compressorPool sync.Pool 108 compressorPool sync.Pool
109 compLevel int 109 compLevel int
110 followSymlinks pathtools.ShouldFollowSymlinks
111} 110}
112 111
113type zipEntry struct { 112type zipEntry struct {
@@ -133,7 +132,6 @@ type ZipArgs struct {
133 NumParallelJobs int 132 NumParallelJobs int
134 NonDeflatedFiles map[string]bool 133 NonDeflatedFiles map[string]bool
135 WriteIfChanged bool 134 WriteIfChanged bool
136 StoreSymlinks bool
137} 135}
138 136
139const NOQUOTE = '\x00' 137const NOQUOTE = '\x00'
@@ -214,16 +212,12 @@ func Run(args ZipArgs) (err error) {
214 args.AddDirectoryEntriesToZip = true 212 args.AddDirectoryEntriesToZip = true
215 } 213 }
216 214
217 // Have Glob follow symlinks if they are not being stored as symlinks in the zip file.
218 followSymlinks := pathtools.ShouldFollowSymlinks(!args.StoreSymlinks)
219
220 w := &ZipWriter{ 215 w := &ZipWriter{
221 time: jar.DefaultTime, 216 time: jar.DefaultTime,
222 createdDirs: make(map[string]string), 217 createdDirs: make(map[string]string),
223 createdFiles: make(map[string]string), 218 createdFiles: make(map[string]string),
224 directories: args.AddDirectoryEntriesToZip, 219 directories: args.AddDirectoryEntriesToZip,
225 compLevel: args.CompressionLevel, 220 compLevel: args.CompressionLevel,
226 followSymlinks: followSymlinks,
227 } 221 }
228 pathMappings := []pathMapping{} 222 pathMappings := []pathMapping{}
229 223
@@ -232,14 +226,14 @@ func Run(args ZipArgs) (err error) {
232 for _, fa := range args.FileArgs { 226 for _, fa := range args.FileArgs {
233 var srcs []string 227 var srcs []string
234 for _, s := range fa.SourceFiles { 228 for _, s := range fa.SourceFiles {
235 globbed, _, err := pathtools.Glob(s, nil, followSymlinks) 229 globbed, _, err := pathtools.Glob(s, nil, pathtools.DontFollowSymlinks)
236 if err != nil { 230 if err != nil {
237 return err 231 return err
238 } 232 }
239 srcs = append(srcs, globbed...) 233 srcs = append(srcs, globbed...)
240 } 234 }
241 if fa.GlobDir != "" { 235 if fa.GlobDir != "" {
242 globbed, _, err := pathtools.Glob(filepath.Join(fa.GlobDir, "**/*"), nil, followSymlinks) 236 globbed, _, err := pathtools.Glob(filepath.Join(fa.GlobDir, "**/*"), nil, pathtools.DontFollowSymlinks)
243 if err != nil { 237 if err != nil {
244 return err 238 return err
245 } 239 }
@@ -478,15 +472,7 @@ func (z *ZipWriter) addFile(dest, src string, method uint16, emulateJar bool) er
478 var fileSize int64 472 var fileSize int64
479 var executable bool 473 var executable bool
480 474
481 var s os.FileInfo 475 if s, err := os.Lstat(src); err != nil {
482 var err error
483 if z.followSymlinks {
484 s, err = os.Stat(src)
485 } else {
486 s, err = os.Lstat(src)
487 }
488
489 if err != nil {
490 return err 476 return err
491 } else if s.IsDir() { 477 } else if s.IsDir() {
492 if z.directories { 478 if z.directories {