Skip to content

Commit

Permalink
Fix the installer path for Ubuntu Focal
Browse files Browse the repository at this point in the history
Ubuntu has started depreciating the Debian installer in focal
and moved the installer images to a different path. In versions
after focal, they are completly removed. This basically gives
us more time to figure out how to use the new system.
  • Loading branch information
Robert LeBlanc authored and neolynx committed Mar 6, 2024
1 parent 72a7780 commit 6a229c0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
8 changes: 6 additions & 2 deletions deb/index_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func newIndexFiles(publishedStorage aptly.PublishedStorage, basePath, tempDir, s
}
}

func (files *indexFiles) PackageIndex(component, arch string, udeb, installer bool) *indexFile {
func (files *indexFiles) PackageIndex(component, arch string, udeb bool, installer bool, distribution string) *indexFile {
if arch == ArchitectureSource {
udeb = false
}
Expand All @@ -264,7 +264,11 @@ func (files *indexFiles) PackageIndex(component, arch string, udeb, installer bo
if udeb {
relativePath = filepath.Join(component, "debian-installer", fmt.Sprintf("binary-%s", arch), "Packages")
} else if installer {
relativePath = filepath.Join(component, fmt.Sprintf("installer-%s", arch), "current", "images", "SHA256SUMS")
if distribution == "focal" {
relativePath = filepath.Join(component, fmt.Sprintf("installer-%s", arch), "current", "legacy-images", "SHA256SUMS")
} else {
relativePath = filepath.Join(component, fmt.Sprintf("installer-%s", arch), "current", "images", "SHA256SUMS")
}
} else {
relativePath = filepath.Join(component, fmt.Sprintf("binary-%s", arch), "Packages")
}
Expand Down
7 changes: 6 additions & 1 deletion deb/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ func NewInstallerPackageFromControlFile(input Stanza, repo *RemoteRepo, componen
return nil, err
}

relPath := filepath.Join("dists", repo.Distribution, component, fmt.Sprintf("%s-%s", p.Name, architecture), "current", "images")
var relPath string
if repo.Distribution == "focal" {
relPath = filepath.Join("dists", repo.Distribution, component, fmt.Sprintf("%s-%s", p.Name, architecture), "current", "legacy-images")
} else {
relPath = filepath.Join("dists", repo.Distribution, component, fmt.Sprintf("%s-%s", p.Name, architecture), "current", "images")
}
for i := range files {
files[i].downloadPath = relPath

Expand Down
12 changes: 8 additions & 4 deletions deb/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP

// For all architectures, pregenerate packages/sources files
for _, arch := range p.Architectures {
indexes.PackageIndex(component, arch, false, false)
indexes.PackageIndex(component, arch, false, false, p.Distribution)
}

list.PrepareIndex()
Expand All @@ -665,7 +665,11 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
}
relPath = filepath.Join("pool", component, poolDir)
} else {
relPath = filepath.Join("dists", p.Distribution, component, fmt.Sprintf("%s-%s", pkg.Name, arch), "current", "images")
if p.Distribution == "focal" {
relPath = filepath.Join("dists", p.Distribution, component, fmt.Sprintf("%s-%s", pkg.Name, arch), "current", "legacy-images")
} else {
relPath = filepath.Join("dists", p.Distribution, component, fmt.Sprintf("%s-%s", pkg.Name, arch), "current", "images")
}
}

err = pkg.LinkFromPool(publishedStorage, packagePool, p.Prefix, relPath, forceOverwrite)
Expand Down Expand Up @@ -703,7 +707,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
}
}

bufWriter, err = indexes.PackageIndex(component, arch, pkg.IsUdeb, pkg.IsInstaller).BufWriter()
bufWriter, err = indexes.PackageIndex(component, arch, pkg.IsUdeb, pkg.IsInstaller, p.Distribution).BufWriter()
if err != nil {
return err
}
Expand Down Expand Up @@ -757,7 +761,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP

// For all architectures, pregenerate .udeb indexes
for _, arch := range p.Architectures {
indexes.PackageIndex(component, arch, true, false)
indexes.PackageIndex(component, arch, true, false, p.Distribution)
}
}

Expand Down
6 changes: 5 additions & 1 deletion deb/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ func (repo *RemoteRepo) UdebPath(component string, architecture string) string {
// InstallerPath returns path of Packages files for given component and
// architecture
func (repo *RemoteRepo) InstallerPath(component string, architecture string) string {
return fmt.Sprintf("%s/installer-%s/current/images/SHA256SUMS", component, architecture)
if repo.Distribution == "focal" {
return fmt.Sprintf("%s/installer-%s/current/legacy-images/SHA256SUMS", component, architecture)
} else {

Check warning on line 264 in deb/remote.go

View workflow job for this annotation

GitHub Actions / test

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
return fmt.Sprintf("%s/installer-%s/current/images/SHA256SUMS", component, architecture)
}
}

// PackageURL returns URL of package file relative to repository root
Expand Down

0 comments on commit 6a229c0

Please sign in to comment.