mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-11 03:11:50 +00:00
committed by
André Roth
parent
73cdf5417b
commit
14c29ff912
@@ -429,6 +429,17 @@ func apiPublishUpdateSwitch(c *gin.Context) {
|
||||
published.MultiDist = *b.MultiDist
|
||||
}
|
||||
|
||||
revision := published.ObtainRevision()
|
||||
sources := revision.Sources
|
||||
|
||||
if published.SourceKind == deb.SourceSnapshot {
|
||||
for _, snapshotInfo := range b.Snapshots {
|
||||
component := snapshotInfo.Component
|
||||
name := snapshotInfo.Name
|
||||
sources[component] = name
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -625,7 +636,7 @@ func apiPublishSourcesList(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, revision.ToJSON()["Sources"])
|
||||
c.JSON(http.StatusOK, revision.SourceList())
|
||||
}
|
||||
|
||||
// @Router /api/publish/{prefix}/{distribution}/sources [put]
|
||||
|
||||
@@ -57,7 +57,7 @@ func aptlyPublishSourceListTxt(published *deb.PublishedRepo) error {
|
||||
func aptlyPublishSourceListJSON(published *deb.PublishedRepo) error {
|
||||
revision := published.Revision
|
||||
|
||||
output, err := json.MarshalIndent(revision.ToJSON()["Sources"], "", " ")
|
||||
output, err := json.MarshalIndent(revision.SourceList(), "", " ")
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to list: %s", err)
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ import (
|
||||
"github.com/aptly-dev/aptly/utils"
|
||||
)
|
||||
|
||||
type SourceEntry struct {
|
||||
Component, Name string
|
||||
}
|
||||
|
||||
type PublishedRepoUpdateResult struct {
|
||||
AddedSources map[string]string
|
||||
UpdatedSources map[string]string
|
||||
@@ -129,6 +133,21 @@ func (revision *PublishedRepoRevision) Components() []string {
|
||||
return components
|
||||
}
|
||||
|
||||
func (revision *PublishedRepoRevision) SourceList() []SourceEntry {
|
||||
sources := revision.Sources
|
||||
components := revision.Components()
|
||||
sourceList := make([]SourceEntry, 0, len(sources))
|
||||
for _, component := range components {
|
||||
name := sources[component]
|
||||
sourceList = append(sourceList, SourceEntry{
|
||||
Component: component,
|
||||
Name: name,
|
||||
})
|
||||
}
|
||||
|
||||
return sourceList
|
||||
}
|
||||
|
||||
func (revision *PublishedRepoRevision) SourceNames() []string {
|
||||
sources := revision.Sources
|
||||
names := make([]string, 0, len(sources))
|
||||
@@ -449,40 +468,26 @@ func NewPublishedRepo(storage, prefix, distribution string, architectures []stri
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type sourceInfo struct {
|
||||
Component, Name string
|
||||
}
|
||||
|
||||
func (revision *PublishedRepoRevision) ToJSON() map[string]any {
|
||||
sources := []sourceInfo{}
|
||||
for _, component := range revision.Components() {
|
||||
name := revision.Sources[component]
|
||||
sources = append(sources, sourceInfo{
|
||||
Component: component,
|
||||
Name: name,
|
||||
})
|
||||
}
|
||||
return map[string]any{"Sources": sources}
|
||||
}
|
||||
|
||||
func (revision *PublishedRepoRevision) MarshalJSON() ([]byte, error) {
|
||||
sources := []sourceInfo{}
|
||||
for _, component := range revision.Components() {
|
||||
name := revision.Sources[component]
|
||||
sources = append(sources, sourceInfo{
|
||||
sources := revision.Sources
|
||||
components := revision.Components()
|
||||
sourceList := make([]SourceEntry, 0, len(sources))
|
||||
for _, component := range components {
|
||||
name := sources[component]
|
||||
sourceList = append(sourceList, SourceEntry{
|
||||
Component: component,
|
||||
Name: name,
|
||||
})
|
||||
}
|
||||
|
||||
return json.Marshal(map[string]interface{}{
|
||||
"Sources": sources,
|
||||
"Sources": sourceList,
|
||||
})
|
||||
}
|
||||
|
||||
// MarshalJSON requires object to filled by "LoadShallow" or "LoadComplete"
|
||||
func (p *PublishedRepo) MarshalJSON() ([]byte, error) {
|
||||
sources := []sourceInfo{}
|
||||
sources := []SourceEntry{}
|
||||
for _, component := range p.Components() {
|
||||
item := p.sourceItems[component]
|
||||
name := ""
|
||||
@@ -493,7 +498,7 @@ func (p *PublishedRepo) MarshalJSON() ([]byte, error) {
|
||||
} else {
|
||||
panic("no snapshot/local repo")
|
||||
}
|
||||
sources = append(sources, sourceInfo{
|
||||
sources = append(sources, SourceEntry{
|
||||
Component: component,
|
||||
Name: name,
|
||||
})
|
||||
|
||||
@@ -1,8 +1 @@
|
||||
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 a, c...
|
||||
|
||||
Publish for snapshot ./maverick [i386] publishes {a: [snap2]: Created as empty}, {b: [snap2]: Created as empty}, {c: [snap3]: Created as empty} has been successfully switched to new snapshot.
|
||||
ERROR: unable to switch: component c does not exist in published repository
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
WARNING: force overwrite mode enabled, aptly might corrupt other published repositories sharing the same package pool.
|
||||
|
||||
Loading packages...
|
||||
Generating metadata files and linking package files...
|
||||
Finalizing metadata files...
|
||||
|
||||
@@ -3,6 +3,5 @@ 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 main...
|
||||
|
||||
Published local repository ./maverick [i386, source] publishes {main: [local-repo]} has been successfully updated.
|
||||
|
||||
@@ -3,5 +3,6 @@ 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 main...
|
||||
|
||||
Published local repository ./maverick [i386, source] publishes {main: [local-repo]} has been successfully updated.
|
||||
|
||||
@@ -5,4 +5,4 @@ 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 main...
|
||||
|
||||
Published local repository ./maverick [i386, source] publishes {main: [local-repo]} has been successfully updated.
|
||||
Published local repository ./bookworm [i386, source] publishes {main: [local-repo]} has been successfully updated.
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
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 main...
|
||||
|
||||
Published local repository ./bookworm [i386, source] publishes {main: [local-repo]} has been successfully updated.
|
||||
@@ -1 +1,8 @@
|
||||
ERROR: unable to update: not a local repository publish
|
||||
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 contrib, main...
|
||||
|
||||
Published local repository ./maverick [i386, source] publishes {contrib: [repo2]}, {main: [repo1]} has been successfully updated.
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
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 contrib, main...
|
||||
|
||||
Published local repository ./maverick [i386, source] publishes {contrib: [repo2]}, {main: [repo1]} has been successfully updated.
|
||||
Published local repository ./squeeze [i386] publishes {contrib: [repo2]}, {main: [repo1]} has been successfully updated.
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
Loading packages...
|
||||
Generating metadata files and linking package files...
|
||||
Finalizing metadata files...
|
||||
Cleaning up prefix "." components contrib, main...
|
||||
|
||||
Published local repository ./squeeze [i386] publishes {contrib: [repo2]}, {main: [repo1]} has been successfully updated.
|
||||
ERROR: unable to publish: unable to process packages: error linking file to ${HOME}/.aptly/public/pool/main/p/pyspi/pyspi_0.6.1.orig.tar.gz: file already exists and is different
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
WARNING: force overwrite mode enabled, aptly might corrupt other published repositories sharing the same package pool.
|
||||
|
||||
Loading packages...
|
||||
Generating metadata files and linking package files...
|
||||
ERROR: unable to publish: unable to process packages: error linking file to ${HOME}/.aptly/public/pool/main/p/pyspi/pyspi_0.6.1.orig.tar.gz: file already exists and is different
|
||||
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 main...
|
||||
|
||||
Published local repository ./maverick [i386, source] publishes {main: [local-repo]} has been successfully updated.
|
||||
|
||||
@@ -424,22 +424,15 @@ class PublishSwitch11Test(BaseTest):
|
||||
|
||||
class PublishSwitch12Test(BaseTest):
|
||||
"""
|
||||
publish switch: add new component to publish
|
||||
publish switch: wrong component names
|
||||
"""
|
||||
fixtureCmds = [
|
||||
"aptly snapshot create snap1 empty",
|
||||
"aptly snapshot create snap2 empty",
|
||||
"aptly snapshot create snap3 empty",
|
||||
"aptly publish snapshot -architectures=i386 -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=a,b snap1 snap2",
|
||||
]
|
||||
runCmd = "aptly publish switch -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=a,c maverick snap2 snap3"
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
def check(self):
|
||||
super(PublishSwitch12Test, self).check()
|
||||
|
||||
self.check_exists('public/dists/maverick/a/binary-i386/Packages')
|
||||
self.check_exists('public/dists/maverick/c/binary-i386/Packages')
|
||||
runCmd = "aptly publish switch -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=a,c maverick snap2 snap1"
|
||||
expectedCode = 1
|
||||
|
||||
|
||||
class PublishSwitch13Test(BaseTest):
|
||||
|
||||
@@ -217,20 +217,6 @@ class PublishUpdate5Test(BaseTest):
|
||||
|
||||
|
||||
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):
|
||||
"""
|
||||
publish update: multiple components, add some packages
|
||||
"""
|
||||
@@ -246,7 +232,7 @@ class PublishUpdate7Test(BaseTest):
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
def check(self):
|
||||
super(PublishUpdate7Test, self).check()
|
||||
super(PublishUpdate6Test, self).check()
|
||||
|
||||
self.check_exists('public/dists/maverick/InRelease')
|
||||
self.check_exists('public/dists/maverick/Release')
|
||||
@@ -280,7 +266,7 @@ class PublishUpdate7Test(BaseTest):
|
||||
self.check_file_contents('public/dists/maverick/contrib/binary-i386/Packages', 'binary2', match_prepare=lambda s: "\n".join(sorted(s.split("\n"))))
|
||||
|
||||
|
||||
class PublishUpdate8Test(BaseTest):
|
||||
class PublishUpdate7Test(BaseTest):
|
||||
"""
|
||||
publish update: update empty repos to empty repos
|
||||
"""
|
||||
@@ -293,7 +279,7 @@ class PublishUpdate8Test(BaseTest):
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
|
||||
class PublishUpdate9Test(BaseTest):
|
||||
class PublishUpdate8Test(BaseTest):
|
||||
"""
|
||||
publish update: conflicting files in the repo
|
||||
"""
|
||||
@@ -309,7 +295,7 @@ class PublishUpdate9Test(BaseTest):
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
|
||||
class PublishUpdate10Test(BaseTest):
|
||||
class PublishUpdate9Test(BaseTest):
|
||||
"""
|
||||
publish update: -force-overwrite
|
||||
"""
|
||||
@@ -324,12 +310,12 @@ class PublishUpdate10Test(BaseTest):
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
def check(self):
|
||||
super(PublishUpdate10Test, self).check()
|
||||
super(PublishUpdate9Test, self).check()
|
||||
|
||||
self.check_file_contents("public/pool/main/p/pyspi/pyspi_0.6.1.orig.tar.gz", "file")
|
||||
|
||||
|
||||
class PublishUpdate11Test(BaseTest):
|
||||
class PublishUpdate10Test(BaseTest):
|
||||
"""
|
||||
publish update: -skip-contents
|
||||
"""
|
||||
@@ -343,7 +329,7 @@ class PublishUpdate11Test(BaseTest):
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
def check(self):
|
||||
super(PublishUpdate11Test, self).check()
|
||||
super(PublishUpdate10Test, self).check()
|
||||
|
||||
self.check_exists('public/dists/maverick/InRelease')
|
||||
self.check_exists('public/dists/maverick/Release')
|
||||
@@ -353,7 +339,7 @@ class PublishUpdate11Test(BaseTest):
|
||||
self.check_not_exists('public/dists/maverick/main/Contents-i386.gz')
|
||||
|
||||
|
||||
class PublishUpdate12Test(BaseTest):
|
||||
class PublishUpdate11Test(BaseTest):
|
||||
"""
|
||||
publish update: removed some packages skipping cleanup
|
||||
"""
|
||||
@@ -367,7 +353,7 @@ class PublishUpdate12Test(BaseTest):
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
def check(self):
|
||||
super(PublishUpdate12Test, self).check()
|
||||
super(PublishUpdate11Test, self).check()
|
||||
|
||||
self.check_exists('public/dists/maverick/InRelease')
|
||||
self.check_exists('public/dists/maverick/Release')
|
||||
@@ -439,7 +425,7 @@ class PublishUpdate12Test(BaseTest):
|
||||
raise Exception("path seen wrong: %r" % (pathsSeen, ))
|
||||
|
||||
|
||||
class PublishUpdate13Test(BaseTest):
|
||||
class PublishUpdate12Test(BaseTest):
|
||||
"""
|
||||
publish update: -skip-bz2
|
||||
"""
|
||||
@@ -453,7 +439,7 @@ class PublishUpdate13Test(BaseTest):
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
def check(self):
|
||||
super(PublishUpdate13Test, self).check()
|
||||
super(PublishUpdate12Test, self).check()
|
||||
|
||||
self.check_exists('public/dists/maverick/InRelease')
|
||||
self.check_exists('public/dists/maverick/Release')
|
||||
@@ -464,7 +450,7 @@ class PublishUpdate13Test(BaseTest):
|
||||
self.check_not_exists('public/dists/maverick/main/binary-i386/Packages.bz2')
|
||||
|
||||
|
||||
class PublishUpdate14Test(BaseTest):
|
||||
class PublishUpdate13Test(BaseTest):
|
||||
"""
|
||||
publish update: -multi-dist
|
||||
"""
|
||||
@@ -477,7 +463,7 @@ class PublishUpdate14Test(BaseTest):
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
def check(self):
|
||||
super(PublishUpdate14Test, self).check()
|
||||
super(PublishUpdate13Test, self).check()
|
||||
|
||||
self.check_exists('public/dists/bookworm/InRelease')
|
||||
self.check_exists('public/dists/bookworm/Release')
|
||||
|
||||
Reference in New Issue
Block a user