mirror of
https://github.com/Jguer/yay
synced 2024-09-06 16:43:03 +00:00
Updated go-alpm vendored version
This commit is contained in:
parent
9cbef8d643
commit
92e9eed230
4
Gopkg.lock
generated
4
Gopkg.lock
generated
|
@ -5,7 +5,7 @@
|
|||
branch = "master"
|
||||
name = "github.com/jguer/go-alpm"
|
||||
packages = ["."]
|
||||
revision = "f82ad11b38f675991ef2425dbeff03ef346bc113"
|
||||
revision = "542c122094f863fd9f5d412ab7c0bb57474e08ef"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -17,7 +17,7 @@
|
|||
branch = "master"
|
||||
name = "github.com/mikkeloscar/gopkgbuild"
|
||||
packages = ["."]
|
||||
revision = "a185f55210904932d0a58aaf30890f2c17218604"
|
||||
revision = "a8070a8ab45a0f8cd4201ca7ed0f3efe4897bd2f"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
|
|
2
vendor/github.com/jguer/go-alpm/alpm_test.go
generated
vendored
2
vendor/github.com/jguer/go-alpm/alpm_test.go
generated
vendored
|
@ -31,7 +31,7 @@ func init() {
|
|||
func ExampleVersion() {
|
||||
fmt.Println(Version())
|
||||
// output:
|
||||
// 8.0.2
|
||||
// 10.0.2
|
||||
}
|
||||
|
||||
func ExampleVerCmp() {
|
||||
|
|
119
vendor/github.com/jguer/go-alpm/conf.go
generated
vendored
119
vendor/github.com/jguer/go-alpm/conf.go
generated
vendored
|
@ -13,6 +13,7 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
|
@ -43,6 +44,7 @@ type PacmanConfig struct {
|
|||
RootDir string
|
||||
DBPath string
|
||||
CacheDir []string
|
||||
HookDir []string
|
||||
GPGDir string
|
||||
LogFile string
|
||||
HoldPkg []string
|
||||
|
@ -57,7 +59,7 @@ type PacmanConfig struct {
|
|||
SigLevel SigLevel
|
||||
LocalFileSigLevel SigLevel
|
||||
RemoteFileSigLevel SigLevel
|
||||
UseDelta string
|
||||
UseDelta float64
|
||||
Options PacmanOption
|
||||
Repos []RepoConfig
|
||||
}
|
||||
|
@ -112,14 +114,18 @@ func (rdr *confReader) ParseLine() (tok iniToken, err error) {
|
|||
rdr.Lineno++
|
||||
|
||||
line = bytes.TrimSpace(line)
|
||||
|
||||
comment := bytes.IndexByte(line, '#')
|
||||
if comment >= 0 {
|
||||
line = line[:comment]
|
||||
}
|
||||
|
||||
if len(line) == 0 {
|
||||
tok.Type = tokenComment
|
||||
return
|
||||
}
|
||||
|
||||
switch line[0] {
|
||||
case '#':
|
||||
tok.Type = tokenComment
|
||||
return
|
||||
case '[':
|
||||
closing := bytes.IndexByte(line, ']')
|
||||
if closing < 0 {
|
||||
|
@ -208,6 +214,17 @@ lineloop:
|
|||
rdr = newConfReader(f)
|
||||
rdrStack = append(rdrStack, rdr)
|
||||
continue lineloop
|
||||
case "UseDelta":
|
||||
if len(line.Values) > 0 {
|
||||
deltaRatio, err := strconv.ParseFloat(line.Values[0], 64)
|
||||
|
||||
if err != nil {
|
||||
return conf, err
|
||||
}
|
||||
|
||||
conf.UseDelta = deltaRatio
|
||||
}
|
||||
continue lineloop
|
||||
}
|
||||
|
||||
if currentSection != "options" {
|
||||
|
@ -233,7 +250,7 @@ lineloop:
|
|||
*fieldP = strings.Join(line.Values, " ")
|
||||
case *[]string:
|
||||
//many valued option.
|
||||
*fieldP = append(*fieldP, line.Values...)
|
||||
*fieldP = line.Values
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -243,6 +260,17 @@ lineloop:
|
|||
func (conf *PacmanConfig) SetDefaults() {
|
||||
conf.RootDir = "/"
|
||||
conf.DBPath = "/var/lib/pacman"
|
||||
conf.DBPath = "/var/lib/pacman/"
|
||||
conf.CacheDir = []string{"/var/cache/pacman/pkg/"}
|
||||
conf.HookDir = []string{"/etc/pacman.d/hooks/"}
|
||||
conf.GPGDir = "/etc/pacman.d/gnupg/"
|
||||
conf.LogFile = "/var/log/pacman.log"
|
||||
conf.UseDelta = 0.7
|
||||
conf.CleanMethod = "KeepInstalled"
|
||||
|
||||
conf.SigLevel = SigPackage | SigPackageOptional | SigDatabase | SigDatabaseOptional
|
||||
conf.LocalFileSigLevel = SigUseDefault
|
||||
conf.RemoteFileSigLevel = SigUseDefault
|
||||
}
|
||||
|
||||
func getArch() (string, error) {
|
||||
|
@ -272,6 +300,7 @@ func (conf *PacmanConfig) CreateHandle() (*Handle, error) {
|
|||
return nil, fmt.Errorf("architecture is 'auto' but couldn't uname()")
|
||||
}
|
||||
}
|
||||
|
||||
for _, repoconf := range conf.Repos {
|
||||
// TODO: set SigLevel
|
||||
db, err := h.RegisterSyncDb(repoconf.Name, 0)
|
||||
|
@ -284,5 +313,85 @@ func (conf *PacmanConfig) CreateHandle() (*Handle, error) {
|
|||
db.SetServers(repoconf.Servers)
|
||||
}
|
||||
}
|
||||
|
||||
err = h.SetCacheDirs(conf.CacheDir...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// add hook directories 1-by-1 to avoid overwriting the system directory
|
||||
for _,dir := range conf.HookDir {
|
||||
err = h.AddHookDir(dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
err = h.SetGPGDir(conf.GPGDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = h.SetLogFile(conf.LogFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = h.SetIgnorePkgs(conf.IgnorePkg...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = h.SetIgnoreGroups(conf.IgnoreGroup...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = h.SetArch(conf.Architecture)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
h.SetNoUpgrades(conf.NoUpgrade...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
h.SetNoExtracts(conf.NoExtract...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = h.SetDefaultSigLevel(conf.SigLevel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = h.SetLocalFileSigLevel(conf.LocalFileSigLevel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
err = h.SetRemoteFileSigLevel(conf.RemoteFileSigLevel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = h.SetDeltaRatio(conf.UseDelta)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = h.SetUseSyslog(conf.Options & ConfUseSyslog > 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = h.SetCheckSpace(conf.Options & ConfCheckSpace > 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return h, nil
|
||||
}
|
||||
|
|
2
vendor/github.com/jguer/go-alpm/conf_test.go
generated
vendored
2
vendor/github.com/jguer/go-alpm/conf_test.go
generated
vendored
|
@ -22,7 +22,7 @@ var pacmanConfRef = PacmanConfig{
|
|||
XferCommand: "/usr/bin/wget --passive-ftp -c -O %o %u",
|
||||
Architecture: "auto",
|
||||
CleanMethod: "KeepInstalled",
|
||||
UseDelta: "0.7",
|
||||
UseDelta: 0.7,
|
||||
IgnorePkg: []string{"hello", "world"},
|
||||
IgnoreGroup: []string{"kde"},
|
||||
NoUpgrade: nil,
|
||||
|
|
530
vendor/github.com/jguer/go-alpm/handle.go
generated
vendored
530
vendor/github.com/jguer/go-alpm/handle.go
generated
vendored
|
@ -12,6 +12,8 @@
|
|||
package alpm
|
||||
|
||||
// #include <alpm.h>
|
||||
// #include <stdio.h> //C.free
|
||||
// #include <fnmatch.h> //C.FNM_NOMATCH
|
||||
import "C"
|
||||
|
||||
import (
|
||||
|
@ -25,12 +27,13 @@ type Handle struct {
|
|||
// Initialize
|
||||
func Init(root, dbpath string) (*Handle, error) {
|
||||
c_root := C.CString(root)
|
||||
defer C.free(unsafe.Pointer(c_root))
|
||||
c_dbpath := C.CString(dbpath)
|
||||
defer C.free(unsafe.Pointer(c_dbpath))
|
||||
var c_err C.alpm_errno_t
|
||||
h := C.alpm_initialize(c_root, c_dbpath, &c_err)
|
||||
|
||||
defer C.free(unsafe.Pointer(c_root))
|
||||
defer C.free(unsafe.Pointer(c_dbpath))
|
||||
|
||||
if c_err != 0 {
|
||||
return nil, Error(c_err)
|
||||
}
|
||||
|
@ -46,14 +49,6 @@ func (h *Handle) Release() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (h Handle) Root() string {
|
||||
return C.GoString(C.alpm_option_get_root(h.ptr))
|
||||
}
|
||||
|
||||
func (h Handle) DbPath() string {
|
||||
return C.GoString(C.alpm_option_get_dbpath(h.ptr))
|
||||
}
|
||||
|
||||
// LastError gets the last pm_error
|
||||
func (h Handle) LastError() error {
|
||||
if h.ptr != nil {
|
||||
|
@ -65,21 +60,524 @@ func (h Handle) LastError() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (h Handle) UseSyslog() bool {
|
||||
value := C.alpm_option_get_usesyslog(h.ptr)
|
||||
return (value != 0)
|
||||
//
|
||||
//alpm options getters and setters
|
||||
//
|
||||
|
||||
//helper functions for wrapping list_t getters and setters
|
||||
func (h Handle) optionGetList(f func(*C.alpm_handle_t) *C.alpm_list_t) (StringList, error){
|
||||
alpmList := f(h.ptr)
|
||||
goList := StringList{(*list)(unsafe.Pointer(alpmList))}
|
||||
|
||||
if alpmList == nil {
|
||||
return goList, h.LastError()
|
||||
}
|
||||
return goList, nil
|
||||
}
|
||||
|
||||
|
||||
func (h Handle) optionSetList(hookDirs []string, f func(*C.alpm_handle_t, *C.alpm_list_t) C.int) error {
|
||||
var list *C.alpm_list_t = nil
|
||||
|
||||
for _, dir := range hookDirs {
|
||||
c_dir := C.CString(dir)
|
||||
list = C.alpm_list_add(list, unsafe.Pointer(c_dir))
|
||||
defer C.free(unsafe.Pointer(c_dir))
|
||||
}
|
||||
|
||||
ok := f(h.ptr, list)
|
||||
if ok < 0 {
|
||||
return h.LastError()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h Handle) optionAddList(hookDir string, f func(*C.alpm_handle_t, *C.char) C.int) error {
|
||||
c_hookdir := C.CString(hookDir)
|
||||
defer C.free(unsafe.Pointer(c_hookdir))
|
||||
ok := f(h.ptr, c_hookdir)
|
||||
if ok < 0 {
|
||||
return h.LastError()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h Handle) optionRemoveList(dir string, f func(*C.alpm_handle_t, *C.char) C.int) (bool, error) {
|
||||
c_dir := C.CString(dir)
|
||||
ok := f(h.ptr, c_dir)
|
||||
defer C.free(unsafe.Pointer(c_dir))
|
||||
if ok < 0 {
|
||||
return ok == 1, h.LastError()
|
||||
}
|
||||
return ok == 1, nil
|
||||
}
|
||||
|
||||
func (h Handle) optionMatchList(dir string, f func(*C.alpm_handle_t, *C.char) C.int) (bool, error) {
|
||||
c_dir := C.CString(dir)
|
||||
ok := f(h.ptr, c_dir)
|
||||
defer C.free(unsafe.Pointer(c_dir))
|
||||
if ok == 0 {
|
||||
return true, nil
|
||||
} else if ok == C.FNM_NOMATCH {
|
||||
return false, h.LastError()
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
//helper functions for *char based getters and setters
|
||||
func (h Handle) optionGetStr(f func(*C.alpm_handle_t) *C.char) (string, error) {
|
||||
c_str := f(h.ptr)
|
||||
str := C.GoString(c_str)
|
||||
if c_str == nil {
|
||||
return str, h.LastError()
|
||||
}
|
||||
|
||||
return str, nil
|
||||
}
|
||||
|
||||
func (h Handle) optionSetStr(str string, f func(*C.alpm_handle_t, *C.char) C.int) error {
|
||||
c_str := C.CString(str)
|
||||
defer C.free(unsafe.Pointer(c_str))
|
||||
ok := f(h.ptr, c_str)
|
||||
|
||||
if ok < 0 {
|
||||
h.LastError()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
//end of helpers
|
||||
//
|
||||
|
||||
func (h Handle) Root() (string, error) {
|
||||
return h.optionGetStr(func(handle *C.alpm_handle_t) *C.char {
|
||||
return C.alpm_option_get_root(handle)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) DBPath() (string, error) {
|
||||
return h.optionGetStr(func(handle *C.alpm_handle_t) *C.char {
|
||||
return C.alpm_option_get_dbpath(handle)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) Lockfile() (string, error) {
|
||||
return h.optionGetStr(func(handle *C.alpm_handle_t) *C.char {
|
||||
return C.alpm_option_get_lockfile(handle)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
func (h Handle) CacheDirs() (StringList, error) {
|
||||
return h.optionGetList(func(handle *C.alpm_handle_t) *C.alpm_list_t {
|
||||
return C.alpm_option_get_cachedirs(handle)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) AddCacheDir(hookDir string) error {
|
||||
return h.optionAddList(hookDir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_add_cachedir(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) SetCacheDirs(hookDirs ...string) error {
|
||||
return h.optionSetList(hookDirs, func(handle *C.alpm_handle_t, l *C.alpm_list_t) C.int {
|
||||
return C.alpm_option_set_cachedirs(handle, l)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) RemoveCacheDir(dir string) (bool, error) {
|
||||
return h.optionRemoveList(dir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_remove_cachedir(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) HookDirs() (StringList, error) {
|
||||
return h.optionGetList(func(handle *C.alpm_handle_t) *C.alpm_list_t {
|
||||
return C.alpm_option_get_hookdirs(handle)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) AddHookDir(hookDir string) error {
|
||||
return h.optionAddList(hookDir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_add_hookdir(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) SetHookDirs(hookDirs ...string) error {
|
||||
return h.optionSetList(hookDirs, func(handle *C.alpm_handle_t, l *C.alpm_list_t) C.int {
|
||||
return C.alpm_option_set_hookdirs(handle, l)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) RemoveHookDir(dir string) (bool, error) {
|
||||
return h.optionRemoveList(dir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_remove_hookdir(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) LogFile() (string, error) {
|
||||
return h.optionGetStr(func(handle *C.alpm_handle_t) *C.char {
|
||||
return C.alpm_option_get_logfile(handle)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) SetLogFile(str string) error {
|
||||
return h.optionSetStr(str, func(handle *C.alpm_handle_t, c_str *C.char) C.int {
|
||||
return C.alpm_option_set_logfile(handle, c_str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) GPGDir() (string, error) {
|
||||
return h.optionGetStr(func(handle *C.alpm_handle_t) *C.char {
|
||||
return C.alpm_option_get_gpgdir(handle)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) SetGPGDir(str string) error {
|
||||
return h.optionSetStr(str, func(handle *C.alpm_handle_t, c_str *C.char) C.int {
|
||||
return C.alpm_option_set_gpgdir(handle, c_str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) UseSyslog() (bool, error) {
|
||||
ok := C.alpm_option_get_usesyslog(h.ptr)
|
||||
b := false
|
||||
|
||||
if ok > 0 {
|
||||
b = true
|
||||
}
|
||||
if ok < 0 {
|
||||
return b, h.LastError()
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func (h Handle) SetUseSyslog(value bool) error {
|
||||
var int_value C.int
|
||||
var int_value C.int = 0
|
||||
if value {
|
||||
int_value = 1
|
||||
} else {
|
||||
int_value = 0
|
||||
}
|
||||
|
||||
ok := C.alpm_option_set_usesyslog(h.ptr, int_value)
|
||||
if ok < 0 {
|
||||
return h.LastError()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h Handle) NoUpgrades() (StringList, error) {
|
||||
return h.optionGetList(func(handle *C.alpm_handle_t) *C.alpm_list_t {
|
||||
return C.alpm_option_get_noupgrades(handle)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) AddNoUpgrade(hookDir string) error {
|
||||
return h.optionAddList(hookDir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_add_noupgrade(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) SetNoUpgrades(hookDirs ...string) error {
|
||||
return h.optionSetList(hookDirs, func(handle *C.alpm_handle_t, l *C.alpm_list_t) C.int {
|
||||
return C.alpm_option_set_noupgrades(handle, l)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) RemoveNoUpgrade(dir string) (bool, error) {
|
||||
return h.optionRemoveList(dir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_remove_noupgrade(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) MatchNoUpgrade(dir string) (bool, error) {
|
||||
return h.optionMatchList(dir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_match_noupgrade(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) NoExtracts() (StringList, error) {
|
||||
return h.optionGetList(func(handle *C.alpm_handle_t) *C.alpm_list_t {
|
||||
return C.alpm_option_get_noextracts(handle)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) AddNoExtract(hookDir string) error {
|
||||
return h.optionAddList(hookDir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_add_noextract(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) SetNoExtracts(hookDirs ...string) error {
|
||||
return h.optionSetList(hookDirs, func(handle *C.alpm_handle_t, l *C.alpm_list_t) C.int {
|
||||
return C.alpm_option_set_noextracts(handle, l)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) RemoveNoExtract(dir string) (bool, error) {
|
||||
return h.optionRemoveList(dir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_remove_noextract(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) MatchNoExtract(dir string) (bool, error) {
|
||||
return h.optionMatchList(dir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_match_noextract(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) IgnorePkgs() (StringList, error) {
|
||||
return h.optionGetList(func(handle *C.alpm_handle_t) *C.alpm_list_t {
|
||||
return C.alpm_option_get_ignorepkgs(handle)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) AddIgnorePkg(hookDir string) error {
|
||||
return h.optionAddList(hookDir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_add_ignorepkg(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) SetIgnorePkgs(hookDirs ...string) error {
|
||||
return h.optionSetList(hookDirs, func(handle *C.alpm_handle_t, l *C.alpm_list_t) C.int {
|
||||
return C.alpm_option_set_ignorepkgs(handle, l)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) RemoveIgnorePkg(dir string) (bool, error) {
|
||||
return h.optionRemoveList(dir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_remove_ignorepkg(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) IgnoreGroups() (StringList, error) {
|
||||
return h.optionGetList(func(handle *C.alpm_handle_t) *C.alpm_list_t {
|
||||
return C.alpm_option_get_ignoregroups(handle)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) AddIgnoreGroup(hookDir string) error {
|
||||
return h.optionAddList(hookDir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_add_ignoregroup(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) SetIgnoreGroups(hookDirs ...string) error {
|
||||
return h.optionSetList(hookDirs, func(handle *C.alpm_handle_t, l *C.alpm_list_t) C.int {
|
||||
return C.alpm_option_set_ignoregroups(handle, l)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) RemoveIgnoreGroup(dir string) (bool, error) {
|
||||
return h.optionRemoveList(dir, func(handle *C.alpm_handle_t, str *C.char) C.int {
|
||||
return C.alpm_option_remove_ignoregroup(handle, str)
|
||||
})
|
||||
}
|
||||
|
||||
/*func (h Handle) optionGetList(f func(*C.alpm_handle_t) *C.alpm_list_t) (StringList, error){
|
||||
alpmList := f(h.ptr)
|
||||
goList := StringList{(*list)(unsafe.Pointer(alpmList))}
|
||||
|
||||
if alpmList == nil {
|
||||
return goList, h.LastError()
|
||||
}
|
||||
return goList, nil
|
||||
}*/
|
||||
|
||||
//use alpm_depend_t
|
||||
func (h Handle) AssumeInstalled() (DependList, error) {
|
||||
alpmList := C.alpm_option_get_assumeinstalled(h.ptr)
|
||||
depList := DependList{(*list)(unsafe.Pointer(alpmList))}
|
||||
|
||||
if alpmList == nil {
|
||||
return depList, h.LastError()
|
||||
}
|
||||
return depList, nil
|
||||
}
|
||||
|
||||
func (h Handle) AddAssumeInstalled(dep Depend) error {
|
||||
c_dep := convertCDepend(dep)
|
||||
defer freeCDepend(c_dep)
|
||||
|
||||
ok := C.alpm_option_add_assumeinstalled(h.ptr, c_dep)
|
||||
if ok < 0 {
|
||||
return h.LastError()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h Handle) SetAssumeInstalled(deps ...Depend) error {
|
||||
//calling this function the first time causes alpm to set the
|
||||
//assumeinstalled list to a list containing go allocated alpm_depend_t's
|
||||
//this is bad because alpm might at some point tree to free them
|
||||
//i believe this is whats causing this function to misbhave
|
||||
//although i am not 100% sure
|
||||
//maybe using C.malloc to make the struct could fix the problem
|
||||
//pacamn does not use alpm_option_set_assumeinstalled in its source
|
||||
//code so anybody using this should beable to do file without it
|
||||
//although for the sake of completeness it would be nice to have this
|
||||
//working
|
||||
panic("This function (SetAssumeInstalled) does not work properly, please do not use. See source code for more details")
|
||||
var list *C.alpm_list_t = nil
|
||||
|
||||
for _, dep := range deps {
|
||||
c_dep := convertCDepend(dep)
|
||||
defer freeCDepend(c_dep)
|
||||
list = C.alpm_list_add(list, unsafe.Pointer(c_dep))
|
||||
}
|
||||
|
||||
ok := C.alpm_option_set_assumeinstalled(h.ptr, list)
|
||||
if ok < 0 {
|
||||
return h.LastError()
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (h Handle) RemoveAssumeInstalled(dep Depend) (bool, error) {
|
||||
//internally alpm uses alpm_list_remove to remove a alpm_depend_t from
|
||||
//the list
|
||||
//i believe this function considers items equal if they are the same
|
||||
//item in memeory, not just the same data
|
||||
//every time we convert a go Depend to a alpm_depend_c we create a new
|
||||
//instance of a alpm_depend_c
|
||||
//this means that if you add a Depend using AddAssumeInstalled then try
|
||||
//to remove it using the same Depend c will consider them different
|
||||
//items and not remove them
|
||||
//pacamn does not use alpm_option_set_assumeinstalled in its source
|
||||
//code so anybody using this should beable to do file without it
|
||||
//although for the sake of completeness it would be nice to have this
|
||||
//working
|
||||
panic("This function (RemoveAssumeInstalled) does not work properly, please do not use. See source code for more details")
|
||||
c_dep := convertCDepend(dep)
|
||||
defer freeCDepend(c_dep)
|
||||
|
||||
ok := C.alpm_option_remove_assumeinstalled(h.ptr, c_dep)
|
||||
if ok < 0 {
|
||||
return ok == 1, h.LastError()
|
||||
}
|
||||
return ok == 1, nil
|
||||
}
|
||||
|
||||
func (h Handle) Arch() (string, error) {
|
||||
return h.optionGetStr(func(handle *C.alpm_handle_t) *C.char {
|
||||
return C.alpm_option_get_arch(handle)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) SetArch(str string) error {
|
||||
return h.optionSetStr(str, func(handle *C.alpm_handle_t, c_str *C.char) C.int {
|
||||
return C.alpm_option_set_arch(handle, c_str)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
func (h Handle) DeltaRatio() (float64, error) {
|
||||
ok := C.alpm_option_get_deltaratio(h.ptr)
|
||||
if ok < 0 {
|
||||
return float64(ok), h.LastError()
|
||||
}
|
||||
return float64(ok), nil
|
||||
}
|
||||
|
||||
func (h Handle) SetDeltaRatio(ratio float64) error {
|
||||
ok := C.alpm_option_set_deltaratio(h.ptr, C.double(ratio))
|
||||
if ok < 0 {
|
||||
return h.LastError()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
func (h Handle) CheckSpace() (bool, error) {
|
||||
ok := C.alpm_option_get_checkspace(h.ptr)
|
||||
b := false
|
||||
|
||||
if ok > 0 {
|
||||
b = true
|
||||
}
|
||||
if ok < 0 {
|
||||
return b, h.LastError()
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func (h Handle) SetCheckSpace(value bool) error {
|
||||
var int_value C.int = 0
|
||||
if value {
|
||||
int_value = 1
|
||||
}
|
||||
|
||||
ok := C.alpm_option_set_checkspace(h.ptr, int_value)
|
||||
if ok < 0 {
|
||||
return h.LastError()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h Handle) DBExt() (string, error) {
|
||||
return h.optionGetStr(func(handle *C.alpm_handle_t) *C.char {
|
||||
return C.alpm_option_get_dbext(handle)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) SetDBExt(str string) error {
|
||||
return h.optionSetStr(str, func(handle *C.alpm_handle_t, c_str *C.char) C.int {
|
||||
return C.alpm_option_set_dbext(handle, c_str)
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handle) GetDefaultSigLevel() (SigLevel, error) {
|
||||
sigLevel := C.alpm_option_get_default_siglevel(h.ptr)
|
||||
|
||||
if sigLevel < 0 {
|
||||
return SigLevel(sigLevel), h.LastError()
|
||||
}
|
||||
return SigLevel(sigLevel), nil
|
||||
}
|
||||
|
||||
func (h Handle) SetDefaultSigLevel(siglevel SigLevel) error {
|
||||
ok := C.alpm_option_set_default_siglevel(h.ptr, C.alpm_siglevel_t(siglevel))
|
||||
|
||||
if ok < 0 {
|
||||
return h.LastError()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h Handle) GetLocalFileSigLevel() (SigLevel, error) {
|
||||
sigLevel := C.alpm_option_get_local_file_siglevel(h.ptr)
|
||||
|
||||
if sigLevel < 0 {
|
||||
return SigLevel(sigLevel), h.LastError()
|
||||
}
|
||||
return SigLevel(sigLevel), nil
|
||||
}
|
||||
|
||||
func (h Handle) SetLocalFileSigLevel(siglevel SigLevel) error {
|
||||
ok := C.alpm_option_set_local_file_siglevel(h.ptr, C.alpm_siglevel_t(siglevel))
|
||||
|
||||
if ok < 0 {
|
||||
return h.LastError()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h Handle) GetRemoteFileSigLevel() (SigLevel, error) {
|
||||
sigLevel := C.alpm_option_get_remote_file_siglevel(h.ptr)
|
||||
|
||||
if sigLevel < 0 {
|
||||
return SigLevel(sigLevel), h.LastError()
|
||||
}
|
||||
return SigLevel(sigLevel), nil
|
||||
}
|
||||
|
||||
func (h Handle) SetRemoteFileSigLevel(siglevel SigLevel) error {
|
||||
ok := C.alpm_option_set_remote_file_siglevel(h.ptr, C.alpm_siglevel_t(siglevel))
|
||||
|
||||
if ok < 0 {
|
||||
return h.LastError()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
17
vendor/github.com/jguer/go-alpm/package.go
generated
vendored
17
vendor/github.com/jguer/go-alpm/package.go
generated
vendored
|
@ -13,9 +13,15 @@ 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;
|
||||
unsigned long int s1 = alpm_pkg_get_isize(p1);
|
||||
unsigned long int s2 = alpm_pkg_get_isize(p2);
|
||||
return(s2 - s1);
|
||||
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"
|
||||
|
@ -244,3 +250,8 @@ func (pkg Package) NewVersion(l DbList) *Package {
|
|||
}
|
||||
return &Package{ptr, l.handle}
|
||||
}
|
||||
|
||||
func (pkg Package) ShouldIgnore() bool {
|
||||
result := C.alpm_pkg_should_ignore(pkg.handle.ptr, pkg.pmpkg)
|
||||
return result == 1
|
||||
}
|
||||
|
|
2
vendor/github.com/jguer/go-alpm/package_test.go
generated
vendored
2
vendor/github.com/jguer/go-alpm/package_test.go
generated
vendored
|
@ -79,11 +79,13 @@ func TestPkginfo(t *testing.T) {
|
|||
buf := bytes.NewBuffer(nil)
|
||||
pkginfo_tpl.Execute(buf, PrettyPackage{*pkg})
|
||||
t.Logf("%s...", buf.Bytes()[:1024])
|
||||
t.Logf("Should ignore %t", pkg.ShouldIgnore())
|
||||
|
||||
pkg, _ = db.PkgByName("linux")
|
||||
if pkg != nil {
|
||||
buf = bytes.NewBuffer(nil)
|
||||
pkginfo_tpl.Execute(buf, PrettyPackage{*pkg})
|
||||
t.Logf("%s...", buf.Bytes()[:1024])
|
||||
t.Logf("Should ignore %t", pkg.ShouldIgnore())
|
||||
}
|
||||
}
|
||||
|
|
33
vendor/github.com/jguer/go-alpm/types.go
generated
vendored
33
vendor/github.com/jguer/go-alpm/types.go
generated
vendored
|
@ -19,14 +19,41 @@ import (
|
|||
type Depend struct {
|
||||
Name string
|
||||
Version string
|
||||
Description string
|
||||
NameHash uint
|
||||
Mod DepMod
|
||||
}
|
||||
|
||||
func convertDepend(dep *C.alpm_depend_t) Depend {
|
||||
return Depend{
|
||||
Name: C.GoString(dep.name),
|
||||
Version: C.GoString(dep.version),
|
||||
Mod: DepMod(dep.mod)}
|
||||
Name: C.GoString(dep.name),
|
||||
Version: C.GoString(dep.version),
|
||||
Mod: DepMod(dep.mod),
|
||||
Description: C.GoString(dep.desc),
|
||||
NameHash: uint(dep.name_hash),
|
||||
}
|
||||
}
|
||||
|
||||
func convertCDepend(dep Depend) *C.alpm_depend_t {
|
||||
c_name := C.CString(dep.Name)
|
||||
c_version := C.CString(dep.Version)
|
||||
c_desc := C.CString(dep.Description)
|
||||
|
||||
c_dep := C.alpm_depend_t{
|
||||
name: c_name,
|
||||
version: c_version,
|
||||
desc: c_desc,
|
||||
name_hash: C.ulong(dep.NameHash),
|
||||
mod: C.alpm_depmod_t(dep.Mod),
|
||||
}
|
||||
|
||||
return &c_dep
|
||||
}
|
||||
|
||||
func freeCDepend(dep *C.alpm_depend_t) {
|
||||
defer C.free(unsafe.Pointer(dep.name))
|
||||
defer C.free(unsafe.Pointer(dep.version))
|
||||
defer C.free(unsafe.Pointer(dep.desc))
|
||||
}
|
||||
|
||||
func (dep Depend) String() string {
|
||||
|
|
13
vendor/github.com/mikkeloscar/gopkgbuild/pkgbuild.go
generated
vendored
13
vendor/github.com/mikkeloscar/gopkgbuild/pkgbuild.go
generated
vendored
|
@ -204,6 +204,13 @@ func ParseSRCINFO(path string) (*PKGBUILD, error) {
|
|||
return parsePKGBUILD(string(f))
|
||||
}
|
||||
|
||||
// ParseSRCINFOContent parses a .SRCINFO formatted byte slice.
|
||||
// This is a safe alternative to ParsePKGBUILD given that the .SRCINFO content
|
||||
// is available
|
||||
func ParseSRCINFOContent(content []byte) (*PKGBUILD, error) {
|
||||
return parsePKGBUILD(string(content))
|
||||
}
|
||||
|
||||
// parse a PKGBUILD and check that the required fields has a non-empty value
|
||||
func parsePKGBUILD(input string) (*PKGBUILD, error) {
|
||||
pkgb, err := parse(input)
|
||||
|
@ -447,6 +454,10 @@ func parseDependency(dep string, deps []*Dependency) ([]*Dependency, error) {
|
|||
var name string
|
||||
var dependency *Dependency
|
||||
|
||||
if dep == "" {
|
||||
return deps, nil
|
||||
}
|
||||
|
||||
if dep[0] == '-' {
|
||||
return nil, fmt.Errorf("invalid dependency name")
|
||||
}
|
||||
|
@ -526,5 +537,5 @@ func isValidPkgnameChar(c uint8) bool {
|
|||
|
||||
// check if c is a valid pkgver char
|
||||
func isValidPkgverChar(c uint8) bool {
|
||||
return isAlphaNumeric(c) || c == '_' || c == '+' || c == '.'
|
||||
return isAlphaNumeric(c) || c == '_' || c == '+' || c == '.' || c == '~'
|
||||
}
|
||||
|
|
6
vendor/github.com/mikkeloscar/gopkgbuild/pkgbuild_test.go
generated
vendored
6
vendor/github.com/mikkeloscar/gopkgbuild/pkgbuild_test.go
generated
vendored
|
@ -9,11 +9,16 @@ func TestVersionParsing(t *testing.T) {
|
|||
"1.0.0.0.2": true,
|
||||
"a.3_4": true,
|
||||
"A.2": true,
|
||||
"a~b~c": true,
|
||||
"_1.2": false,
|
||||
".2": false,
|
||||
"a.2Ø": false,
|
||||
"1.?": false,
|
||||
"1.-": false,
|
||||
"1 2": false,
|
||||
"1\t2": false,
|
||||
"1\n2": false,
|
||||
"1\r2": false,
|
||||
}
|
||||
|
||||
for version, valid := range versions {
|
||||
|
@ -172,6 +177,7 @@ func TestRandomCoreSRCINFOs(t *testing.T) {
|
|||
"glibc",
|
||||
"systemd",
|
||||
"linux",
|
||||
"pip2pkgbuild",
|
||||
}
|
||||
|
||||
for _, srcinfo := range srcinfos {
|
||||
|
|
40
vendor/github.com/mikkeloscar/gopkgbuild/test_pkgbuilds/PKGBUILD_pip2pkgbuild
generated
vendored
Normal file
40
vendor/github.com/mikkeloscar/gopkgbuild/test_pkgbuilds/PKGBUILD_pip2pkgbuild
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
# Maintainer: wenLiangcan <boxeed at gmail dot com>
|
||||
|
||||
pkgbase=('pip2pkgbuild')
|
||||
pkgname=('pip2pkgbuild' 'python2-pip2pkgbuild')
|
||||
_module='pip2pkgbuild'
|
||||
pkgver='0.2.3'
|
||||
pkgrel=1
|
||||
pkgdesc="Generate PKGBUILD file for a Python module from PyPi"
|
||||
url="https://github.com/wenLiangcan/pip2pkgbuild"
|
||||
depends=()
|
||||
makedepends=('python-setuptools' 'python2-setuptools')
|
||||
license=('MIT')
|
||||
arch=('any')
|
||||
source=("https://files.pythonhosted.org/packages/source/p/pip2pkgbuild/pip2pkgbuild-${pkgver}.tar.gz")
|
||||
md5sums=('ba4c7a94ce78b8a62a5233bd8c265ec3')
|
||||
|
||||
prepare() {
|
||||
cp -a "${srcdir}/${_module}-${pkgver}"{,-python2}
|
||||
}
|
||||
|
||||
build() {
|
||||
cd "${srcdir}/${_module}-${pkgver}"
|
||||
python setup.py build
|
||||
|
||||
cd "${srcdir}/${_module}-${pkgver}-python2"
|
||||
python2 setup.py build
|
||||
}
|
||||
|
||||
package_pip2pkgbuild() {
|
||||
depends+=('python' 'python-pip')
|
||||
cd "${srcdir}/${_module}-${pkgver}"
|
||||
python setup.py install --root="${pkgdir}" --optimize=1 --skip-build
|
||||
}
|
||||
|
||||
package_python2-pip2pkgbuild() {
|
||||
depends+=('python2' 'python2-pip')
|
||||
cd "${srcdir}/${_module}-${pkgver}-python2"
|
||||
python2 setup.py install --root="${pkgdir}" --optimize=1 --skip-build
|
||||
mv "${pkgdir}/usr/bin/pip2pkgbuild"{,2}
|
||||
}
|
24
vendor/github.com/mikkeloscar/gopkgbuild/test_pkgbuilds/SRCINFO_pip2pkgbuild
generated
vendored
Normal file
24
vendor/github.com/mikkeloscar/gopkgbuild/test_pkgbuilds/SRCINFO_pip2pkgbuild
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Generated by mksrcinfo v8
|
||||
# Sat Dec 17 05:53:18 UTC 2016
|
||||
pkgbase = pip2pkgbuild
|
||||
pkgdesc = Generate PKGBUILD file for a Python module from PyPi
|
||||
pkgver = 0.2.3
|
||||
pkgrel = 1
|
||||
url = https://github.com/wenLiangcan/pip2pkgbuild
|
||||
arch = any
|
||||
license = MIT
|
||||
makedepends = python-setuptools
|
||||
makedepends = python2-setuptools
|
||||
source = https://files.pythonhosted.org/packages/source/p/pip2pkgbuild/pip2pkgbuild-0.2.3.tar.gz
|
||||
md5sums = ba4c7a94ce78b8a62a5233bd8c265ec3
|
||||
|
||||
pkgname = pip2pkgbuild
|
||||
depends =
|
||||
depends = python
|
||||
depends = python-pip
|
||||
|
||||
pkgname = python2-pip2pkgbuild
|
||||
depends =
|
||||
depends = python2
|
||||
depends = python2-pip
|
||||
|
Loading…
Reference in a new issue