Skip to content

Commit e2ebcbb

Browse files
committed
Release file: support Version field
https://wiki.debian.org/DebianRepository/Format#Version The Version field, if specified, shall be the version of the release. On the other hand, if not set or set to an empty value, the Version field will not be included in the Release file. Signed-off-by: Zhang Xiao <xiao.zhang@windriver.com>
1 parent 9defe70 commit e2ebcbb

23 files changed

+189
-13
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,4 @@ List of contributors, in chronological order:
8181
* Brian Witt (https://github.com/bwitt)
8282
* Ales Bregar (https://github.com/abregar)
8383
* Tim Foerster (https://github.com/tonobo)
84+
* Zhang Xiao (https://github.com/xzhang1)

api/publish.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ type publishedRepoCreateParams struct {
186186
SignedBy *string ` json:"SignedBy" example:""`
187187
// Enable multiple packages with the same filename in different distributions
188188
MultiDist *bool ` json:"MultiDist" example:"false"`
189+
// Version of the release
190+
Version string ` json:"Version" example:""`
189191
}
190192

191193
// @Summary Create Published Repository
@@ -361,6 +363,10 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
361363
published.SignedBy = *b.SignedBy
362364
}
363365

366+
if b.Version != "" {
367+
published.Version = b.Version
368+
}
369+
364370
duplicate := collection.CheckDuplicate(published)
365371
if duplicate != nil {
366372
_ = collectionFactory.PublishedRepoCollection().LoadComplete(duplicate, collectionFactory)
@@ -404,6 +410,8 @@ type publishedRepoUpdateSwitchParams struct {
404410
Label *string ` json:"Label" example:"Debian"`
405411
// Value of Origin: field in published repository stanza
406412
Origin *string ` json:"Origin" example:"Debian"`
413+
// Version of the release: Optional
414+
Version *string ` json:"Version" example:"13.3"`
407415
}
408416

409417
// @Summary Update Published Repository
@@ -503,6 +511,10 @@ func apiPublishUpdateSwitch(c *gin.Context) {
503511
published.Origin = *b.Origin
504512
}
505513

514+
if b.Version != nil {
515+
published.Version = *b.Version
516+
}
517+
506518
resources := []string{string(published.Key())}
507519
taskName := fmt.Sprintf("Update published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution)
508520
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
@@ -1000,6 +1012,8 @@ type publishedRepoUpdateParams struct {
10001012
Label *string ` json:"Label" example:"Debian"`
10011013
// Value of Origin: field in published repository stanza
10021014
Origin *string ` json:"Origin" example:"Debian"`
1015+
// Version of the release: Optional
1016+
Version *string ` json:"Version" example:"13.3"`
10031017
}
10041018

10051019
// @Summary Update Published Repository
@@ -1080,6 +1094,10 @@ func apiPublishUpdate(c *gin.Context) {
10801094
published.Origin = *b.Origin
10811095
}
10821096

1097+
if b.Version != nil {
1098+
published.Version = *b.Version
1099+
}
1100+
10831101
resources := []string{string(published.Key())}
10841102
taskName := fmt.Sprintf("Update published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution)
10851103
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {

cmd/publish_repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Example:
5353
cmd.Flag.Bool("acquire-by-hash", false, "provide index files by hash")
5454
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")
5555
cmd.Flag.Bool("multi-dist", false, "enable multiple packages with the same filename in different distributions")
56+
cmd.Flag.String("version", "", "version of the release")
5657

5758
return cmd
5859
}

cmd/publish_snapshot.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
158158
published.MultiDist = context.Flags().Lookup("multi-dist").Value.Get().(bool)
159159
}
160160

161+
if context.Flags().IsSet("version") {
162+
published.Version = context.Flags().Lookup("version").Value.String()
163+
}
164+
161165
duplicate := collectionFactory.PublishedRepoCollection().CheckDuplicate(published)
162166
if duplicate != nil {
163167
_ = collectionFactory.PublishedRepoCollection().LoadComplete(duplicate, collectionFactory)
@@ -252,6 +256,7 @@ Example:
252256
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
253257
cmd.Flag.Bool("acquire-by-hash", false, "provide index files by hash")
254258
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")
259+
cmd.Flag.String("version", "", "version of the release")
255260
cmd.Flag.Bool("multi-dist", false, "enable multiple packages with the same filename in different distributions")
256261

257262
return cmd

cmd/publish_switch.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error {
103103
published.SignedBy = context.Flags().Lookup("signed-by").Value.String()
104104
}
105105

106+
if context.Flags().IsSet("version") {
107+
published.Version = context.Flags().Lookup("version").Value.String()
108+
}
109+
106110
if context.Flags().IsSet("multi-dist") {
107111
published.MultiDist = context.Flags().Lookup("multi-dist").Value.Get().(bool)
108112
}
@@ -167,6 +171,7 @@ This command would switch published repository (with one component) named ppa/wh
167171
cmd.Flag.String("component", "", "component names to update (for multi-component publishing, separate components with commas)")
168172
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
169173
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")
174+
cmd.Flag.String("version", "", "version of the release")
170175
cmd.Flag.Bool("skip-cleanup", false, "don't remove unreferenced files in prefix/component")
171176
cmd.Flag.Bool("multi-dist", false, "enable multiple packages with the same filename in different distributions")
172177

cmd/publish_update.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ func aptlyPublishUpdate(cmd *commander.Command, args []string) error {
7676
published.MultiDist = context.Flags().Lookup("multi-dist").Value.Get().(bool)
7777
}
7878

79+
if context.Flags().IsSet("version") {
80+
published.Version = context.Flags().Lookup("version").Value.String()
81+
}
82+
7983
err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.Progress(), forceOverwrite, context.SkelPath())
8084
if err != nil {
8185
return fmt.Errorf("unable to publish: %s", err)
@@ -142,6 +146,7 @@ Example:
142146
cmd.Flag.Bool("multi-dist", false, "enable multiple packages with the same filename in different distributions")
143147
cmd.Flag.String("origin", "", "overwrite origin name to publish")
144148
cmd.Flag.String("label", "", "overwrite label to publish")
149+
cmd.Flag.String("version", "", "version of the release")
145150

146151
return cmd
147152
}

deb/publish.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type PublishedRepo struct {
5555
Label string
5656
Suite string
5757
Codename string
58+
Version string
5859
// Architectures is a list of all architectures published
5960
Architectures []string
6061
// SourceKind is "local"/"repo"
@@ -526,6 +527,7 @@ func (p *PublishedRepo) MarshalJSON() ([]byte, error) {
526527
"Origin": p.Origin,
527528
"Suite": p.Suite,
528529
"Codename": p.Codename,
530+
"Version": p.Version,
529531
"NotAutomatic": p.NotAutomatic,
530532
"ButAutomaticUpgrades": p.ButAutomaticUpgrades,
531533
"Prefix": p.Prefix,
@@ -1080,6 +1082,9 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
10801082
if p.SignedBy != "" {
10811083
release["Signed-By"] = p.SignedBy
10821084
}
1085+
if p.Version != "" {
1086+
release["Version"] = p.Version
1087+
}
10831088

10841089
var bufWriter *bufio.Writer
10851090
bufWriter, err = indexes.ReleaseIndex(component, arch, udeb).BufWriter()
@@ -1158,6 +1163,9 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
11581163
// Let's use a century as a "forever" value.
11591164
release["Valid-Until"] = publishDate.AddDate(100, 0, 0).Format(datetime_format)
11601165
}
1166+
if p.Version != "" {
1167+
release["Version"] = p.Version
1168+
}
11611169
release["Description"] = " Generated by aptly\n"
11621170
release["MD5Sum"] = ""
11631171
release["SHA1"] = ""

man/aptly.1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,10 @@ Options:
15691569
set value for Signed-By field
15701570
.
15711571
.TP
1572+
\-\fBversion\fR
1573+
version of the release
1574+
.
1575+
.TP
15721576
\-\fBacquire\-by\-hash\fR
15731577
provide index files by hash
15741578
.
@@ -1714,6 +1718,10 @@ Options:
17141718
set value for Signed-By field
17151719
.
17161720
.TP
1721+
\-\fBversion\fR
1722+
version of the release
1723+
.
1724+
.TP
17171725
\-\fBacquire\-by\-hash\fR
17181726
provide index files by hash
17191727
.
@@ -2187,6 +2195,10 @@ Options:
21872195
set value for Signed-By field
21882196
.
21892197
.TP
2198+
\-\fBversion\fR
2199+
version of the release
2200+
.
2201+
.TP
21902202
\-\fBbatch\fR
21912203
run GPG with detached tty
21922204
.

system/t06_publish/PublishList5Test_gold

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
}
2525
],
2626
"Storage": "",
27-
"Suite": ""
27+
"Suite": "",
28+
"Version": ""
2829
},
2930
{
3031
"AcquireByHash": false,
@@ -50,7 +51,8 @@
5051
}
5152
],
5253
"Storage": "",
53-
"Suite": ""
54+
"Suite": "",
55+
"Version": ""
5456
},
5557
{
5658
"AcquireByHash": false,
@@ -77,7 +79,8 @@
7779
}
7880
],
7981
"Storage": "",
80-
"Suite": ""
82+
"Suite": "",
83+
"Version": ""
8184
},
8285
{
8386
"AcquireByHash": false,
@@ -104,6 +107,7 @@
104107
}
105108
],
106109
"Storage": "",
107-
"Suite": ""
110+
"Suite": "",
111+
"Version": ""
108112
}
109113
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
7+
Local repo local-repo has been successfully published.
8+
Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing.
9+
Now you can add following line to apt sources:
10+
deb http://your-server/ maverick contrib
11+
deb-src http://your-server/ maverick contrib
12+
Don't forget to add your GPG key to apt with apt-key.
13+
14+
You can also use `aptly serve` to publish your repositories over HTTP quickly.

0 commit comments

Comments
 (0)