当前位置: 首页>>代码示例>>Golang>>正文


Golang PackagePool.Path方法代码示例

本文整理汇总了Golang中github.com/smira/aptly/aptly.PackagePool.Path方法的典型用法代码示例。如果您正苦于以下问题:Golang PackagePool.Path方法的具体用法?Golang PackagePool.Path怎么用?Golang PackagePool.Path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/smira/aptly/aptly.PackagePool的用法示例。


在下文中一共展示了PackagePool.Path方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: LinkFromPool

// 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
}
开发者ID:sromberg,项目名称:aptly,代码行数:30,代码来源:package.go

示例2: LinkFromPool

// 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
}
开发者ID:hdonnay,项目名称:aptly,代码行数:28,代码来源:package.go

示例3: Verify

// 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
}
开发者ID:pombredanne,项目名称:aptly,代码行数:16,代码来源:package_files.go

示例4: CalculateContents

// 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
}
开发者ID:pombredanne,项目名称:aptly,代码行数:19,代码来源:package.go

示例5: DownloadList

// 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
}
开发者ID:sromberg,项目名称:aptly,代码行数:23,代码来源:package.go


注:本文中的github.com/smira/aptly/aptly.PackagePool.Path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。