mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
Support for switching to smira/commander with free placement of flags. #17
This commit is contained in:
+14
-11
@@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/smira/aptly/files"
|
"github.com/smira/aptly/files"
|
||||||
"github.com/smira/aptly/http"
|
"github.com/smira/aptly/http"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/smira/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/flag"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -28,6 +28,7 @@ var context struct {
|
|||||||
collectionFactory *debian.CollectionFactory
|
collectionFactory *debian.CollectionFactory
|
||||||
dependencyOptions int
|
dependencyOptions int
|
||||||
architecturesList []string
|
architecturesList []string
|
||||||
|
flags *flag.FlagSet
|
||||||
// Debug features
|
// Debug features
|
||||||
fileCPUProfile *os.File
|
fileCPUProfile *os.File
|
||||||
fileMemProfile *os.File
|
fileMemProfile *os.File
|
||||||
@@ -35,25 +36,27 @@ var context struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// InitContext initializes context with default settings
|
// InitContext initializes context with default settings
|
||||||
func InitContext(cmd *commander.Command) error {
|
func InitContext(flags *flag.FlagSet) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
context.flags = flags
|
||||||
|
|
||||||
context.dependencyOptions = 0
|
context.dependencyOptions = 0
|
||||||
if utils.Config.DepFollowSuggests || cmd.Flag.Lookup("dep-follow-suggests").Value.Get().(bool) {
|
if utils.Config.DepFollowSuggests || flags.Lookup("dep-follow-suggests").Value.Get().(bool) {
|
||||||
context.dependencyOptions |= debian.DepFollowSuggests
|
context.dependencyOptions |= debian.DepFollowSuggests
|
||||||
}
|
}
|
||||||
if utils.Config.DepFollowRecommends || cmd.Flag.Lookup("dep-follow-recommends").Value.Get().(bool) {
|
if utils.Config.DepFollowRecommends || flags.Lookup("dep-follow-recommends").Value.Get().(bool) {
|
||||||
context.dependencyOptions |= debian.DepFollowRecommends
|
context.dependencyOptions |= debian.DepFollowRecommends
|
||||||
}
|
}
|
||||||
if utils.Config.DepFollowAllVariants || cmd.Flag.Lookup("dep-follow-all-variants").Value.Get().(bool) {
|
if utils.Config.DepFollowAllVariants || flags.Lookup("dep-follow-all-variants").Value.Get().(bool) {
|
||||||
context.dependencyOptions |= debian.DepFollowAllVariants
|
context.dependencyOptions |= debian.DepFollowAllVariants
|
||||||
}
|
}
|
||||||
if utils.Config.DepFollowSource || cmd.Flag.Lookup("dep-follow-source").Value.Get().(bool) {
|
if utils.Config.DepFollowSource || flags.Lookup("dep-follow-source").Value.Get().(bool) {
|
||||||
context.dependencyOptions |= debian.DepFollowSource
|
context.dependencyOptions |= debian.DepFollowSource
|
||||||
}
|
}
|
||||||
|
|
||||||
context.architecturesList = utils.Config.Architectures
|
context.architecturesList = utils.Config.Architectures
|
||||||
optionArchitectures := cmd.Flag.Lookup("architectures").Value.String()
|
optionArchitectures := flags.Lookup("architectures").Value.String()
|
||||||
if optionArchitectures != "" {
|
if optionArchitectures != "" {
|
||||||
context.architecturesList = strings.Split(optionArchitectures, ",")
|
context.architecturesList = strings.Split(optionArchitectures, ",")
|
||||||
}
|
}
|
||||||
@@ -74,7 +77,7 @@ func InitContext(cmd *commander.Command) error {
|
|||||||
context.publishedStorage = files.NewPublishedStorage(utils.Config.RootDir)
|
context.publishedStorage = files.NewPublishedStorage(utils.Config.RootDir)
|
||||||
|
|
||||||
if aptly.EnableDebug {
|
if aptly.EnableDebug {
|
||||||
cpuprofile := cmd.Flag.Lookup("cpuprofile").Value.String()
|
cpuprofile := flags.Lookup("cpuprofile").Value.String()
|
||||||
if cpuprofile != "" {
|
if cpuprofile != "" {
|
||||||
context.fileCPUProfile, err = os.Create(cpuprofile)
|
context.fileCPUProfile, err = os.Create(cpuprofile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -83,7 +86,7 @@ func InitContext(cmd *commander.Command) error {
|
|||||||
pprof.StartCPUProfile(context.fileCPUProfile)
|
pprof.StartCPUProfile(context.fileCPUProfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
memprofile := cmd.Flag.Lookup("memprofile").Value.String()
|
memprofile := flags.Lookup("memprofile").Value.String()
|
||||||
if memprofile != "" {
|
if memprofile != "" {
|
||||||
context.fileMemProfile, err = os.Create(memprofile)
|
context.fileMemProfile, err = os.Create(memprofile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -91,9 +94,9 @@ func InitContext(cmd *commander.Command) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memstats := cmd.Flag.Lookup("memstats").Value.String()
|
memstats := flags.Lookup("memstats").Value.String()
|
||||||
if memstats != "" {
|
if memstats != "" {
|
||||||
interval := cmd.Flag.Lookup("meminterval").Value.Get().(time.Duration)
|
interval := flags.Lookup("meminterval").Value.Get().(time.Duration)
|
||||||
|
|
||||||
context.fileMemStats, err = os.Create(memstats)
|
context.fileMemStats, err = os.Create(memstats)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func makeCmdDb() *commander.Command {
|
func makeCmdDb() *commander.Command {
|
||||||
@@ -12,6 +11,5 @@ func makeCmdDb() *commander.Command {
|
|||||||
Subcommands: []*commander.Command{
|
Subcommands: []*commander.Command{
|
||||||
makeCmdDbCleanup(),
|
makeCmdDbCleanup(),
|
||||||
},
|
},
|
||||||
Flag: *flag.NewFlagSet("aptly-db", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"github.com/smira/aptly/debian"
|
"github.com/smira/aptly/debian"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/smira/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
"sort"
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -159,7 +158,6 @@ Example:
|
|||||||
|
|
||||||
$ aptly db cleanup
|
$ aptly db cleanup
|
||||||
`,
|
`,
|
||||||
Flag: *flag.NewFlagSet("aptly-db-cleanup", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/smira/aptly/debian"
|
"github.com/smira/aptly/debian"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@@ -196,7 +195,6 @@ Example:
|
|||||||
|
|
||||||
$ aptly graph
|
$ aptly graph
|
||||||
`,
|
`,
|
||||||
Flag: *flag.NewFlagSet("aptly-graph", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
+5
-6
@@ -7,13 +7,15 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getVerifier(cmd *commander.Command) (utils.Verifier, error) {
|
func getVerifier(flags *flag.FlagSet) (utils.Verifier, error) {
|
||||||
if utils.Config.GpgDisableVerify || cmd.Flag.Lookup("ignore-signatures").Value.Get().(bool) {
|
if utils.Config.GpgDisableVerify || flags.Lookup("ignore-signatures").Value.Get().(bool) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keyRings := flags.Lookup("keyring").Value.Get().([]string)
|
||||||
|
|
||||||
verifier := &utils.GpgVerifier{}
|
verifier := &utils.GpgVerifier{}
|
||||||
for _, keyRing := range keyRings.keyRings {
|
for _, keyRing := range keyRings {
|
||||||
verifier.AddKeyring(keyRing)
|
verifier.AddKeyring(keyRing)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,8 +44,6 @@ func (k *keyRingsFlag) String() string {
|
|||||||
return strings.Join(k.keyRings, ",")
|
return strings.Join(k.keyRings, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
var keyRings = keyRingsFlag{}
|
|
||||||
|
|
||||||
func makeCmdMirror() *commander.Command {
|
func makeCmdMirror() *commander.Command {
|
||||||
return &commander.Command{
|
return &commander.Command{
|
||||||
UsageLine: "mirror",
|
UsageLine: "mirror",
|
||||||
@@ -55,6 +55,5 @@ func makeCmdMirror() *commander.Command {
|
|||||||
makeCmdMirrorDrop(),
|
makeCmdMirrorDrop(),
|
||||||
makeCmdMirrorUpdate(),
|
makeCmdMirrorUpdate(),
|
||||||
},
|
},
|
||||||
Flag: *flag.NewFlagSet("aptly-mirror", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func aptlyMirrorCreate(cmd *commander.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadSources := utils.Config.DownloadSourcePackages || cmd.Flag.Lookup("with-sources").Value.Get().(bool)
|
downloadSources := utils.Config.DownloadSourcePackages || context.flags.Lookup("with-sources").Value.Get().(bool)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
mirrorName, archiveURL, distribution string
|
mirrorName, archiveURL, distribution string
|
||||||
@@ -38,7 +38,7 @@ func aptlyMirrorCreate(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to create mirror: %s", err)
|
return fmt.Errorf("unable to create mirror: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
verifier, err := getVerifier(cmd)
|
verifier, err := getVerifier(context.flags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to initialize GPG verifier: %s", err)
|
return fmt.Errorf("unable to initialize GPG verifier: %s", err)
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ Example:
|
|||||||
|
|
||||||
cmd.Flag.Bool("ignore-signatures", false, "disable verification of Release file signatures")
|
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-sources", false, "download source packages in addition to binary packages")
|
||||||
cmd.Flag.Var(&keyRings, "keyring", "gpg keyring to use when verifying Release file (could be specified multiple times)")
|
cmd.Flag.Var(&keyRingsFlag{}, "keyring", "gpg keyring to use when verifying Release file (could be specified multiple times)")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ func aptlyMirrorDrop(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to drop: %s", err)
|
return fmt.Errorf("unable to drop: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
force := cmd.Flag.Lookup("force").Value.Get().(bool)
|
force := context.flags.Lookup("force").Value.Get().(bool)
|
||||||
if !force {
|
if !force {
|
||||||
snapshots := context.collectionFactory.SnapshotCollection().ByRemoteRepoSource(repo)
|
snapshots := context.collectionFactory.SnapshotCollection().ByRemoteRepoSource(repo)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/smira/aptly/debian"
|
"github.com/smira/aptly/debian"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
"sort"
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -49,7 +48,6 @@ Example:
|
|||||||
|
|
||||||
$ aptly mirror list
|
$ aptly mirror list
|
||||||
`,
|
`,
|
||||||
Flag: *flag.NewFlagSet("aptly-mirror-list", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ func aptlyMirrorShow(cmd *commander.Command, args []string) error {
|
|||||||
fmt.Printf("%s: %s\n", k, repo.Meta[k])
|
fmt.Printf("%s: %s\n", k, repo.Meta[k])
|
||||||
}
|
}
|
||||||
|
|
||||||
withPackages := cmd.Flag.Lookup("with-packages").Value.Get().(bool)
|
withPackages := context.flags.Lookup("with-packages").Value.Get().(bool)
|
||||||
if withPackages {
|
if withPackages {
|
||||||
if repo.LastDownloadDate.IsZero() {
|
if repo.LastDownloadDate.IsZero() {
|
||||||
fmt.Printf("Unable to show package list, mirror hasn't been downloaded yet.\n")
|
fmt.Printf("Unable to show package list, mirror hasn't been downloaded yet.\n")
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to update: %s", err)
|
return fmt.Errorf("unable to update: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ignoreMismatch := cmd.Flag.Lookup("ignore-checksums").Value.Get().(bool)
|
ignoreMismatch := context.flags.Lookup("ignore-checksums").Value.Get().(bool)
|
||||||
|
|
||||||
verifier, err := getVerifier(cmd)
|
verifier, err := getVerifier(context.flags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to initialize GPG verifier: %s", err)
|
return fmt.Errorf("unable to initialize GPG verifier: %s", err)
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ Example:
|
|||||||
|
|
||||||
cmd.Flag.Bool("ignore-checksums", false, "ignore checksum mismatches while downloading package files and metadata")
|
cmd.Flag.Bool("ignore-checksums", false, "ignore checksum mismatches while downloading package files and metadata")
|
||||||
cmd.Flag.Bool("ignore-signatures", false, "disable verification of Release file signatures")
|
cmd.Flag.Bool("ignore-signatures", false, "disable verification of Release file signatures")
|
||||||
cmd.Flag.Var(&keyRings, "keyring", "gpg keyring to use when verifying Release file (could be specified multiple times)")
|
cmd.Flag.Var(&keyRingsFlag{}, "keyring", "gpg keyring to use when verifying Release file (could be specified multiple times)")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -6,14 +6,14 @@ import (
|
|||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getSigner(cmd *commander.Command) (utils.Signer, error) {
|
func getSigner(flags *flag.FlagSet) (utils.Signer, error) {
|
||||||
if cmd.Flag.Lookup("skip-signing").Value.Get().(bool) || utils.Config.GpgDisableSign {
|
if flags.Lookup("skip-signing").Value.Get().(bool) || utils.Config.GpgDisableSign {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
signer := &utils.GpgSigner{}
|
signer := &utils.GpgSigner{}
|
||||||
signer.SetKey(cmd.Flag.Lookup("gpg-key").Value.String())
|
signer.SetKey(flags.Lookup("gpg-key").Value.String())
|
||||||
signer.SetKeyRing(cmd.Flag.Lookup("keyring").Value.String(), cmd.Flag.Lookup("secret-keyring").Value.String())
|
signer.SetKeyRing(flags.Lookup("keyring").Value.String(), flags.Lookup("secret-keyring").Value.String())
|
||||||
|
|
||||||
err := signer.Init()
|
err := signer.Init()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -34,6 +34,5 @@ func makeCmdPublish() *commander.Command {
|
|||||||
makeCmdPublishList(),
|
makeCmdPublishList(),
|
||||||
makeCmdPublishDrop(),
|
makeCmdPublishDrop(),
|
||||||
},
|
},
|
||||||
Flag: *flag.NewFlagSet("aptly-publish", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func aptlyPublishDrop(cmd *commander.Command, args []string) error {
|
func aptlyPublishDrop(cmd *commander.Command, args []string) error {
|
||||||
@@ -43,7 +42,6 @@ Example:
|
|||||||
|
|
||||||
$ aptly publish drop wheezy
|
$ aptly publish drop wheezy
|
||||||
`,
|
`,
|
||||||
Flag: *flag.NewFlagSet("aptly-publish-drop", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/smira/aptly/debian"
|
"github.com/smira/aptly/debian"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
"sort"
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -59,7 +58,6 @@ Example:
|
|||||||
|
|
||||||
$ aptly publish list
|
$ aptly publish list
|
||||||
`,
|
`,
|
||||||
Flag: *flag.NewFlagSet("aptly-publish-list", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ Example:
|
|||||||
cmd.Flag.String("distribution", "", "distribution name to publish")
|
cmd.Flag.String("distribution", "", "distribution name to publish")
|
||||||
cmd.Flag.String("component", "", "component name to publish")
|
cmd.Flag.String("component", "", "component name to publish")
|
||||||
cmd.Flag.String("gpg-key", "", "GPG key ID to use when signing the release")
|
cmd.Flag.String("gpg-key", "", "GPG key ID to use when signing the release")
|
||||||
cmd.Flag.String("keyring", "", "GPG keyring to use (instead of default)")
|
cmd.Flag.Var(&keyRingsFlag{}, "keyring", "GPG keyring to use (instead of default)")
|
||||||
cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)")
|
cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)")
|
||||||
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
|
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
|
|||||||
panic("unknown command")
|
panic("unknown command")
|
||||||
}
|
}
|
||||||
|
|
||||||
component := cmd.Flag.Lookup("component").Value.String()
|
component := context.flags.Lookup("component").Value.String()
|
||||||
distribution := cmd.Flag.Lookup("distribution").Value.String()
|
distribution := context.flags.Lookup("distribution").Value.String()
|
||||||
|
|
||||||
published, err := debian.NewPublishedRepo(prefix, distribution, component, context.architecturesList, source, context.collectionFactory)
|
published, err := debian.NewPublishedRepo(prefix, distribution, component, context.architecturesList, source, context.collectionFactory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -74,7 +74,7 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("prefix/distribution already used by another published repo: %s", duplicate)
|
return fmt.Errorf("prefix/distribution already used by another published repo: %s", duplicate)
|
||||||
}
|
}
|
||||||
|
|
||||||
signer, err := getSigner(cmd)
|
signer, err := getSigner(context.flags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to initialize GPG signer: %s", err)
|
return fmt.Errorf("unable to initialize GPG signer: %s", err)
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ Example:
|
|||||||
cmd.Flag.String("distribution", "", "distribution name to publish")
|
cmd.Flag.String("distribution", "", "distribution name to publish")
|
||||||
cmd.Flag.String("component", "", "component name to publish")
|
cmd.Flag.String("component", "", "component name to publish")
|
||||||
cmd.Flag.String("gpg-key", "", "GPG key ID to use when signing the release")
|
cmd.Flag.String("gpg-key", "", "GPG key ID to use when signing the release")
|
||||||
cmd.Flag.String("keyring", "", "GPG keyring to use (instead of default)")
|
cmd.Flag.Var(&keyRingsFlag{}, "keyring", "GPG keyring to use (instead of default)")
|
||||||
cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)")
|
cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)")
|
||||||
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
|
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func makeCmdRepo() *commander.Command {
|
func makeCmdRepo() *commander.Command {
|
||||||
@@ -21,6 +20,5 @@ func makeCmdRepo() *commander.Command {
|
|||||||
makeCmdRepoRemove(),
|
makeCmdRepoRemove(),
|
||||||
makeCmdRepoShow(),
|
makeCmdRepoShow(),
|
||||||
},
|
},
|
||||||
Flag: *flag.NewFlagSet("aptly-repo", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -165,7 +165,7 @@ func aptlyRepoAdd(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to save: %s", err)
|
return fmt.Errorf("unable to save: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Flag.Lookup("remove-files").Value.Get().(bool) {
|
if context.flags.Lookup("remove-files").Value.Get().(bool) {
|
||||||
processedFiles = utils.StrSliceDeduplicate(processedFiles)
|
processedFiles = utils.StrSliceDeduplicate(processedFiles)
|
||||||
|
|
||||||
for _, file := range processedFiles {
|
for _, file := range processedFiles {
|
||||||
|
|||||||
+3
-3
@@ -14,9 +14,9 @@ func aptlyRepoCreate(cmd *commander.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
repo := debian.NewLocalRepo(args[0], cmd.Flag.Lookup("comment").Value.String())
|
repo := debian.NewLocalRepo(args[0], context.flags.Lookup("comment").Value.String())
|
||||||
repo.DefaultDistribution = cmd.Flag.Lookup("distribution").Value.String()
|
repo.DefaultDistribution = context.flags.Lookup("distribution").Value.String()
|
||||||
repo.DefaultComponent = cmd.Flag.Lookup("component").Value.String()
|
repo.DefaultComponent = context.flags.Lookup("component").Value.String()
|
||||||
|
|
||||||
err = context.collectionFactory.LocalRepoCollection().Add(repo)
|
err = context.collectionFactory.LocalRepoCollection().Add(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ func aptlyRepoDrop(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to drop: local repo is published")
|
return fmt.Errorf("unable to drop: local repo is published")
|
||||||
}
|
}
|
||||||
|
|
||||||
force := cmd.Flag.Lookup("force").Value.Get().(bool)
|
force := context.flags.Lookup("force").Value.Get().(bool)
|
||||||
if !force {
|
if !force {
|
||||||
snapshots := context.collectionFactory.SnapshotCollection().ByLocalRepoSource(repo)
|
snapshots := context.collectionFactory.SnapshotCollection().ByLocalRepoSource(repo)
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -23,16 +23,16 @@ func aptlyRepoEdit(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to edit: %s", err)
|
return fmt.Errorf("unable to edit: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Flag.Lookup("comment").Value.String() != "" {
|
if context.flags.Lookup("comment").Value.String() != "" {
|
||||||
repo.Comment = cmd.Flag.Lookup("comment").Value.String()
|
repo.Comment = context.flags.Lookup("comment").Value.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Flag.Lookup("distribution").Value.String() != "" {
|
if context.flags.Lookup("distribution").Value.String() != "" {
|
||||||
repo.DefaultDistribution = cmd.Flag.Lookup("distribution").Value.String()
|
repo.DefaultDistribution = context.flags.Lookup("distribution").Value.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Flag.Lookup("component").Value.String() != "" {
|
if context.flags.Lookup("component").Value.String() != "" {
|
||||||
repo.DefaultComponent = cmd.Flag.Lookup("component").Value.String()
|
repo.DefaultComponent = context.flags.Lookup("component").Value.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
err = context.collectionFactory.LocalRepoCollection().Update(repo)
|
err = context.collectionFactory.LocalRepoCollection().Update(repo)
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/smira/aptly/debian"
|
"github.com/smira/aptly/debian"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
"sort"
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -54,7 +53,6 @@ Example:
|
|||||||
|
|
||||||
$ aptly repo list
|
$ aptly repo list
|
||||||
`,
|
`,
|
||||||
Flag: *flag.NewFlagSet("aptly-repo-list", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
+2
-2
@@ -86,7 +86,7 @@ func aptlyRepoMoveCopyImport(cmd *commander.Command, args []string) error {
|
|||||||
|
|
||||||
var architecturesList []string
|
var architecturesList []string
|
||||||
|
|
||||||
withDeps := cmd.Flag.Lookup("with-deps").Value.Get().(bool)
|
withDeps := context.flags.Lookup("with-deps").Value.Get().(bool)
|
||||||
|
|
||||||
if withDeps {
|
if withDeps {
|
||||||
dstList.PrepareIndex()
|
dstList.PrepareIndex()
|
||||||
@@ -136,7 +136,7 @@ func aptlyRepoMoveCopyImport(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to %s: %s", command, err)
|
return fmt.Errorf("unable to %s: %s", command, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Flag.Lookup("dry-run").Value.Get().(bool) {
|
if context.flags.Lookup("dry-run").Value.Get().(bool) {
|
||||||
context.progress.Printf("\nChanges not saved, as dry run has been requested.\n")
|
context.progress.Printf("\nChanges not saved, as dry run has been requested.\n")
|
||||||
} else {
|
} else {
|
||||||
dstRepo.UpdateRefList(debian.NewPackageRefListFromPackageList(dstList))
|
dstRepo.UpdateRefList(debian.NewPackageRefListFromPackageList(dstList))
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ func aptlyRepoRemove(cmd *commander.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
if cmd.Flag.Lookup("dry-run").Value.Get().(bool) {
|
if context.flags.Lookup("dry-run").Value.Get().(bool) {
|
||||||
context.progress.Printf("\nChanges not saved, as dry run has been requested.\n")
|
context.progress.Printf("\nChanges not saved, as dry run has been requested.\n")
|
||||||
} else {
|
} else {
|
||||||
repo.UpdateRefList(debian.NewPackageRefListFromPackageList(list))
|
repo.UpdateRefList(debian.NewPackageRefListFromPackageList(list))
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ func aptlyRepoShow(cmd *commander.Command, args []string) error {
|
|||||||
fmt.Printf("Default Component: %s\n", repo.DefaultComponent)
|
fmt.Printf("Default Component: %s\n", repo.DefaultComponent)
|
||||||
fmt.Printf("Number of packages: %d\n", repo.NumPackages())
|
fmt.Printf("Number of packages: %d\n", repo.NumPackages())
|
||||||
|
|
||||||
withPackages := cmd.Flag.Lookup("with-packages").Value.Get().(bool)
|
withPackages := context.flags.Lookup("with-packages").Value.Get().(bool)
|
||||||
if withPackages {
|
if withPackages {
|
||||||
ListPackagesRefList(repo.RefList())
|
ListPackagesRefList(repo.RefList())
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ func aptlyServe(cmd *commander.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
listen := cmd.Flag.Lookup("listen").Value.String()
|
listen := context.flags.Lookup("listen").Value.String()
|
||||||
|
|
||||||
listenHost, listenPort, err := net.SplitHostPort(listen)
|
listenHost, listenPort, err := net.SplitHostPort(listen)
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func makeCmdSnapshot() *commander.Command {
|
func makeCmdSnapshot() *commander.Command {
|
||||||
@@ -19,6 +18,5 @@ func makeCmdSnapshot() *commander.Command {
|
|||||||
makeCmdSnapshotMerge(),
|
makeCmdSnapshotMerge(),
|
||||||
makeCmdSnapshotDrop(),
|
makeCmdSnapshotDrop(),
|
||||||
},
|
},
|
||||||
Flag: *flag.NewFlagSet("aptly-snapshot", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/smira/aptly/debian"
|
"github.com/smira/aptly/debian"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func aptlySnapshotCreate(cmd *commander.Command, args []string) error {
|
func aptlySnapshotCreate(cmd *commander.Command, args []string) error {
|
||||||
@@ -97,7 +96,6 @@ Example:
|
|||||||
|
|
||||||
$ aptly snapshot create wheezy-main-today from mirror wheezy-main
|
$ aptly snapshot create wheezy-main-today from mirror wheezy-main
|
||||||
`,
|
`,
|
||||||
Flag: *flag.NewFlagSet("aptly-snapshot-create", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ func aptlySnapshotDiff(cmd *commander.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
onlyMatching := cmd.Flag.Lookup("only-matching").Value.Get().(bool)
|
onlyMatching := context.flags.Lookup("only-matching").Value.Get().(bool)
|
||||||
|
|
||||||
// Load <name-a> snapshot
|
// Load <name-a> snapshot
|
||||||
snapshotA, err := context.collectionFactory.SnapshotCollection().ByName(args[0])
|
snapshotA, err := context.collectionFactory.SnapshotCollection().ByName(args[0])
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func aptlySnapshotDrop(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to drop: snapshot is published")
|
return fmt.Errorf("unable to drop: snapshot is published")
|
||||||
}
|
}
|
||||||
|
|
||||||
force := cmd.Flag.Lookup("force").Value.Get().(bool)
|
force := context.flags.Lookup("force").Value.Get().(bool)
|
||||||
if !force {
|
if !force {
|
||||||
snapshots := context.collectionFactory.SnapshotCollection().BySnapshotSource(snapshot)
|
snapshots := context.collectionFactory.SnapshotCollection().BySnapshotSource(snapshot)
|
||||||
if len(snapshots) > 0 {
|
if len(snapshots) > 0 {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/smira/aptly/debian"
|
"github.com/smira/aptly/debian"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
"sort"
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -52,7 +51,6 @@ Example:
|
|||||||
|
|
||||||
$ aptly snapshot list
|
$ aptly snapshot list
|
||||||
`,
|
`,
|
||||||
Flag: *flag.NewFlagSet("aptly-snapshot-list", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/smira/aptly/debian"
|
"github.com/smira/aptly/debian"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -70,7 +69,6 @@ Example:
|
|||||||
|
|
||||||
$ aptly snapshot merge wheezy-w-backports wheezy-main wheezy-backports
|
$ aptly snapshot merge wheezy-w-backports wheezy-main wheezy-backports
|
||||||
`,
|
`,
|
||||||
Flag: *flag.NewFlagSet("aptly-snapshot-merge", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ func aptlySnapshotPull(cmd *commander.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
noDeps := cmd.Flag.Lookup("no-deps").Value.Get().(bool)
|
noDeps := context.flags.Lookup("no-deps").Value.Get().(bool)
|
||||||
noRemove := cmd.Flag.Lookup("no-remove").Value.Get().(bool)
|
noRemove := context.flags.Lookup("no-remove").Value.Get().(bool)
|
||||||
|
|
||||||
// Load <name> snapshot
|
// Load <name> snapshot
|
||||||
snapshot, err := context.collectionFactory.SnapshotCollection().ByName(args[0])
|
snapshot, err := context.collectionFactory.SnapshotCollection().ByName(args[0])
|
||||||
@@ -147,7 +147,7 @@ func aptlySnapshotPull(cmd *commander.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Flag.Lookup("dry-run").Value.Get().(bool) {
|
if context.flags.Lookup("dry-run").Value.Get().(bool) {
|
||||||
context.progress.Printf("\nNot creating snapshot, as dry run was requested.\n")
|
context.progress.Printf("\nNot creating snapshot, as dry run was requested.\n")
|
||||||
} else {
|
} else {
|
||||||
// Create <destination> snapshot
|
// Create <destination> snapshot
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func aptlySnapshotShow(cmd *commander.Command, args []string) error {
|
|||||||
fmt.Printf("Description: %s\n", snapshot.Description)
|
fmt.Printf("Description: %s\n", snapshot.Description)
|
||||||
fmt.Printf("Number of packages: %d\n", snapshot.NumPackages())
|
fmt.Printf("Number of packages: %d\n", snapshot.NumPackages())
|
||||||
|
|
||||||
withPackages := cmd.Flag.Lookup("with-packages").Value.Get().(bool)
|
withPackages := context.flags.Lookup("with-packages").Value.Get().(bool)
|
||||||
if withPackages {
|
if withPackages {
|
||||||
ListPackagesRefList(snapshot.RefList())
|
ListPackagesRefList(snapshot.RefList())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/smira/aptly/debian"
|
"github.com/smira/aptly/debian"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
"sort"
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -110,7 +109,6 @@ Example:
|
|||||||
|
|
||||||
$ aptly snapshot verify wheezy-main wheezy-contrib wheezy-non-free
|
$ aptly snapshot verify wheezy-main wheezy-contrib wheezy-non-free
|
||||||
`,
|
`,
|
||||||
Flag: *flag.NewFlagSet("aptly-snapshot-verify", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/smira/aptly/aptly"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func aptlyVersion(cmd *commander.Command, args []string) error {
|
func aptlyVersion(cmd *commander.Command, args []string) error {
|
||||||
@@ -23,6 +22,5 @@ Shows aptly version.
|
|||||||
ex:
|
ex:
|
||||||
$ aptly version
|
$ aptly version
|
||||||
`,
|
`,
|
||||||
Flag: *flag.NewFlagSet("aptly-version", flag.ExitOnError),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ func main() {
|
|||||||
|
|
||||||
command := cmd.RootCommand()
|
command := cmd.RootCommand()
|
||||||
|
|
||||||
err := command.Flag.Parse(os.Args[1:])
|
flags, args, err := command.ParseFlags(os.Args[1:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err)
|
fatal(err)
|
||||||
return
|
return
|
||||||
@@ -82,14 +82,14 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cmd.InitContext(command)
|
err = cmd.InitContext(flags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err)
|
fatal(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer cmd.ShutdownContext()
|
defer cmd.ShutdownContext()
|
||||||
|
|
||||||
err = command.Dispatch(command.Flag.Args())
|
err = command.Dispatch(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err)
|
fatal(err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ Example:
|
|||||||
$ aptly mirror create wheezy-main http://mirror.yandex.ru/debian/ wheezy main
|
$ aptly mirror create wheezy-main http://mirror.yandex.ru/debian/ wheezy main
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
-architectures="": list of architectures to consider during (comma-separated), default to all available
|
||||||
|
-config="": location of configuration file (default locations are /etc/aptly.conf, ~/.aptly.conf)
|
||||||
|
-dep-follow-all-variants=false: when processing dependencies, follow a & b if depdency is 'a|b'
|
||||||
|
-dep-follow-recommends=false: when processing dependencies, follow Recommends
|
||||||
|
-dep-follow-source=false: when processing dependencies, follow from binary to Source packages
|
||||||
|
-dep-follow-suggests=false: when processing dependencies, follow Suggests
|
||||||
-ignore-signatures=false: disable verification of Release file signatures
|
-ignore-signatures=false: disable verification of Release file signatures
|
||||||
-keyring=: gpg keyring to use when verifying Release file (could be specified multiple times)
|
-keyring=: gpg keyring to use when verifying Release file (could be specified multiple times)
|
||||||
-with-sources=false: download source packages in addition to binary packages
|
-with-sources=false: download source packages in addition to binary packages
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ aptly mirror create - create new mirror
|
|||||||
|
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
-architectures="": list of architectures to consider during (comma-separated), default to all available
|
||||||
|
-config="": location of configuration file (default locations are /etc/aptly.conf, ~/.aptly.conf)
|
||||||
|
-dep-follow-all-variants=false: when processing dependencies, follow a & b if depdency is 'a|b'
|
||||||
|
-dep-follow-recommends=false: when processing dependencies, follow Recommends
|
||||||
|
-dep-follow-source=false: when processing dependencies, follow from binary to Source packages
|
||||||
|
-dep-follow-suggests=false: when processing dependencies, follow Suggests
|
||||||
-ignore-signatures=false: disable verification of Release file signatures
|
-ignore-signatures=false: disable verification of Release file signatures
|
||||||
-keyring=: gpg keyring to use when verifying Release file (could be specified multiple times)
|
-keyring=: gpg keyring to use when verifying Release file (could be specified multiple times)
|
||||||
-with-sources=false: download source packages in addition to binary packages
|
-with-sources=false: download source packages in addition to binary packages
|
||||||
|
|||||||
@@ -10,3 +10,11 @@ Commands:
|
|||||||
|
|
||||||
Use "mirror help <command>" for more information about a command.
|
Use "mirror help <command>" for more information about a command.
|
||||||
|
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-architectures="": list of architectures to consider during (comma-separated), default to all available
|
||||||
|
-config="": location of configuration file (default locations are /etc/aptly.conf, ~/.aptly.conf)
|
||||||
|
-dep-follow-all-variants=false: when processing dependencies, follow a & b if depdency is 'a|b'
|
||||||
|
-dep-follow-recommends=false: when processing dependencies, follow Recommends
|
||||||
|
-dep-follow-source=false: when processing dependencies, follow from binary to Source packages
|
||||||
|
-dep-follow-suggests=false: when processing dependencies, follow Suggests
|
||||||
|
|||||||
@@ -10,3 +10,11 @@ Commands:
|
|||||||
|
|
||||||
Use "mirror help <command>" for more information about a command.
|
Use "mirror help <command>" for more information about a command.
|
||||||
|
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-architectures="": list of architectures to consider during (comma-separated), default to all available
|
||||||
|
-config="": location of configuration file (default locations are /etc/aptly.conf, ~/.aptly.conf)
|
||||||
|
-dep-follow-all-variants=false: when processing dependencies, follow a & b if depdency is 'a|b'
|
||||||
|
-dep-follow-recommends=false: when processing dependencies, follow Recommends
|
||||||
|
-dep-follow-source=false: when processing dependencies, follow from binary to Source packages
|
||||||
|
-dep-follow-suggests=false: when processing dependencies, follow Suggests
|
||||||
|
|||||||
Reference in New Issue
Block a user