Parcourir la source

Why you shouldn't just rely on: git commit -a

morganamilo il y a 6 ans
Parent
commit
4b2279edbc

+ 44 - 0
vendor/github.com/jguer/go-alpm/deps.go

@@ -0,0 +1,44 @@
+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) (*Package, 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) (*Package, 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
+}

+ 17 - 0
vendor/github.com/jguer/go-alpm/version.go

@@ -0,0 +1,17 @@
+package alpm
+
+// #include <alpm.h>
+import "C"
+
+import "unsafe"
+
+// VerCmp performs version comparison according to Pacman conventions. Return
+// value is <0 if and only if v1 is older than v2.
+func VerCmp(v1, v2 string) int {
+	c1 := C.CString(v1)
+	c2 := C.CString(v2)
+	defer C.free(unsafe.Pointer(c1))
+	defer C.free(unsafe.Pointer(c2))
+	result := C.alpm_pkg_vercmp(c1, c2)
+	return int(result)
+}