// LinkFromPool links package file from pool to dist's pool location func (p *Package) LinkFromPool(publishedStorage aptly.PublishedStorage, packagePool aptly.PackagePool, prefix string, component string) error { poolDir, err := p.PoolDirectory() if err != nil { return err } for i, f := range p.Files() { sourcePath, err := packagePool.Path(f.Filename, f.Checksums.MD5) if err != nil { return err } relPath := filepath.Join("pool", component, poolDir) publishedDirectory := filepath.Join(prefix, relPath) err = publishedStorage.LinkFromPool(publishedDirectory, packagePool, sourcePath) if err != nil { return err } if p.IsSource { p.Extra()["Directory"] = relPath } else { p.Files()[i].downloadPath = relPath } } return nil }
// LinkFromPool links package file from pool to dist's pool location func (p *Package) LinkFromPool(publishedStorage aptly.PublishedStorage, packagePool aptly.PackagePool, prefix string, component string) error { poolDir, err := p.PoolDirectory() if err != nil { return err } for i, f := range p.Files { sourcePath, err := packagePool.Path(f.Filename, f.Checksums.MD5) if err != nil { return err } relPath, err := publishedStorage.LinkFromPool(prefix, component, poolDir, packagePool, sourcePath) if err != nil { return err } dir := filepath.Dir(relPath) if p.IsSource { p.Extra["Directory"] = dir } else { p.Files[i].downloadPath = dir } } return nil }
// Verify that package file is present and correct func (f *PackageFile) Verify(packagePool aptly.PackagePool) (bool, error) { poolPath, err := packagePool.Path(f.Filename, f.Checksums.MD5) if err != nil { return false, err } st, err := os.Stat(poolPath) if err != nil { return false, nil } // verify size // TODO: verify checksum if configured return st.Size() == f.Checksums.Size, nil }
// CalculateContents looks up contents in package file func (p *Package) CalculateContents(packagePool aptly.PackagePool) []string { if p.IsSource { return nil } file := p.Files()[0] path, err := packagePool.Path(file.Filename, file.Checksums.MD5) if err != nil { panic(err) } contents, err := GetContentsFromDeb(path) if err != nil { panic(err) } return contents }
// DownloadList returns list of missing package files for download in format // [[srcpath, dstpath]] func (p *Package) DownloadList(packagePool aptly.PackagePool) (result []PackageDownloadTask, err error) { result = make([]PackageDownloadTask, 0, 1) for _, f := range p.Files() { poolPath, err := packagePool.Path(f.Filename, f.Checksums.MD5) if err != nil { return nil, err } verified, err := f.Verify(packagePool) if err != nil { return nil, err } if !verified { result = append(result, PackageDownloadTask{RepoURI: f.DownloadURL(), DestinationPath: poolPath, Checksums: f.Checksums}) } } return result, nil }