summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2017-06-23 14:08:42 -0700
committer Colin Cross <ccross@android.com> 2017-06-23 14:08:42 -0700
commit06382991e00459d2f8dfab8acb72edc69f90cd33 (patch)
treea24218f3551b5b399ced6ca560274ccc938a35bb
parent8936b02b58901cda6a14788a299d65f384b7b30d (diff)
Make '**' implicit
Default to copying all entries in the input zip to the output zip. Test: zip2zip_test Change-Id: I0d70620c621bfeee2b7fe2a64b350b4866ad2877
-rw-r--r--cmd/zip2zip/zip2zip.go12
-rw-r--r--cmd/zip2zip/zip2zip_test.go25
2 files changed, 34 insertions, 3 deletions
diff --git a/cmd/zip2zip/zip2zip.go b/cmd/zip2zip/zip2zip.go
index fb2fa620e..815059c90 100644
--- a/cmd/zip2zip/zip2zip.go
+++ b/cmd/zip2zip/zip2zip.go
@@ -47,15 +47,17 @@ func main() {
fmt.Fprintln(os.Stderr, " <glob>:<out_dir>/")
fmt.Fprintln(os.Stderr, "")
fmt.Fprintln(os.Stderr, "<glob> uses the rules at https://golang.org/pkg/path/filepath/#Match")
- fmt.Fprintln(os.Stderr, "As a special exception, '**' is supported to specify all files in the input zip")
+ fmt.Fprintln(os.Stderr, "As a special exception, '**' is supported to specify all files in the input zip.")
fmt.Fprintln(os.Stderr, "")
fmt.Fprintln(os.Stderr, "Files will be copied with their existing compression from the input zipfile to")
- fmt.Fprintln(os.Stderr, "the output zipfile, in the order of filespec arguments")
+ fmt.Fprintln(os.Stderr, "the output zipfile, in the order of filespec arguments.")
+ fmt.Fprintln(os.Stderr, "")
+ fmt.Fprintln(os.Stderr, "If no filepsec is provided all files are copied (equivalent to '**').")
}
flag.Parse()
- if flag.NArg() == 0 || *input == "" || *output == "" {
+ if *input == "" || *output == "" {
flag.Usage()
os.Exit(1)
}
@@ -93,6 +95,10 @@ type pair struct {
}
func zip2zip(reader *zip.Reader, writer *zip.Writer, sortGlobs, sortJava, setTime bool, args []string) error {
+ if len(args) == 0 {
+ // If no filespec is provided, default to copying everything
+ args = []string{"**"}
+ }
for _, arg := range args {
var input string
var output string
diff --git a/cmd/zip2zip/zip2zip_test.go b/cmd/zip2zip/zip2zip_test.go
index 2b5b5623a..53c8ce2bd 100644
--- a/cmd/zip2zip/zip2zip_test.go
+++ b/cmd/zip2zip/zip2zip_test.go
@@ -117,6 +117,31 @@ var testCases = []struct {
},
},
{
+ name: "sort all implicit",
+
+ inputFiles: []string{
+ "RADIO/a",
+ "IMAGES/system.img",
+ "IMAGES/b.txt",
+ "IMAGES/recovery.img",
+ "IMAGES/vendor.img",
+ "OTA/b",
+ "OTA/android-info.txt",
+ },
+ sortGlobs: true,
+ args: nil,
+
+ outputFiles: []string{
+ "IMAGES/b.txt",
+ "IMAGES/recovery.img",
+ "IMAGES/system.img",
+ "IMAGES/vendor.img",
+ "OTA/android-info.txt",
+ "OTA/b",
+ "RADIO/a",
+ },
+ },
+ {
name: "sort jar",
inputFiles: []string{