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

@@ -164,7 +164,7 @@ _aptly()
"edit")
if [[ $numargs -eq 0 ]]; then
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "-filter= -filter-with-deps -with-sources -with-udebs" -- ${cur}))
COMPREPLY=($(compgen -W "-archive-url= -filter= -filter-with-deps -ignore-signatures -keyring= -with-sources -with-udebs" -- ${cur}))
else
COMPREPLY=($(compgen -W "$(__aptly_mirror_list)" -- ${cur}))
fi

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
}

View File

@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "APTLY" "1" "September 2017" "" ""
.TH "APTLY" "1" "November 2017" "" ""
.
.SH "NAME"
\fBaptly\fR \- Debian repository management tool
@@ -617,6 +617,10 @@ $ aptly mirror edit \-filter=nginx \-filter\-with\-deps some\-mirror
Options:
.
.TP
\-\fBarchive\-url\fR=
archive url is the root of archive
.
.TP
\-\fBfilter\fR=
filter packages in mirror
.
@@ -625,6 +629,14 @@ filter packages in mirror
when filtering, include dependencies of matching packages as well
.
.TP
\-\fBignore\-signatures\fR
disable verification of Release file signatures
.
.TP
\-\fBkeyring\fR=
gpg keyring to use when verifying Release file (could be specified multiple times)
.
.TP
\-\fBwith\-sources\fR
download source packages in addition to binary packages
.

View File

@@ -0,0 +1,2 @@
Downloading ftp://ftp.ru.debian.org/debian/dists/wheezy/Release...
Mirror [mirror10]: ftp://ftp.ch.debian.org/debian wheezy successfully updated.

View File

@@ -65,7 +65,7 @@ class EditMirror6Test(BaseTest):
edit mirror: change architectures
"""
fixtureDB = True
runCmd = "aptly mirror edit -architectures=amd64,s390 wheezy-main"
runCmd = "aptly mirror edit -ignore-signatures -architectures=amd64,s390 wheezy-main"
def check(self):
self.check_output()
@@ -77,7 +77,7 @@ class EditMirror7Test(BaseTest):
edit mirror: change architectures to missing archs
"""
fixtureDB = True
runCmd = "aptly mirror edit -architectures=amd64,x56 wheezy-main"
runCmd = "aptly mirror edit -ignore-signatures -architectures=amd64,x56 wheezy-main"
expectedCode = 1
@@ -101,3 +101,11 @@ class EditMirror9Test(BaseTest):
fixtureGpg = True
runCmd = "aptly mirror edit -with-udebs mirror9"
expectedCode = 1
class EditMirror10Test(BaseTest):
"""
edit mirror: change archive url
"""
fixtureCmds = ["aptly mirror create -ignore-signatures mirror10 ftp://ftp.ru.debian.org/debian wheezy main"]
runCmd = "aptly mirror edit -ignore-signatures -archive-url ftp://ftp.ch.debian.org/debian mirror10"