diff --git a/cmd/publish_repo.go b/cmd/publish_repo.go index f7787dc1..2545d4e0 100644 --- a/cmd/publish_repo.go +++ b/cmd/publish_repo.go @@ -40,6 +40,7 @@ Example: cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG") cmd.Flag.String("origin", "", "origin name to publish") cmd.Flag.String("label", "", "label to publish") + cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch") return cmd } diff --git a/cmd/publish_snapshot.go b/cmd/publish_snapshot.go index d979b01f..c63032fc 100644 --- a/cmd/publish_snapshot.go +++ b/cmd/publish_snapshot.go @@ -130,7 +130,13 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error { return fmt.Errorf("unable to initialize GPG signer: %s", err) } - err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, context.Progress()) + forceOverwrite := context.flags.Lookup("force-overwrite").Value.Get().(bool) + if forceOverwrite { + context.Progress().Printf("WARNING: force overwrite mode enabled, aptly might corrupt other published repositories sharing " + + "the same package pool.") + } + + err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, context.Progress(), forceOverwrite) if err != nil { return fmt.Errorf("unable to publish: %s", err) } @@ -196,6 +202,7 @@ Example: cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG") cmd.Flag.String("origin", "", "origin name to publish") cmd.Flag.String("label", "", "label to publish") + cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch") return cmd } diff --git a/cmd/publish_switch.go b/cmd/publish_switch.go index dcf684e0..1669ee1a 100644 --- a/cmd/publish_switch.go +++ b/cmd/publish_switch.go @@ -79,7 +79,13 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error { return fmt.Errorf("unable to initialize GPG signer: %s", err) } - err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, context.Progress()) + forceOverwrite := context.flags.Lookup("force-overwrite").Value.Get().(bool) + if forceOverwrite { + context.Progress().Printf("WARNING: force overwrite mode enabled, aptly might corrupt other published repositories sharing " + + "the same package pool.") + } + + err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, context.Progress(), forceOverwrite) if err != nil { return fmt.Errorf("unable to publish: %s", err) } @@ -127,6 +133,7 @@ Example: 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.String("component", "", "component names to update (for multi-component publishing, separate components with commas)") + cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch") return cmd } diff --git a/cmd/publish_update.go b/cmd/publish_update.go index 4ea05636..0a0bf9f0 100644 --- a/cmd/publish_update.go +++ b/cmd/publish_update.go @@ -48,7 +48,13 @@ func aptlyPublishUpdate(cmd *commander.Command, args []string) error { return fmt.Errorf("unable to initialize GPG signer: %s", err) } - err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, context.Progress()) + forceOverwrite := context.flags.Lookup("force-overwrite").Value.Get().(bool) + if forceOverwrite { + context.Progress().Printf("WARNING: force overwrite mode enabled, aptly might corrupt other published repositories sharing " + + "the same package pool.") + } + + err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, context.Progress(), forceOverwrite) if err != nil { return fmt.Errorf("unable to publish: %s", err) } @@ -93,6 +99,7 @@ Example: 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.Bool("skip-signing", false, "don't sign Release files with GPG") + cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch") return cmd }