Skip to content
Open
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 cmd/chisel/cmd_cut.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (cmd *cmdCut) Execute(args []string) error {
PubKeys: archiveInfo.PubKeys,
Maintained: archiveInfo.Maintained,
OldRelease: archiveInfo.OldRelease,
Url: archiveInfo.Url,
})
if err != nil {
if err == archive.ErrCredentialsNotFound {
Expand Down
25 changes: 22 additions & 3 deletions internal/archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type Options struct {
// OldRelease is set for Ubuntu releases which are moved from the regular
// archive which happens after the release's end of life date.
OldRelease bool
// Custom url for an archive. Can't be used with 'Pro', probably.
Url string
}

func Open(options *Options) (Archive, error) {
Expand Down Expand Up @@ -223,10 +225,23 @@ func openUbuntu(options *Options) (Archive, error) {
if len(options.Version) == 0 {
return nil, fmt.Errorf("archive options missing version")
}
var baseURL string
var creds *credentials

baseURL, creds, err := archiveURL(options.Pro, options.Arch, options.OldRelease)
if err != nil {
return nil, err
if options.Url == "" {
var err error
baseURL, creds, err = archiveURL(options.Pro, options.Arch, options.OldRelease)
if err != nil {
return nil, err
}
} else {
if strings.HasPrefix(options.Url, "http://") ||
strings.HasPrefix(options.Url, "https://") {
baseURL = options.Url
creds = nil
} else {
return nil, fmt.Errorf("archive url should start with http:// or https://. Got %q", options.Url)
}
}

archive := &ubuntuArchive{
Expand Down Expand Up @@ -318,6 +333,10 @@ func (index *ubuntuIndex) fetchRelease() error {
if index.archive.options.Pro != "" {
label = proArchiveInfo[index.archive.options.Pro].Label
}
// Custom archive name must match it's label
if index.archive.options.Url != "" {
label = index.archive.options.Label
}
section := ctrl.Section(label)
if section == nil {
return fmt.Errorf("corrupted archive InRelease file: no %s section", label)
Expand Down
1 change: 1 addition & 0 deletions internal/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type Archive struct {
// OldRelease is set for Ubuntu releases which are moved from the regular
// archive which happens after the release's end of life date.
OldRelease bool
Url string
}

// Package holds a collection of slices that represent parts of themselves.
Expand Down
2 changes: 2 additions & 0 deletions internal/setup/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type yamlArchive struct {
Pro string `yaml:"pro"`
Default bool `yaml:"default"`
PubKeys []string `yaml:"public-keys"`
Url string `yaml:"url"`
}

type yamlStore struct {
Expand Down Expand Up @@ -371,6 +372,7 @@ func parseRelease(baseDir, filePath string, data []byte) (*Release, error) {
Pro: details.Pro,
Priority: priority,
PubKeys: archiveKeys,
Url: details.Url,
}
}
if (hasPriority && archiveNoPriority != "") ||
Expand Down