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
+1
View File
@@ -35,6 +35,7 @@ coverage.out:
for i in database debian files http utils; do go test -coverprofile=coverage.$$i.out -covermode=count ./$$i; done for i in database debian files http utils; do go test -coverprofile=coverage.$$i.out -covermode=count ./$$i; done
echo "mode: count" > coverage.out echo "mode: count" > coverage.out
grep -v -h "mode: count" coverage.*.out >> coverage.out grep -v -h "mode: count" coverage.*.out >> coverage.out
rm -f coverage.*.out
coverage: coverage.out coverage: coverage.out
go tool cover -html=coverage.out go tool cover -html=coverage.out
+4 -2
View File
@@ -37,13 +37,15 @@ func RootCommand() *commander.Command {
Short: "Debian repository management tool", Short: "Debian repository management tool",
Long: ` Long: `
aptly is a tool to create partial and full mirrors of remote aptly is a tool to create partial and full mirrors of remote
repositories, filter them, merge, upgrade individual packages, repositories, manage local repositories, filter them, merge,
take snapshots and publish them back as Debian repositories.`, upgrade individual packages, take snapshots and publish them
back as Debian repositories.`,
Flag: *flag.NewFlagSet("aptly", flag.ExitOnError), Flag: *flag.NewFlagSet("aptly", flag.ExitOnError),
Subcommands: []*commander.Command{ Subcommands: []*commander.Command{
makeCmdDb(), makeCmdDb(),
makeCmdGraph(), makeCmdGraph(),
makeCmdMirror(), makeCmdMirror(),
makeCmdRepo(),
makeCmdServe(), makeCmdServe(),
makeCmdSnapshot(), makeCmdSnapshot(),
makeCmdPublish(), 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
}
+1
View File
@@ -6,6 +6,7 @@ Commands:
graph display graph of dependencies between aptly objects (requires graphviz) graph display graph of dependencies between aptly objects (requires graphviz)
mirror manage mirrors of remote repositories mirror manage mirrors of remote repositories
publish manage published repositories publish manage published repositories
repo manage local package repositories
serve start embedded HTTP server to serve published repositories serve start embedded HTTP server to serve published repositories
snapshot manage snapshots of repositories snapshot manage snapshots of repositories
version display version version display version
+3 -2
View File
@@ -1,6 +1,7 @@
aptly is a tool to create partial and full mirrors of remote aptly is a tool to create partial and full mirrors of remote
repositories, filter them, merge, upgrade individual packages, repositories, manage local repositories, filter them, merge,
take snapshots and publish them back as Debian repositories. upgrade individual packages, take snapshots and publish them
back as Debian repositories.
Options: Options:
-architectures="": list of architectures to consider during (comma-separated), default to all available -architectures="": list of architectures to consider during (comma-separated), default to all available
+1
View File
@@ -6,6 +6,7 @@ Commands:
graph display graph of dependencies between aptly objects (requires graphviz) graph display graph of dependencies between aptly objects (requires graphviz)
mirror manage mirrors of remote repositories mirror manage mirrors of remote repositories
publish manage published repositories publish manage published repositories
repo manage local package repositories
serve start embedded HTTP server to serve published repositories serve start embedded HTTP server to serve published repositories
snapshot manage snapshots of repositories snapshot manage snapshots of repositories
version display version version display version
+3
View File
@@ -0,0 +1,3 @@
Local repo [repo1] successfully added.
You can run 'aptly repo add repo1 ...' to add packages to repository.
+3
View File
@@ -0,0 +1,3 @@
Local repo [repo2]: Repository2 successfully added.
You can run 'aptly repo add repo2 ...' to add packages to repository.
+1
View File
@@ -0,0 +1 @@
ERROR: unable to add local repo: local repo with name repo3 already exists
+5
View File
@@ -0,0 +1,5 @@
"""
Testing local repo management
"""
from .create import *
+32
View File
@@ -0,0 +1,32 @@
from lib import BaseTest
class CreateRepo1Test(BaseTest):
"""
create local repo: regular repo
"""
runCmd = "aptly repo create repo1"
def check(self):
self.check_output()
#self.check_cmd_output("aptly mirror show mirror1", "mirror_show")
class CreateRepo2Test(BaseTest):
"""
create local repo: regular repo with comment
"""
runCmd = "aptly repo create -comment=Repository2 repo2"
def check(self):
self.check_output()
#self.check_cmd_output("aptly mirror show mirror1", "mirror_show")
class CreateRepo3Test(BaseTest):
"""
create local repo: duplicate name
"""
fixtureCmds = ["aptly repo create repo3"]
runCmd = "aptly repo create -comment=Repository3 repo3"
expectedCode = 1