Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a custom Suite when publishing #874

Merged
merged 6 commits into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ List of contributors, in chronological order:
* Shengjing Zhu (https://github.com/zhsj)
* Nabil Bendafi (https://github.com/nabilbendafi)
* Raphael Medaer (https://github.com/rmedaer)
* Raul Benencia (https://github.com/rul)
1 change: 1 addition & 0 deletions cmd/publish_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Example:
cmd.Flag.String("notautomatic", "", "set value for NotAutomatic field")
cmd.Flag.String("butautomaticupgrades", "", "set value for ButAutomaticUpgrades field")
cmd.Flag.String("label", "", "label to publish")
cmd.Flag.String("suite", "", "suite to publish (defaults to distribution)")
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
cmd.Flag.Bool("acquire-by-hash", false, "provide index files by hash")

Expand Down
2 changes: 2 additions & 0 deletions cmd/publish_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
published.ButAutomaticUpgrades = butAutomaticUpgrades
}
published.Label = context.Flags().Lookup("label").Value.String()
published.Suite = context.Flags().Lookup("suite").Value.String()

published.SkipContents = context.Config().SkipContentsPublishing

Expand Down Expand Up @@ -230,6 +231,7 @@ Example:
cmd.Flag.String("notautomatic", "", "overwrite value for NotAutomatic field")
cmd.Flag.String("butautomaticupgrades", "", "overwrite value for ButAutomaticUpgrades field")
cmd.Flag.String("label", "", "label to publish")
cmd.Flag.String("suite", "", "suite to publish (defaults to distribution)")
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
cmd.Flag.Bool("acquire-by-hash", false, "provide index files by hash")

Expand Down
1 change: 1 addition & 0 deletions completion.d/_aptly
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ local keyring="*-keyring=[gpg keyring to use when verifying Release file (could
"-butautomaticupgrades=[set value for ButAutomaticUpgrades field]:$bool"
"-distribution=[distribution name to publish]:distribution:($dists)"
"-label=[label to publish]:label: "
"-suite=[suite to publish]:suite: "
"-notautomatic=[set value for NotAutomatic field]:notautomatic: "
"-origin=[origin name to publish]:origin: "
${components_options[@]}
Expand Down
2 changes: 1 addition & 1 deletion completion.d/aptly
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ _aptly()
"snapshot"|"repo")
if [[ $numargs -eq 0 ]]; then
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "-acquire-by-hash -batch -butautomaticupgrades= -component= -distribution= -force-overwrite -gpg-key= -keyring= -label= -notautomatic= -origin= -passphrase= -passphrase-file= -secret-keyring= -skip-contents -skip-signing" -- ${cur}))
COMPREPLY=($(compgen -W "-acquire-by-hash -batch -butautomaticupgrades= -component= -distribution= -force-overwrite -gpg-key= -keyring= -label= -suite= -notautomatic= -origin= -passphrase= -passphrase-file= -secret-keyring= -skip-contents -skip-signing" -- ${cur}))
else
if [[ "$subcmd" == "snapshot" ]]; then
COMPREPLY=($(compgen -W "$(__aptly_snapshot_list)" -- ${cur}))
Expand Down
17 changes: 16 additions & 1 deletion deb/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type PublishedRepo struct {
NotAutomatic string
ButAutomaticUpgrades string
Label string
Suite string
// Architectures is a list of all architectures published
Architectures []string
// SourceKind is "local"/"repo"
Expand Down Expand Up @@ -308,6 +309,7 @@ func (p *PublishedRepo) MarshalJSON() ([]byte, error) {
"Distribution": p.Distribution,
"Label": p.Label,
"Origin": p.Origin,
"Suite": p.Suite,
"NotAutomatic": p.NotAutomatic,
"ButAutomaticUpgrades": p.ButAutomaticUpgrades,
"Prefix": p.Prefix,
Expand Down Expand Up @@ -357,6 +359,10 @@ func (p *PublishedRepo) String() string {
extras = append(extras, fmt.Sprintf("label: %s", p.Label))
}

if p.Suite != "" {
extras = append(extras, fmt.Sprintf("suite: %s", p.Suite))
}

extra = strings.Join(extras, ", ")

if extra != "" {
Expand Down Expand Up @@ -485,6 +491,14 @@ func (p *PublishedRepo) GetLabel() string {
return p.Label
}

// GetSuite returns default or manual Suite:
func (p *PublishedRepo) GetSuite() string {
if p.Suite == "" {
return p.Distribution
}
return p.Suite
}

// Publish publishes snapshot (repository) contents, links package files, generates Packages & Release files, signs them
func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageProvider aptly.PublishedStorageProvider,
collectionFactory *CollectionFactory, signer pgp.Signer, progress aptly.Progress, forceOverwrite bool) error {
Expand Down Expand Up @@ -707,6 +721,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
release["Component"] = component
release["Origin"] = p.GetOrigin()
release["Label"] = p.GetLabel()
release["Suite"] = p.GetSuite()
if p.AcquireByHash {
release["Acquire-By-Hash"] = "yes"
}
Expand Down Expand Up @@ -763,7 +778,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
release["ButAutomaticUpgrades"] = p.ButAutomaticUpgrades
}
release["Label"] = p.GetLabel()
release["Suite"] = p.Distribution
release["Suite"] = p.GetSuite()
release["Codename"] = p.Distribution
release["Date"] = time.Now().UTC().Format("Mon, 2 Jan 2006 15:04:05 MST")
release["Architectures"] = strings.Join(utils.StrSlicesSubstract(p.Architectures, []string{ArchitectureSource}), " ")
Expand Down
24 changes: 21 additions & 3 deletions man/aptly.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "APTLY" "1" "August 2019" "" ""
.TH "APTLY" "1" "September 2019" "" ""
.
.SH "NAME"
\fBaptly\fR \- Debian repository management tool
Expand Down Expand Up @@ -39,8 +39,8 @@ Configuration file is stored in JSON format (default values shown below):
"downloadConcurrency": 4,
"downloadSpeedLimit": 0,
"downloadRetries": 0,
"architectures": [],
"databaseOpenAttempts": 10,
"architectures": [],
"dependencyFollowSuggests": false,
"dependencyFollowRecommends": false,
"dependencyFollowAllVariants": false,
Expand Down Expand Up @@ -124,7 +124,7 @@ number of retries for download attempts
.
.TP
\fBdatabaseOpenAttempts\fR
number of attempts to open DB if it's locked by other instance; could be overridden with option \fB\-db-open-attempts\fR
number of attempts to open DB if it\(cqs locked by other instance; could be overridden with option \fB\-db\-open\-attempts\fR
.
.TP
\fBarchitectures\fR
Expand Down Expand Up @@ -1454,6 +1454,10 @@ don\(cqt generate Contents indexes
\-\fBskip\-signing\fR
don\(cqt sign Release files with GPG
.
.TP
\-\fBsuite\fR=
suite to publish (defaults to distribution)
.
.SH "PUBLISH SNAPSHOT"
\fBaptly\fR \fBpublish\fR \fBsnapshot\fR \fIname\fR [[\fIendpoint\fR:]\fIprefix\fR]
.
Expand Down Expand Up @@ -1553,6 +1557,10 @@ don\(cqt generate Contents indexes
\-\fBskip\-signing\fR
don\(cqt sign Release files with GPG
.
.TP
\-\fBsuite\fR=
suite to publish (defaults to distribution)
.
.SH "UPDATE PUBLISHED REPOSITORY BY SWITCHING TO NEW SNAPSHOT"
\fBaptly\fR \fBpublish\fR \fBswitch\fR \fIdistribution\fR [[\fIendpoint\fR:]\fIprefix\fR] \fInew\-snapshot\fR
.
Expand Down Expand Up @@ -2066,4 +2074,14 @@ William Manley (https://github\.com/wmanley)
.IP "\[ci]" 4
Shengjing Zhu (https://github\.com/zhsj)
.
.IP "\[ci]" 4
Nabil Bendafi (https://github\.com/nabilbendafi)
.
.IP "\[ci]" 4
Raphael Medaer (https://github\.com/rmedaer)
.
.IP "\[ci]" 4
Raul Benencia (https://github\.com/rul)
.
.IP "" 0

1 change: 1 addition & 0 deletions system/t06_publish/PublishSnapshot1Test_release_amd64
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Origin: LP-PPA-gladky-anton-gnuplot
Label: . maverick
Archive: maverick
Suite: maverick
Architecture: amd64
Component: main
1 change: 1 addition & 0 deletions system/t06_publish/PublishSnapshot1Test_release_i386
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Origin: LP-PPA-gladky-anton-gnuplot
Label: . maverick
Archive: maverick
Suite: maverick
Architecture: i386
Component: main
1 change: 1 addition & 0 deletions system/t06_publish/PublishSnapshot35Test_release_udeb_i386
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Origin: Debian
Label: . stretch
Archive: stretch
Suite: stretch
Architecture: i386
Component: main
Loading