mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
committed by
André Roth
parent
9dffe791ad
commit
d87d8bac92
+41
-35
@@ -113,7 +113,7 @@ func apiPublishList(c *gin.Context) {
|
|||||||
func apiPublishShow(c *gin.Context) {
|
func apiPublishShow(c *gin.Context) {
|
||||||
param := slashEscape(c.Params.ByName("prefix"))
|
param := slashEscape(c.Params.ByName("prefix"))
|
||||||
storage, prefix := deb.ParsePrefix(param)
|
storage, prefix := deb.ParsePrefix(param)
|
||||||
distribution := parseEscapedPath(c.Params.ByName("distribution"))
|
distribution := slashEscape(c.Params.ByName("distribution"))
|
||||||
|
|
||||||
collectionFactory := context.NewCollectionFactory()
|
collectionFactory := context.NewCollectionFactory()
|
||||||
collection := collectionFactory.PublishedRepoCollection()
|
collection := collectionFactory.PublishedRepoCollection()
|
||||||
@@ -179,7 +179,7 @@ type publishedRepoCreateParams struct {
|
|||||||
// @Failure 500 {object} Error "Internal Error"
|
// @Failure 500 {object} Error "Internal Error"
|
||||||
// @Router /api/publish/{prefix} [post]
|
// @Router /api/publish/{prefix} [post]
|
||||||
func apiPublishRepoOrSnapshot(c *gin.Context) {
|
func apiPublishRepoOrSnapshot(c *gin.Context) {
|
||||||
param := parseEscapedPath(c.Params.ByName("prefix"))
|
param := slashEscape(c.Params.ByName("prefix"))
|
||||||
storage, prefix := deb.ParsePrefix(param)
|
storage, prefix := deb.ParsePrefix(param)
|
||||||
|
|
||||||
var b publishedRepoCreateParams
|
var b publishedRepoCreateParams
|
||||||
@@ -196,7 +196,7 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(b.Sources) == 0 {
|
if len(b.Sources) == 0 {
|
||||||
AbortWithJSONError(c, http.StatusBadRequest, fmt.Errorf("unable to publish: soures are empty"))
|
AbortWithJSONError(c, http.StatusBadRequest, fmt.Errorf("unable to publish: sources are empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,7 +353,7 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
|
|||||||
func apiPublishUpdateSwitch(c *gin.Context) {
|
func apiPublishUpdateSwitch(c *gin.Context) {
|
||||||
param := slashEscape(c.Params.ByName("prefix"))
|
param := slashEscape(c.Params.ByName("prefix"))
|
||||||
storage, prefix := deb.ParsePrefix(param)
|
storage, prefix := deb.ParsePrefix(param)
|
||||||
distribution := utils.SanitizePath(c.Params.ByName("distribution"))
|
distribution := slashEscape(c.Params.ByName("distribution"))
|
||||||
|
|
||||||
var b struct {
|
var b struct {
|
||||||
ForceOverwrite bool
|
ForceOverwrite bool
|
||||||
@@ -483,24 +483,19 @@ func apiPublishUpdateSwitch(c *gin.Context) {
|
|||||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to save to DB: %s", err)
|
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to save to DB: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
updatedComponents := result.UpdatedComponents()
|
|
||||||
removedComponents := result.RemovedComponents()
|
|
||||||
|
|
||||||
if b.SkipCleanup == nil || !*b.SkipCleanup {
|
if b.SkipCleanup == nil || !*b.SkipCleanup {
|
||||||
publishedStorage := context.GetPublishedStorage(storage)
|
publishedStorage := context.GetPublishedStorage(storage)
|
||||||
|
|
||||||
err = collection.CleanupPrefixComponentFiles(published.Prefix, updatedComponents, publishedStorage, collectionFactory, out)
|
err = collection.CleanupPrefixComponentFiles(published.Prefix, result.UpdatedComponents(), publishedStorage, collectionFactory, out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err)
|
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(removedComponents) > 0 {
|
// Cleanup files belonging to a removed component by dropping the component directory from the storage backend.
|
||||||
// Cleanup files belonging to a removed component by dropping the component directory from the storage backend.
|
for _, component := range result.RemovedComponents() {
|
||||||
for _, component := range removedComponents {
|
err = publishedStorage.RemoveDirs(filepath.Join(prefix, "dists", distribution, component), out)
|
||||||
err = publishedStorage.RemoveDirs(filepath.Join(prefix, "dists", distribution, component), out)
|
if err != nil {
|
||||||
if err != nil {
|
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err)
|
||||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -529,7 +524,7 @@ func apiPublishDrop(c *gin.Context) {
|
|||||||
|
|
||||||
param := slashEscape(c.Params.ByName("prefix"))
|
param := slashEscape(c.Params.ByName("prefix"))
|
||||||
storage, prefix := deb.ParsePrefix(param)
|
storage, prefix := deb.ParsePrefix(param)
|
||||||
distribution := parseEscapedPath(c.Params.ByName("distribution"))
|
distribution := slashEscape(c.Params.ByName("distribution"))
|
||||||
|
|
||||||
collectionFactory := context.NewCollectionFactory()
|
collectionFactory := context.NewCollectionFactory()
|
||||||
collection := collectionFactory.PublishedRepoCollection()
|
collection := collectionFactory.PublishedRepoCollection()
|
||||||
@@ -560,9 +555,9 @@ func apiPublishSourcesCreate(c *gin.Context) {
|
|||||||
b sourceParams
|
b sourceParams
|
||||||
)
|
)
|
||||||
|
|
||||||
param := parseEscapedPath(c.Params.ByName("prefix"))
|
param := slashEscape(c.Params.ByName("prefix"))
|
||||||
storage, prefix := deb.ParsePrefix(param)
|
storage, prefix := deb.ParsePrefix(param)
|
||||||
distribution := parseEscapedPath(c.Params.ByName("distribution"))
|
distribution := slashEscape(c.Params.ByName("distribution"))
|
||||||
|
|
||||||
collectionFactory := context.NewCollectionFactory()
|
collectionFactory := context.NewCollectionFactory()
|
||||||
collection := collectionFactory.PublishedRepoCollection()
|
collection := collectionFactory.PublishedRepoCollection()
|
||||||
@@ -605,15 +600,15 @@ func apiPublishSourcesCreate(c *gin.Context) {
|
|||||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to save to DB: %s", err)
|
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to save to DB: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &task.ProcessReturnValue{Code: http.StatusOK, Value: published}, nil
|
return &task.ProcessReturnValue{Code: http.StatusCreated, Value: published}, nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Router /api/publish/{prefix}/{distribution}/sources [get]
|
// @Router /api/publish/{prefix}/{distribution}/sources [get]
|
||||||
func apiPublishSourcesList(c *gin.Context) {
|
func apiPublishSourcesList(c *gin.Context) {
|
||||||
param := parseEscapedPath(c.Params.ByName("prefix"))
|
param := slashEscape(c.Params.ByName("prefix"))
|
||||||
storage, prefix := deb.ParsePrefix(param)
|
storage, prefix := deb.ParsePrefix(param)
|
||||||
distribution := parseEscapedPath(c.Params.ByName("distribution"))
|
distribution := slashEscape(c.Params.ByName("distribution"))
|
||||||
|
|
||||||
collectionFactory := context.NewCollectionFactory()
|
collectionFactory := context.NewCollectionFactory()
|
||||||
collection := collectionFactory.PublishedRepoCollection()
|
collection := collectionFactory.PublishedRepoCollection()
|
||||||
@@ -646,9 +641,9 @@ func apiPublishSourcesUpdate(c *gin.Context) {
|
|||||||
b []sourceParams
|
b []sourceParams
|
||||||
)
|
)
|
||||||
|
|
||||||
param := parseEscapedPath(c.Params.ByName("prefix"))
|
param := slashEscape(c.Params.ByName("prefix"))
|
||||||
storage, prefix := deb.ParsePrefix(param)
|
storage, prefix := deb.ParsePrefix(param)
|
||||||
distribution := parseEscapedPath(c.Params.ByName("distribution"))
|
distribution := slashEscape(c.Params.ByName("distribution"))
|
||||||
|
|
||||||
collectionFactory := context.NewCollectionFactory()
|
collectionFactory := context.NewCollectionFactory()
|
||||||
collection := collectionFactory.PublishedRepoCollection()
|
collection := collectionFactory.PublishedRepoCollection()
|
||||||
@@ -693,26 +688,37 @@ func apiPublishSourcesUpdate(c *gin.Context) {
|
|||||||
|
|
||||||
// @Router /api/publish/{prefix}/{distribution}/sources [delete]
|
// @Router /api/publish/{prefix}/{distribution}/sources [delete]
|
||||||
func apiPublishSourcesDelete(c *gin.Context) {
|
func apiPublishSourcesDelete(c *gin.Context) {
|
||||||
param := parseEscapedPath(c.Params.ByName("prefix"))
|
param := slashEscape(c.Params.ByName("prefix"))
|
||||||
storage, prefix := deb.ParsePrefix(param)
|
storage, prefix := deb.ParsePrefix(param)
|
||||||
distribution := parseEscapedPath(c.Params.ByName("distribution"))
|
distribution := slashEscape(c.Params.ByName("distribution"))
|
||||||
|
|
||||||
collectionFactory := context.NewCollectionFactory()
|
collectionFactory := context.NewCollectionFactory()
|
||||||
collection := collectionFactory.PublishedRepoCollection()
|
collection := collectionFactory.PublishedRepoCollection()
|
||||||
|
|
||||||
published, err := collection.ByStoragePrefixDistribution(storage, prefix, distribution)
|
published, err := collection.ByStoragePrefixDistribution(storage, prefix, distribution)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
AbortWithJSONError(c, http.StatusNotFound, fmt.Errorf("unable to show: %s", err))
|
AbortWithJSONError(c, http.StatusNotFound, fmt.Errorf("unable to delete: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.LoadComplete(published, collectionFactory)
|
err = collection.LoadComplete(published, collectionFactory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
AbortWithJSONError(c, http.StatusInternalServerError, fmt.Errorf("unable to show: %s", err))
|
AbortWithJSONError(c, http.StatusInternalServerError, fmt.Errorf("unable to delete: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
published.DropRevision()
|
published.DropRevision()
|
||||||
|
|
||||||
|
resources := []string{string(published.Key())}
|
||||||
|
taskName := fmt.Sprintf("Update published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution)
|
||||||
|
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
|
||||||
|
err = collection.Update(published)
|
||||||
|
if err != nil {
|
||||||
|
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to save to DB: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &task.ProcessReturnValue{Code: http.StatusOK, Value: published}, nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Router /api/publish/{prefix}/{distribution}/sources/{component} [put]
|
// @Router /api/publish/{prefix}/{distribution}/sources/{component} [put]
|
||||||
@@ -722,10 +728,10 @@ func apiPublishSourceUpdate(c *gin.Context) {
|
|||||||
b sourceParams
|
b sourceParams
|
||||||
)
|
)
|
||||||
|
|
||||||
param := parseEscapedPath(c.Params.ByName("prefix"))
|
param := slashEscape(c.Params.ByName("prefix"))
|
||||||
storage, prefix := deb.ParsePrefix(param)
|
storage, prefix := deb.ParsePrefix(param)
|
||||||
distribution := parseEscapedPath(c.Params.ByName("distribution"))
|
distribution := slashEscape(c.Params.ByName("distribution"))
|
||||||
component := parseEscapedPath(c.Params.ByName("component"))
|
component := slashEscape(c.Params.ByName("component"))
|
||||||
|
|
||||||
collectionFactory := context.NewCollectionFactory()
|
collectionFactory := context.NewCollectionFactory()
|
||||||
collection := collectionFactory.PublishedRepoCollection()
|
collection := collectionFactory.PublishedRepoCollection()
|
||||||
@@ -782,10 +788,10 @@ func apiPublishSourceUpdate(c *gin.Context) {
|
|||||||
func apiPublishSourceDelete(c *gin.Context) {
|
func apiPublishSourceDelete(c *gin.Context) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
param := parseEscapedPath(c.Params.ByName("prefix"))
|
param := slashEscape(c.Params.ByName("prefix"))
|
||||||
storage, prefix := deb.ParsePrefix(param)
|
storage, prefix := deb.ParsePrefix(param)
|
||||||
distribution := parseEscapedPath(c.Params.ByName("distribution"))
|
distribution := slashEscape(c.Params.ByName("distribution"))
|
||||||
component := parseEscapedPath(c.Params.ByName("component"))
|
component := slashEscape(c.Params.ByName("component"))
|
||||||
|
|
||||||
collectionFactory := context.NewCollectionFactory()
|
collectionFactory := context.NewCollectionFactory()
|
||||||
collection := collectionFactory.PublishedRepoCollection()
|
collection := collectionFactory.PublishedRepoCollection()
|
||||||
@@ -821,9 +827,9 @@ func apiPublishSourceDelete(c *gin.Context) {
|
|||||||
|
|
||||||
// @Router /api/publish/{prefix}/{distribution}/update [post]
|
// @Router /api/publish/{prefix}/{distribution}/update [post]
|
||||||
func apiPublishUpdate(c *gin.Context) {
|
func apiPublishUpdate(c *gin.Context) {
|
||||||
param := parseEscapedPath(c.Params.ByName("prefix"))
|
param := slashEscape(c.Params.ByName("prefix"))
|
||||||
storage, prefix := deb.ParsePrefix(param)
|
storage, prefix := deb.ParsePrefix(param)
|
||||||
distribution := parseEscapedPath(c.Params.ByName("distribution"))
|
distribution := slashEscape(c.Params.ByName("distribution"))
|
||||||
|
|
||||||
var b struct {
|
var b struct {
|
||||||
AcquireByHash *bool
|
AcquireByHash *bool
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ func aptlyPublishSourceAdd(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to save to DB: %s", err)
|
return fmt.Errorf("unable to save to DB: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.Progress().Printf("\nYou can run 'aptly publish update %s %s' to update the content of the published repository.\n",
|
||||||
|
distribution, published.StoragePrefix())
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,9 +66,9 @@ func makeCmdPublishSourceAdd() *commander.Command {
|
|||||||
cmd := &commander.Command{
|
cmd := &commander.Command{
|
||||||
Run: aptlyPublishSourceAdd,
|
Run: aptlyPublishSourceAdd,
|
||||||
UsageLine: "add <distribution> <source>",
|
UsageLine: "add <distribution> <source>",
|
||||||
Short: "add package source to published repository",
|
Short: "add source to staged source list of published repository",
|
||||||
Long: `
|
Long: `
|
||||||
The command adds (in place) one or multiple package sources to a published repository.
|
The command adds sources to the staged source list of the published repository.
|
||||||
|
|
||||||
The flag -component is mandatory. Use a comma-separated list of components, if
|
The flag -component is mandatory. Use a comma-separated list of components, if
|
||||||
multiple components should be modified. The number of given components must be
|
multiple components should be modified. The number of given components must be
|
||||||
|
|||||||
@@ -45,13 +45,13 @@ func makeCmdPublishSourceDrop() *commander.Command {
|
|||||||
cmd := &commander.Command{
|
cmd := &commander.Command{
|
||||||
Run: aptlyPublishSourceDrop,
|
Run: aptlyPublishSourceDrop,
|
||||||
UsageLine: "drop <distribution>",
|
UsageLine: "drop <distribution>",
|
||||||
Short: "drops revision of published repository",
|
Short: "drops staged source changes of published repository",
|
||||||
Long: `
|
Long: `
|
||||||
Command drops revision of a published repository.
|
Command drops the staged source changes of the published repository.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
$ aptly publish revision drop wheezy
|
$ aptly publish source drop wheezy
|
||||||
`,
|
`,
|
||||||
Flag: *flag.NewFlagSet("aptly-publish-revision-create", flag.ExitOnError),
|
Flag: *flag.NewFlagSet("aptly-publish-revision-create", flag.ExitOnError),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func aptlyPublishSourceRemove(cmd *commander.Command, args []string) error {
|
|||||||
for _, component := range components {
|
for _, component := range components {
|
||||||
name, exists := sources[component]
|
name, exists := sources[component]
|
||||||
if !exists {
|
if !exists {
|
||||||
return fmt.Errorf("unable to remove: Component %q is not part of revision", component)
|
return fmt.Errorf("unable to remove: component %q does not exist", component)
|
||||||
}
|
}
|
||||||
context.Progress().Printf("Removing component %q with source %q [%s]...\n", component, name, published.SourceKind)
|
context.Progress().Printf("Removing component %q with source %q [%s]...\n", component, name, published.SourceKind)
|
||||||
|
|
||||||
@@ -54,6 +54,9 @@ func aptlyPublishSourceRemove(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to save to DB: %s", err)
|
return fmt.Errorf("unable to save to DB: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.Progress().Printf("\nYou can run 'aptly publish update %s %s' to update the content of the published repository.\n",
|
||||||
|
distribution, published.StoragePrefix())
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,9 +64,9 @@ func makeCmdPublishSourceRemove() *commander.Command {
|
|||||||
cmd := &commander.Command{
|
cmd := &commander.Command{
|
||||||
Run: aptlyPublishSourceRemove,
|
Run: aptlyPublishSourceRemove,
|
||||||
UsageLine: "remove <distribution> [[<endpoint>:]<prefix>] <source>",
|
UsageLine: "remove <distribution> [[<endpoint>:]<prefix>] <source>",
|
||||||
Short: "remove package source to published repository",
|
Short: "remove source from staged source list of published repository",
|
||||||
Long: `
|
Long: `
|
||||||
The command removes one or multiple components from a published repository.
|
The command removes sources from the staged source list of the published repository.
|
||||||
|
|
||||||
The flag -component is mandatory. Use a comma-separated list of components, if
|
The flag -component is mandatory. Use a comma-separated list of components, if
|
||||||
multiple components should be removed, e.g.:
|
multiple components should be removed, e.g.:
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ func aptlyPublishSourceUpdate(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to save to DB: %s", err)
|
return fmt.Errorf("unable to save to DB: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.Progress().Printf("\nYou can run 'aptly publish update %s %s' to update the content of the published repository.\n",
|
||||||
|
distribution, published.StoragePrefix())
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,9 +66,9 @@ func makeCmdPublishSourceUpdate() *commander.Command {
|
|||||||
cmd := &commander.Command{
|
cmd := &commander.Command{
|
||||||
Run: aptlyPublishSourceUpdate,
|
Run: aptlyPublishSourceUpdate,
|
||||||
UsageLine: "update <distribution> <source>",
|
UsageLine: "update <distribution> <source>",
|
||||||
Short: "update package source to published repository",
|
Short: "update source in staged source list of published repository",
|
||||||
Long: `
|
Long: `
|
||||||
The command updates one or multiple components in a published repository.
|
The command updates sources in the staged source list of the published repository.
|
||||||
|
|
||||||
The flag -component is mandatory. Use a comma-separated list of components, if
|
The flag -component is mandatory. Use a comma-separated list of components, if
|
||||||
multiple components should be modified. The number of given components must be
|
multiple components should be modified. The number of given components must be
|
||||||
|
|||||||
+18
-37
@@ -43,6 +43,10 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to switch: %s", err)
|
return fmt.Errorf("unable to switch: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if published.SourceKind != deb.SourceSnapshot {
|
||||||
|
return fmt.Errorf("unable to switch: not a published snapshot repository")
|
||||||
|
}
|
||||||
|
|
||||||
err = collectionFactory.PublishedRepoCollection().LoadComplete(published, collectionFactory)
|
err = collectionFactory.PublishedRepoCollection().LoadComplete(published, collectionFactory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to switch: %s", err)
|
return fmt.Errorf("unable to switch: %s", err)
|
||||||
@@ -57,46 +61,23 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("mismatch in number of components (%d) and snapshots (%d)", len(components), len(names))
|
return fmt.Errorf("mismatch in number of components (%d) and snapshots (%d)", len(components), len(names))
|
||||||
}
|
}
|
||||||
|
|
||||||
if published.SourceKind == deb.SourceLocalRepo {
|
snapshotCollection := collectionFactory.SnapshotCollection()
|
||||||
localRepoCollection := collectionFactory.LocalRepoCollection()
|
for i, component := range components {
|
||||||
for i, component := range components {
|
if !utils.StrSliceHasItem(publishedComponents, component) {
|
||||||
if !utils.StrSliceHasItem(publishedComponents, component) {
|
return fmt.Errorf("unable to switch: component %s does not exist in published repository", component)
|
||||||
return fmt.Errorf("unable to switch: component %s does not exist in published repository", component)
|
|
||||||
}
|
|
||||||
|
|
||||||
localRepo, err := localRepoCollection.ByName(names[i])
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("unable to switch: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = localRepoCollection.LoadComplete(localRepo)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("unable to switch: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
published.UpdateLocalRepo(component, localRepo)
|
|
||||||
}
|
}
|
||||||
} else if published.SourceKind == deb.SourceSnapshot {
|
|
||||||
snapshotCollection := collectionFactory.SnapshotCollection()
|
|
||||||
for i, component := range components {
|
|
||||||
if !utils.StrSliceHasItem(publishedComponents, component) {
|
|
||||||
return fmt.Errorf("unable to switch: component %s does not exist in published repository", component)
|
|
||||||
}
|
|
||||||
|
|
||||||
snapshot, err := snapshotCollection.ByName(names[i])
|
snapshot, err := snapshotCollection.ByName(names[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to switch: %s", err)
|
return fmt.Errorf("unable to switch: %s", err)
|
||||||
}
|
|
||||||
|
|
||||||
err = snapshotCollection.LoadComplete(snapshot)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("unable to switch: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
published.UpdateSnapshot(component, snapshot)
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return fmt.Errorf("unknown published repository type")
|
err = snapshotCollection.LoadComplete(snapshot)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to switch: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
published.UpdateSnapshot(component, snapshot)
|
||||||
}
|
}
|
||||||
|
|
||||||
signer, err := getSigner(context.Flags())
|
signer, err := getSigner(context.Flags())
|
||||||
|
|||||||
+11
-1
@@ -2,6 +2,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/aptly-dev/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
@@ -76,11 +77,20 @@ func aptlyPublishUpdate(cmd *commander.Command, args []string) error {
|
|||||||
|
|
||||||
skipCleanup := context.Flags().Lookup("skip-cleanup").Value.Get().(bool)
|
skipCleanup := context.Flags().Lookup("skip-cleanup").Value.Get().(bool)
|
||||||
if !skipCleanup {
|
if !skipCleanup {
|
||||||
|
publishedStorage := context.GetPublishedStorage(storage)
|
||||||
err = collectionFactory.PublishedRepoCollection().CleanupPrefixComponentFiles(published.Prefix, result.UpdatedComponents(),
|
err = collectionFactory.PublishedRepoCollection().CleanupPrefixComponentFiles(published.Prefix, result.UpdatedComponents(),
|
||||||
context.GetPublishedStorage(storage), collectionFactory, context.Progress())
|
publishedStorage, collectionFactory, context.Progress())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to update: %s", err)
|
return fmt.Errorf("unable to update: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cleanup files belonging to a removed component by dropping the component directory from the storage backend.
|
||||||
|
for _, component := range result.RemovedComponents() {
|
||||||
|
err = publishedStorage.RemoveDirs(filepath.Join(prefix, "dists", distribution, component), context.Progress())
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to update: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Progress().Printf("\nPublished %s repository %s has been successfully updated.\n", published.SourceKind, published.String())
|
context.Progress().Printf("\nPublished %s repository %s has been successfully updated.\n", published.SourceKind, published.String())
|
||||||
|
|||||||
+68
-59
@@ -194,69 +194,78 @@ func (p *PublishedRepo) Update(collectionFactory *CollectionFactory, _ aptly.Pro
|
|||||||
RemovedSources: map[string]string{},
|
RemovedSources: map[string]string{},
|
||||||
}
|
}
|
||||||
|
|
||||||
revision := p.ObtainRevision()
|
revision := p.DropRevision()
|
||||||
p.DropRevision()
|
if revision == nil {
|
||||||
|
if p.SourceKind == SourceLocalRepo {
|
||||||
publishedComponents := p.Components()
|
// Re-fetch packages from local repository
|
||||||
|
for component, item := range p.sourceItems {
|
||||||
for _, component := range publishedComponents {
|
localRepo := item.localRepo
|
||||||
name, exists := revision.Sources[component]
|
if localRepo != nil {
|
||||||
if !exists {
|
p.UpdateLocalRepo(component, localRepo)
|
||||||
p.RemoveComponent(component)
|
result.UpdatedSources[component] = localRepo.Name
|
||||||
result.RemovedSources[component] = name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.SourceKind == SourceLocalRepo {
|
|
||||||
localRepoCollection := collectionFactory.LocalRepoCollection()
|
|
||||||
for component, name := range revision.Sources {
|
|
||||||
localRepo, err := localRepoCollection.ByName(name)
|
|
||||||
if err != nil {
|
|
||||||
return result, fmt.Errorf("unable to update: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = localRepoCollection.LoadComplete(localRepo)
|
|
||||||
if err != nil {
|
|
||||||
return result, fmt.Errorf("unable to update: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, exists := p.Sources[component]
|
|
||||||
if exists {
|
|
||||||
// Even in the case, when the local repository has not been changed as package source,
|
|
||||||
// it may contain a modified set of packages that requires (re-)publication.
|
|
||||||
p.UpdateLocalRepo(component, localRepo)
|
|
||||||
result.UpdatedSources[component] = name
|
|
||||||
} else {
|
|
||||||
p.UpdateLocalRepo(component, localRepo)
|
|
||||||
result.AddedSources[component] = name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if p.SourceKind == SourceSnapshot {
|
|
||||||
snapshotCollection := collectionFactory.SnapshotCollection()
|
|
||||||
for component, name := range revision.Sources {
|
|
||||||
snapshot, err := snapshotCollection.ByName(name)
|
|
||||||
if err != nil {
|
|
||||||
return result, fmt.Errorf("unable to update: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = snapshotCollection.LoadComplete(snapshot)
|
|
||||||
if err != nil {
|
|
||||||
return result, fmt.Errorf("unable to update: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceUUID, exists := p.Sources[component]
|
|
||||||
if exists {
|
|
||||||
if snapshot.UUID != sourceUUID {
|
|
||||||
p.UpdateSnapshot(component, snapshot)
|
|
||||||
result.UpdatedSources[component] = name
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
p.UpdateSnapshot(component, snapshot)
|
|
||||||
result.AddedSources[component] = name
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return result, fmt.Errorf("unknown published repository type")
|
for _, component := range p.Components() {
|
||||||
|
name, exists := revision.Sources[component]
|
||||||
|
if !exists {
|
||||||
|
p.RemoveComponent(component)
|
||||||
|
result.RemovedSources[component] = name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.SourceKind == SourceLocalRepo {
|
||||||
|
localRepoCollection := collectionFactory.LocalRepoCollection()
|
||||||
|
for component, name := range revision.Sources {
|
||||||
|
localRepo, err := localRepoCollection.ByName(name)
|
||||||
|
if err != nil {
|
||||||
|
return result, fmt.Errorf("unable to update: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = localRepoCollection.LoadComplete(localRepo)
|
||||||
|
if err != nil {
|
||||||
|
return result, fmt.Errorf("unable to update: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, exists := p.Sources[component]
|
||||||
|
if exists {
|
||||||
|
// Even in the case, when the local repository has not been changed as package source,
|
||||||
|
// it may contain a modified set of packages that requires (re-)publication.
|
||||||
|
p.UpdateLocalRepo(component, localRepo)
|
||||||
|
result.UpdatedSources[component] = name
|
||||||
|
} else {
|
||||||
|
p.UpdateLocalRepo(component, localRepo)
|
||||||
|
result.AddedSources[component] = name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if p.SourceKind == SourceSnapshot {
|
||||||
|
snapshotCollection := collectionFactory.SnapshotCollection()
|
||||||
|
for component, name := range revision.Sources {
|
||||||
|
snapshot, err := snapshotCollection.ByName(name)
|
||||||
|
if err != nil {
|
||||||
|
return result, fmt.Errorf("unable to update: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = snapshotCollection.LoadComplete(snapshot)
|
||||||
|
if err != nil {
|
||||||
|
return result, fmt.Errorf("unable to update: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceUUID, exists := p.Sources[component]
|
||||||
|
if exists {
|
||||||
|
if snapshot.UUID != sourceUUID {
|
||||||
|
p.UpdateSnapshot(component, snapshot)
|
||||||
|
result.UpdatedSources[component] = name
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p.UpdateSnapshot(component, snapshot)
|
||||||
|
result.AddedSources[component] = name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return result, fmt.Errorf("unknown published repository type")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
Test
|
Adding component "test" with source "snap2" [snapshot]...
|
||||||
|
|
||||||
|
You can run 'aptly publish update maverick .' to update the content of the published repository.
|
||||||
|
|||||||
@@ -1 +1,4 @@
|
|||||||
Test
|
Adding component "test" with source "snap2" [snapshot]...
|
||||||
|
Adding component "other-test" with source "snap3" [snapshot]...
|
||||||
|
|
||||||
|
You can run 'aptly publish update maverick .' to update the content of the published repository.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
Test
|
ERROR: unable to add: component "main" has already been added
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
Test
|
Source changes have been removed successfully.
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
Test
|
Sources:
|
||||||
|
main: snap1 [snapshot]
|
||||||
|
test: snap2 [snapshot]
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"Component": "main",
|
||||||
|
"Name": "snap1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Component": "test",
|
||||||
|
"Name": "snap2"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ERROR: unable to list: no source changes exist
|
||||||
@@ -1 +1,3 @@
|
|||||||
Test
|
Removing component "test" with source "snap2" [snapshot]...
|
||||||
|
|
||||||
|
You can run 'aptly publish update maverick .' to update the content of the published repository.
|
||||||
|
|||||||
@@ -1 +1,4 @@
|
|||||||
Test
|
Removing component "test" with source "snap2" [snapshot]...
|
||||||
|
Removing component "other-test" with source "snap3" [snapshot]...
|
||||||
|
|
||||||
|
You can run 'aptly publish update maverick .' to update the content of the published repository.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
Test
|
ERROR: unable to remove: component "not-existent" does not exist
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
Test
|
Updating component "main" with source "snap2" [snapshot]...
|
||||||
|
|
||||||
|
You can run 'aptly publish update maverick .' to update the content of the published repository.
|
||||||
|
|||||||
@@ -1 +1,4 @@
|
|||||||
Test
|
Updating component "main" with source "snap2" [snapshot]...
|
||||||
|
Updating component "test" with source "snap3" [snapshot]...
|
||||||
|
|
||||||
|
You can run 'aptly publish update maverick .' to update the content of the published repository.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
Test
|
ERROR: unable to update: component "not-existent" does not exist
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
ERROR: unable to switch: local repo with name snap1 not found
|
ERROR: unable to switch: not a published snapshot repository
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
Loading packages...
|
||||||
|
Generating metadata files and linking package files...
|
||||||
|
Finalizing metadata files...
|
||||||
|
Signing file 'Release' with gpg, please enter your passphrase when prompted:
|
||||||
|
Clearsigning file 'Release' with gpg, please enter your passphrase when prompted:
|
||||||
|
Cleaning up prefix "." components ...
|
||||||
|
|
||||||
|
Published snapshot repository ./maverick (origin: LP-PPA-gladky-anton-gnuplot) [i386] publishes {main: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick}, {other-test: [snap3]: Created as empty}, {test: [snap2]: Created as empty} has been successfully updated.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
Loading packages...
|
||||||
|
Generating metadata files and linking package files...
|
||||||
|
Finalizing metadata files...
|
||||||
|
Signing file 'Release' with gpg, please enter your passphrase when prompted:
|
||||||
|
Clearsigning file 'Release' with gpg, please enter your passphrase when prompted:
|
||||||
|
Cleaning up prefix "." components ...
|
||||||
|
|
||||||
|
Published snapshot repository ./maverick [i386] publishes {main: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick} has been successfully updated.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
Loading packages...
|
||||||
|
Generating metadata files and linking package files...
|
||||||
|
Finalizing metadata files...
|
||||||
|
Signing file 'Release' with gpg, please enter your passphrase when prompted:
|
||||||
|
Clearsigning file 'Release' with gpg, please enter your passphrase when prompted:
|
||||||
|
Cleaning up prefix "." components other-test, test...
|
||||||
|
|
||||||
|
Published snapshot repository ./maverick [i386] publishes {main: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick}, {other-test: [snap5]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick}, {test: [snap4]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick} has been successfully updated.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
Loading packages...
|
||||||
|
Generating metadata files and linking package files...
|
||||||
|
Finalizing metadata files...
|
||||||
|
Signing file 'Release' with gpg, please enter your passphrase when prompted:
|
||||||
|
Clearsigning file 'Release' with gpg, please enter your passphrase when prompted:
|
||||||
|
Cleaning up prefix "." components test...
|
||||||
|
|
||||||
|
Published snapshot repository ./maverick [i386] publishes {other-test: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick}, {test: [snap3]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick} has been successfully updated.
|
||||||
@@ -3,4 +3,4 @@ Generating metadata files and linking package files...
|
|||||||
Finalizing metadata files...
|
Finalizing metadata files...
|
||||||
Cleaning up prefix "." components contrib, main...
|
Cleaning up prefix "." components contrib, main...
|
||||||
|
|
||||||
Publish for local repo ./squeeze [i386] publishes {contrib: [repo2]}, {main: [repo1]} has been successfully updated.
|
Published local repository ./squeeze [i386] publishes {contrib: [repo2]}, {main: [repo1]} has been successfully updated.
|
||||||
|
|||||||
@@ -8,32 +8,13 @@ class PublishSourceAdd1Test(BaseTest):
|
|||||||
fixtureDB = True
|
fixtureDB = True
|
||||||
fixturePool = True
|
fixturePool = True
|
||||||
fixtureCmds = [
|
fixtureCmds = [
|
||||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
"aptly snapshot create snap2 from mirror wheezy-contrib",
|
"aptly snapshot create snap2 empty",
|
||||||
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1",
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1",
|
||||||
"aptly publish source add -component=contrib wheezy snap2"
|
|
||||||
]
|
]
|
||||||
runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec"
|
runCmd = "aptly publish source add -component=test maverick snap2"
|
||||||
|
|
||||||
gold_processor = BaseTest.expand_environ
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
def check(self):
|
|
||||||
super(PublishSourceAdd1Test, self).check()
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/binary-i386/Packages')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/binary-i386/Packages.gz')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/binary-i386/Packages.bz2')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/Contents-i386.gz')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/binary-amd64/Packages')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/binary-amd64/Packages.gz')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/binary-amd64/Packages.bz2')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/Contents-amd64.gz')
|
|
||||||
|
|
||||||
release = self.read_file('public/dists/wheezy/Release').split('\n')
|
|
||||||
components = next((e.split(': ')[1] for e in release if e.startswith('Components')), None)
|
|
||||||
components = sorted(components.split(' '))
|
|
||||||
if ['contrib', 'main'] != components:
|
|
||||||
raise Exception("value of 'Components' in release file is '%s' and does not match '%s'." % (' '.join(components), 'contrib main'))
|
|
||||||
|
|
||||||
|
|
||||||
class PublishSourceAdd2Test(BaseTest):
|
class PublishSourceAdd2Test(BaseTest):
|
||||||
"""
|
"""
|
||||||
@@ -42,42 +23,14 @@ class PublishSourceAdd2Test(BaseTest):
|
|||||||
fixtureDB = True
|
fixtureDB = True
|
||||||
fixturePool = True
|
fixturePool = True
|
||||||
fixtureCmds = [
|
fixtureCmds = [
|
||||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
"aptly snapshot create snap2 from mirror wheezy-contrib",
|
"aptly snapshot create snap2 empty",
|
||||||
"aptly snapshot create snap3 from mirror wheezy-non-free",
|
"aptly snapshot create snap3 empty",
|
||||||
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1",
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1",
|
||||||
"aptly publish source add -component=contrib,non-free wheezy snap2 snap3"
|
|
||||||
]
|
]
|
||||||
runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec"
|
runCmd = "aptly publish source add -component=test,other-test maverick snap2 snap3"
|
||||||
|
|
||||||
gold_processor = BaseTest.expand_environ
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
def check(self):
|
|
||||||
super(PublishSourceAdd2Test, self).check()
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/binary-i386/Packages')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/binary-i386/Packages.gz')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/binary-i386/Packages.bz2')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/Contents-i386.gz')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/binary-amd64/Packages')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/binary-amd64/Packages.gz')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/binary-amd64/Packages.bz2')
|
|
||||||
self.check_exists('public/dists/wheezy/contrib/Contents-amd64.gz')
|
|
||||||
|
|
||||||
self.check_exists('public/dists/wheezy/non-free/binary-i386/Packages')
|
|
||||||
self.check_exists('public/dists/wheezy/non-free/binary-i386/Packages.gz')
|
|
||||||
self.check_exists('public/dists/wheezy/non-free/binary-i386/Packages.bz2')
|
|
||||||
self.check_exists('public/dists/wheezy/non-free/Contents-i386.gz')
|
|
||||||
self.check_exists('public/dists/wheezy/non-free/binary-amd64/Packages')
|
|
||||||
self.check_exists('public/dists/wheezy/non-free/binary-amd64/Packages.gz')
|
|
||||||
self.check_exists('public/dists/wheezy/non-free/binary-amd64/Packages.bz2')
|
|
||||||
self.check_exists('public/dists/wheezy/non-free/Contents-amd64.gz')
|
|
||||||
|
|
||||||
release = self.read_file('public/dists/wheezy/Release').split('\n')
|
|
||||||
components = next((e.split(': ')[1] for e in release if e.startswith('Components')), None)
|
|
||||||
components = sorted(components.split(' '))
|
|
||||||
if ['contrib', 'main', 'non-free'] != components:
|
|
||||||
raise Exception("value of 'Components' in release file is '%s' and does not match '%s'." % (' '.join(components), 'contrib main non-free'))
|
|
||||||
|
|
||||||
|
|
||||||
class PublishSourceAdd3Test(BaseTest):
|
class PublishSourceAdd3Test(BaseTest):
|
||||||
"""
|
"""
|
||||||
@@ -86,11 +39,11 @@ class PublishSourceAdd3Test(BaseTest):
|
|||||||
fixtureDB = True
|
fixtureDB = True
|
||||||
fixturePool = True
|
fixturePool = True
|
||||||
fixtureCmds = [
|
fixtureCmds = [
|
||||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
"aptly snapshot create snap2 from mirror gnuplot-maverick",
|
"aptly snapshot create snap2 empty",
|
||||||
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1",
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1",
|
||||||
]
|
]
|
||||||
runCmd = "aptly publish add -component=main wheezy snap2"
|
runCmd = "aptly publish source add -component=main maverick snap2"
|
||||||
expectedCode = 1
|
expectedCode = 1
|
||||||
gold_processor = BaseTest.expand_environ
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
@@ -102,12 +55,44 @@ class PublishSourceList1Test(BaseTest):
|
|||||||
fixtureDB = True
|
fixtureDB = True
|
||||||
fixturePool = True
|
fixturePool = True
|
||||||
fixtureCmds = [
|
fixtureCmds = [
|
||||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
"aptly snapshot create snap2 from mirror wheezy-contrib",
|
"aptly snapshot create snap2 empty",
|
||||||
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1",
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1",
|
||||||
|
"aptly publish source add -component=test maverick snap2",
|
||||||
]
|
]
|
||||||
runCmd = "aptly publish source list"
|
runCmd = "aptly publish source list maverick"
|
||||||
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
|
||||||
|
class PublishSourceList2Test(BaseTest):
|
||||||
|
"""
|
||||||
|
publish source list: show source changes as JSON
|
||||||
|
"""
|
||||||
|
fixtureDB = True
|
||||||
|
fixturePool = True
|
||||||
|
fixtureCmds = [
|
||||||
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
|
"aptly snapshot create snap2 empty",
|
||||||
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1",
|
||||||
|
"aptly publish source add -component=test maverick snap2",
|
||||||
|
]
|
||||||
|
runCmd = "aptly publish source list -json maverick"
|
||||||
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
|
||||||
|
class PublishSourceList3Test(BaseTest):
|
||||||
|
"""
|
||||||
|
publish source list: show source changes (empty)
|
||||||
|
"""
|
||||||
|
fixtureDB = True
|
||||||
|
fixturePool = True
|
||||||
|
fixtureCmds = [
|
||||||
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
|
"aptly snapshot create snap2 empty",
|
||||||
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1",
|
||||||
|
]
|
||||||
|
runCmd = "aptly publish source list maverick"
|
||||||
|
expectedCode = 1
|
||||||
gold_processor = BaseTest.expand_environ
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
|
||||||
@@ -118,12 +103,11 @@ class PublishSourceDrop1Test(BaseTest):
|
|||||||
fixtureDB = True
|
fixtureDB = True
|
||||||
fixturePool = True
|
fixturePool = True
|
||||||
fixtureCmds = [
|
fixtureCmds = [
|
||||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
"aptly snapshot create snap2 from mirror wheezy-contrib",
|
"aptly snapshot create snap2 empty",
|
||||||
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1",
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1",
|
||||||
]
|
]
|
||||||
runCmd = "aptly publish source drop"
|
runCmd = "aptly publish source drop maverick"
|
||||||
|
|
||||||
gold_processor = BaseTest.expand_environ
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
|
||||||
@@ -134,12 +118,11 @@ class PublishSourceUpdate1Test(BaseTest):
|
|||||||
fixtureDB = True
|
fixtureDB = True
|
||||||
fixturePool = True
|
fixturePool = True
|
||||||
fixtureCmds = [
|
fixtureCmds = [
|
||||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
"aptly snapshot create snap2 from mirror gnuplot-maverick",
|
"aptly snapshot create snap2 empty",
|
||||||
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1",
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1",
|
||||||
]
|
]
|
||||||
runCmd = "aptly publish source update -component=main wheezy snap2"
|
runCmd = "aptly publish source update -component=main maverick snap2"
|
||||||
|
|
||||||
gold_processor = BaseTest.expand_environ
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
|
||||||
@@ -150,13 +133,12 @@ class PublishSourceUpdate2Test(BaseTest):
|
|||||||
fixtureDB = True
|
fixtureDB = True
|
||||||
fixturePool = True
|
fixturePool = True
|
||||||
fixtureCmds = [
|
fixtureCmds = [
|
||||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
"aptly snapshot create snap2 from mirror wheezy-main",
|
"aptly snapshot create snap2 empty",
|
||||||
"aptly snapshot create snap3 from mirror gnuplot-maverick",
|
"aptly snapshot create snap3 empty",
|
||||||
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main,test snap1 snap2",
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main,test snap1 snap2",
|
||||||
]
|
]
|
||||||
runCmd = "aptly publish source update -component=main,test wheezy snap2 snap3"
|
runCmd = "aptly publish source update -component=main,test maverick snap2 snap3"
|
||||||
|
|
||||||
gold_processor = BaseTest.expand_environ
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
|
||||||
@@ -167,11 +149,10 @@ class PublishSourceUpdate3Test(BaseTest):
|
|||||||
fixtureDB = True
|
fixtureDB = True
|
||||||
fixturePool = True
|
fixturePool = True
|
||||||
fixtureCmds = [
|
fixtureCmds = [
|
||||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1",
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1",
|
||||||
]
|
]
|
||||||
runCmd = "aptly publish source update -component=not-existent wheezy snap1"
|
runCmd = "aptly publish source update -component=not-existent maverick snap1"
|
||||||
|
|
||||||
gold_processor = BaseTest.expand_environ
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
|
||||||
@@ -182,12 +163,11 @@ class PublishSourceRemove1Test(BaseTest):
|
|||||||
fixtureDB = True
|
fixtureDB = True
|
||||||
fixturePool = True
|
fixturePool = True
|
||||||
fixtureCmds = [
|
fixtureCmds = [
|
||||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
"aptly snapshot create snap2 from mirror wheezy-contrib",
|
"aptly snapshot create snap2 empty",
|
||||||
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main,contrib snap1 snap2",
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main,test snap1 snap2",
|
||||||
]
|
]
|
||||||
runCmd = "aptly publish source remove -component=contrib wheezy"
|
runCmd = "aptly publish source remove -component=test maverick"
|
||||||
|
|
||||||
gold_processor = BaseTest.expand_environ
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
|
||||||
@@ -198,13 +178,12 @@ class PublishSourceRemove2Test(BaseTest):
|
|||||||
fixtureDB = True
|
fixtureDB = True
|
||||||
fixturePool = True
|
fixturePool = True
|
||||||
fixtureCmds = [
|
fixtureCmds = [
|
||||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
"aptly snapshot create snap2 from mirror wheezy-contrib",
|
"aptly snapshot create snap2 empty",
|
||||||
"aptly snapshot create snap3 from mirror wheezy-non-free",
|
"aptly snapshot create snap3 empty",
|
||||||
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main,contrib,non-free snap1 snap2 snap3",
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main,test,other-test snap1 snap2 snap3",
|
||||||
]
|
]
|
||||||
runCmd = "aptly publish source remove -component=contrib,non-free wheezy"
|
runCmd = "aptly publish source remove -component=test,other-test maverick"
|
||||||
|
|
||||||
gold_processor = BaseTest.expand_environ
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
|
||||||
@@ -215,9 +194,9 @@ class PublishSourceRemove3Test(BaseTest):
|
|||||||
fixtureDB = True
|
fixtureDB = True
|
||||||
fixturePool = True
|
fixturePool = True
|
||||||
fixtureCmds = [
|
fixtureCmds = [
|
||||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1",
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1",
|
||||||
]
|
]
|
||||||
runCmd = "aptly publish source remove -component=not-existent wheezy"
|
runCmd = "aptly publish source remove -component=not-existent maverick"
|
||||||
expectedCode = 1
|
expectedCode = 1
|
||||||
gold_processor = BaseTest.expand_environ
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|||||||
+166
-47
@@ -175,39 +175,6 @@ class PublishUpdate3Test(BaseTest):
|
|||||||
self.check_exists('public/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb')
|
self.check_exists('public/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb')
|
||||||
|
|
||||||
|
|
||||||
#class PublishUpdate4Test(BaseTest):
|
|
||||||
# """
|
|
||||||
# publish update: added some packages, but list of published archs doesn't change
|
|
||||||
# """
|
|
||||||
# fixtureCmds = [
|
|
||||||
# "aptly repo create local-repo",
|
|
||||||
# "aptly repo add local-repo ${files}/pyspi_0.6.1-1.3.dsc",
|
|
||||||
# "aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick local-repo",
|
|
||||||
# "aptly repo add local-repo ${files}/libboost-program-options-dev_1.49.0.1_i386.deb"
|
|
||||||
# ]
|
|
||||||
# runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec maverick"
|
|
||||||
# gold_processor = BaseTest.expand_environ
|
|
||||||
#
|
|
||||||
# def check(self):
|
|
||||||
# super(PublishUpdate4Test, self).check()
|
|
||||||
#
|
|
||||||
# self.check_exists('public/dists/maverick/InRelease')
|
|
||||||
# self.check_exists('public/dists/maverick/Release')
|
|
||||||
# self.check_exists('public/dists/maverick/Release.gpg')
|
|
||||||
#
|
|
||||||
# self.check_not_exists('public/dists/maverick/main/binary-i386/Packages')
|
|
||||||
# self.check_not_exists('public/dists/maverick/main/binary-i386/Packages.gz')
|
|
||||||
# self.check_not_exists('public/dists/maverick/main/binary-i386/Packages.bz2')
|
|
||||||
# self.check_exists('public/dists/maverick/main/source/Sources')
|
|
||||||
# self.check_exists('public/dists/maverick/main/source/Sources.gz')
|
|
||||||
# self.check_exists('public/dists/maverick/main/source/Sources.bz2')
|
|
||||||
#
|
|
||||||
# self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.dsc')
|
|
||||||
# self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.diff.gz')
|
|
||||||
# self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1.orig.tar.gz')
|
|
||||||
# self.check_not_exists('public/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb')
|
|
||||||
|
|
||||||
|
|
||||||
class PublishUpdate5Test(BaseTest):
|
class PublishUpdate5Test(BaseTest):
|
||||||
"""
|
"""
|
||||||
publish update: no such publish
|
publish update: no such publish
|
||||||
@@ -216,20 +183,6 @@ class PublishUpdate5Test(BaseTest):
|
|||||||
expectedCode = 1
|
expectedCode = 1
|
||||||
|
|
||||||
|
|
||||||
class PublishUpdate6Test(BaseTest):
|
|
||||||
"""
|
|
||||||
publish update: not a local repo
|
|
||||||
"""
|
|
||||||
fixtureDB = True
|
|
||||||
fixturePool = True
|
|
||||||
fixtureCmds = [
|
|
||||||
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
|
||||||
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec snap1",
|
|
||||||
]
|
|
||||||
runCmd = "aptly publish update maverick"
|
|
||||||
expectedCode = 1
|
|
||||||
|
|
||||||
|
|
||||||
class PublishUpdate7Test(BaseTest):
|
class PublishUpdate7Test(BaseTest):
|
||||||
"""
|
"""
|
||||||
publish update: multiple components, add some packages
|
publish update: multiple components, add some packages
|
||||||
@@ -487,3 +440,169 @@ class PublishUpdate14Test(BaseTest):
|
|||||||
self.check_exists('public/dists/bookworm/main/binary-i386/Packages.gz')
|
self.check_exists('public/dists/bookworm/main/binary-i386/Packages.gz')
|
||||||
|
|
||||||
self.check_exists('public/pool/bookworm/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb')
|
self.check_exists('public/pool/bookworm/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb')
|
||||||
|
|
||||||
|
|
||||||
|
class PublishUpdate15Test(BaseTest):
|
||||||
|
"""
|
||||||
|
publish update: source added
|
||||||
|
"""
|
||||||
|
fixtureDB = True
|
||||||
|
fixturePool = True
|
||||||
|
fixtureCmds = [
|
||||||
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
|
"aptly snapshot create snap2 empty",
|
||||||
|
"aptly snapshot create snap3 empty",
|
||||||
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -architectures=i386 -component=main snap1",
|
||||||
|
"aptly publish source add -component=test,other-test maverick snap2 snap3"
|
||||||
|
]
|
||||||
|
runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec maverick"
|
||||||
|
|
||||||
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
super(PublishUpdate15Test, self).check()
|
||||||
|
self.check_exists('public/dists/maverick/InRelease')
|
||||||
|
self.check_exists('public/dists/maverick/Release')
|
||||||
|
self.check_exists('public/dists/maverick/Release.gpg')
|
||||||
|
|
||||||
|
self.check_exists('public/dists/maverick/main/binary-i386/Packages')
|
||||||
|
self.check_exists('public/dists/maverick/main/binary-i386/Packages.gz')
|
||||||
|
self.check_exists('public/dists/maverick/main/binary-i386/Packages.bz2')
|
||||||
|
|
||||||
|
self.check_exists('public/dists/maverick/test/binary-i386/Packages')
|
||||||
|
self.check_exists('public/dists/maverick/test/binary-i386/Packages.gz')
|
||||||
|
self.check_exists('public/dists/maverick/test/binary-i386/Packages.bz2')
|
||||||
|
|
||||||
|
self.check_exists('public/dists/maverick/other-test/binary-i386/Packages')
|
||||||
|
self.check_exists('public/dists/maverick/other-test/binary-i386/Packages.gz')
|
||||||
|
self.check_exists('public/dists/maverick/other-test/binary-i386/Packages.bz2')
|
||||||
|
|
||||||
|
release = self.read_file('public/dists/maverick/Release').split('\n')
|
||||||
|
components = next((e.split(': ')[1] for e in release if e.startswith('Components')), None)
|
||||||
|
components = sorted(components.split(' '))
|
||||||
|
if ['main', 'other-test', 'test'] != components:
|
||||||
|
raise Exception("value of 'Components' in release file is '%s' and does not match '%s'." % (' '.join(components), 'main other-test test'))
|
||||||
|
|
||||||
|
|
||||||
|
class PublishUpdate16Test(BaseTest):
|
||||||
|
"""
|
||||||
|
publish update: source removed
|
||||||
|
"""
|
||||||
|
fixtureDB = True
|
||||||
|
fixturePool = True
|
||||||
|
fixtureCmds = [
|
||||||
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
|
"aptly snapshot create snap2 empty",
|
||||||
|
"aptly snapshot create snap3 empty",
|
||||||
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -architectures=i386 -component=main,test,other-test snap1 snap2 snap3",
|
||||||
|
"aptly publish source remove -component=test,other-test maverick"
|
||||||
|
]
|
||||||
|
runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec maverick"
|
||||||
|
|
||||||
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
super(PublishUpdate16Test, self).check()
|
||||||
|
self.check_exists('public/dists/maverick/InRelease')
|
||||||
|
self.check_exists('public/dists/maverick/Release')
|
||||||
|
self.check_exists('public/dists/maverick/Release.gpg')
|
||||||
|
|
||||||
|
self.check_exists('public/dists/maverick/main/binary-i386/Packages')
|
||||||
|
self.check_exists('public/dists/maverick/main/binary-i386/Packages.gz')
|
||||||
|
self.check_exists('public/dists/maverick/main/binary-i386/Packages.bz2')
|
||||||
|
self.check_exists('public/dists/maverick/main/Contents-i386.gz')
|
||||||
|
|
||||||
|
release = self.read_file('public/dists/maverick/Release').split('\n')
|
||||||
|
components = next((e.split(': ')[1] for e in release if e.startswith('Components')), None)
|
||||||
|
components = sorted(components.split(' '))
|
||||||
|
if ['main'] != components:
|
||||||
|
raise Exception("value of 'Components' in release file is '%s' and does not match '%s'." % (' '.join(components), 'main'))
|
||||||
|
|
||||||
|
|
||||||
|
class PublishUpdate17Test(BaseTest):
|
||||||
|
"""
|
||||||
|
publish update: source updated
|
||||||
|
"""
|
||||||
|
fixtureDB = True
|
||||||
|
fixturePool = True
|
||||||
|
fixtureCmds = [
|
||||||
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
|
"aptly snapshot create snap2 empty",
|
||||||
|
"aptly snapshot create snap3 empty",
|
||||||
|
"aptly snapshot create snap4 from mirror gnuplot-maverick",
|
||||||
|
"aptly snapshot create snap5 from mirror gnuplot-maverick",
|
||||||
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -architectures=i386 -component=main,test,other-test snap1 snap2 snap3",
|
||||||
|
"aptly publish source update -component=test,other-test maverick snap4 snap5"
|
||||||
|
]
|
||||||
|
runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec maverick"
|
||||||
|
|
||||||
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
super(PublishUpdate17Test, self).check()
|
||||||
|
self.check_exists('public/dists/maverick/InRelease')
|
||||||
|
self.check_exists('public/dists/maverick/Release')
|
||||||
|
self.check_exists('public/dists/maverick/Release.gpg')
|
||||||
|
|
||||||
|
self.check_exists('public/dists/maverick/main/binary-i386/Packages')
|
||||||
|
self.check_exists('public/dists/maverick/main/binary-i386/Packages.gz')
|
||||||
|
self.check_exists('public/dists/maverick/main/binary-i386/Packages.bz2')
|
||||||
|
self.check_exists('public/dists/maverick/main/Contents-i386.gz')
|
||||||
|
|
||||||
|
self.check_exists('public/dists/maverick/test/binary-i386/Packages')
|
||||||
|
self.check_exists('public/dists/maverick/test/binary-i386/Packages.gz')
|
||||||
|
self.check_exists('public/dists/maverick/test/binary-i386/Packages.bz2')
|
||||||
|
self.check_exists('public/dists/maverick/test/Contents-i386.gz')
|
||||||
|
|
||||||
|
self.check_exists('public/dists/maverick/other-test/binary-i386/Packages')
|
||||||
|
self.check_exists('public/dists/maverick/other-test/binary-i386/Packages.gz')
|
||||||
|
self.check_exists('public/dists/maverick/other-test/binary-i386/Packages.bz2')
|
||||||
|
self.check_exists('public/dists/maverick/other-test/Contents-i386.gz')
|
||||||
|
|
||||||
|
release = self.read_file('public/dists/maverick/Release').split('\n')
|
||||||
|
components = next((e.split(': ')[1] for e in release if e.startswith('Components')), None)
|
||||||
|
components = sorted(components.split(' '))
|
||||||
|
if ['main', 'other-test', 'test'] != components:
|
||||||
|
raise Exception("value of 'Components' in release file is '%s' and does not match '%s'." % (' '.join(components), 'main other-test test'))
|
||||||
|
|
||||||
|
|
||||||
|
class PublishUpdate18Test(BaseTest):
|
||||||
|
"""
|
||||||
|
publish update: source added, updated and removed
|
||||||
|
"""
|
||||||
|
fixtureDB = True
|
||||||
|
fixturePool = True
|
||||||
|
fixtureCmds = [
|
||||||
|
"aptly snapshot create snap1 from mirror gnuplot-maverick",
|
||||||
|
"aptly snapshot create snap2 empty",
|
||||||
|
"aptly snapshot create snap3 from mirror gnuplot-maverick",
|
||||||
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -architectures=i386 -component=main,test snap1 snap2",
|
||||||
|
"aptly publish source remove -component=main maverick",
|
||||||
|
"aptly publish source update -component=test maverick snap3",
|
||||||
|
"aptly publish source add -component=other-test maverick snap1"
|
||||||
|
]
|
||||||
|
runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec maverick"
|
||||||
|
|
||||||
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
super(PublishUpdate18Test, self).check()
|
||||||
|
self.check_exists('public/dists/maverick/InRelease')
|
||||||
|
self.check_exists('public/dists/maverick/Release')
|
||||||
|
self.check_exists('public/dists/maverick/Release.gpg')
|
||||||
|
|
||||||
|
self.check_exists('public/dists/maverick/test/binary-i386/Packages')
|
||||||
|
self.check_exists('public/dists/maverick/test/binary-i386/Packages.gz')
|
||||||
|
self.check_exists('public/dists/maverick/test/binary-i386/Packages.bz2')
|
||||||
|
self.check_exists('public/dists/maverick/test/Contents-i386.gz')
|
||||||
|
|
||||||
|
self.check_exists('public/dists/maverick/other-test/binary-i386/Packages')
|
||||||
|
self.check_exists('public/dists/maverick/other-test/binary-i386/Packages.gz')
|
||||||
|
self.check_exists('public/dists/maverick/other-test/binary-i386/Packages.bz2')
|
||||||
|
self.check_exists('public/dists/maverick/other-test/Contents-i386.gz')
|
||||||
|
|
||||||
|
release = self.read_file('public/dists/maverick/Release').split('\n')
|
||||||
|
components = next((e.split(': ')[1] for e in release if e.startswith('Components')), None)
|
||||||
|
components = sorted(components.split(' '))
|
||||||
|
if ['other-test', 'test'] != components:
|
||||||
|
raise Exception("value of 'Components' in release file is '%s' and does not match '%s'." % (' '.join(components), 'other-test test'))
|
||||||
|
|||||||
@@ -905,6 +905,58 @@ class PublishSwitchAPISkipCleanupTestRepo(APITest):
|
|||||||
self.check_exists("public/" + prefix + "/pool/main/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc")
|
self.check_exists("public/" + prefix + "/pool/main/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc")
|
||||||
|
|
||||||
|
|
||||||
|
class PublishShowAPITestRepo(APITest):
|
||||||
|
"""
|
||||||
|
GET /publish/:prefix/:distribution
|
||||||
|
"""
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
repo1_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(
|
||||||
|
self.upload("/api/files/" + d,
|
||||||
|
"pyspi_0.6.1-1.3.dsc",
|
||||||
|
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
|
||||||
|
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
|
||||||
|
self.check_equal(self.post_task("/api/repos/" + repo1_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
# publishing under prefix, default distribution
|
||||||
|
prefix = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/publish/" + prefix,
|
||||||
|
json={
|
||||||
|
"Architectures": ["i386", "source"],
|
||||||
|
"SourceKind": "local",
|
||||||
|
"Sources": [{"Component": "main", "Name": repo1_name}],
|
||||||
|
"Signing": DefaultSigningOptions,
|
||||||
|
}
|
||||||
|
).status_code, 201)
|
||||||
|
|
||||||
|
repo_expected = {
|
||||||
|
'AcquireByHash': False,
|
||||||
|
'Architectures': ['i386', 'source'],
|
||||||
|
'Codename': '',
|
||||||
|
'Distribution': 'wheezy',
|
||||||
|
'Label': '',
|
||||||
|
'NotAutomatic': '',
|
||||||
|
'ButAutomaticUpgrades': '',
|
||||||
|
'Origin': '',
|
||||||
|
'Path': prefix + '/' + 'wheezy',
|
||||||
|
'Prefix': prefix,
|
||||||
|
'SkipContents': False,
|
||||||
|
'MultiDist': False,
|
||||||
|
'SourceKind': 'local',
|
||||||
|
'Sources': [{'Component': 'main', 'Name': repo1_name}],
|
||||||
|
'Storage': '',
|
||||||
|
'Suite': ''}
|
||||||
|
repo = self.get("/api/publish/" + prefix + "/wheezy")
|
||||||
|
self.check_equal(repo.status_code, 200)
|
||||||
|
self.check_equal(repo_expected, repo.json())
|
||||||
|
|
||||||
|
|
||||||
class ServePublishedListTestRepo(APITest):
|
class ServePublishedListTestRepo(APITest):
|
||||||
"""
|
"""
|
||||||
GET /repos
|
GET /repos
|
||||||
@@ -1036,3 +1088,420 @@ class ServePublishedNotFoundTestRepo(APITest):
|
|||||||
get = self.get("/repos/apiandserve/pool/main/b/boost-defaults/i-dont-exist")
|
get = self.get("/repos/apiandserve/pool/main/b/boost-defaults/i-dont-exist")
|
||||||
if get.status_code != 404:
|
if get.status_code != 404:
|
||||||
raise Exception(f"Expected status 404 != {get.status_code}")
|
raise Exception(f"Expected status 404 != {get.status_code}")
|
||||||
|
|
||||||
|
|
||||||
|
class PublishSourcesAddAPITestRepo(APITest):
|
||||||
|
"""
|
||||||
|
POST /publish/:prefix/:distribution/sources
|
||||||
|
"""
|
||||||
|
fixtureGpg = True
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
repo1_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc",
|
||||||
|
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
|
||||||
|
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
# publishing under prefix, default distribution
|
||||||
|
prefix = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/publish/" + prefix,
|
||||||
|
json={
|
||||||
|
"SourceKind": "local",
|
||||||
|
"Sources": [{"Component": "main", "Name": repo1_name}],
|
||||||
|
"Signing": DefaultSigningOptions,
|
||||||
|
}
|
||||||
|
).status_code, 201)
|
||||||
|
|
||||||
|
repo2_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
# Actual test
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/publish/" + prefix + "/wheezy/sources",
|
||||||
|
json={"Component": "test", "Name": repo2_name}
|
||||||
|
).status_code, 201)
|
||||||
|
|
||||||
|
sources_expected = [{"Component": "main", "Name": repo1_name}, {"Component": "test", "Name": repo2_name}]
|
||||||
|
sources = self.get("/api/publish/" + prefix + "/wheezy/sources")
|
||||||
|
self.check_equal(sources.status_code, 200)
|
||||||
|
self.check_equal(sources_expected, sources.json())
|
||||||
|
|
||||||
|
|
||||||
|
class PublishSourceUpdateAPITestRepo(APITest):
|
||||||
|
"""
|
||||||
|
PUT /publish/:prefix/:distribution/sources/main
|
||||||
|
"""
|
||||||
|
fixtureGpg = True
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
repo1_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc",
|
||||||
|
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
|
||||||
|
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
# publishing under prefix, default distribution
|
||||||
|
prefix = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/publish/" + prefix,
|
||||||
|
json={
|
||||||
|
"SourceKind": "local",
|
||||||
|
"Sources": [{"Component": "main", "Name": repo1_name}],
|
||||||
|
"Signing": DefaultSigningOptions,
|
||||||
|
}
|
||||||
|
).status_code, 201)
|
||||||
|
|
||||||
|
repo2_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
# Actual test
|
||||||
|
self.check_equal(self.put(
|
||||||
|
"/api/publish/" + prefix + "/wheezy/sources/main",
|
||||||
|
json={"Component": "main", "Name": repo2_name}
|
||||||
|
).status_code, 200)
|
||||||
|
|
||||||
|
sources_expected = [{"Component": "main", "Name": repo2_name}]
|
||||||
|
sources = self.get("/api/publish/" + prefix + "/wheezy/sources")
|
||||||
|
self.check_equal(sources.status_code, 200)
|
||||||
|
self.check_equal(sources_expected, sources.json())
|
||||||
|
|
||||||
|
|
||||||
|
class PublishSourcesUpdateAPITestRepo(APITest):
|
||||||
|
"""
|
||||||
|
PUT /publish/:prefix/:distribution/sources
|
||||||
|
"""
|
||||||
|
fixtureGpg = True
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
repo1_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc",
|
||||||
|
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
|
||||||
|
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
repo2_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
# publishing under prefix, default distribution
|
||||||
|
prefix = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/publish/" + prefix,
|
||||||
|
json={
|
||||||
|
"SourceKind": "local",
|
||||||
|
"Sources": [{"Component": "main", "Name": repo1_name}],
|
||||||
|
"Signing": DefaultSigningOptions,
|
||||||
|
}
|
||||||
|
).status_code, 201)
|
||||||
|
|
||||||
|
# Actual test
|
||||||
|
self.check_equal(self.put(
|
||||||
|
"/api/publish/" + prefix + "/wheezy/sources",
|
||||||
|
json=[{"Component": "test", "Name": repo1_name}, {"Component": "other-test", "Name": repo2_name}]
|
||||||
|
).status_code, 200)
|
||||||
|
|
||||||
|
sources_expected = [{"Component": "other-test", "Name": repo2_name}, {"Component": "test", "Name": repo1_name}]
|
||||||
|
sources = self.get("/api/publish/" + prefix + "/wheezy/sources")
|
||||||
|
self.check_equal(sources.status_code, 200)
|
||||||
|
self.check_equal(sources_expected, sources.json())
|
||||||
|
|
||||||
|
|
||||||
|
class PublishSourceRemoveAPITestRepo(APITest):
|
||||||
|
"""
|
||||||
|
DELETE /publish/:prefix/:distribution/sources/test
|
||||||
|
"""
|
||||||
|
fixtureGpg = True
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
repo1_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc",
|
||||||
|
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
|
||||||
|
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
repo2_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
# publishing under prefix, default distribution
|
||||||
|
prefix = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/publish/" + prefix,
|
||||||
|
json={
|
||||||
|
"SourceKind": "local",
|
||||||
|
"Sources": [{"Component": "main", "Name": repo1_name}, {"Component": "test", "Name": repo2_name}],
|
||||||
|
"Signing": DefaultSigningOptions,
|
||||||
|
}
|
||||||
|
).status_code, 201)
|
||||||
|
|
||||||
|
# Actual test
|
||||||
|
self.check_equal(self.delete("/api/publish/" + prefix + "/wheezy/sources/test").status_code, 200)
|
||||||
|
|
||||||
|
sources_expected = [{"Component": "main", "Name": repo1_name}]
|
||||||
|
sources = self.get("/api/publish/" + prefix + "/wheezy/sources")
|
||||||
|
self.check_equal(sources.status_code, 200)
|
||||||
|
self.check_equal(sources_expected, sources.json())
|
||||||
|
|
||||||
|
|
||||||
|
class PublishSourcesDropAPITestRepo(APITest):
|
||||||
|
"""
|
||||||
|
DELETE /publish/:prefix/:distribution/sources
|
||||||
|
"""
|
||||||
|
fixtureGpg = True
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
repo1_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc",
|
||||||
|
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
|
||||||
|
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
repo2_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
# publishing under prefix, default distribution
|
||||||
|
prefix = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/publish/" + prefix,
|
||||||
|
json={
|
||||||
|
"SourceKind": "local",
|
||||||
|
"Sources": [{"Component": "main", "Name": repo1_name}, {"Component": "test", "Name": repo2_name}],
|
||||||
|
"Signing": DefaultSigningOptions,
|
||||||
|
}
|
||||||
|
).status_code, 201)
|
||||||
|
|
||||||
|
self.check_equal(self.delete("/api/publish/" + prefix + "/wheezy/sources/test").status_code, 200)
|
||||||
|
|
||||||
|
# Actual test
|
||||||
|
self.check_equal(self.delete("/api/publish/" + prefix + "/wheezy/sources").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.get("/api/publish/" + prefix + "/wheezy/sources").status_code, 404)
|
||||||
|
|
||||||
|
|
||||||
|
class PublishSourcesListAPITestRepo(APITest):
|
||||||
|
"""
|
||||||
|
GET /publish/:prefix/:distribution/sources
|
||||||
|
"""
|
||||||
|
fixtureGpg = True
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
repo1_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc",
|
||||||
|
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
|
||||||
|
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
repo2_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
# publishing under prefix, default distribution
|
||||||
|
prefix = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/publish/" + prefix,
|
||||||
|
json={
|
||||||
|
"SourceKind": "local",
|
||||||
|
"Sources": [{"Component": "main", "Name": repo1_name}],
|
||||||
|
"Signing": DefaultSigningOptions,
|
||||||
|
}
|
||||||
|
).status_code, 201)
|
||||||
|
|
||||||
|
# Actual test
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/publish/" + prefix + "/wheezy/sources",
|
||||||
|
json={"Component": "test", "Name": repo1_name}
|
||||||
|
).status_code, 201)
|
||||||
|
|
||||||
|
self.check_equal(self.put(
|
||||||
|
"/api/publish/" + prefix + "/wheezy/sources/main",
|
||||||
|
json={"Component": "main", "Name": repo2_name}
|
||||||
|
).status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.delete("/api/publish/" + prefix + "/wheezy/sources/main").status_code, 200)
|
||||||
|
|
||||||
|
sources_expected = [{"Component": "test", "Name": repo1_name}]
|
||||||
|
sources = self.get("/api/publish/" + prefix + "/wheezy/sources")
|
||||||
|
self.check_equal(sources.status_code, 200)
|
||||||
|
self.check_equal(sources_expected, sources.json())
|
||||||
|
|
||||||
|
|
||||||
|
class PublishUpdateSourcesAPITestRepo(APITest):
|
||||||
|
"""
|
||||||
|
POST /publish/:prefix/:distribution/update
|
||||||
|
"""
|
||||||
|
fixtureGpg = True
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
repo1_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc",
|
||||||
|
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
|
||||||
|
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
repo2_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
repo3_name = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/repos", json={"Name": repo3_name, "DefaultDistribution": "wheezy"}).status_code, 201)
|
||||||
|
|
||||||
|
d = self.random_name()
|
||||||
|
self.check_equal(self.upload("/api/files/" + d,
|
||||||
|
"libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200)
|
||||||
|
|
||||||
|
self.check_equal(self.post("/api/repos/" + repo3_name + "/file/" + d).status_code, 200)
|
||||||
|
|
||||||
|
# publishing under prefix, default distribution
|
||||||
|
prefix = self.random_name()
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/publish/" + prefix,
|
||||||
|
json={
|
||||||
|
"Signing": DefaultSigningOptions,
|
||||||
|
"SourceKind": "local",
|
||||||
|
"Sources": [{"Component": "main", "Name": repo1_name}, {"Component": "test", "Name": repo2_name}],
|
||||||
|
}
|
||||||
|
).status_code, 201)
|
||||||
|
|
||||||
|
# remove 'main' component
|
||||||
|
self.check_equal(self.delete("/api/publish/" + prefix + "/wheezy/sources/main").status_code, 200)
|
||||||
|
|
||||||
|
# update 'test' component
|
||||||
|
self.check_equal(self.put(
|
||||||
|
"/api/publish/" + prefix + "/wheezy/sources/test",
|
||||||
|
json={"Component": "test", "Name": repo1_name}
|
||||||
|
).status_code, 200)
|
||||||
|
|
||||||
|
# add 'other-test' component
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/publish/" + prefix + "/wheezy/sources",
|
||||||
|
json={"Component": "other-test", "Name": repo3_name}
|
||||||
|
).status_code, 201)
|
||||||
|
|
||||||
|
sources_expected = [{"Component": "other-test", "Name": repo3_name}, {"Component": "test", "Name": repo1_name}]
|
||||||
|
sources = self.get("/api/publish/" + prefix + "/wheezy/sources")
|
||||||
|
self.check_equal(sources.status_code, 200)
|
||||||
|
self.check_equal(sources_expected, sources.json())
|
||||||
|
|
||||||
|
# update published repository and publish new content
|
||||||
|
self.check_equal(self.post(
|
||||||
|
"/api/publish/" + prefix + "/wheezy/update",
|
||||||
|
json={
|
||||||
|
"AcquireByHash": True,
|
||||||
|
"MultiDist": False,
|
||||||
|
"Signing": DefaultSigningOptions,
|
||||||
|
"SkipBz2": True,
|
||||||
|
"SkipContents": True,
|
||||||
|
}
|
||||||
|
).status_code, 200)
|
||||||
|
|
||||||
|
repo_expected = {
|
||||||
|
'AcquireByHash': True,
|
||||||
|
'Architectures': ['i386', 'source'],
|
||||||
|
'Codename': '',
|
||||||
|
'Distribution': 'wheezy',
|
||||||
|
'Label': '',
|
||||||
|
'Origin': '',
|
||||||
|
'NotAutomatic': '',
|
||||||
|
'ButAutomaticUpgrades': '',
|
||||||
|
'Path': prefix + '/' + 'wheezy',
|
||||||
|
'Prefix': prefix,
|
||||||
|
'SkipContents': True,
|
||||||
|
'MultiDist': False,
|
||||||
|
'SourceKind': 'local',
|
||||||
|
'Sources': [{"Component": "other-test", "Name": repo3_name}, {"Component": "test", "Name": repo1_name}],
|
||||||
|
'Storage': '',
|
||||||
|
'Suite': ''}
|
||||||
|
|
||||||
|
all_repos = self.get("/api/publish")
|
||||||
|
self.check_equal(all_repos.status_code, 200)
|
||||||
|
self.check_in(repo_expected, all_repos.json())
|
||||||
|
|||||||
Reference in New Issue
Block a user