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

Enable the ability to set a custom Codename when publishing #892

Closed
wants to merge 4 commits into from
Closed
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
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ List of contributors, in chronological order:
* Raphael Medaer (https://github.com/rmedaer)
* Raul Benencia (https://github.com/rul)
* Don Kuntz (https://github.com/dkuntz2)
* Steven Stone (https://github.com/smstone)
* Joshua Colson (https://github.com/freakinhippie)
* Andre Roth (https://github.com/neolynx)
* Lorenzo Bolla (https://github.com/lbolla)
* Benj Fassbind (https://github.com/randombenj)
* Benj Fassbind (https://github.com/randombenj)
1 change: 1 addition & 0 deletions cmd/publish_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Example:
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.String("codename", "", "codename 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 @@ -132,6 +132,7 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
}
published.Label = context.Flags().Lookup("label").Value.String()
published.Suite = context.Flags().Lookup("suite").Value.String()
published.Codename = context.Flags().Lookup("codename").Value.String()

published.SkipContents = context.Config().SkipContentsPublishing

Expand Down Expand Up @@ -233,6 +234,7 @@ Example:
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.String("codename", "", "codename 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 @@ -455,6 +455,7 @@ local keyring="*-keyring=[gpg keyring to use when verifying Release file (could
"-distribution=[distribution name to publish]:distribution:($dists)"
"-label=[label to publish]:label: "
"-suite=[suite to publish]:suite: "
"-codename=[codename to publish]:codename: "
"-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 @@ -503,7 +503,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= -suite= -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= -codename= -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 {
ButAutomaticUpgrades string
Label string
Suite string
Codename string
// Architectures is a list of all architectures published
Architectures []string
// SourceKind is "local"/"repo"
Expand Down Expand Up @@ -309,6 +310,7 @@ func (p *PublishedRepo) MarshalJSON() ([]byte, error) {
"Label": p.Label,
"Origin": p.Origin,
"Suite": p.Suite,
"Codename": p.Codename,
"NotAutomatic": p.NotAutomatic,
"ButAutomaticUpgrades": p.ButAutomaticUpgrades,
"Prefix": p.Prefix,
Expand Down Expand Up @@ -363,6 +365,10 @@ func (p *PublishedRepo) String() string {
extras = append(extras, fmt.Sprintf("suite: %s", p.Suite))
}

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

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

if extra != "" {
Expand Down Expand Up @@ -510,6 +516,14 @@ func (p *PublishedRepo) GetSuite() string {
return p.Suite
}

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

// 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 @@ -732,6 +746,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
release["Origin"] = p.GetOrigin()
release["Label"] = p.GetLabel()
release["Suite"] = p.GetSuite()
release["Codename"] = p.GetCodename()
if p.AcquireByHash {
release["Acquire-By-Hash"] = "yes"
}
Expand Down Expand Up @@ -790,7 +805,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
}
release["Label"] = p.GetLabel()
release["Suite"] = p.GetSuite()
release["Codename"] = p.Distribution
release["Codename"] = p.GetCodename()
release["Date"] = time.Now().UTC().Format("Mon, 2 Jan 2006 15:04:05 MST")
release["Architectures"] = strings.Join(utils.StrSlicesSubstract(p.Architectures, []string{ArchitectureSource}), " ")
if p.AcquireByHash {
Expand Down
8 changes: 8 additions & 0 deletions man/aptly.1
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,10 @@ don\(cqt sign Release files with GPG
\-\fBsuite\fR=
suite to publish (defaults to distribution)
.
.TP
\-\fBcodename\fR=
codename to publish (defaults to distribution)
.
.SH "PUBLISH SNAPSHOT"
\fBaptly\fR \fBpublish\fR \fBsnapshot\fR \fIname\fR [[\fIendpoint\fR:]\fIprefix\fR]
.
Expand Down Expand Up @@ -1561,6 +1565,10 @@ don\(cqt sign Release files with GPG
\-\fBsuite\fR=
suite to publish (defaults to distribution)
.
.TP
\-\fBcodename\fR=
codename 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
1 change: 1 addition & 0 deletions system/t06_publish/PublishSnapshot1Test_release_amd64
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ Origin: LP-PPA-gladky-anton-gnuplot
Label: . maverick
Archive: maverick
Suite: maverick
Codename: 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
Expand Up @@ -2,5 +2,6 @@ Origin: LP-PPA-gladky-anton-gnuplot
Label: . maverick
Archive: maverick
Suite: maverick
Codename: 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
Expand Up @@ -2,5 +2,6 @@ Origin: Debian
Label: . stretch
Archive: stretch
Suite: stretch
Codename: stretch
Architecture: i386
Component: main
1 change: 1 addition & 0 deletions system/t06_publish/PublishSnapshot39Test_release_amd64
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ Origin: LP-PPA-gladky-anton-gnuplot
Label: . maverick
Archive: maverick
Suite: stable
Codename: maverick
Architecture: amd64
Component: main
1 change: 1 addition & 0 deletions system/t06_publish/PublishSnapshot39Test_release_i386
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ Origin: LP-PPA-gladky-anton-gnuplot
Label: . maverick
Archive: maverick
Suite: stable
Codename: maverick
Architecture: i386
Component: main
10 changes: 10 additions & 0 deletions system/t12_api/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def check(self):
repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'],
'Codename': '',
'Distribution': 'wheezy',
'Label': '',
'Origin': '',
Expand Down Expand Up @@ -86,6 +87,7 @@ def check(self):
repo2_expected = {
'AcquireByHash': False,
'Architectures': ['amd64', 'i386'],
'Codename': '',
'Distribution': distribution,
'Label': '',
'Origin': '',
Expand Down Expand Up @@ -164,6 +166,7 @@ def check(self):
repo_expected = {
'AcquireByHash': True,
'Architectures': ['i386'],
'Codename': '',
'Distribution': 'squeeze',
'Label': 'fun',
'Origin': 'earth',
Expand Down Expand Up @@ -249,6 +252,7 @@ def check(self):
repo_expected = {
'AcquireByHash': True,
'Architectures': ['i386', 'source'],
'Codename': '',
'Distribution': 'wheezy',
'Label': '',
'Origin': '',
Expand Down Expand Up @@ -343,6 +347,7 @@ def check(self):
repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'],
'Codename': '',
'Distribution': 'wheezy',
'Label': '',
'Origin': '',
Expand Down Expand Up @@ -406,6 +411,7 @@ def check(self):
repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'],
'Codename': '',
'Distribution': 'wheezy',
'Label': '',
'NotAutomatic': '',
Expand Down Expand Up @@ -449,6 +455,7 @@ def check(self):
repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'],
'Codename': '',
'Distribution': 'wheezy',
'Label': '',
'Origin': '',
Expand Down Expand Up @@ -510,6 +517,7 @@ def check(self):
repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'],
'Codename': '',
'Distribution': 'wheezy',
'Label': '',
'NotAutomatic': '',
Expand Down Expand Up @@ -546,6 +554,7 @@ def check(self):
repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'],
'Codename': '',
'Distribution': 'otherdist',
'Label': '',
'NotAutomatic': '',
Expand Down Expand Up @@ -584,6 +593,7 @@ def check(self):
repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'],
'Codename': '',
'Distribution': 'wheezy',
'Label': '',
'Origin': '',
Expand Down