mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-12 06:30:35 +00:00
Mirror update, show and list.
This commit is contained in:
+94
-4
@@ -10,7 +10,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func aptlyMirrorList(cmd *commander.Command, args []string) {
|
func aptlyMirrorList(cmd *commander.Command, args []string) {
|
||||||
fmt.Printf("MIRROR LIST\n")
|
if len(args) != 0 {
|
||||||
|
cmd.Usage()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("List of mirrors:\n")
|
||||||
|
|
||||||
|
repoCollection := debian.NewRemoteRepoCollection(context.database)
|
||||||
|
repoCollection.ForEach(func(repo *debian.RemoteRepo) {
|
||||||
|
fmt.Printf(" * %s\n", repo)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func aptlyMirrorCreate(cmd *commander.Command, args []string) {
|
func aptlyMirrorCreate(cmd *commander.Command, args []string) {
|
||||||
@@ -42,7 +52,53 @@ func aptlyMirrorCreate(cmd *commander.Command, args []string) {
|
|||||||
log.Fatalf("Unable to add mirror: %s", err)
|
log.Fatalf("Unable to add mirror: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Mirror %s successfully added.\nYou can run 'aptly mirror update %s' to download repository contents.\n", repo, repo.Name)
|
fmt.Printf("\nMirror %s successfully added.\nYou can run 'aptly mirror update %s' to download repository contents.\n", repo, repo.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func aptlyMirrorShow(cmd *commander.Command, args []string) {
|
||||||
|
if len(args) != 1 {
|
||||||
|
cmd.Usage()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
repoCollection := debian.NewRemoteRepoCollection(context.database)
|
||||||
|
repo, err := repoCollection.ByName(name)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to show: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Name: %s\n", repo.Name)
|
||||||
|
fmt.Printf("Archive Root URL: %s\n", repo.ArchiveRoot)
|
||||||
|
fmt.Printf("Distribution: %s\n", repo.Distribution)
|
||||||
|
fmt.Printf("Components: %s\n", strings.Join(repo.Components, ", "))
|
||||||
|
fmt.Printf("Architectures: %s\n", strings.Join(repo.Architectures, ", "))
|
||||||
|
}
|
||||||
|
|
||||||
|
func aptlyMirrorUpdate(cmd *commander.Command, args []string) {
|
||||||
|
if len(args) != 1 {
|
||||||
|
cmd.Usage()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
repoCollection := debian.NewRemoteRepoCollection(context.database)
|
||||||
|
repo, err := repoCollection.ByName(name)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to update: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = repo.Fetch(context.downloader)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to update: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = repo.Download(context.downloader, context.database, context.packageRepository)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to update: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeCmdMirrorCreate() *commander.Command {
|
func makeCmdMirrorCreate() *commander.Command {
|
||||||
@@ -82,6 +138,40 @@ ex:
|
|||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func makeCmdMirrorShow() *commander.Command {
|
||||||
|
cmd := &commander.Command{
|
||||||
|
Run: aptlyMirrorShow,
|
||||||
|
UsageLine: "show",
|
||||||
|
Short: "show details about remote repository mirror",
|
||||||
|
Long: `
|
||||||
|
show shows full information about mirror.
|
||||||
|
|
||||||
|
ex:
|
||||||
|
$ aptly mirror show <name>
|
||||||
|
`,
|
||||||
|
Flag: *flag.NewFlagSet("aptly-mirror-show", flag.ExitOnError),
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeCmdMirrorUpdate() *commander.Command {
|
||||||
|
cmd := &commander.Command{
|
||||||
|
Run: aptlyMirrorUpdate,
|
||||||
|
UsageLine: "update",
|
||||||
|
Short: "update packages from remote mirror",
|
||||||
|
Long: `
|
||||||
|
Update downloads list of packages and packages themselves.
|
||||||
|
|
||||||
|
ex:
|
||||||
|
$ aptly mirror update <name>
|
||||||
|
`,
|
||||||
|
Flag: *flag.NewFlagSet("aptly-mirror-update", flag.ExitOnError),
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
func makeCmdMirror() *commander.Commander {
|
func makeCmdMirror() *commander.Commander {
|
||||||
return &commander.Commander{
|
return &commander.Commander{
|
||||||
Name: "mirror",
|
Name: "mirror",
|
||||||
@@ -89,9 +179,9 @@ func makeCmdMirror() *commander.Commander {
|
|||||||
Commands: []*commander.Command{
|
Commands: []*commander.Command{
|
||||||
makeCmdMirrorCreate(),
|
makeCmdMirrorCreate(),
|
||||||
makeCmdMirrorList(),
|
makeCmdMirrorList(),
|
||||||
//makeCmdMirrorShow(),
|
makeCmdMirrorShow(),
|
||||||
//makeCmdMirrorDelete(),
|
//makeCmdMirrorDelete(),
|
||||||
//makeCmdMirrorUpdate(),
|
makeCmdMirrorUpdate(),
|
||||||
},
|
},
|
||||||
Flag: flag.NewFlagSet("aptly-mirror", flag.ExitOnError),
|
Flag: flag.NewFlagSet("aptly-mirror", flag.ExitOnError),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user