-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepo_ebuild.go
53 lines (44 loc) · 1.38 KB
/
repo_ebuild.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package pkgcraft
// #cgo pkg-config: pkgcraft
// #include <pkgcraft.h>
import "C"
import (
"runtime"
)
type EbuildRepo struct {
*BaseRepo
// cached fields
eapi *Eapi
}
// Return an ebuild repo's EAPI.
func (self *EbuildRepo) Eapi() *Eapi {
if self.eapi == nil {
ptr := C.pkgcraft_repo_ebuild_eapi(self.ptr)
s := C.pkgcraft_eapi_as_str(ptr)
defer C.pkgcraft_str_free(s)
self.eapi = EAPIS[C.GoString(s)]
}
return self.eapi
}
func (self *EbuildRepo) createPkg(ptr *C.Pkg) *EbuildPkg {
format := PkgFormat(C.pkgcraft_pkg_format(ptr))
pkg := &EbuildPkg{&BasePkg{ptr: ptr, format: format}}
runtime.SetFinalizer(pkg, func(self *EbuildPkg) { C.pkgcraft_pkg_free(self.ptr) })
return pkg
}
// Return an iterator over the packages of a repo.
func (self *EbuildRepo) Iter() *repoIter[*EbuildPkg] {
return newRepoIter[*EbuildPkg](self)
}
// Return a channel iterating over the packages of a repo.
func (self *EbuildRepo) Pkgs() <-chan *EbuildPkg {
return repoPkgs[*EbuildPkg](self)
}
// Return an iterator over the restricted packages of a repo.
func (self *EbuildRepo) IterRestrict(restrict *Restrict) *repoIterRestrict[*EbuildPkg] {
return newRepoIterRestrict[*EbuildPkg](self, restrict)
}
// Return a channel iterating over the restricted packages of a repo.
func (self *EbuildRepo) RestrictPkgs(restrict *Restrict) <-chan *EbuildPkg {
return repoRestrictPkgs[*EbuildPkg](self, restrict)
}