Switch aptly repo move/copy/import/remove to use new filters based on queries.

This commit is contained in:
Andrey Smirnov
2014-07-12 13:58:38 +04:00
parent e08d44ff0a
commit e320ac31d5
6 changed files with 24 additions and 6 deletions

View File

@@ -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"
"sort"
@@ -105,7 +106,15 @@ func aptlyRepoMoveCopyImport(cmd *commander.Command, args []string) error {
}
}
toProcess, err := srcList.Filter(args[2:], withDeps, dstList, context.DependencyOptions(), architecturesList)
queries := make([]deb.PackageQuery, len(args)-2)
for i := 0; i < len(args)-2; i++ {
queries[i], err = query.Parse(args[i+2])
if err != nil {
return fmt.Errorf("unable to %s: %s", command, err)
}
}
toProcess, err := srcList.Filter(queries, withDeps, dstList, context.DependencyOptions(), architecturesList)
if err != nil {
return fmt.Errorf("unable to %s: %s", command, err)
}

View File

@@ -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"
)
@@ -33,8 +34,16 @@ func aptlyRepoRemove(cmd *commander.Command, args []string) error {
return fmt.Errorf("unable to load packages: %s", err)
}
queries := make([]deb.PackageQuery, len(args)-1)
for i := 0; i < len(args)-1; i++ {
queries[i], err = query.Parse(args[i+1])
if err != nil {
return fmt.Errorf("unable to remove: %s", err)
}
}
list.PrepareIndex()
toRemove, err := list.Filter(args[1:], false, nil, 0, nil)
toRemove, err := list.Filter(queries, false, nil, 0, nil)
if err != nil {
return fmt.Errorf("unable to remove: %s", err)
}

View File

@@ -1,3 +1,3 @@
ERROR: unable to copy: unable to parse dependency: pyspi >> 0.6.1-1.3)
ERROR: unable to copy: parsing failed: unexpected token >>: expecting end of query
Loading packages...

View File

@@ -1,3 +1,3 @@
ERROR: unable to import: unable to parse dependency: pyspi >> 0.6.1-1.3)
ERROR: unable to import: parsing failed: unexpected token >>: expecting end of query
Loading packages...

View File

@@ -1,3 +1,3 @@
ERROR: unable to move: unable to parse dependency: pyspi >> 0.6.1-1.3)
ERROR: unable to move: parsing failed: unexpected token >>: expecting end of query
Loading packages...

View File

@@ -10,7 +10,7 @@ class ImportRepo1Test(BaseTest):
"aptly repo create -comment=Cool -distribution=squeeze repo1",
"aptly repo add repo1 ${files}"
]
runCmd = "aptly repo import wheezy-main repo1 nginx unpaper_0.4.2-1_amd64"
runCmd = "aptly repo import wheezy-main repo1 'nginx (>= 1.2)' unpaper_0.4.2-1_amd64"
def check(self):
self.check_output()