Allow editing of mirror archive url

This is needed in case a mirror has moved or is down and need to move
to new mirror.
This commit is contained in:
Oliver Sauder
2017-11-21 16:05:59 +01:00
parent 10e0966edc
commit b98abcc049
5 changed files with 44 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"github.com/smira/aptly/pgp"
"github.com/smira/aptly/query"
"github.com/smira/commander"
"github.com/smira/flag"
@@ -25,6 +26,7 @@ func aptlyMirrorEdit(cmd *commander.Command, args []string) error {
return fmt.Errorf("unable to edit: %s", err)
}
fetchMirror := false
context.Flags().Visit(func(flag *flag.Flag) {
switch flag.Name {
case "filter":
@@ -35,6 +37,9 @@ func aptlyMirrorEdit(cmd *commander.Command, args []string) error {
repo.DownloadSources = flag.Value.Get().(bool)
case "with-udebs":
repo.DownloadUdebs = flag.Value.Get().(bool)
case "archive-url":
repo.ArchiveRoot = flag.Value.String()
fetchMirror = true
}
})
@@ -51,8 +56,17 @@ func aptlyMirrorEdit(cmd *commander.Command, args []string) error {
if context.GlobalFlags().Lookup("architectures").Value.String() != "" {
repo.Architectures = context.ArchitecturesList()
fetchMirror = true
}
err = repo.Fetch(context.Downloader(), nil)
if fetchMirror {
var verifier pgp.Verifier
verifier, err = getVerifier(context.Flags())
if err != nil {
return fmt.Errorf("unable to initialize GPG verifier: %s", err)
}
err = repo.Fetch(context.Downloader(), verifier)
if err != nil {
return fmt.Errorf("unable to edit: %s", err)
}
@@ -83,10 +97,13 @@ Example:
Flag: *flag.NewFlagSet("aptly-mirror-edit", flag.ExitOnError),
}
cmd.Flag.String("archive-url", "", "archive url is the root of archive")
cmd.Flag.String("filter", "", "filter packages in mirror")
cmd.Flag.Bool("filter-with-deps", false, "when filtering, include dependencies of matching packages as well")
cmd.Flag.Bool("ignore-signatures", false, "disable verification of Release file signatures")
cmd.Flag.Bool("with-sources", false, "download source packages in addition to binary packages")
cmd.Flag.Bool("with-udebs", false, "download .udeb packages (Debian installer support)")
cmd.Flag.Var(&keyRingsFlag{}, "keyring", "gpg keyring to use when verifying Release file (could be specified multiple times)")
return cmd
}