Skip to content

Commit

Permalink
remove libalpm.so=13 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Jguer committed Mar 23, 2024
1 parent e5b2e18 commit 6f5a783
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 218 deletions.
12 changes: 12 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
32 changes: 0 additions & 32 deletions db_git.go

This file was deleted.

32 changes: 0 additions & 32 deletions db_six.go

This file was deleted.

9 changes: 3 additions & 6 deletions deps.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build !next
// +build !next

package alpm

/*
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
50 changes: 0 additions & 50 deletions deps_git.go

This file was deleted.

30 changes: 30 additions & 0 deletions package.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ package alpm

/*
#include <alpm.h>
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"

Expand Down Expand Up @@ -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}
}
49 changes: 0 additions & 49 deletions package_git.go

This file was deleted.

49 changes: 0 additions & 49 deletions package_six.go

This file was deleted.

0 comments on commit 6f5a783

Please sign in to comment.