mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
When importing package into local repo, verify that it matches package restriction based on .changes file. #71
This commit is contained in:
+1
-1
@@ -324,7 +324,7 @@ func apiReposPackageFromDir(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processedFiles, failedFiles2, err = deb.ImportPackageFiles(list, packageFiles, forceReplace, verifier, context.PackagePool(),
|
processedFiles, failedFiles2, err = deb.ImportPackageFiles(list, packageFiles, forceReplace, verifier, context.PackagePool(),
|
||||||
context.CollectionFactory().PackageCollection(), reporter)
|
context.CollectionFactory().PackageCollection(), reporter, nil)
|
||||||
failedFiles = append(failedFiles, failedFiles2...)
|
failedFiles = append(failedFiles, failedFiles2...)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ func aptlyRepoAdd(cmd *commander.Command, args []string) error {
|
|||||||
var processedFiles, failedFiles2 []string
|
var processedFiles, failedFiles2 []string
|
||||||
|
|
||||||
processedFiles, failedFiles2, err = deb.ImportPackageFiles(list, packageFiles, forceReplace, verifier, context.PackagePool(),
|
processedFiles, failedFiles2, err = deb.ImportPackageFiles(list, packageFiles, forceReplace, verifier, context.PackagePool(),
|
||||||
context.CollectionFactory().PackageCollection(), &aptly.ConsoleResultReporter{Progress: context.Progress()})
|
context.CollectionFactory().PackageCollection(), &aptly.ConsoleResultReporter{Progress: context.Progress()}, nil)
|
||||||
failedFiles = append(failedFiles, failedFiles2...)
|
failedFiles = append(failedFiles, failedFiles2...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to import package files: %s", err)
|
return fmt.Errorf("unable to import package files: %s", err)
|
||||||
|
|||||||
+11
-1
@@ -99,10 +99,20 @@ func aptlyRepoInclude(cmd *commander.Command, args []string) error {
|
|||||||
|
|
||||||
packageFiles, _ := deb.CollectPackageFiles([]string{changes.TempDir}, reporter)
|
packageFiles, _ := deb.CollectPackageFiles([]string{changes.TempDir}, reporter)
|
||||||
|
|
||||||
|
var restriction deb.PackageQuery
|
||||||
|
|
||||||
|
restriction, err = changes.PackageQuery()
|
||||||
|
if err != nil {
|
||||||
|
failedFiles = append(failedFiles, path)
|
||||||
|
reporter.Warning("unable to process file %s: %s", changes.ChangesName, err)
|
||||||
|
changes.Cleanup()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
var processedFiles2, failedFiles2 []string
|
var processedFiles2, failedFiles2 []string
|
||||||
|
|
||||||
processedFiles2, failedFiles2, err = deb.ImportPackageFiles(list, packageFiles, forceReplace, verifier, context.PackagePool(),
|
processedFiles2, failedFiles2, err = deb.ImportPackageFiles(list, packageFiles, forceReplace, verifier, context.PackagePool(),
|
||||||
context.CollectionFactory().PackageCollection(), reporter)
|
context.CollectionFactory().PackageCollection(), reporter, restriction)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to import package files: %s", err)
|
return fmt.Errorf("unable to import package files: %s", err)
|
||||||
|
|||||||
+7
-1
@@ -53,7 +53,7 @@ func CollectPackageFiles(locations []string, reporter aptly.ResultReporter) (pac
|
|||||||
|
|
||||||
// ImportPackageFiles imports files into local repository
|
// ImportPackageFiles imports files into local repository
|
||||||
func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace bool, verifier utils.Verifier,
|
func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace bool, verifier utils.Verifier,
|
||||||
pool aptly.PackagePool, collection *PackageCollection, reporter aptly.ResultReporter) (processedFiles []string, failedFiles []string, err error) {
|
pool aptly.PackagePool, collection *PackageCollection, reporter aptly.ResultReporter, restriction PackageQuery) (processedFiles []string, failedFiles []string, err error) {
|
||||||
if forceReplace {
|
if forceReplace {
|
||||||
list.PrepareIndex()
|
list.PrepareIndex()
|
||||||
}
|
}
|
||||||
@@ -150,6 +150,12 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if restriction != nil && !restriction.Matches(p) {
|
||||||
|
reporter.Warning("%s has been ignored as it doesn't match restriction", p)
|
||||||
|
failedFiles = append(failedFiles, file)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
err = collection.Update(p)
|
err = collection.Update(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reporter.Warning("Unable to save package %s: %s", p, err)
|
reporter.Warning("Unable to save package %s: %s", p, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user