From 6f5a7838b931487b3b30a7cfe7206ce2df91e0b9 Mon Sep 17 00:00:00 2001 From: jguer Date: Sat, 23 Mar 2024 20:02:36 +0100 Subject: [PATCH] remove libalpm.so=13 support --- db.go | 12 ++++++++++++ db_git.go | 32 -------------------------------- db_six.go | 32 -------------------------------- deps.go | 9 +++------ deps_git.go | 50 -------------------------------------------------- package.go | 30 ++++++++++++++++++++++++++++++ package_git.go | 49 ------------------------------------------------- package_six.go | 49 ------------------------------------------------- 8 files changed, 45 insertions(+), 218 deletions(-) delete mode 100644 db_git.go delete mode 100644 db_six.go delete mode 100644 deps_git.go delete mode 100644 package_git.go delete mode 100644 package_six.go diff --git a/db.go b/db.go index 639406b..b629256 100644 --- a/db.go +++ b/db.go @@ -206,3 +206,15 @@ func (db *DB) Search(targets []string) IPackageList { return PackageList{(*list)(unsafe.Pointer(ret)), db.handle} } + +// PkgCachebyGroup returns a PackageList of packages belonging to a group +func (l DBList) FindGroupPkgs(name string) IPackageList { + cName := C.CString(name) + + defer C.free(unsafe.Pointer(cName)) + + pkglist := (*C.struct__alpm_list_t)(unsafe.Pointer(l.list)) + pkgcache := (*list)(unsafe.Pointer(C.alpm_find_group_pkgs(pkglist, cName))) + + return PackageList{pkgcache, l.handle} +} diff --git a/db_git.go b/db_git.go deleted file mode 100644 index 99487e1..0000000 --- a/db_git.go +++ /dev/null @@ -1,32 +0,0 @@ -//go:build next -// +build next - -// db.go - Functions for database handling. -// -// Copyright (c) 2013 The go-alpm Authors -// -// MIT Licensed. See LICENSE for details. - -package alpm - -/* -#include -#include -*/ -import "C" - -import ( - "unsafe" -) - -// PkgCachebyGroup returns a PackageList of packages belonging to a group -func (l DBList) FindGroupPkgs(name string) IPackageList { - cName := C.CString(name) - - defer C.free(unsafe.Pointer(cName)) - - pkglist := (*C.struct__alpm_list_t)(unsafe.Pointer(l.list)) - pkgcache := (*list)(unsafe.Pointer(C.alpm_find_group_pkgs(pkglist, cName))) - - return PackageList{pkgcache, l.handle} -} diff --git a/db_six.go b/db_six.go deleted file mode 100644 index 3d9273a..0000000 --- a/db_six.go +++ /dev/null @@ -1,32 +0,0 @@ -//go:build !next -// +build !next - -// db.go - Functions for database handling. -// -// Copyright (c) 2013 The go-alpm Authors -// -// MIT Licensed. See LICENSE for details. - -package alpm - -/* -#include -#include -*/ -import "C" - -import ( - "unsafe" -) - -// PkgCachebyGroup returns a PackageList of packages belonging to a group -func (l DBList) FindGroupPkgs(name string) IPackageList { - cName := C.CString(name) - - defer C.free(unsafe.Pointer(cName)) - - pkglist := (*C.struct___alpm_list_t)(unsafe.Pointer(l.list)) - pkgcache := (*list)(unsafe.Pointer(C.alpm_find_group_pkgs(pkglist, cName))) - - return PackageList{pkgcache, l.handle} -} diff --git a/deps.go b/deps.go index 476152a..b538b4f 100644 --- a/deps.go +++ b/deps.go @@ -1,6 +1,3 @@ -//go:build !next -// +build !next - package alpm /* @@ -20,8 +17,8 @@ func (l DBList) FindSatisfier(depstring string) (IPackage, error) { 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)) + 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 { @@ -38,7 +35,7 @@ func (l PackageList) FindSatisfier(depstring string) (IPackage, error) { defer C.free(unsafe.Pointer(cDepString)) - pkgList := (*C.struct___alpm_list_t)(unsafe.Pointer(l.list)) + pkgList := (*C.struct__alpm_list_t)(unsafe.Pointer(l.list)) ptr := C.alpm_find_satisfier(pkgList, cDepString) if ptr == nil { diff --git a/deps_git.go b/deps_git.go deleted file mode 100644 index b242ee3..0000000 --- a/deps_git.go +++ /dev/null @@ -1,50 +0,0 @@ -//go:build next -// +build next - -package alpm - -/* -#include -*/ -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 -} diff --git a/package.go b/package.go index 5e2936a..2558936 100644 --- a/package.go +++ b/package.go @@ -8,6 +8,21 @@ package alpm /* #include + +int pkg_cmp(const void *v1, const void *v2) +{ + alpm_pkg_t *p1 = (alpm_pkg_t *)v1; + alpm_pkg_t *p2 = (alpm_pkg_t *)v2; + off_t s1 = alpm_pkg_get_isize(p1); + off_t s2 = alpm_pkg_get_isize(p2); + + if (s1 > s2) + return -1; + else if (s1 < s2) + return 1; + else + return 0; +} */ import "C" @@ -287,3 +302,18 @@ func (pkg *Package) ShouldIgnore() bool { func (pkg *Package) Type() string { return "alpm" } + +// SortBySize returns a PackageList sorted by size. +func (l PackageList) SortBySize() IPackageList { + pkgList := (*C.struct__alpm_list_t)(unsafe.Pointer(l.list)) + + pkgCache := (*list)(unsafe.Pointer( + C.alpm_list_msort(pkgList, //nolint + C.alpm_list_count(pkgList), + C.alpm_list_fn_cmp(C.pkg_cmp)))) + if pkgCache == nil { + return nil + } + + return PackageList{pkgCache, l.handle} +} diff --git a/package_git.go b/package_git.go deleted file mode 100644 index 4d0ea30..0000000 --- a/package_git.go +++ /dev/null @@ -1,49 +0,0 @@ -//go:build next -// +build next - -// package.go - libalpm package type and methods. -// -// Copyright (c) 2013 The go-alpm Authors -// -// MIT Licensed. See LICENSE for details. - -package alpm - -/* -#include - -int pkg_cmp(const void *v1, const void *v2) -{ - alpm_pkg_t *p1 = (alpm_pkg_t *)v1; - alpm_pkg_t *p2 = (alpm_pkg_t *)v2; - off_t s1 = alpm_pkg_get_isize(p1); - off_t s2 = alpm_pkg_get_isize(p2); - - if (s1 > s2) - return -1; - else if (s1 < s2) - return 1; - else - return 0; -} -*/ -import "C" - -import ( - "unsafe" -) - -// SortBySize returns a PackageList sorted by size. -func (l PackageList) SortBySize() IPackageList { - pkgList := (*C.struct__alpm_list_t)(unsafe.Pointer(l.list)) - - pkgCache := (*list)(unsafe.Pointer( - C.alpm_list_msort(pkgList, //nolint - C.alpm_list_count(pkgList), - C.alpm_list_fn_cmp(C.pkg_cmp)))) - if pkgCache == nil { - return nil - } - - return PackageList{pkgCache, l.handle} -} diff --git a/package_six.go b/package_six.go deleted file mode 100644 index 3e59c56..0000000 --- a/package_six.go +++ /dev/null @@ -1,49 +0,0 @@ -//go:build !next -// +build !next - -// package.go - libalpm package type and methods. -// -// Copyright (c) 2013 The go-alpm Authors -// -// MIT Licensed. See LICENSE for details. - -package alpm - -/* -#include - -int pkg_cmp(const void *v1, const void *v2) -{ - alpm_pkg_t *p1 = (alpm_pkg_t *)v1; - alpm_pkg_t *p2 = (alpm_pkg_t *)v2; - off_t s1 = alpm_pkg_get_isize(p1); - off_t s2 = alpm_pkg_get_isize(p2); - - if (s1 > s2) - return -1; - else if (s1 < s2) - return 1; - else - return 0; -} -*/ -import "C" - -import ( - "unsafe" -) - -// SortBySize returns a PackageList sorted by size. -func (l PackageList) SortBySize() IPackageList { - pkgList := (*C.struct___alpm_list_t)(unsafe.Pointer(l.list)) - - pkgCache := (*list)(unsafe.Pointer( - C.alpm_list_msort(pkgList, //nolint - C.alpm_list_count(pkgList), - C.alpm_list_fn_cmp(C.pkg_cmp)))) - if pkgCache == nil { - return nil - } - - return PackageList{pkgCache, l.handle} -}