Command aptly repo create.

This commit is contained in:
Andrey Smirnov
2014-02-20 12:01:41 +04:00
parent 8df4378f4c
commit 63cd4a80bb
12 changed files with 118 additions and 4 deletions
+4 -2
View File
@@ -37,13 +37,15 @@ func RootCommand() *commander.Command {
Short: "Debian repository management tool",
Long: `
aptly is a tool to create partial and full mirrors of remote
repositories, filter them, merge, upgrade individual packages,
take snapshots and publish them back as Debian repositories.`,
repositories, manage local repositories, filter them, merge,
upgrade individual packages, take snapshots and publish them
back as Debian repositories.`,
Flag: *flag.NewFlagSet("aptly", flag.ExitOnError),
Subcommands: []*commander.Command{
makeCmdDb(),
makeCmdGraph(),
makeCmdMirror(),
makeCmdRepo(),
makeCmdServe(),
makeCmdSnapshot(),
makeCmdPublish(),
+17
View File
@@ -0,0 +1,17 @@
package cmd
import (
"github.com/gonuts/commander"
"github.com/gonuts/flag"
)
func makeCmdRepo() *commander.Command {
return &commander.Command{
UsageLine: "repo",
Short: "manage local package repositories",
Subcommands: []*commander.Command{
makeCmdRepoCreate(),
},
Flag: *flag.NewFlagSet("aptly-repo", flag.ExitOnError),
}
}
+47
View File
@@ -0,0 +1,47 @@
package cmd
import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
"github.com/smira/aptly/debian"
)
func aptlyRepoCreate(cmd *commander.Command, args []string) error {
var err error
if len(args) != 1 {
cmd.Usage()
return err
}
repo := debian.NewLocalRepo(args[0], cmd.Flag.Lookup("comment").Value.String())
localRepoCollection := debian.NewLocalRepoCollection(context.database)
err = localRepoCollection.Add(repo)
if err != nil {
return fmt.Errorf("unable to add local repo: %s", err)
}
fmt.Printf("\nLocal repo %s successfully added.\nYou can run 'aptly repo add %s ...' to add packages to repository.\n", repo, repo.Name)
return err
}
func makeCmdRepoCreate() *commander.Command {
cmd := &commander.Command{
Run: aptlyRepoCreate,
UsageLine: "create <name>",
Short: "create new local package repository",
Long: `
Creates new empty local package repository.
ex:
$ aptly repo create testing
`,
Flag: *flag.NewFlagSet("aptly-repo-create", flag.ExitOnError),
}
cmd.Flag.String("comment", "", "comment for the repository")
return cmd
}