mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-11 03:11:50 +00:00
Command aptly repo create.
This commit is contained in:
1
Makefile
1
Makefile
@@ -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
|
||||
echo "mode: count" > coverage.out
|
||||
grep -v -h "mode: count" coverage.*.out >> coverage.out
|
||||
rm -f coverage.*.out
|
||||
|
||||
coverage: coverage.out
|
||||
go tool cover -html=coverage.out
|
||||
|
||||
@@ -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
cmd/repo.go
Normal file
17
cmd/repo.go
Normal 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
cmd/repo_create.go
Normal file
47
cmd/repo_create.go
Normal 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
|
||||
}
|
||||
@@ -6,6 +6,7 @@ Commands:
|
||||
graph display graph of dependencies between aptly objects (requires graphviz)
|
||||
mirror manage mirrors of remote repositories
|
||||
publish manage published repositories
|
||||
repo manage local package repositories
|
||||
serve start embedded HTTP server to serve published repositories
|
||||
snapshot manage snapshots of repositories
|
||||
version display version
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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.
|
||||
|
||||
Options:
|
||||
-architectures="": list of architectures to consider during (comma-separated), default to all available
|
||||
|
||||
@@ -6,6 +6,7 @@ Commands:
|
||||
graph display graph of dependencies between aptly objects (requires graphviz)
|
||||
mirror manage mirrors of remote repositories
|
||||
publish manage published repositories
|
||||
repo manage local package repositories
|
||||
serve start embedded HTTP server to serve published repositories
|
||||
snapshot manage snapshots of repositories
|
||||
version display version
|
||||
|
||||
3
system/t09_repo/CreateRepo1Test_gold
Normal file
3
system/t09_repo/CreateRepo1Test_gold
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
Local repo [repo1] successfully added.
|
||||
You can run 'aptly repo add repo1 ...' to add packages to repository.
|
||||
3
system/t09_repo/CreateRepo2Test_gold
Normal file
3
system/t09_repo/CreateRepo2Test_gold
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
Local repo [repo2]: Repository2 successfully added.
|
||||
You can run 'aptly repo add repo2 ...' to add packages to repository.
|
||||
1
system/t09_repo/CreateRepo3Test_gold
Normal file
1
system/t09_repo/CreateRepo3Test_gold
Normal file
@@ -0,0 +1 @@
|
||||
ERROR: unable to add local repo: local repo with name repo3 already exists
|
||||
5
system/t09_repo/__init__.py
Normal file
5
system/t09_repo/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
"""
|
||||
Testing local repo management
|
||||
"""
|
||||
|
||||
from .create import *
|
||||
32
system/t09_repo/create.py
Normal file
32
system/t09_repo/create.py
Normal 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
|
||||
Reference in New Issue
Block a user