Skip to content

Commit 2d0d211

Browse files
committed
Support updating label and origin domain of publish
Signed-off-by: Zhang Xiao <[email protected]>
1 parent 8ca4cb8 commit 2d0d211

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
@@ -378,6 +378,10 @@ type publishedRepoUpdateSwitchParams struct {
378378
AcquireByHash *bool ` json:"AcquireByHash" example:"false"`
379379
// Enable multiple packages with the same filename in different distributions
380380
MultiDist *bool ` json:"MultiDist" example:"false"`
381+
// Value of Label: field in published repository stanza
382+
Label *string ` json:"Label" example:"Debian"`
383+
// Value of Origin: field in published repository stanza
384+
Origin *string ` json:"Origin" example:"Debian"`
381385
}
382386

383387
// @Summary Update Published Repository
@@ -466,6 +470,14 @@ func apiPublishUpdateSwitch(c *gin.Context) {
466470
published.MultiDist = *b.MultiDist
467471
}
468472

473+
if b.Label != nil {
474+
published.Label = *b.Label
475+
}
476+
477+
if b.Origin != nil {
478+
published.Origin = *b.Origin
479+
}
480+
469481
resources := []string{string(published.Key())}
470482
taskName := fmt.Sprintf("Update published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution)
471483
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
@@ -957,6 +969,10 @@ type publishedRepoUpdateParams struct {
957969
AcquireByHash *bool ` json:"AcquireByHash" example:"false"`
958970
// Enable multiple packages with the same filename in different distributions
959971
MultiDist *bool ` json:"MultiDist" example:"false"`
972+
// Value of Label: field in published repository stanza
973+
Label *string ` json:"Label" example:"Debian"`
974+
// Value of Origin: field in published repository stanza
975+
Origin *string ` json:"Origin" example:"Debian"`
960976
}
961977

962978
// @Summary Update Published Repository
@@ -1025,6 +1041,14 @@ func apiPublishUpdate(c *gin.Context) {
10251041
published.MultiDist = *b.MultiDist
10261042
}
10271043

1044+
if b.Label != nil {
1045+
published.Label = *b.Label
1046+
}
1047+
1048+
if b.Origin != nil {
1049+
published.Origin = *b.Origin
1050+
}
1051+
10281052
resources := []string{string(published.Key())}
10291053
taskName := fmt.Sprintf("Update published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution)
10301054
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
@@ -60,6 +60,14 @@ func aptlyPublishUpdate(cmd *commander.Command, args []string) error {
6060
published.SkipBz2 = context.Flags().Lookup("skip-bz2").Value.Get().(bool)
6161
}
6262

63+
if context.Flags().IsSet("origin") {
64+
published.Origin = context.Flags().Lookup("origin").Value.String()
65+
}
66+
67+
if context.Flags().IsSet("label") {
68+
published.Label = context.Flags().Lookup("label").Value.String()
69+
}
70+
6371
if context.Flags().IsSet("multi-dist") {
6472
published.MultiDist = context.Flags().Lookup("multi-dist").Value.Get().(bool)
6573
}
@@ -127,6 +135,8 @@ Example:
127135
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
128136
cmd.Flag.Bool("skip-cleanup", false, "don't remove unreferenced files in prefix/component")
129137
cmd.Flag.Bool("multi-dist", false, "enable multiple packages with the same filename in different distributions")
138+
cmd.Flag.String("origin", "", "overwrite origin name to publish")
139+
cmd.Flag.String("label", "", "overwrite label to publish")
130140

131141
return cmd
132142
}
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
@@ -606,3 +606,25 @@ def check(self):
606606
components = sorted(components.split(' '))
607607
if ['other-test', 'test'] != components:
608608
raise Exception("value of 'Components' in release file is '%s' and does not match '%s'." % (' '.join(components), 'other-test test'))
609+
610+
611+
class PublishUpdate19Test(BaseTest):
612+
"""
613+
publish update: update label and origin
614+
"""
615+
fixtureCmds = [
616+
"aptly repo create local-repo",
617+
"aptly repo add local-repo ${files}/",
618+
"aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -skip-bz2 local-repo",
619+
"aptly repo remove local-repo pyspi"
620+
]
621+
runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -label=fun -origin=earth maverick"
622+
gold_processor = BaseTest.expand_environ
623+
624+
def check(self):
625+
super(PublishUpdate19Test, self).check()
626+
627+
self.check_exists('public/dists/maverick/InRelease')
628+
629+
# verify contents except of sums
630+
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
@@ -725,15 +725,17 @@ def check(self):
725725
"Snapshots": [{"Component": "main", "Name": snapshot2_name}],
726726
"Signing": DefaultSigningOptions,
727727
"SkipContents": True,
728+
"Label": "fun",
729+
"Origin": "earth",
728730
})
729731
self.check_task(task)
730732
repo_expected = {
731733
'AcquireByHash': False,
732734
'Architectures': ['i386', 'source'],
733735
'Codename': '',
734736
'Distribution': 'wheezy',
735-
'Label': '',
736-
'Origin': '',
737+
'Label': 'fun',
738+
'Origin': 'earth',
737739
'NotAutomatic': '',
738740
'ButAutomaticUpgrades': '',
739741
'Path': prefix + '/' + 'wheezy',
@@ -1533,6 +1535,8 @@ def check(self):
15331535
"Signing": DefaultSigningOptions,
15341536
"SkipBz2": True,
15351537
"SkipContents": True,
1538+
"Label": "fun",
1539+
"Origin": "earth",
15361540
}
15371541
).status_code, 200)
15381542

@@ -1541,8 +1545,8 @@ def check(self):
15411545
'Architectures': ['i386', 'source'],
15421546
'Codename': '',
15431547
'Distribution': 'wheezy',
1544-
'Label': '',
1545-
'Origin': '',
1548+
'Label': 'fun',
1549+
'Origin': 'earth',
15461550
'NotAutomatic': '',
15471551
'ButAutomaticUpgrades': '',
15481552
'Path': prefix + '/' + 'wheezy',

0 commit comments

Comments
 (0)