This commit is contained in:
Andrey Smirnov
2015-03-19 23:58:48 +03:00
parent 02a82f3545
commit c8713aa412
+23
View File
@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"github.com/smira/aptly/aptly" "github.com/smira/aptly/aptly"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/query"
"github.com/smira/aptly/utils" "github.com/smira/aptly/utils"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
@@ -39,6 +40,19 @@ func aptlyRepoInclude(cmd *commander.Command, args []string) error {
return fmt.Errorf("error parsing -repo template: %s", err) return fmt.Errorf("error parsing -repo template: %s", err)
} }
uploaders := (*deb.Uploaders)(nil)
uploadersFile := context.Flags().Lookup("uploaders-file").Value.Get().(string)
if uploadersFile != "" {
uploaders, err = deb.NewUploadersFromFile(uploadersFile)
for i := range uploaders.Rules {
uploaders.Rules[i].CompiledCondition, err = query.Parse(uploaders.Rules[i].Condition)
if err != nil {
return fmt.Errorf("error parsing query %s: %s", uploaders.Rules[i].Condition, err)
}
}
}
reporter := &aptly.ConsoleResultReporter{Progress: context.Progress()} reporter := &aptly.ConsoleResultReporter{Progress: context.Progress()}
var changesFiles, failedFiles, processedFiles []string var changesFiles, failedFiles, processedFiles []string
@@ -63,6 +77,14 @@ func aptlyRepoInclude(cmd *commander.Command, args []string) error {
continue continue
} }
if uploaders != nil && !uploaders.IsAllowed(changes) {
failedFiles = append(failedFiles, path)
reporter.Warning("changes file is not allowed accoring to uploaders config: %s, keys %#v",
changes.ChangesName, changes.SignatureKeys)
changes.Cleanup()
continue
}
err = changes.Prepare() err = changes.Prepare()
if err != nil { if err != nil {
failedFiles = append(failedFiles, path) failedFiles = append(failedFiles, path)
@@ -187,6 +209,7 @@ Example:
cmd.Flag.Var(&keyRingsFlag{}, "keyring", "gpg keyring to use when verifying Release file (could be specified multiple times)") cmd.Flag.Var(&keyRingsFlag{}, "keyring", "gpg keyring to use when verifying Release file (could be specified multiple times)")
cmd.Flag.Bool("ignore-signatures", false, "disable verification of .changes file signature") cmd.Flag.Bool("ignore-signatures", false, "disable verification of .changes file signature")
cmd.Flag.Bool("accept-unsigned", false, "accept unsigned .changes files") cmd.Flag.Bool("accept-unsigned", false, "accept unsigned .changes files")
cmd.Flag.String("uploaders-file", "", "path to uploaders.json file")
return cmd return cmd
} }