mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-11 03:11:50 +00:00
Allow filter to be empty for aptly * search commands
Empty filter implies "select all packages".
This commit is contained in:
3
Makefile
3
Makefile
@@ -4,6 +4,7 @@ ALL_PACKAGES=api aptly context cmd console database deb files http query swift s
|
||||
BINPATH=$(abspath ./vendor/bin)
|
||||
GOM_ENVIRONMENT=-test
|
||||
PYTHON?=python
|
||||
TESTS?=
|
||||
|
||||
ifeq ($(GOVERSION), devel)
|
||||
TRAVIS_TARGET=coveralls
|
||||
@@ -45,7 +46,7 @@ install:
|
||||
system-test: install
|
||||
if [ ! -e ~/aptly-fixture-db ]; then git clone https://github.com/aptly-dev/aptly-fixture-db.git ~/aptly-fixture-db/; fi
|
||||
if [ ! -e ~/aptly-fixture-pool ]; then git clone https://github.com/aptly-dev/aptly-fixture-pool.git ~/aptly-fixture-pool/; fi
|
||||
PATH=$(BINPATH)/:$(PATH) $(PYTHON) system/run.py --long
|
||||
PATH=$(BINPATH)/:$(PATH) $(PYTHON) system/run.py --long $(TESTS)
|
||||
|
||||
travis: $(TRAVIS_TARGET) system-test
|
||||
|
||||
|
||||
@@ -8,11 +8,13 @@ import (
|
||||
func makeCmdMirrorSearch() *commander.Command {
|
||||
cmd := &commander.Command{
|
||||
Run: aptlySnapshotMirrorRepoSearch,
|
||||
UsageLine: "search <name> <package-query>",
|
||||
UsageLine: "search <name> [<package-query>]",
|
||||
Short: "search mirror for packages matching query",
|
||||
Long: `
|
||||
Command search displays list of packages in mirror that match package query
|
||||
|
||||
If query is not specified, all the packages are displayed.
|
||||
|
||||
Example:
|
||||
|
||||
$ aptly mirror search wheezy-main '$Architecture (i386), Name (% *-dev)'
|
||||
|
||||
@@ -2,21 +2,31 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/smira/aptly/deb"
|
||||
"github.com/smira/aptly/query"
|
||||
"github.com/smira/commander"
|
||||
"github.com/smira/flag"
|
||||
)
|
||||
|
||||
func aptlyPackageSearch(cmd *commander.Command, args []string) error {
|
||||
var err error
|
||||
if len(args) != 1 {
|
||||
var (
|
||||
err error
|
||||
q deb.PackageQuery
|
||||
)
|
||||
|
||||
if len(args) > 1 {
|
||||
cmd.Usage()
|
||||
return commander.ErrCommandError
|
||||
}
|
||||
|
||||
q, err := query.Parse(args[0])
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to search: %s", err)
|
||||
if len(args) == 1 {
|
||||
q, err = query.Parse(args[0])
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to search: %s", err)
|
||||
}
|
||||
} else {
|
||||
q = &deb.MatchAllQuery{}
|
||||
}
|
||||
|
||||
result := q.Query(context.CollectionFactory().PackageCollection())
|
||||
@@ -33,10 +43,12 @@ func aptlyPackageSearch(cmd *commander.Command, args []string) error {
|
||||
func makeCmdPackageSearch() *commander.Command {
|
||||
cmd := &commander.Command{
|
||||
Run: aptlyPackageSearch,
|
||||
UsageLine: "search <package-query>",
|
||||
UsageLine: "search [<package-query>]",
|
||||
Short: "search for packages matching query",
|
||||
Long: `
|
||||
Command search displays list of packages in whole DB that match package query
|
||||
Command search displays list of packages in whole DB that match package query.
|
||||
|
||||
If query is not specified, all the packages are displayed.
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -8,11 +8,13 @@ import (
|
||||
func makeCmdRepoSearch() *commander.Command {
|
||||
cmd := &commander.Command{
|
||||
Run: aptlySnapshotMirrorRepoSearch,
|
||||
UsageLine: "search <name> <package-query>",
|
||||
UsageLine: "search <name> [<package-query>]",
|
||||
Short: "search repo for packages matching query",
|
||||
Long: `
|
||||
Command search displays list of packages in local repository that match package query
|
||||
|
||||
If query is not specified, all the packages are displayed.
|
||||
|
||||
Example:
|
||||
|
||||
$ aptly repo search my-software '$Architecture (i386), Name (% *-dev)'
|
||||
|
||||
@@ -2,16 +2,21 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/smira/aptly/deb"
|
||||
"github.com/smira/aptly/query"
|
||||
"github.com/smira/commander"
|
||||
"github.com/smira/flag"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func aptlySnapshotMirrorRepoSearch(cmd *commander.Command, args []string) error {
|
||||
var err error
|
||||
if len(args) != 2 {
|
||||
var (
|
||||
err error
|
||||
q deb.PackageQuery
|
||||
)
|
||||
|
||||
if len(args) < 1 || len(args) > 2 {
|
||||
cmd.Usage()
|
||||
return commander.ErrCommandError
|
||||
}
|
||||
@@ -68,9 +73,13 @@ func aptlySnapshotMirrorRepoSearch(cmd *commander.Command, args []string) error
|
||||
|
||||
list.PrepareIndex()
|
||||
|
||||
q, err := query.Parse(args[1])
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to search: %s", err)
|
||||
if len(args) == 2 {
|
||||
q, err = query.Parse(args[1])
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to search: %s", err)
|
||||
}
|
||||
} else {
|
||||
q = &deb.MatchAllQuery{}
|
||||
}
|
||||
|
||||
withDeps := context.Flags().Lookup("with-deps").Value.Get().(bool)
|
||||
@@ -109,11 +118,13 @@ func aptlySnapshotMirrorRepoSearch(cmd *commander.Command, args []string) error
|
||||
func makeCmdSnapshotSearch() *commander.Command {
|
||||
cmd := &commander.Command{
|
||||
Run: aptlySnapshotMirrorRepoSearch,
|
||||
UsageLine: "search <name> <package-query>",
|
||||
UsageLine: "search <name> [<package-query>]",
|
||||
Short: "search snapshot for packages matching query",
|
||||
Long: `
|
||||
Command search displays list of packages in snapshot that match package query
|
||||
|
||||
If query is not specified, all the packages are displayed.
|
||||
|
||||
Example:
|
||||
|
||||
$ aptly snapshot search wheezy-main '$Architecture (i386), Name (% *-dev)'
|
||||
|
||||
23
deb/query.go
23
deb/query.go
@@ -72,6 +72,9 @@ type DependencyQuery struct {
|
||||
Dep Dependency
|
||||
}
|
||||
|
||||
// MatchAllQuery is query that matches all the packages
|
||||
type MatchAllQuery struct{}
|
||||
|
||||
// Matches if any of L, R matches
|
||||
func (q *OrQuery) Matches(pkg PackageLike) bool {
|
||||
return q.L.Matches(pkg) || q.R.Matches(pkg)
|
||||
@@ -275,3 +278,23 @@ func (q *PkgQuery) Query(list PackageCatalog) (result *PackageList) {
|
||||
func (q *PkgQuery) String() string {
|
||||
return fmt.Sprintf("%s_%s_%s", q.Pkg, q.Version, q.Arch)
|
||||
}
|
||||
|
||||
// Matches on specific properties
|
||||
func (q *MatchAllQuery) Matches(pkg PackageLike) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Fast is always true for match all query
|
||||
func (q *MatchAllQuery) Fast(list PackageCatalog) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Query looks up specific package
|
||||
func (q *MatchAllQuery) Query(list PackageCatalog) (result *PackageList) {
|
||||
return list.Scan(q)
|
||||
}
|
||||
|
||||
// String interface
|
||||
func (q *MatchAllQuery) String() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
24
man/aptly.1
24
man/aptly.1
@@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "APTLY" "1" "January 2017" "" ""
|
||||
.TH "APTLY" "1" "February 2017" "" ""
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBaptly\fR \- Debian repository management tool
|
||||
@@ -554,12 +554,15 @@ download source packages in addition to binary packages
|
||||
download \.udeb packages (Debian installer support)
|
||||
.
|
||||
.SH "SEARCH MIRROR FOR PACKAGES MATCHING QUERY"
|
||||
\fBaptly\fR \fBmirror\fR \fBsearch\fR \fIname\fR \fIpackage\-query\fR
|
||||
\fBaptly\fR \fBmirror\fR \fBsearch\fR \fIname\fR [\fIpackage\-query\fR]
|
||||
.
|
||||
.P
|
||||
Command search displays list of packages in mirror that match package query
|
||||
.
|
||||
.P
|
||||
If query is not specified, all the packages are displayed\.
|
||||
.
|
||||
.P
|
||||
Example:
|
||||
.
|
||||
.IP "" 4
|
||||
@@ -823,12 +826,15 @@ Example:
|
||||
$ aptly repo rename wheezy\-min wheezy\-main
|
||||
.
|
||||
.SH "SEARCH REPO FOR PACKAGES MATCHING QUERY"
|
||||
\fBaptly\fR \fBrepo\fR \fBsearch\fR \fIname\fR \fIpackage\-query\fR
|
||||
\fBaptly\fR \fBrepo\fR \fBsearch\fR \fIname\fR [\fIpackage\-query\fR]
|
||||
.
|
||||
.P
|
||||
Command search displays list of packages in local repository that match package query
|
||||
.
|
||||
.P
|
||||
If query is not specified, all the packages are displayed\.
|
||||
.
|
||||
.P
|
||||
Example:
|
||||
.
|
||||
.IP "" 4
|
||||
@@ -1117,12 +1123,15 @@ Example:
|
||||
$ aptly snapshot rename wheezy\-min wheezy\-main
|
||||
.
|
||||
.SH "SEARCH SNAPSHOT FOR PACKAGES MATCHING QUERY"
|
||||
\fBaptly\fR \fBsnapshot\fR \fBsearch\fR \fIname\fR \fIpackage\-query\fR
|
||||
\fBaptly\fR \fBsnapshot\fR \fBsearch\fR \fIname\fR [\fIpackage\-query\fR]
|
||||
.
|
||||
.P
|
||||
Command search displays list of packages in snapshot that match package query
|
||||
.
|
||||
.P
|
||||
If query is not specified, all the packages are displayed\.
|
||||
.
|
||||
.P
|
||||
Example:
|
||||
.
|
||||
.IP "" 4
|
||||
@@ -1560,10 +1569,13 @@ $ aptly publish show wheezy
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "SEARCH FOR PACKAGES MATCHING QUERY"
|
||||
\fBaptly\fR \fBpackage\fR \fBsearch\fR \fIpackage\-query\fR
|
||||
\fBaptly\fR \fBpackage\fR \fBsearch\fR [\fIpackage\-query\fR]
|
||||
.
|
||||
.P
|
||||
Command search displays list of packages in whole DB that match package query
|
||||
Command search displays list of packages in whole DB that match package query\.
|
||||
.
|
||||
.P
|
||||
If query is not specified, all the packages are displayed\.
|
||||
.
|
||||
.P
|
||||
Example:
|
||||
|
||||
56122
system/t04_mirror/SearchMirror6Test_gold
Normal file
56122
system/t04_mirror/SearchMirror6Test_gold
Normal file
File diff suppressed because it is too large
Load Diff
@@ -43,3 +43,12 @@ class SearchMirror5Test(BaseTest):
|
||||
fixtureDB = True
|
||||
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n")))
|
||||
runCmd = "aptly mirror search -format='{{.Package}}#{{.Version}}' wheezy-main '$$Architecture (i386), Name (% *-dev)'"
|
||||
|
||||
|
||||
class SearchMirror6Test(BaseTest):
|
||||
"""
|
||||
search mirror: no query
|
||||
"""
|
||||
fixtureDB = True
|
||||
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n")))
|
||||
runCmd = "aptly mirror search -format='{{.Package}}#{{.Version}}' wheezy-main"
|
||||
|
||||
56122
system/t05_snapshot/SearchSnapshot7Test_gold
Normal file
56122
system/t05_snapshot/SearchSnapshot7Test_gold
Normal file
File diff suppressed because it is too large
Load Diff
@@ -57,3 +57,12 @@ class SearchSnapshot6Test(BaseTest):
|
||||
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n")))
|
||||
fixtureCmds = ["aptly snapshot create wheezy-main from mirror wheezy-main"]
|
||||
runCmd = "aptly snapshot search -format='{{.Package}}#{{.Version}}' wheezy-main '$$Architecture (i386), Name (% *-dev)'"
|
||||
|
||||
class SearchSnapshot7Test(BaseTest):
|
||||
"""
|
||||
search snapshot: without query
|
||||
"""
|
||||
fixtureDB = True
|
||||
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n")))
|
||||
fixtureCmds = ["aptly snapshot create wheezy-main from mirror wheezy-main"]
|
||||
runCmd = "aptly snapshot search -format='{{.Package}}#{{.Version}}' wheezy-main"
|
||||
|
||||
56122
system/t09_repo/SearchRepo6Test_gold
Normal file
56122
system/t09_repo/SearchRepo6Test_gold
Normal file
File diff suppressed because it is too large
Load Diff
@@ -47,3 +47,12 @@ class SearchRepo5Test(BaseTest):
|
||||
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n")))
|
||||
fixtureCmds = ["aptly repo create wheezy-main", "aptly repo import wheezy-main wheezy-main Name"]
|
||||
runCmd = "aptly repo search -format='{{.Package}}#{{.Version}}' wheezy-main '$$Architecture (i386), Name (% *-dev)'"
|
||||
|
||||
class SearchRepo6Test(BaseTest):
|
||||
"""
|
||||
search repo: without query
|
||||
"""
|
||||
fixtureDB = True
|
||||
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n")))
|
||||
fixtureCmds = ["aptly repo create wheezy-main", "aptly repo import wheezy-main wheezy-main Name"]
|
||||
runCmd = "aptly repo search wheezy-main"
|
||||
|
||||
80414
system/t11_package/SearchPackage6Test_gold
Normal file
80414
system/t11_package/SearchPackage6Test_gold
Normal file
File diff suppressed because it is too large
Load Diff
@@ -42,3 +42,11 @@ class SearchPackage5Test(BaseTest):
|
||||
fixtureDB = True
|
||||
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n")))
|
||||
runCmd = "aptly package search -format='{{.Package}}#{{.Version}}' '$$Architecture (i386), Name (% *-dev)'"
|
||||
|
||||
class SearchPackage6Test(BaseTest):
|
||||
"""
|
||||
search package: no query
|
||||
"""
|
||||
fixtureDB = True
|
||||
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n")))
|
||||
runCmd = "aptly package search"
|
||||
|
||||
Reference in New Issue
Block a user