forked from remyoudompheng/go-alpm
-
Notifications
You must be signed in to change notification settings - Fork 14
/
deps.go
47 lines (35 loc) · 1.13 KB
/
deps.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
package alpm
/*
#include <alpm.h>
*/
import "C"
import (
"fmt"
"unsafe"
)
// FindSatisfier searches a DBList for a package that satisfies depstring
// Example "glibc>=2.12"
func (l DBList) FindSatisfier(depstring string) (IPackage, error) {
cDepString := C.CString(depstring)
defer C.free(unsafe.Pointer(cDepString))
pkgList := (*C.struct__alpm_list_t)(unsafe.Pointer(l.list))
pkgHandle := (*C.struct__alpm_handle_t)(unsafe.Pointer(l.handle.ptr))
ptr := C.alpm_find_dbs_satisfier(pkgHandle, pkgList, cDepString)
if ptr == nil {
return nil,
fmt.Errorf("unable to satisfy dependency %s in DBlist", depstring)
}
return &Package{ptr, l.handle}, nil
}
// FindSatisfier finds a package that satisfies depstring from PkgList
func (l PackageList) FindSatisfier(depstring string) (IPackage, error) {
cDepString := C.CString(depstring)
defer C.free(unsafe.Pointer(cDepString))
pkgList := (*C.struct__alpm_list_t)(unsafe.Pointer(l.list))
ptr := C.alpm_find_satisfier(pkgList, cDepString)
if ptr == nil {
return nil,
fmt.Errorf("unable to find dependency %s in PackageList", depstring)
}
return &Package{ptr, l.handle}, nil
}