Skip to content

Commit 60f3eb1

Browse files
authored
Merge pull request #1484 from xzhang1/update_label
Support updating label and origin domain of publish
2 parents 19b98c6 + 0db9797 commit 60f3eb1

File tree

6 files changed

+84
-4
lines changed

6 files changed

+84
-4
lines changed

api/publish.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ type publishedRepoUpdateSwitchParams struct {
386386
SignedBy *string ` json:"SignedBy" example:""`
387387
// Enable multiple packages with the same filename in different distributions
388388
MultiDist *bool ` json:"MultiDist" example:"false"`
389+
// Value of Label: field in published repository stanza
390+
Label *string ` json:"Label" example:"Debian"`
391+
// Value of Origin: field in published repository stanza
392+
Origin *string ` json:"Origin" example:"Debian"`
389393
}
390394

391395
// @Summary Update Published Repository
@@ -477,6 +481,14 @@ func apiPublishUpdateSwitch(c *gin.Context) {
477481
published.MultiDist = *b.MultiDist
478482
}
479483

484+
if b.Label != nil {
485+
published.Label = *b.Label
486+
}
487+
488+
if b.Origin != nil {
489+
published.Origin = *b.Origin
490+
}
491+
480492
resources := []string{string(published.Key())}
481493
taskName := fmt.Sprintf("Update published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution)
482494
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
@@ -970,6 +982,10 @@ type publishedRepoUpdateParams struct {
970982
SignedBy *string ` json:"SignedBy" example:""`
971983
// Enable multiple packages with the same filename in different distributions
972984
MultiDist *bool ` json:"MultiDist" example:"false"`
985+
// Value of Label: field in published repository stanza
986+
Label *string ` json:"Label" example:"Debian"`
987+
// Value of Origin: field in published repository stanza
988+
Origin *string ` json:"Origin" example:"Debian"`
973989
}
974990

975991
// @Summary Update Published Repository
@@ -1042,6 +1058,14 @@ func apiPublishUpdate(c *gin.Context) {
10421058
published.MultiDist = *b.MultiDist
10431059
}
10441060

1061+
if b.Label != nil {
1062+
published.Label = *b.Label
1063+
}
1064+
1065+
if b.Origin != nil {
1066+
published.Origin = *b.Origin
1067+
}
1068+
10451069
resources := []string{string(published.Key())}
10461070
taskName := fmt.Sprintf("Update published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution)
10471071
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {

cmd/publish_update.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ func aptlyPublishUpdate(cmd *commander.Command, args []string) error {
6464
published.SignedBy = context.Flags().Lookup("signed-by").Value.String()
6565
}
6666

67+
if context.Flags().IsSet("origin") {
68+
published.Origin = context.Flags().Lookup("origin").Value.String()
69+
}
70+
71+
if context.Flags().IsSet("label") {
72+
published.Label = context.Flags().Lookup("label").Value.String()
73+
}
74+
6775
if context.Flags().IsSet("multi-dist") {
6876
published.MultiDist = context.Flags().Lookup("multi-dist").Value.Get().(bool)
6977
}
@@ -132,6 +140,8 @@ Example:
132140
cmd.Flag.String("signed-by", "", "an optional field containing a comma separated list of OpenPGP key fingerprints to be used for validating the next Release file")
133141
cmd.Flag.Bool("skip-cleanup", false, "don't remove unreferenced files in prefix/component")
134142
cmd.Flag.Bool("multi-dist", false, "enable multiple packages with the same filename in different distributions")
143+
cmd.Flag.String("origin", "", "overwrite origin name to publish")
144+
cmd.Flag.String("label", "", "overwrite label to publish")
135145

136146
return cmd
137147
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Loading packages...
2+
Generating metadata files and linking package files...
3+
Finalizing metadata files...
4+
Signing file 'Release' with gpg, please enter your passphrase when prompted:
5+
Clearsigning file 'Release' with gpg, please enter your passphrase when prompted:
6+
Cleaning up published repository ./maverick...
7+
Cleaning up component 'main'...
8+
9+
Published local repository ./maverick (origin: earth, label: fun) [i386, source] publishes {main: [local-repo]} has been updated successfully.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Origin: earth
2+
Label: fun
3+
Suite: maverick
4+
Codename: maverick
5+
Architectures: i386
6+
Components: main
7+
Description: Generated by aptly
8+
MD5Sum:
9+
SHA1:
10+
SHA256:
11+
SHA512:

system/t06_publish/update.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,3 +625,25 @@ def check(self):
625625
super(PublishUpdate19Test, self).check()
626626

627627
self.check_file_contents('public/dists/maverick/Release', 'release', match_prepare=strip_processor)
628+
629+
630+
class PublishUpdate20Test(BaseTest):
631+
"""
632+
publish update: update label and origin
633+
"""
634+
fixtureCmds = [
635+
"aptly repo create local-repo",
636+
"aptly repo add local-repo ${files}/",
637+
"aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -skip-bz2 local-repo",
638+
"aptly repo remove local-repo pyspi"
639+
]
640+
runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -label=fun -origin=earth maverick"
641+
gold_processor = BaseTest.expand_environ
642+
643+
def check(self):
644+
super(PublishUpdate20Test, self).check()
645+
646+
self.check_exists('public/dists/maverick/InRelease')
647+
648+
# verify contents except of sums
649+
self.check_file_contents('public/dists/maverick/Release', 'release', match_prepare=strip_processor)

system/t12_api/publish.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -938,15 +938,17 @@ def check(self):
938938
"Snapshots": [{"Component": "main", "Name": snapshot2_name}],
939939
"Signing": DefaultSigningOptions,
940940
"SkipContents": True,
941+
"Label": "fun",
942+
"Origin": "earth",
941943
})
942944
self.check_task(task)
943945
repo_expected = {
944946
'AcquireByHash': False,
945947
'Architectures': ['i386', 'source'],
946948
'Codename': '',
947949
'Distribution': 'wheezy',
948-
'Label': '',
949-
'Origin': '',
950+
'Label': 'fun',
951+
'Origin': 'earth',
950952
'NotAutomatic': '',
951953
'ButAutomaticUpgrades': '',
952954
'Path': prefix + '/' + 'wheezy',
@@ -1845,6 +1847,8 @@ def check(self):
18451847
"Signing": DefaultSigningOptions,
18461848
"SkipBz2": True,
18471849
"SkipContents": True,
1850+
"Label": "fun",
1851+
"Origin": "earth",
18481852
}
18491853
).status_code, 200)
18501854

@@ -1853,8 +1857,8 @@ def check(self):
18531857
'Architectures': ['i386', 'source'],
18541858
'Codename': '',
18551859
'Distribution': 'wheezy',
1856-
'Label': '',
1857-
'Origin': '',
1860+
'Label': 'fun',
1861+
'Origin': 'earth',
18581862
'NotAutomatic': '',
18591863
'ButAutomaticUpgrades': '',
18601864
'Path': prefix + '/' + 'wheezy',

0 commit comments

Comments
 (0)