Enable the ability to pass in a custom codename

While testing out Aptly, the `apt-get` client complains with the following error, since the `codename` was switched from the InRelease files that are baked out by Aptly:

```
E: Repository 'http://debianrepo.example.com/bionic testing InRelease' changed its 'Codename' value from '' to 'testing'
```
This commit is contained in:
Steven Stone
2019-10-30 18:43:57 -04:00
committed by Benj Fassbind
parent 393d1a6888
commit a59cad6f20
11 changed files with 43 additions and 2 deletions
+16 -1
View File
@@ -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"
@@ -312,6 +313,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,
@@ -366,6 +368,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 != "" {
@@ -513,6 +519,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 {
@@ -735,6 +749,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"
}
@@ -793,7 +808,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 {