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
+10 -1
View File
@@ -3,6 +3,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/query"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
"sort" "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 { if err != nil {
return fmt.Errorf("unable to %s: %s", command, err) return fmt.Errorf("unable to %s: %s", command, err)
} }
+10 -1
View File
@@ -3,6 +3,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/query"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "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) 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() list.PrepareIndex()
toRemove, err := list.Filter(args[1:], false, nil, 0, nil) toRemove, err := list.Filter(queries, false, nil, 0, nil)
if err != nil { if err != nil {
return fmt.Errorf("unable to remove: %s", err) return fmt.Errorf("unable to remove: %s", err)
} }
+1 -1
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... Loading packages...
+1 -1
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... Loading packages...
+1 -1
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... Loading packages...
+1 -1
View File
@@ -10,7 +10,7 @@ class ImportRepo1Test(BaseTest):
"aptly repo create -comment=Cool -distribution=squeeze repo1", "aptly repo create -comment=Cool -distribution=squeeze repo1",
"aptly repo add repo1 ${files}" "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): def check(self):
self.check_output() self.check_output()