NewRemoteRepo creates new instance of Debian remote repository with specified params
(name string, archiveRoot string, distribution string, components []string, architectures []string, downloadSources bool, downloadUdebs bool, downloadInstaller bool, downloadAppStream bool)
| 86 | |
| 87 | // NewRemoteRepo creates new instance of Debian remote repository with specified params |
| 88 | func NewRemoteRepo(name string, archiveRoot string, distribution string, components []string, |
| 89 | architectures []string, downloadSources bool, downloadUdebs bool, downloadInstaller bool, downloadAppStream bool) (*RemoteRepo, error) { |
| 90 | result := &RemoteRepo{ |
| 91 | UUID: uuid.NewString(), |
| 92 | Name: name, |
| 93 | ArchiveRoot: archiveRoot, |
| 94 | Distribution: distribution, |
| 95 | Components: components, |
| 96 | Architectures: architectures, |
| 97 | DownloadSources: downloadSources, |
| 98 | DownloadUdebs: downloadUdebs, |
| 99 | DownloadInstaller: downloadInstaller, |
| 100 | DownloadAppStream: downloadAppStream, |
| 101 | } |
| 102 | |
| 103 | err := result.prepare() |
| 104 | if err != nil { |
| 105 | return nil, err |
| 106 | } |
| 107 | |
| 108 | if strings.HasSuffix(result.Distribution, "/") || strings.HasPrefix(result.Distribution, ".") { |
| 109 | // flat repo |
| 110 | if !strings.HasPrefix(result.Distribution, ".") { |
| 111 | result.Distribution = "./" + result.Distribution |
| 112 | } |
| 113 | if len(result.Components) > 0 { |
| 114 | return nil, fmt.Errorf("components aren't supported for flat repos") |
| 115 | } |
| 116 | if result.DownloadUdebs { |
| 117 | return nil, fmt.Errorf("debian-installer udebs aren't supported for flat repos") |
| 118 | } |
| 119 | if result.DownloadAppStream { |
| 120 | return nil, fmt.Errorf("AppStream (DEP-11) metadata isn't supported for flat repos") |
| 121 | } |
| 122 | result.Components = nil |
| 123 | } |
| 124 | |
| 125 | return result, nil |
| 126 | } |
| 127 | |
| 128 | // SetArchiveRoot of remote repo |
| 129 | func (repo *RemoteRepo) SetArchiveRoot(archiveRoot string) { |