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


Golang aptly.PackagePool类代码示例

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


在下文中一共展示了PackagePool类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: FilepathList

// FilepathList returns list of paths to files in package repository
func (p *Package) FilepathList(packagePool aptly.PackagePool) ([]string, error) {
	var err error
	result := make([]string, len(p.Files()))

	for i, f := range p.Files() {
		result[i], err = packagePool.RelativePath(f.Filename, f.Checksums.MD5)
		if err != nil {
			return nil, err
		}
	}

	return result, nil
}
开发者ID:sromberg,项目名称:aptly,代码行数:14,代码来源:package.go

示例4: 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

示例5: 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

示例6: 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

示例7: ImportPackageFiles

// ImportPackageFiles imports files into local repository
func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace bool, verifier utils.Verifier,
	pool aptly.PackagePool, collection *PackageCollection, reporter aptly.ResultReporter, restriction PackageQuery) (processedFiles []string, failedFiles []string, err error) {
	if forceReplace {
		list.PrepareIndex()
	}

	for _, file := range packageFiles {
		var (
			stanza Stanza
			p      *Package
		)

		candidateProcessedFiles := []string{}
		isSourcePackage := strings.HasSuffix(file, ".dsc")
		isUdebPackage := strings.HasSuffix(file, ".udeb")

		if isSourcePackage {
			stanza, err = GetControlFileFromDsc(file, verifier)

			if err == nil {
				stanza["Package"] = stanza["Source"]
				delete(stanza, "Source")

				p, err = NewSourcePackageFromControlFile(stanza)
			}
		} else {
			stanza, err = GetControlFileFromDeb(file)
			if isUdebPackage {
				p = NewUdebPackageFromControlFile(stanza)
			} else {
				p = NewPackageFromControlFile(stanza)
			}
		}
		if err != nil {
			reporter.Warning("Unable to read file %s: %s", file, err)
			failedFiles = append(failedFiles, file)
			continue
		}

		if p.Name == "" {
			reporter.Warning("Empty package name on %s", file)
			failedFiles = append(failedFiles, file)
			continue
		}

		if p.Version == "" {
			reporter.Warning("Empty version on %s", file)
			failedFiles = append(failedFiles, file)
			continue
		}

		if p.Architecture == "" {
			reporter.Warning("Empty architecture on %s", file)
			failedFiles = append(failedFiles, file)
			continue
		}

		var checksums utils.ChecksumInfo
		checksums, err = utils.ChecksumsForFile(file)
		if err != nil {
			return nil, nil, err
		}

		if isSourcePackage {
			p.UpdateFiles(append(p.Files(), PackageFile{Filename: filepath.Base(file), Checksums: checksums}))
		} else {
			p.UpdateFiles([]PackageFile{{Filename: filepath.Base(file), Checksums: checksums}})
		}

		err = pool.Import(file, checksums.MD5)
		if err != nil {
			reporter.Warning("Unable to import file %s into pool: %s", file, err)
			failedFiles = append(failedFiles, file)
			continue
		}

		candidateProcessedFiles = append(candidateProcessedFiles, file)

		// go over all files, except for the last one (.dsc/.deb itself)
		for _, f := range p.Files() {
			if filepath.Base(f.Filename) == filepath.Base(file) {
				continue
			}
			sourceFile := filepath.Join(filepath.Dir(file), filepath.Base(f.Filename))
			err = pool.Import(sourceFile, f.Checksums.MD5)
			if err != nil {
				reporter.Warning("Unable to import file %s into pool: %s", sourceFile, err)
				failedFiles = append(failedFiles, file)
				break
			}

			candidateProcessedFiles = append(candidateProcessedFiles, sourceFile)
		}
		if err != nil {
			// some files haven't been imported
			continue
		}

		if restriction != nil && !restriction.Matches(p) {
//.........这里部分代码省略.........
开发者ID:liftup,项目名称:aptly,代码行数:101,代码来源:import.go


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