浏览代码

Update vendored dependencies

morganamilo 6 年之前
父节点
当前提交
2f975c7157

+ 2 - 2
Gopkg.lock

@@ -11,13 +11,13 @@
   branch = "master"
   name = "github.com/jguer/go-alpm"
   packages = ["."]
-  revision = "1114f773cdfb05f577438f7a0538eccabc9cf012"
+  revision = "c3ee958efac942186012cc67de8fe5e7a5b3685d"
 
 [[projects]]
   branch = "master"
   name = "github.com/mikkeloscar/aur"
   packages = ["."]
-  revision = "2980c04ca5c926b2cb7c4ac3ac8dc0b7f70d29ba"
+  revision = "f998dbf94dc47ef839c76740efeb673d3459be1f"
 
 [solve-meta]
   analyzer-name = "dep"

+ 1 - 1
vendor/github.com/jguer/go-alpm/callbacks.c

@@ -9,7 +9,7 @@
 #include <stdarg.h>
 #include <alpm.h>
 
-void logCallback(uint16_t level, char *cstring);
+void logCallback(alpm_loglevel_t level, char *cstring);
 void questionCallback(alpm_question_t *question);
 
 void go_alpm_log_cb(alpm_loglevel_t level, const char *fmt, va_list arg) {

+ 5 - 5
vendor/github.com/jguer/go-alpm/callbacks.go

@@ -9,7 +9,7 @@ package alpm
 /*
 #include <stdint.h>
 #include <alpm.h>
-void logCallback(uint16_t level, char *cstring);
+void logCallback(alpm_loglevel_t level, char *cstring);
 void go_alpm_log_cb(alpm_loglevel_t level, const char *fmt, va_list arg);
 void go_alpm_set_logging(alpm_handle_t *handle);
 void go_alpm_set_question(alpm_handle_t *handle);
@@ -20,12 +20,12 @@ import (
 	"unsafe"
 )
 
-type logCallbackSig func(uint16, string)
+type logCallbackSig func(LogLevel, string)
 type questionCallbackSig func(QuestionAny)
 
 var DefaultLogLevel = LogWarning
 
-func DefaultLogCallback(lvl uint16, s string) {
+func DefaultLogCallback(lvl LogLevel, s string) {
 	if lvl <= DefaultLogLevel {
 		print("go-alpm: ", s)
 	}
@@ -35,8 +35,8 @@ var log_callback logCallbackSig
 var question_callback questionCallbackSig
 
 //export logCallback
-func logCallback(level uint16, cstring *C.char) {
-	log_callback(level, C.GoString(cstring))
+func logCallback(level C.alpm_loglevel_t, cstring *C.char) {
+	log_callback(LogLevel(level), C.GoString(cstring))
 }
 
 //export questionCallback

+ 27 - 0
vendor/github.com/jguer/go-alpm/conf.go

@@ -69,6 +69,7 @@ type PacmanConfig struct {
 type RepoConfig struct {
 	Name     string
 	SigLevel SigLevel
+	Usage    Usage
 	Servers  []string
 }
 
@@ -197,6 +198,24 @@ lineloop:
 			case "SigLevel":
 				// TODO: implement SigLevel parsing.
 				continue lineloop
+			case "Usage":
+				for _, usage := range line.Values {
+					switch usage {
+					case "Sync":
+						curRepo.Usage |= UsageSync
+					case "Search":
+						curRepo.Usage |= UsageSearch
+					case "Install":
+						curRepo.Usage |= UsageInstall
+					case "Upgrade":
+						curRepo.Usage |= UsageUpgrade
+					case "All":
+						curRepo.Usage |= UsageAll
+					default:
+						err = fmt.Errorf("unknown option at line %d: %s", rdr.Lineno, line.Name)
+						break lineloop
+					}
+				}
 			case "Server":
 				curRepo.Servers = append(curRepo.Servers, line.Values...)
 				continue lineloop
@@ -261,6 +280,13 @@ lineloop:
 		conf.CacheDir = []string{"/var/cache/pacman/pkg/"} //should only be set if the config does not specify this
 	}
 
+	for n, _ := range conf.Repos {
+		repo := &conf.Repos[n]
+		if repo.Usage == 0 {
+			repo.Usage = UsageAll
+		}
+	}
+
 	return conf, err
 }
 
@@ -316,6 +342,7 @@ func (conf *PacmanConfig) CreateHandle() (*Handle, error) {
 				repoconf.Servers[i] = addr
 			}
 			db.SetServers(repoconf.Servers)
+			db.SetUsage(repoconf.Usage)
 		}
 	}
 

+ 25 - 0
vendor/github.com/jguer/go-alpm/db.go

@@ -117,6 +117,11 @@ func (db Db) SetServers(servers []string) {
 	}
 }
 
+// SetUsage sets the Usage of the database
+func (db Db) SetUsage(usage Usage) {
+	C.alpm_db_set_usage(db.ptr, C.int(usage))
+}
+
 // PkgByName searches a package in db.
 func (db Db) PkgByName(name string) (*Package, error) {
 	cName := C.CString(name)
@@ -151,3 +156,23 @@ func (db Db) PkgCache() PackageList {
 	pkgcache := (*list)(unsafe.Pointer(C.alpm_db_get_pkgcache(db.ptr)))
 	return PackageList{pkgcache, db.handle}
 }
+
+func (db Db) Search(targets []string) PackageList {
+	needles := &C.alpm_list_t{}
+	head := needles
+	needles.data = unsafe.Pointer(C.CString(targets[0]))
+
+	for _, str := range targets[1:] {
+		needles.next = &C.alpm_list_t{}
+		needles = needles.next
+		needles.data = unsafe.Pointer(C.CString(str))
+	}
+
+	pkglist := (*list)(unsafe.Pointer(C.alpm_db_search(db.ptr, needles)))
+
+	for needles = head; needles != nil; needles = needles.next {
+		C.free(needles.data)
+	}
+
+	return PackageList{pkglist, db.handle}
+}

+ 38 - 1
vendor/github.com/jguer/go-alpm/enums.go

@@ -89,9 +89,11 @@ const (
 	SigStatusKeyDisabled
 )
 
+type LogLevel uint16
+
 // Logging levels.
 const (
-	LogError uint16 = 1 << iota
+	LogError LogLevel = 1 << iota
 	LogWarning
 	LogDebug
 	LogFunction
@@ -118,3 +120,38 @@ const (
 	ValidationSignature
 	ValidationUnkown Validation = 0
 )
+
+type Usage int
+
+const (
+	UsageSync Usage = 1 << iota
+	UsageSearch
+	UsageInstall
+	UsageUpgrade
+	UsageAll = (1 << 4) - 1
+)
+
+type TransFlag int
+
+const (
+	TransFlagNoDeps TransFlag = 1 << iota
+	TransFlagForce
+	TransFlagNoSave
+	TransFlagNoDepVersion
+	TransFlagCascade
+	TransFlagRecurse
+	// 7 is missing
+	_
+	TransFlagDbOnly
+	TransFlagAllDeps
+	TransFlagDownloadOnly
+	TransFlagNoScriptlets
+	// 12 is missing
+	_
+	TransFlagNoConflicts
+	TransFlagNeeded
+	TransFlagAllExplicit
+	TransFlagUnneeded
+	TransFlagRecurseAll
+	TransFlagNoLock
+)

+ 27 - 0
vendor/github.com/jguer/go-alpm/sync.go

@@ -0,0 +1,27 @@
+// db.go - Functions for database handling.
+//
+// Copyright (c) 2013 The go-alpm Authors
+//
+// MIT Licensed. See LICENSE for details.
+
+package alpm
+
+/*
+#include <alpm.h>
+*/
+import "C"
+
+func (h *Handle) SyncSysupgrade(enableDowngrade bool) error {
+	intEnableDowngrade := C.int(0)
+
+	if enableDowngrade {
+		intEnableDowngrade = C.int(1)
+	}
+
+	ret := C.alpm_sync_sysupgrade(h.ptr, intEnableDowngrade)
+	if ret != 0 {
+		return h.LastError()
+	}
+
+	return nil
+}

+ 54 - 0
vendor/github.com/jguer/go-alpm/trans.go

@@ -0,0 +1,54 @@
+// db.go - Functions for database handling.
+//
+// Copyright (c) 2013 The go-alpm Authors
+//
+// MIT Licensed. See LICENSE for details.
+
+package alpm
+
+/*
+#include <alpm.h>
+*/
+import "C"
+
+import (
+	"unsafe"
+)
+
+func (h *Handle) TransInit(flags TransFlag) error {
+	ret := C.alpm_trans_init(h.ptr, C.int(flags))
+	if ret != 0 {
+		return h.LastError()
+	}
+
+	return nil
+}
+
+func (h *Handle) TransRelease() error {
+	ret := C.alpm_trans_release(h.ptr)
+	if ret != 0 {
+		return h.LastError()
+	}
+
+	return nil
+}
+
+func (h *Handle) TransGetAdd() PackageList {
+	pkgs := C.alpm_trans_get_add(h.ptr)
+	return PackageList{(*list)(unsafe.Pointer(pkgs)), *h}
+}
+
+func (h *Handle) TransGetRemove() PackageList {
+	pkgs := C.alpm_trans_get_remove(h.ptr)
+	return PackageList{(*list)(unsafe.Pointer(pkgs)), *h}
+}
+
+func (h *Handle) TransGetFalgs() (TransFlag, error) {
+	flags := C.alpm_trans_get_flags(h.ptr)
+
+	if flags == -1 {
+		return -1, h.LastError()
+	}
+
+	return TransFlag(flags), nil
+}

+ 8 - 0
vendor/github.com/jguer/go-alpm/types.go

@@ -192,6 +192,14 @@ func (question QuestionAny) QuestionSelectProvider() (QuestionSelectProvider, er
 	return QuestionSelectProvider{}, fmt.Errorf("Can not convert to QuestionInstallIgnorepkg")
 }
 
+func (question QuestionAny) QuestionReplace() (QuestionReplace, error) {
+	if question.Type() == QuestionTypeReplacePkg {
+		return *(*QuestionReplace)(unsafe.Pointer(&question)), nil
+	}
+
+	return QuestionReplace{}, fmt.Errorf("Can not convert to QuestionReplace")
+}
+
 func (question QuestionInstallIgnorepkg) SetInstall(install bool) {
 	if install {
 		question.ptr.install = 1

+ 2 - 2
vendor/github.com/mikkeloscar/aur/aur.go

@@ -2,7 +2,7 @@ package aur
 
 import (
 	"encoding/json"
-	"fmt"
+	"errors"
 	"net/http"
 	"net/url"
 )
@@ -62,7 +62,7 @@ func get(values url.Values) ([]Pkg, error) {
 	}
 
 	if len(result.Error) > 0 {
-		return nil, fmt.Errorf(result.Error)
+		return nil, errors.New(result.Error)
 	}
 
 	return result.Results, nil