forked from remyoudompheng/go-alpm
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(alpm): Add changes for pacman-git (#54)
* update gitignore * specify test packages * add pacman-git changes * separate git test * add go flags for -git
- Loading branch information
Showing
16 changed files
with
286 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Test pacman-git | ||
# This workflow is triggered on pushes to the repository. | ||
on: | ||
push: | ||
branches-ignore: | ||
- pacman* | ||
paths-ignore: | ||
- "examples/**" | ||
- "Dockerfile" | ||
- "**/builder-image.yml" | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
name: Build and test go-alpm | ||
runs-on: ubuntu-latest | ||
container: | ||
image: jguer/goalpm-builder:latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Build and install pacman-git | ||
run: | | ||
useradd github | ||
pacman -Syu --noconfirm --overwrite=* --needed sudo base-devel git | ||
echo "github ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | ||
git clone https://aur.archlinux.org/pacman-git | ||
chown -R github pacman-git | ||
su github -c "cd pacman-git; yes | makepkg -si --nocheck" | ||
- name: Run Build and Tests with pacman-git | ||
run: make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,28 @@ | ||
_obj/ | ||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
|
||
# Folders | ||
_obj | ||
_test | ||
.vscode | ||
|
||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
_cgo_gotypes.go | ||
_cgo_export.* | ||
|
||
*.exe | ||
*.test | ||
*.prof | ||
*.tar.gz | ||
qemu-* | ||
.go | ||
|
||
# Locale | ||
*.mo | ||
*.pot | ||
*.po~ | ||
*.pprof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//go:build next | ||
|
||
// db.go - Functions for database handling. | ||
// | ||
// Copyright (c) 2013 The go-alpm Authors | ||
// | ||
// MIT Licensed. See LICENSE for details. | ||
|
||
package alpm | ||
|
||
/* | ||
#include <alpm.h> | ||
#include <alpm_list.h> | ||
*/ | ||
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} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//go:build !next | ||
|
||
// db.go - Functions for database handling. | ||
// | ||
// Copyright (c) 2013 The go-alpm Authors | ||
// | ||
// MIT Licensed. See LICENSE for details. | ||
|
||
package alpm | ||
|
||
/* | ||
#include <alpm.h> | ||
#include <alpm_list.h> | ||
*/ | ||
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} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build !next | ||
|
||
package alpm | ||
|
||
/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//go:build next | ||
|
||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//go: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 <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" | ||
|
||
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} | ||
} |
Oops, something went wrong.