diff --git a/cmd/mirror_create.go b/cmd/mirror_create.go index 32c88be6..b902b26c 100644 --- a/cmd/mirror_create.go +++ b/cmd/mirror_create.go @@ -3,6 +3,7 @@ package cmd import ( "fmt" "github.com/smira/aptly/deb" + "github.com/smira/aptly/query" "github.com/smira/commander" "github.com/smira/flag" "strings" @@ -37,6 +38,16 @@ func aptlyMirrorCreate(cmd *commander.Command, args []string) error { return fmt.Errorf("unable to create mirror: %s", err) } + repo.Filter = context.flags.Lookup("filter").Value.String() + repo.FilterWithDeps = context.flags.Lookup("filter-with-deps").Value.Get().(bool) + + if repo.Filter != "" { + _, err = query.Parse(repo.Filter) + if err != nil { + return fmt.Errorf("unable to create mirror: %s", err) + } + } + verifier, err := getVerifier(context.flags) if err != nil { return fmt.Errorf("unable to initialize GPG verifier: %s", err) @@ -79,6 +90,8 @@ Example: cmd.Flag.Bool("ignore-signatures", false, "disable verification of Release file signatures") cmd.Flag.Bool("with-sources", false, "download source packages in addition to binary packages") + cmd.Flag.String("filter", "", "filter packages in mirror") + cmd.Flag.Bool("filter-with-deps", false, "when filtering, include dependencies of matching packages as well") cmd.Flag.Var(&keyRingsFlag{}, "keyring", "gpg keyring to use when verifying Release file (could be specified multiple times)") return cmd diff --git a/cmd/mirror_show.go b/cmd/mirror_show.go index d044230c..53296cdb 100644 --- a/cmd/mirror_show.go +++ b/cmd/mirror_show.go @@ -37,6 +37,14 @@ func aptlyMirrorShow(cmd *commander.Command, args []string) error { downloadSources = "yes" } fmt.Printf("Download Sources: %s\n", downloadSources) + if repo.Filter != "" { + fmt.Printf("Filter: %s\n", repo.Filter) + filterWithDeps := "no" + if repo.FilterWithDeps { + filterWithDeps = "yes" + } + fmt.Printf("Filter With Deps: %s\n", filterWithDeps) + } if repo.LastDownloadDate.IsZero() { fmt.Printf("Last update: never\n") } else { diff --git a/cmd/mirror_update.go b/cmd/mirror_update.go index 7498e1a4..7caf564d 100644 --- a/cmd/mirror_update.go +++ b/cmd/mirror_update.go @@ -2,6 +2,8 @@ package cmd import ( "fmt" + "github.com/smira/aptly/deb" + "github.com/smira/aptly/query" "github.com/smira/commander" "github.com/smira/flag" ) @@ -37,7 +39,17 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error { return fmt.Errorf("unable to update: %s", err) } - err = repo.Download(context.Progress(), context.Downloader(), context.CollectionFactory(), context.PackagePool(), ignoreMismatch) + var filterQuery deb.PackageQuery + + if repo.Filter != "" { + filterQuery, err = query.Parse(repo.Filter) + if err != nil { + return fmt.Errorf("unable to update: %s", err) + } + } + + err = repo.Download(context.Progress(), context.Downloader(), context.CollectionFactory(), context.PackagePool(), ignoreMismatch, + context.DependencyOptions(), filterQuery) if err != nil { return fmt.Errorf("unable to update: %s", err) }