Example #1
0
// BuildPkgInfo produces information about a package.
func BuildPkgInfo(pkgname, dbname string) (resp []byte, er error) {
	alpmHandleLock.Lock()
	defer alpmHandleLock.Unlock()

	var (
		pkg *alpm.Package
		db  *alpm.Db
	)
	h := getAlpm()
	switch dbname {
	case "", "local":
		dbname = "local"
		db, er = h.LocalDb()
	default:
		db, er = h.SyncDbByName(dbname)
	}
	if er != nil {
		return
	}

	pkg, er = db.PkgByName(pkgname)
	if er != nil {
		return
	}

	s, er := Execute("pkginfo", CommonData{}, map[string]interface{}{
		"Package": pkg,
		"Repo":    dbname,
	})
	return s, er
}
Example #2
0
// forallFilenames iterates call() over all (relative) file paths
// from packages in db.
func forallFilenames(db *alpm.Db, call func(string) error) error {
	return db.PkgCache().ForEach(func(pkg alpm.Package) error {
		for _, file := range pkg.Files() {
			er := call(file.Name)
			if er != nil {
				return er
			}
		}
		return nil
	})
}