Kaynağa Gözat

Vendoring and cool looking displays

Jguer 7 yıl önce
ebeveyn
işleme
f0b9c0cfe9

+ 9 - 44
actions.go

@@ -4,10 +4,10 @@ import (
 	"fmt"
 	"os"
 
-	alpm "github.com/jguer/go-alpm"
 	aur "github.com/jguer/yay/aur"
 	"github.com/jguer/yay/config"
 	pac "github.com/jguer/yay/pacman"
+	"github.com/jguer/yay/upgrade"
 )
 
 // Install handles package installs
@@ -31,51 +31,16 @@ func install(pkgs []string, flags []string) error {
 }
 
 // Upgrade handles updating the cache and installing updates.
-func upgrade(flags []string) error {
-	errp := config.PassToPacman("-Sy", nil, flags)
-	if errp != nil {
-		return errp
-	}
-
-	pacC := make(chan []alpm.Package)
-	aurC := make(chan []aur.Upgrade)
-	errC := make(chan error)
-	var pacUp []alpm.Package
-	var aurUp []aur.Upgrade
-
-	go func() {
-		pacUpList, err := pac.UpgradeList()
-		errC <- err
-		pacC <- pacUpList
-	}()
-
-	go func() {
-		aurUpList, err := aur.UpgradeList()
-		errC <- err
-		aurC <- aurUpList
-	}()
-
-	var i = 0
-loop:
-	for {
-		select {
-		case pacUp = <-pacC:
-			i++
-		case aurUp = <-aurC:
-			i++
-		case err := <-errC:
-			if err != nil {
-				fmt.Println(err)
-			}
-		default:
-			if i == 2 {
-				break loop
-			}
-		}
+func upgradePkgs(flags []string) error {
+	aurUp, repoUp, err := upgrade.List()
+	if err != nil {
+		return err
 	}
-
 	fmt.Printf("%+v\n", aurUp)
-	fmt.Printf("%+v\n", pacUp)
+	fmt.Printf("%+v\n", repoUp)
+
+	upgrade.Print(len(aurUp), repoUp)
+	upgrade.Print(0, aurUp)
 	// erra := aur.Upgrade(flags)
 
 	// if errp != nil {

+ 0 - 73
aur/aur.go

@@ -131,79 +131,6 @@ func develUpgrade(foreign map[string]alpm.Package, flags []string) error {
 	return nil
 }
 
-type Upgrade struct {
-	Name          string
-	LocalVersion  string
-	RemoteVersion string
-}
-
-func UpgradeList() (toUpgrade []Upgrade, err error) {
-	foreign, foreignNames, err := pacman.ForeignPackageList()
-	if err != nil {
-		return
-	}
-
-	var qtemp Query
-	var j int
-	var routines int
-	var routineDone int
-
-	packageC := make(chan Upgrade)
-	done := make(chan bool)
-
-	for i := len(foreign); i != 0; i = j {
-		j = i - config.YayConf.RequestSplitN
-		if j < 0 {
-			j = 0
-		}
-
-		//Split requests so AUR RPC doesn't get mad at us.
-		qtemp, err = rpc.Info(foreignNames[j:i])
-		if err != nil {
-			return
-		}
-
-		routines++
-		go func(qtemp Query, local []alpm.Package) {
-			// For each item in query: Search equivalent in foreign.
-			// We assume they're ordered and are returned ordered
-			// and will only be missing if they don't exist in AUR.
-			max := len(qtemp) - 1
-			var missing, x int
-
-			fmt.Print("\n")
-			for i, _ := range local {
-				x = i - missing
-				if x > max {
-					break
-				} else if qtemp[x].Name == local[i].Name() {
-					if (config.YayConf.TimeUpdate && (int64(qtemp[x].LastModified) > local[i].BuildDate().Unix())) ||
-						(alpm.VerCmp(local[i].Version(), qtemp[x].Version) < 0) {
-						packageC <- Upgrade{qtemp[x].Name, local[i].Version(), qtemp[x].Version}
-						continue
-					}
-				} else {
-					missing++
-				}
-			}
-			done <- true
-		}(qtemp, foreign[j:i])
-	}
-
-	for {
-		select {
-		case pkg := <-packageC:
-			toUpgrade = append(toUpgrade, pkg)
-		case <-done:
-			routineDone++
-			if routineDone == routines {
-				err = nil
-				return
-			}
-		}
-	}
-}
-
 // Upgrade tries to update every foreign package installed in the system
 // func Upgrade(flags []string) error {
 // 	fmt.Println("\x1b[1;36;1m::\x1b[0m\x1b[1m Starting AUR upgrade...\x1b[0m")

+ 1 - 0
config/config.go

@@ -42,6 +42,7 @@ type Configuration struct {
 	TimeUpdate    bool   `json:"timeupdate"`
 }
 
+
 // YayConf holds the current config values for yay.
 var YayConf Configuration
 

+ 0 - 55
pacman/pacman.go

@@ -134,27 +134,6 @@ func PackageSlices(toCheck []string) (aur []string, repo []string, err error) {
 	return
 }
 
-func UpgradeList() ([]alpm.Package, error) {
-	localDb, err := config.AlpmHandle.LocalDb()
-	if err != nil {
-		return nil, err
-	}
-
-	dbList, err := config.AlpmHandle.SyncDbs()
-	if err != nil {
-		return nil, err
-	}
-
-	slice := []alpm.Package{}
-	for _, pkg := range localDb.PkgCache().Slice() {
-		newPkg := pkg.NewVersion(dbList)
-		if newPkg != nil {
-			slice = append(slice, *newPkg)
-		}
-	}
-	return slice, nil
-}
-
 // BuildDependencies finds packages, on the second run
 // compares with a baselist and avoids searching those
 func BuildDependencies(baselist []string) func(toCheck []string, isBaseList bool, last bool) (repo []string, notFound []string) {
@@ -284,40 +263,6 @@ func ForeignPackages() (foreign map[string]alpm.Package, err error) {
 	return
 }
 
-// ForeignPackages returns a map of foreign packages, with their version and date as values.
-func ForeignPackageList() (packages []alpm.Package, packageNames []string, err error) {
-	localDb, err := config.AlpmHandle.LocalDb()
-	if err != nil {
-		return
-	}
-	dbList, err := config.AlpmHandle.SyncDbs()
-	if err != nil {
-		return
-	}
-
-	f := func(k alpm.Package) error {
-		found := false
-		_ = dbList.ForEach(func(d alpm.Db) error {
-			if found {
-				return nil
-			}
-			_, err = d.PkgByName(k.Name())
-			if err == nil {
-				found = true
-			}
-			return nil
-		})
-
-		if !found {
-			packages = append(packages, k)
-			packageNames = append(packageNames, k.Name())
-		}
-		return nil
-	}
-
-	err = localDb.PkgCache().ForEach(f)
-	return
-}
 
 // Statistics returns statistics about packages installed in system
 func Statistics() (info struct {

+ 226 - 0
upgrade/u.go

@@ -0,0 +1,226 @@
+// Package upgrade package is responsible for returning lists of outdated packages.
+package upgrade
+
+import (
+	"fmt"
+
+	alpm "github.com/jguer/go-alpm"
+	"github.com/jguer/yay/config"
+	rpc "github.com/mikkeloscar/aur"
+	pkgb "github.com/mikkeloscar/gopkgbuild"
+)
+
+// Upgrade type describes a system upgrade.
+type Upgrade struct {
+	Name          string
+	Repository    string
+	LocalVersion  string
+	RemoteVersion string
+}
+
+// FilterPackages filters packages based on source and type.
+func FilterPackages() (local []alpm.Package, remote []alpm.Package,
+	localNames []string, remoteNames []string, err error) {
+	localDb, err := config.AlpmHandle.LocalDb()
+	if err != nil {
+		return
+	}
+	dbList, err := config.AlpmHandle.SyncDbs()
+	if err != nil {
+		return
+	}
+
+	f := func(k alpm.Package) error {
+		found := false
+		// For each DB search for our secret package.
+		_ = dbList.ForEach(func(d alpm.Db) error {
+			if found {
+				return nil
+			}
+			_, err := d.PkgByName(k.Name())
+			if err == nil {
+				found = true
+				local = append(local, k)
+				localNames = append(localNames, k.Name())
+			}
+			return nil
+		})
+
+		if !found {
+			remote = append(remote, k)
+			remoteNames = append(remoteNames, k.Name())
+		}
+		return nil
+	}
+
+	err = localDb.PkgCache().ForEach(f)
+	return
+}
+
+func Print(start int, u []Upgrade) {
+	for _, i := range u {
+		old, err := pkgb.NewCompleteVersion(i.LocalVersion)
+		if err != nil {
+			fmt.Println(i.Name, err)
+		}
+		new, err := pkgb.NewCompleteVersion(i.RemoteVersion)
+		if err != nil {
+			fmt.Println(i.Name, err)
+		}
+
+		f := func(name string) (color int) {
+			var hash = 5381
+			for i := 0; i < len(name); i++ {
+				hash = int(name[i]) + ((hash << 5) + (hash))
+			}
+			return (hash)%6 + 31
+		}
+		// fmt.Printf("\x1b[33m%-2d\x1b[0m ", len(u)+start-k-1)
+		fmt.Printf("\x1b[1;%dm%s\x1b[0m/\x1b[1;39m%-20s\t\t\x1b[0m", f(i.Repository), i.Repository, i.Name)
+
+		if old.Version != new.Version {
+			fmt.Printf("\x1b[31m%10s\x1b[0m-%d -> \x1b[1;32m%s\x1b[0m-%d\x1b[0m",
+				old.Version, old.Pkgrel,
+				new.Version, new.Pkgrel)
+		} else {
+			fmt.Printf("\x1b[0m%10s-\x1b[31m%d\x1b[0m -> %s-\x1b[32m%d\x1b[0m",
+				old.Version, old.Pkgrel,
+				new.Version, new.Pkgrel)
+		}
+		print("\n")
+	}
+}
+
+// List returns lists of packages to upgrade from each source.
+func List() (aurUp []Upgrade, repoUp []Upgrade, err error) {
+	err = config.PassToPacman("-Sy", nil, nil)
+	if err != nil {
+		return
+	}
+
+	local, remote, _, remoteNames, err := FilterPackages()
+	if err != nil {
+		return
+	}
+
+	repoC := make(chan []Upgrade)
+	aurC := make(chan []Upgrade)
+	errC := make(chan error)
+
+	go func() {
+		repoUpList, err := repo(local)
+		errC <- err
+		repoC <- repoUpList
+	}()
+
+	go func() {
+		aurUpList, err := aur(remote, remoteNames)
+		errC <- err
+		aurC <- aurUpList
+	}()
+
+	var i = 0
+loop:
+	for {
+		select {
+		case repoUp = <-repoC:
+			i++
+		case aurUp = <-aurC:
+			i++
+		case err := <-errC:
+			if err != nil {
+				fmt.Println(err)
+			}
+		default:
+			if i == 2 {
+				close(repoC)
+				close(aurC)
+				close(errC)
+				break loop
+			}
+		}
+	}
+	return
+}
+
+// aur gathers foreign packages and checks if they have new versions.
+// Output: Upgrade type package list.
+func aur(remote []alpm.Package, remoteNames []string) (toUpgrade []Upgrade, err error) {
+	var j int
+	var routines int
+	var routineDone int
+
+	packageC := make(chan Upgrade)
+	done := make(chan bool)
+
+	for i := len(remote); i != 0; i = j {
+		//Split requests so AUR RPC doesn't get mad at us.
+		j = i - config.YayConf.RequestSplitN
+		if j < 0 {
+			j = 0
+		}
+
+		routines++
+		go func(local []alpm.Package, remote []string) {
+			qtemp, err := rpc.Info(remoteNames)
+			if err != nil {
+				fmt.Println(err)
+				done <- true
+				return
+			}
+			// For each item in query: Search equivalent in foreign.
+			// We assume they're ordered and are returned ordered
+			// and will only be missing if they don't exist in AUR.
+			max := len(qtemp) - 1
+			var missing, x int
+
+			for i := range local {
+				x = i - missing
+				if x > max {
+					break
+				} else if qtemp[x].Name == local[i].Name() {
+					if (config.YayConf.TimeUpdate && (int64(qtemp[x].LastModified) > local[i].BuildDate().Unix())) ||
+						(alpm.VerCmp(local[i].Version(), qtemp[x].Version) < 0) {
+						packageC <- Upgrade{qtemp[x].Name, "aur", local[i].Version(), qtemp[x].Version}
+					}
+					continue
+				} else {
+					missing++
+				}
+			}
+			done <- true
+		}(remote[j:i], remoteNames[j:i])
+	}
+
+	for {
+		select {
+		case pkg := <-packageC:
+			fmt.Println("Package Received")
+			toUpgrade = append(toUpgrade, pkg)
+		case <-done:
+			routineDone++
+			if routineDone == routines {
+				err = nil
+				return
+			}
+		}
+	}
+}
+
+// repo gathers local packages and checks if they have new versions.
+// Output: Upgrade type package list.
+func repo(local []alpm.Package) ([]Upgrade, error) {
+	dbList, err := config.AlpmHandle.SyncDbs()
+	if err != nil {
+		return nil, err
+	}
+
+	slice := []Upgrade{}
+	for _, pkg := range local {
+		newPkg := pkg.NewVersion(dbList)
+		if newPkg != nil {
+			slice = append(slice, Upgrade{pkg.Name(), newPkg.DB().Name(), pkg.Version(), newPkg.Version()})
+		}
+	}
+	return slice, nil
+}

+ 19 - 0
vendor/github.com/jguer/go-alpm/LICENSE

@@ -0,0 +1,19 @@
+Copyright (C) 2013 The go-alpm Authors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 30 - 0
vendor/github.com/jguer/go-alpm/README.md

@@ -0,0 +1,30 @@
+## go-alpm
+
+go-alpm is a Go package for binding libalpm. With go-alpm, it becomes possible
+to manipulate the Pacman databases and packages just as Pacman would.
+
+This project is MIT Licensed. See LICENSE for details.
+
+## Getting started
+
+1. Import the go-alpm repository in your go script
+
+	import "github.com/demizer/go-alpm"
+
+2. Copy the library to your GOPATH
+
+	mkdir ~/go
+	export GOPATH=~/go
+	go get github.com/demizer/go-alpm
+
+3. Try the included examples
+
+	cd $GOPATH/src/github.com/demizer/go-alpm/examples
+	go run installed.go
+
+## Contributors
+
+* Mike Rosset
+* Dave Reisner
+* Rémy Oudompheng
+* Jesus Alvarez

+ 29 - 0
vendor/github.com/jguer/go-alpm/alpm.go

@@ -0,0 +1,29 @@
+// alpm.go - Implements exported libalpm functions.
+//
+// Copyright (c) 2013 The go-alpm Authors
+//
+// MIT Licensed. See LICENSE for details.
+
+package alpm
+
+// #cgo LDFLAGS: -lalpm
+// #include <alpm.h>
+import "C"
+
+import "unsafe"
+
+// Version returns libalpm version string.
+func Version() string {
+	return C.GoString(C.alpm_version())
+}
+
+// VerCmp performs version comparison according to Pacman conventions. Return
+// value is <0 if and only if v1 is older than v2.
+func VerCmp(v1, v2 string) int {
+	c1 := C.CString(v1)
+	c2 := C.CString(v2)
+	defer C.free(unsafe.Pointer(c1))
+	defer C.free(unsafe.Pointer(c2))
+	result := C.alpm_pkg_vercmp(c1, c2)
+	return int(result)
+}

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

@@ -0,0 +1,31 @@
+// callbacks.c - Sets alpm callbacks to Go functions.
+//
+// Copyright (c) 2013 The go-alpm Authors
+//
+// MIT Licensed. See LICENSE for details.
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <alpm.h>
+
+void logCallback(uint16_t level, char *cstring);
+
+void go_alpm_log_cb(alpm_loglevel_t level, const char *fmt, va_list arg) {
+  char *s = malloc(128);
+  if (s == NULL) return;
+  int16_t length = vsnprintf(s, 128, fmt, arg);
+  if (length > 128) {
+    length = (length + 16) & ~0xf;
+    s = realloc(s, length);
+  }
+  if (s != NULL) {
+		logCallback(level, s);
+		free(s);
+  }
+}
+
+void go_alpm_set_logging(alpm_handle_t *handle) {
+  alpm_option_set_logcb(handle, go_alpm_log_cb);
+}
+

+ 36 - 0
vendor/github.com/jguer/go-alpm/callbacks.go

@@ -0,0 +1,36 @@
+// callbacks.go - Handles libalpm callbacks.
+//
+// Copyright (c) 2013 The go-alpm Authors
+//
+// MIT Licensed. See LICENSE for details.
+
+package alpm
+
+/*
+#include <stdint.h>
+#include <alpm.h>
+void logCallback(uint16_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);
+*/
+import "C"
+
+var DefaultLogLevel = LogWarning
+
+func DefaultLogCallback(lvl uint16, s string) {
+	if lvl <= DefaultLogLevel {
+		print("go-alpm: ", s)
+	}
+}
+
+var log_callback = DefaultLogCallback
+
+//export logCallback
+func logCallback(level uint16, cstring *C.char) {
+	log_callback(level, C.GoString(cstring))
+}
+
+func (h *Handle) SetLogCallback(cb func(uint16, string)) {
+	log_callback = cb
+	C.go_alpm_set_logging(h.ptr)
+}

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

@@ -0,0 +1,288 @@
+// conf.go - Functions for pacman.conf parsing.
+//
+// Copyright (c) 2013 The go-alpm Authors
+//
+// MIT Licensed. See LICENSE for details.
+
+package alpm
+
+import (
+	"bufio"
+	"bytes"
+	"fmt"
+	"io"
+	"os"
+	"reflect"
+	"strings"
+	"syscall"
+)
+
+type PacmanOption uint
+
+const (
+	ConfUseSyslog PacmanOption = 1 << iota
+	ConfColor
+	ConfTotalDownload
+	ConfCheckSpace
+	ConfVerbosePkgLists
+	ConfILoveCandy
+)
+
+var optionsMap = map[string]PacmanOption{
+	"UseSyslog":       ConfUseSyslog,
+	"Color":           ConfColor,
+	"TotalDownload":   ConfTotalDownload,
+	"CheckSpace":      ConfCheckSpace,
+	"VerbosePkgLists": ConfVerbosePkgLists,
+	"ILoveCandy":      ConfILoveCandy,
+}
+
+// PacmanConfig is a type for holding pacman options parsed from pacman
+// configuration data passed to ParseConfig.
+type PacmanConfig struct {
+	RootDir            string
+	DBPath             string
+	CacheDir           []string
+	GPGDir             string
+	LogFile            string
+	HoldPkg            []string
+	IgnorePkg          []string
+	IgnoreGroup        []string
+	Include            []string
+	Architecture       string
+	XferCommand        string
+	NoUpgrade          []string
+	NoExtract          []string
+	CleanMethod        string
+	SigLevel           SigLevel
+	LocalFileSigLevel  SigLevel
+	RemoteFileSigLevel SigLevel
+	UseDelta           string
+	Options            PacmanOption
+	Repos              []RepoConfig
+}
+
+// RepoConfig is a type that stores the signature level of a repository
+// specified in the pacman config file.
+type RepoConfig struct {
+	Name     string
+	SigLevel SigLevel
+	Servers  []string
+}
+
+// Constants for pacman configuration parsing
+const (
+	tokenSection = iota
+	tokenKey
+	tokenComment
+)
+
+type iniToken struct {
+	Type   uint
+	Name   string
+	Values []string
+}
+
+type confReader struct {
+	*bufio.Reader
+	Lineno uint
+}
+
+// newConfReader reads from the io.Reader if it is buffered and returns a
+// confReader containing the number of bytes read and 0 for the first line. If
+// r is not a buffered reader, a new buffered reader is created using r as its
+// input and returned.
+func newConfReader(r io.Reader) confReader {
+	if buf, ok := r.(*bufio.Reader); ok {
+		return confReader{buf, 0}
+	}
+	buf := bufio.NewReader(r)
+	return confReader{buf, 0}
+}
+
+func (rdr *confReader) ParseLine() (tok iniToken, err error) {
+	line, overflow, err := rdr.ReadLine()
+	switch {
+	case err != nil:
+		return
+	case overflow:
+		err = fmt.Errorf("line %d too long", rdr.Lineno)
+		return
+	}
+	rdr.Lineno++
+
+	line = bytes.TrimSpace(line)
+	if len(line) == 0 {
+		tok.Type = tokenComment
+		return
+	}
+	switch line[0] {
+	case '#':
+		tok.Type = tokenComment
+		return
+	case '[':
+		closing := bytes.IndexByte(line, ']')
+		if closing < 0 {
+			err = fmt.Errorf("missing ']' is section name at line %d", rdr.Lineno)
+			return
+		}
+		tok.Name = string(line[1:closing])
+		if closing+1 < len(line) {
+			err = fmt.Errorf("trailing characters %q after section name %s",
+				line[closing+1:], tok.Name)
+			return
+		}
+		return
+	default:
+		tok.Type = tokenKey
+		if idx := bytes.IndexByte(line, '='); idx >= 0 {
+			optname := bytes.TrimSpace(line[:idx])
+			values := bytes.Split(line[idx+1:], []byte{' '})
+			tok.Name = string(optname)
+			tok.Values = make([]string, 0, len(values))
+			for _, word := range values {
+				word = bytes.TrimSpace(word)
+				if len(word) > 0 {
+					tok.Values = append(tok.Values, string(word))
+				}
+			}
+		} else {
+			// boolean option
+			tok.Name = string(line)
+			tok.Values = nil
+		}
+		return
+	}
+}
+
+func ParseConfig(r io.Reader) (conf PacmanConfig, err error) {
+	rdr := newConfReader(r)
+	rdrStack := []confReader{rdr}
+	conf.SetDefaults()
+	confReflect := reflect.ValueOf(&conf).Elem()
+	var currentSection string
+	var curRepo *RepoConfig
+lineloop:
+	for {
+		line, err := rdr.ParseLine()
+		// fmt.Printf("%+v\n", line)
+		switch err {
+		case io.EOF:
+			// pop reader stack.
+			l := len(rdrStack)
+			if l == 1 {
+				return conf, nil
+			}
+			rdr = rdrStack[l-2]
+			rdrStack = rdrStack[:l-1]
+		default:
+			return conf, err
+		case nil:
+			// Ok.
+		}
+
+		switch line.Type {
+		case tokenComment:
+		case tokenSection:
+			currentSection = line.Name
+			if currentSection != "options" {
+				conf.Repos = append(conf.Repos, RepoConfig{})
+				curRepo = &conf.Repos[len(conf.Repos)-1]
+				curRepo.Name = line.Name
+			}
+		case tokenKey:
+			switch line.Name {
+			case "SigLevel":
+				// TODO: implement SigLevel parsing.
+				continue lineloop
+			case "Server":
+				curRepo.Servers = append(curRepo.Servers, line.Values...)
+				continue lineloop
+			case "Include":
+				f, err := os.Open(line.Values[0])
+				if err != nil {
+					err = fmt.Errorf("error while processing Include directive at line %d: %s",
+						rdr.Lineno, err)
+					return conf, err
+				}
+				rdr = newConfReader(f)
+				rdrStack = append(rdrStack, rdr)
+				continue lineloop
+			}
+
+			if currentSection != "options" {
+				err = fmt.Errorf("option %s outside of [options] section, at line %d",
+					line.Name, rdr.Lineno)
+				return conf, err
+			}
+			// main options.
+			if opt, ok := optionsMap[line.Name]; ok {
+				// boolean option.
+				conf.Options |= opt
+			} else {
+				// key-value option.
+				fld := confReflect.FieldByName(line.Name)
+				if !fld.IsValid() || !fld.CanAddr() {
+					_ = fmt.Errorf("unknown option at line %d: %s", rdr.Lineno, line.Name)
+					continue
+				}
+
+				switch fieldP := fld.Addr().Interface().(type) {
+				case *string:
+					// single valued option.
+					*fieldP = strings.Join(line.Values, " ")
+				case *[]string:
+					//many valued option.
+					*fieldP = append(*fieldP, line.Values...)
+				}
+			}
+		}
+	}
+}
+
+func (conf *PacmanConfig) SetDefaults() {
+	conf.RootDir = "/"
+	conf.DBPath = "/var/lib/pacman"
+}
+
+func getArch() (string, error) {
+	var uname syscall.Utsname
+	err := syscall.Uname(&uname)
+	if err != nil {
+		return "", err
+	}
+	var arch [65]byte
+	for i, c := range uname.Machine {
+		if c == 0 {
+			return string(arch[:i]), nil
+		}
+		arch[i] = byte(c)
+	}
+	return string(arch[:]), nil
+}
+
+func (conf *PacmanConfig) CreateHandle() (*Handle, error) {
+	h, err := Init(conf.RootDir, conf.DBPath)
+	if err != nil {
+		return nil, err
+	}
+	if conf.Architecture == "auto" {
+		conf.Architecture, err = getArch()
+		if err != nil {
+			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)
+		if err == nil {
+			for i, addr := range repoconf.Servers {
+				addr = strings.Replace(addr, "$repo", repoconf.Name, -1)
+				addr = strings.Replace(addr, "$arch", conf.Architecture, -1)
+				repoconf.Servers[i] = addr
+			}
+			db.SetServers(repoconf.Servers)
+		}
+	}
+	return h, nil
+}

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

@@ -0,0 +1,153 @@
+// 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 (
+	"fmt"
+	"io"
+	"unsafe"
+)
+
+// Db structure representing a alpm database.
+type Db struct {
+	ptr    *C.alpm_db_t
+	handle Handle
+}
+
+// DbList structure representing a alpm database list.
+type DbList struct {
+	*list
+	handle Handle
+}
+
+// ForEach executes an action on each Db.
+func (l DbList) ForEach(f func(Db) error) error {
+	return l.forEach(func(p unsafe.Pointer) error {
+		return f(Db{(*C.alpm_db_t)(p), l.handle})
+	})
+}
+
+// Slice converst Db list to Db slice.
+func (l DbList) Slice() []Db {
+	slice := []Db{}
+	l.ForEach(func(db Db) error {
+		slice = append(slice, db)
+		return nil
+	})
+	return slice
+}
+
+// LocalDb returns the local database relative to the given handle.
+func (h Handle) LocalDb() (*Db, error) {
+	db := C.alpm_get_localdb(h.ptr)
+	if db == nil {
+		return nil, h.LastError()
+	}
+	return &Db{db, h}, nil
+}
+
+// SyncDbs returns list of Synced DBs.
+func (h Handle) SyncDbs() (DbList, error) {
+	dblist := C.alpm_get_syncdbs(h.ptr)
+	if dblist == nil {
+		return DbList{nil, h}, h.LastError()
+	}
+	dblistPtr := unsafe.Pointer(dblist)
+	return DbList{(*list)(dblistPtr), h}, nil
+}
+
+// SyncDbByName finds a registered database by name.
+func (h Handle) SyncDbByName(name string) (db *Db, err error) {
+	dblist, err := h.SyncDbs()
+	if err != nil {
+		return nil, err
+	}
+	dblist.ForEach(func(b Db) error {
+		if b.Name() == name {
+			db = &b
+			return io.EOF
+		}
+		return nil
+	})
+	if db != nil {
+		return db, nil
+	}
+	return nil, fmt.Errorf("database %s not found", name)
+}
+
+// RegisterSyncDb Loads a sync database with given name and signature check level.
+func (h Handle) RegisterSyncDb(dbname string, siglevel SigLevel) (*Db, error) {
+	cName := C.CString(dbname)
+	defer C.free(unsafe.Pointer(cName))
+
+	db := C.alpm_register_syncdb(h.ptr, cName, C.alpm_siglevel_t(siglevel))
+	if db == nil {
+		return nil, h.LastError()
+	}
+	return &Db{db, h}, nil
+}
+
+// Name returns name of the db
+func (db Db) Name() string {
+	return C.GoString(C.alpm_db_get_name(db.ptr))
+}
+
+// Servers returns host server URL.
+func (db Db) Servers() []string {
+	ptr := unsafe.Pointer(C.alpm_db_get_servers(db.ptr))
+	return StringList{(*list)(ptr)}.Slice()
+}
+
+// SetServers sets server list to use.
+func (db Db) SetServers(servers []string) {
+	C.alpm_db_set_servers(db.ptr, nil)
+	for _, srv := range servers {
+		Csrv := C.CString(srv)
+		defer C.free(unsafe.Pointer(Csrv))
+		C.alpm_db_add_server(db.ptr, Csrv)
+	}
+}
+
+// PkgByName searches a package in db.
+func (db Db) PkgByName(name string) (*Package, error) {
+	cName := C.CString(name)
+	defer C.free(unsafe.Pointer(cName))
+	ptr := C.alpm_db_get_pkg(db.ptr, cName)
+	if ptr == nil {
+		return nil,
+			fmt.Errorf("Error when retrieving %s from database %s: %s",
+				name, db.Name(), db.handle.LastError())
+	}
+	return &Package{ptr, db.handle}, nil
+}
+
+// PkgCachebyGroup returns a PackageList of packages belonging to a group
+func (l DbList) PkgCachebyGroup(name string) (PackageList, error) {
+	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)))
+	if pkgcache == nil {
+		return PackageList{pkgcache, l.handle},
+			fmt.Errorf("Error when retrieving group %s from database list: %s",
+				name, l.handle.LastError())
+	}
+
+	return PackageList{pkgcache, l.handle}, nil
+}
+
+// PkgCache returns the list of packages of the database
+func (db Db) PkgCache() PackageList {
+	pkgcache := (*list)(unsafe.Pointer(C.alpm_db_get_pkgcache(db.ptr)))
+	return PackageList{pkgcache, db.handle}
+}

+ 44 - 0
vendor/github.com/jguer/go-alpm/dependency.go

@@ -0,0 +1,44 @@
+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) (*Package, 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) (*Package, 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
+}

+ 98 - 0
vendor/github.com/jguer/go-alpm/enums.go

@@ -0,0 +1,98 @@
+// enums.go - libaplm enumerations.
+//
+// Copyright (c) 2013 The go-alpm Authors
+//
+// MIT Licensed. See LICENSE for details.
+
+package alpm
+
+// Install reason of a package.
+type PkgReason uint
+
+const (
+	PkgReasonExplicit PkgReason = 0
+	PkgReasonDepend   PkgReason = 1
+)
+
+func (r PkgReason) String() string {
+	switch r {
+	case PkgReasonExplicit:
+		return "Explicitly installed"
+	case PkgReasonDepend:
+		return "Installed as a dependency of another package"
+	}
+	return ""
+}
+
+// Source of a package structure.
+type PkgFrom uint
+
+const (
+	FromFile PkgFrom = iota + 1
+	FromLocalDB
+	FromSyncDB
+)
+
+// Dependency constraint types.
+type DepMod uint
+
+const (
+	DepModAny DepMod = iota + 1 // Any version.
+	DepModEq                    // Specific version.
+	DepModGE                    // Test for >= some version.
+	DepModLE                    // Test for <= some version.
+	DepModGT                    // Test for > some version.
+	DepModLT                    // Test for < some version.
+)
+
+func (mod DepMod) String() string {
+	switch mod {
+	case DepModEq:
+		return "="
+	case DepModGE:
+		return ">="
+	case DepModLE:
+		return "<="
+	case DepModGT:
+		return ">"
+	case DepModLT:
+		return "<"
+	}
+	return ""
+}
+
+// Signature checking level.
+type SigLevel uint
+
+const (
+	SigPackage SigLevel = 1 << iota
+	SigPackageOptional
+	SigPackageMarginalOk
+	SigPackageUnknownOk
+)
+const (
+	SigDatabase SigLevel = 1 << (10 + iota)
+	SigDatabaseOptional
+	SigDatabaseMarginalOk
+	SigDatabaseUnknownOk
+)
+const SigUseDefault SigLevel = 1 << 31
+
+// Signature status
+type SigStatus uint
+
+const (
+	SigStatusValid SigStatus = iota
+	SigStatusKeyExpired
+	SigStatusSigExpired
+	SigStatusKeyUnknown
+	SigStatusKeyDisabled
+)
+
+// Logging levels.
+const (
+	LogError uint16 = 1 << iota
+	LogWarning
+	LogDebug
+	LogFunction
+)

+ 21 - 0
vendor/github.com/jguer/go-alpm/error.go

@@ -0,0 +1,21 @@
+// error.go - Functions for converting libalpm erros to Go errors.
+//
+// Copyright (c) 2013 The go-alpm Authors
+//
+// MIT Licensed. See LICENSE for details.
+
+package alpm
+
+// #include <alpm.h>
+import "C"
+
+// The Error type represents error codes from libalpm.
+type Error C.alpm_errno_t
+
+var _ error = Error(0)
+
+// The string representation of an error is given by C function
+// alpm_strerror().
+func (er Error) Error() string {
+	return C.GoString(C.alpm_strerror(C.alpm_errno_t(er)))
+}

+ 85 - 0
vendor/github.com/jguer/go-alpm/handle.go

@@ -0,0 +1,85 @@
+// handle.go - libalpm handle type and methods.
+//
+// Copyright (c) 2013 The go-alpm Authors
+//
+// MIT Licensed. See LICENSE for details.
+
+// Package alpm implements Go bindings to the libalpm library used by Pacman,
+// the Arch Linux package manager. Libalpm allows the creation of custom front
+// ends to the Arch Linux package ecosystem.
+//
+// Libalpm does not include support for the Arch User Repository (AUR).
+package alpm
+
+// #include <alpm.h>
+import "C"
+
+import (
+	"unsafe"
+)
+
+type Handle struct {
+	ptr *C.alpm_handle_t
+}
+
+// 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)
+
+	if c_err != 0 {
+		return nil, Error(c_err)
+	}
+
+	return &Handle{h}, nil
+}
+
+func (h *Handle) Release() error {
+	if er := C.alpm_release(h.ptr); er != 0 {
+		return Error(er)
+	}
+	h.ptr = nil
+	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 {
+		c_err := C.alpm_errno(h.ptr)
+		if c_err != 0 {
+			return Error(c_err)
+		}
+	}
+	return nil
+}
+
+func (h Handle) UseSyslog() bool {
+	value := C.alpm_option_get_usesyslog(h.ptr)
+	return (value != 0)
+}
+
+func (h Handle) SetUseSyslog(value bool) error {
+	var int_value C.int
+	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
+}

+ 246 - 0
vendor/github.com/jguer/go-alpm/package.go

@@ -0,0 +1,246 @@
+// 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;
+    unsigned long int s1 = alpm_pkg_get_isize(p1);
+    unsigned long int s2 = alpm_pkg_get_isize(p2);
+    return(s2 - s1);
+}
+*/
+import "C"
+
+import (
+	"time"
+	"unsafe"
+)
+
+// Package describes a single package and associated handle.
+type Package struct {
+	pmpkg  *C.alpm_pkg_t
+	handle Handle
+}
+
+// PackageList describes a linked list of packages and associated handle.
+type PackageList struct {
+	*list
+	handle Handle
+}
+
+// ForEach executes an action on each package of the PackageList.
+func (l PackageList) ForEach(f func(Package) error) error {
+	return l.forEach(func(p unsafe.Pointer) error {
+		return f(Package{(*C.alpm_pkg_t)(p), l.handle})
+	})
+}
+
+// Slice converts the PackageList to a Package Slice.
+func (l PackageList) Slice() []Package {
+	slice := []Package{}
+	l.ForEach(func(p Package) error {
+		slice = append(slice, p)
+		return nil
+	})
+	return slice
+}
+
+// SortBySize returns a PackageList sorted by size.
+func (l PackageList) SortBySize() PackageList {
+	pkgList := (*C.struct___alpm_list_t)(unsafe.Pointer(l.list))
+
+	pkgCache := (*list)(unsafe.Pointer(
+		C.alpm_list_msort(pkgList,
+			C.alpm_list_count(pkgList),
+			C.alpm_list_fn_cmp(C.pkg_cmp))))
+
+	return PackageList{pkgCache, l.handle}
+}
+
+// DependList describes a linkedlist of dependency type packages.
+type DependList struct{ *list }
+
+// ForEach executes an action on each package of the DependList.
+func (l DependList) ForEach(f func(Depend) error) error {
+	return l.forEach(func(p unsafe.Pointer) error {
+		dep := convertDepend((*C.alpm_depend_t)(p))
+		return f(dep)
+	})
+}
+
+// Slice converts the DependList to a Depend Slice.
+func (l DependList) Slice() []Depend {
+	slice := []Depend{}
+	l.ForEach(func(dep Depend) error {
+		slice = append(slice, dep)
+		return nil
+	})
+	return slice
+}
+
+// Architecture returns the package target Architecture.
+func (pkg Package) Architecture() string {
+	return C.GoString(C.alpm_pkg_get_arch(pkg.pmpkg))
+}
+
+// Backup returns a list of package backups.
+func (pkg Package) Backup() BackupList {
+	ptr := unsafe.Pointer(C.alpm_pkg_get_backup(pkg.pmpkg))
+	return BackupList{(*list)(ptr)}
+}
+
+// BuildDate returns the BuildDate of the package.
+func (pkg Package) BuildDate() time.Time {
+	t := C.alpm_pkg_get_builddate(pkg.pmpkg)
+	return time.Unix(int64(t), 0)
+}
+
+// Conflicts returns the conflicts of the package as a DependList.
+func (pkg Package) Conflicts() DependList {
+	ptr := unsafe.Pointer(C.alpm_pkg_get_conflicts(pkg.pmpkg))
+	return DependList{(*list)(ptr)}
+}
+
+// DB returns the package's origin database.
+func (pkg Package) DB() *Db {
+	ptr := C.alpm_pkg_get_db(pkg.pmpkg)
+	if ptr == nil {
+		return nil
+	}
+	return &Db{ptr, pkg.handle}
+}
+
+// Depends returns the package's dependency list.
+func (pkg Package) Depends() DependList {
+	ptr := unsafe.Pointer(C.alpm_pkg_get_depends(pkg.pmpkg))
+	return DependList{(*list)(ptr)}
+}
+
+// Description returns the package's description.
+func (pkg Package) Description() string {
+	return C.GoString(C.alpm_pkg_get_desc(pkg.pmpkg))
+}
+
+// Files returns the file list of the package.
+func (pkg Package) Files() []File {
+	cFiles := C.alpm_pkg_get_files(pkg.pmpkg)
+	return convertFilelist(cFiles)
+}
+
+// Groups returns the groups the package belongs to.
+func (pkg Package) Groups() StringList {
+	ptr := unsafe.Pointer(C.alpm_pkg_get_groups(pkg.pmpkg))
+	return StringList{(*list)(ptr)}
+}
+
+// ISize returns the package installed size.
+func (pkg Package) ISize() int64 {
+	t := C.alpm_pkg_get_isize(pkg.pmpkg)
+	return int64(t)
+}
+
+// InstallDate returns the package install date.
+func (pkg Package) InstallDate() time.Time {
+	t := C.alpm_pkg_get_installdate(pkg.pmpkg)
+	return time.Unix(int64(t), 0)
+}
+
+// Licenses returns the package license list.
+func (pkg Package) Licenses() StringList {
+	ptr := unsafe.Pointer(C.alpm_pkg_get_licenses(pkg.pmpkg))
+	return StringList{(*list)(ptr)}
+}
+
+// SHA256Sum returns package SHA256Sum.
+func (pkg Package) SHA256Sum() string {
+	return C.GoString(C.alpm_pkg_get_sha256sum(pkg.pmpkg))
+}
+
+// MD5Sum returns package MD5Sum.
+func (pkg Package) MD5Sum() string {
+	return C.GoString(C.alpm_pkg_get_md5sum(pkg.pmpkg))
+}
+
+// Name returns package name.
+func (pkg Package) Name() string {
+	return C.GoString(C.alpm_pkg_get_name(pkg.pmpkg))
+}
+
+// Packager returns package packager name.
+func (pkg Package) Packager() string {
+	return C.GoString(C.alpm_pkg_get_packager(pkg.pmpkg))
+}
+
+// Provides returns DependList of packages provides by package.
+func (pkg Package) Provides() DependList {
+	ptr := unsafe.Pointer(C.alpm_pkg_get_provides(pkg.pmpkg))
+	return DependList{(*list)(ptr)}
+}
+
+// Reason returns package install reason.
+func (pkg Package) Reason() PkgReason {
+	reason := C.alpm_pkg_get_reason(pkg.pmpkg)
+	return PkgReason(reason)
+}
+
+// Origin returns package origin.
+func (pkg Package) Origin() PkgFrom {
+	origin := C.alpm_pkg_get_origin(pkg.pmpkg)
+	return PkgFrom(origin)
+}
+
+// Replaces returns a DependList with the packages this package replaces.
+func (pkg Package) Replaces() DependList {
+	ptr := unsafe.Pointer(C.alpm_pkg_get_replaces(pkg.pmpkg))
+	return DependList{(*list)(ptr)}
+}
+
+// Size returns the packed package size.
+func (pkg Package) Size() int64 {
+	t := C.alpm_pkg_get_size(pkg.pmpkg)
+	return int64(t)
+}
+
+// URL returns the upstream URL of the package.
+func (pkg Package) URL() string {
+	return C.GoString(C.alpm_pkg_get_url(pkg.pmpkg))
+}
+
+// Version returns the package version.
+func (pkg Package) Version() string {
+	return C.GoString(C.alpm_pkg_get_version(pkg.pmpkg))
+}
+
+// ComputeRequiredBy returns the names of reverse dependencies of a package
+func (pkg Package) ComputeRequiredBy() []string {
+	result := C.alpm_pkg_compute_requiredby(pkg.pmpkg)
+	requiredby := make([]string, 0)
+	for i := (*list)(unsafe.Pointer(result)); i != nil; i = i.Next {
+		defer C.free(unsafe.Pointer(i))
+		if i.Data != nil {
+			defer C.free(unsafe.Pointer(i.Data))
+			name := C.GoString((*C.char)(unsafe.Pointer(i.Data)))
+			requiredby = append(requiredby, name)
+		}
+	}
+	return requiredby
+}
+
+// NewVersion checks if there is a new version of the package in the Synced DBs.
+func (pkg Package) NewVersion(l DbList) *Package {
+	ptr := C.alpm_sync_newversion(pkg.pmpkg,
+		(*C.alpm_list_t)(unsafe.Pointer(l.list)))
+	if ptr == nil {
+		return nil
+	}
+	return &Package{ptr, l.handle}
+}

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

@@ -0,0 +1,125 @@
+// types.go - libalpm types.
+//
+// Copyright (c) 2013 The go-alpm Authors
+//
+// MIT Licensed. See LICENSE for details.
+
+package alpm
+
+// #cgo CFLAGS: -D_FILE_OFFSET_BITS=64
+// #include <alpm.h>
+import "C"
+
+import (
+	"reflect"
+	"unsafe"
+)
+
+// Description of a dependency.
+type Depend struct {
+	Name    string
+	Version string
+	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)}
+}
+
+func (dep Depend) String() string {
+	return dep.Name + dep.Mod.String() + dep.Version
+}
+
+// Description of package files.
+type File struct {
+	Name string
+	Size int64
+	Mode uint32
+}
+
+func convertFilelist(files *C.alpm_filelist_t) []File {
+	size := int(files.count)
+	items := make([]File, size)
+
+	raw_items := reflect.SliceHeader{
+		Len:  size,
+		Cap:  size,
+		Data: uintptr(unsafe.Pointer(files.files))}
+
+	c_files := *(*[]C.alpm_file_t)(unsafe.Pointer(&raw_items))
+
+	for i := 0; i < size; i++ {
+		items[i] = File{
+			Name: C.GoString(c_files[i].name),
+			Size: int64(c_files[i].size),
+			Mode: uint32(c_files[i].mode)}
+	}
+	return items
+}
+
+// Internal alpm list structure.
+type list struct {
+	Data unsafe.Pointer
+	Prev *list
+	Next *list
+}
+
+// Iterates a function on a list and stop on error.
+func (l *list) forEach(f func(unsafe.Pointer) error) error {
+	for ; l != nil; l = l.Next {
+		err := f(l.Data)
+		if err != nil {
+			return err
+		}
+	}
+	return nil
+}
+
+type StringList struct {
+	*list
+}
+
+func (l StringList) ForEach(f func(string) error) error {
+	return l.forEach(func(p unsafe.Pointer) error {
+		return f(C.GoString((*C.char)(p)))
+	})
+}
+
+func (l StringList) Slice() []string {
+	slice := []string{}
+	l.ForEach(func(s string) error {
+		slice = append(slice, s)
+		return nil
+	})
+	return slice
+}
+
+type BackupFile struct {
+	Name string
+	Hash string
+}
+
+type BackupList struct {
+	*list
+}
+
+func (l BackupList) ForEach(f func(BackupFile) error) error {
+	return l.forEach(func(p unsafe.Pointer) error {
+		bf := (*C.alpm_backup_t)(p)
+		return f(BackupFile{
+			Name: C.GoString(bf.name),
+			Hash: C.GoString(bf.hash),
+		})
+	})
+}
+
+func (l BackupList) Slice() (slice []BackupFile) {
+	l.ForEach(func(f BackupFile) error {
+		slice = append(slice, f)
+		return nil
+	})
+	return
+}

+ 674 - 0
vendor/github.com/mikkeloscar/aur/LICENSE

@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.

+ 23 - 0
vendor/github.com/mikkeloscar/aur/README.md

@@ -0,0 +1,23 @@
+[![GoDoc](https://godoc.org/github.com/mikkeloscar/aur?status.svg)](https://godoc.org/github.com/mikkeloscar/aur)
+
+# go wrapper for the AUR JSON API
+
+Wrapper around the json API v5 for AUR found at
+http://aur.archlinux.org/rpc.php
+
+## LICENSE
+
+Copyright (C) 2016  Mikkel Oscar Lyderik Larsen
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.

+ 104 - 0
vendor/github.com/mikkeloscar/aur/aur.go

@@ -0,0 +1,104 @@
+package aur
+
+import (
+	"encoding/json"
+	"fmt"
+	"net/http"
+	"net/url"
+)
+
+const aurURL = "https://aur.archlinux.org/rpc.php?"
+
+type response struct {
+	Error       string `json:"error"`
+	Version     int    `json:"version"`
+	Type        string `json:"type"`
+	ResultCount int    `json:"resultcount"`
+	Results     []Pkg  `json:"results"`
+}
+
+// Pkg holds package information
+type Pkg struct {
+	ID             int      `json:"ID"`
+	Name           string   `json:"Name"`
+	PackageBaseID  int      `json:"PackageBaseID"`
+	PackageBase    string   `json:"PackageBase"`
+	Version        string   `json:"Version"`
+	Description    string   `json:"Description"`
+	URL            string   `json:"URL"`
+	NumVotes       int      `json:"NumVotes"`
+	Popularity     float64  `json:"Popularity"`
+	OutOfDate      int      `json:"OutOfDate"`
+	Maintainer     string   `json:"Maintainer"`
+	FirstSubmitted int      `json:"FirstSubmitted"`
+	LastModified   int      `json:"LastModified"`
+	URLPath        string   `json:"URLPath"`
+	Depends        []string `json:"Depends"`
+	MakeDepends    []string `json:"MakeDepends"`
+	Conflicts      []string `json:"Conflicts"`
+	Replaces       []string `json:"Replaces"`
+	OptDepends     []string `json:"OptDepends"`
+	License        []string `json:"License"`
+	Keywords       []string `json:"Keywords"`
+}
+
+func get(values url.Values) ([]Pkg, error) {
+	values.Set("v", "5")
+	resp, err := http.Get(aurURL + values.Encode())
+	if err != nil {
+		return nil, err
+	}
+	defer resp.Body.Close()
+
+	dec := json.NewDecoder(resp.Body)
+	result := new(response)
+	err = dec.Decode(result)
+	if err != nil {
+		return nil, err
+	}
+
+	if len(result.Error) > 0 {
+		return nil, fmt.Errorf(result.Error)
+	}
+
+	return result.Results, nil
+}
+
+// Search searches for packages by package name.
+func Search(query string) ([]Pkg, error) {
+	v := url.Values{}
+	v.Set("type", "search")
+	v.Set("arg", query)
+
+	return get(v)
+}
+
+// SearchByNameDesc searches for package by package name and description.
+func SearchByNameDesc(query string) ([]Pkg, error) {
+	v := url.Values{}
+	v.Set("type", "search")
+	v.Set("by", "name-desc")
+	v.Set("arg", query)
+
+	return get(v)
+}
+
+// SearchByMaintainer searches for package by maintainer.
+func SearchByMaintainer(query string) ([]Pkg, error) {
+	v := url.Values{}
+	v.Set("type", "search")
+	v.Set("by", "maintainer")
+	v.Set("arg", query)
+
+	return get(v)
+}
+
+// Info shows info for one or multiple packages.
+func Info(pkgs []string) ([]Pkg, error) {
+	v := url.Values{}
+	v.Set("type", "info")
+	for _, arg := range pkgs {
+		v.Add("arg[]", arg)
+	}
+	return get(v)
+}

+ 674 - 0
vendor/github.com/mikkeloscar/gopkgbuild/LICENSE

@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.

+ 65 - 0
vendor/github.com/mikkeloscar/gopkgbuild/README.md

@@ -0,0 +1,65 @@
+[![GoDoc](https://godoc.org/github.com/mikkeloscar/gopkgbuild?status.svg)](https://godoc.org/github.com/mikkeloscar/gopkgbuild)
+
+# goPKGBUILD
+
+A golang package for parsing [Arch Linux][archlinux] `.SRCINFO` files
+([PKGBUILDs][pkgbuilds]).
+
+## TODO
+
+- [x] Handle split PKGBUILDs like [linux][linux-pkg]
+- [ ] Try to parse maintainer from top of PKGBUILD
+- [x] Handle multiple dependency versions
+- [x] Add support for reading a `.SRCINFO` file directly
+- [x] Update to pacman 4.2
+
+## Usage
+
+[Godoc][godoc]
+
+Example usage
+
+```go
+package main
+
+import (
+    "fmt"
+
+    "github.com/mikkeloscar/gopkgbuild"
+)
+
+func main() {
+    pkgb, err := ParseSRCINFO("/path/to/.SRCINFO")
+    if err != nil {
+        fmt.Println(err)
+    }
+
+    for _, subPkg := range pkgb.Pkgnames {
+       fmt.Printf("Package name: %s", subPkg)
+    }
+}
+```
+
+## LICENSE
+
+Copyright (C) 2016  Mikkel Oscar Lyderik Larsen
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+[archlinux]: http://archlinux.org
+[pkgbuilds]: https://wiki.archlinux.org/index.php/PKGBUILD
+[linux-pkg]: https://projects.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/linux
+[pkg-introspec]: https://www.archlinux.org/packages/community/any/pkgbuild-introspection/
+[godoc]: https://godoc.org/github.com/mikkeloscar/gopkgbuild

+ 279 - 0
vendor/github.com/mikkeloscar/gopkgbuild/lex.go

@@ -0,0 +1,279 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// based on the lexer from: src/pkg/text/template/parse/lex.go (golang source)
+
+package pkgbuild
+
+import (
+	"fmt"
+	"strings"
+	"unicode"
+	"unicode/utf8"
+)
+
+// pos is a position in input being scanned
+type pos int
+
+type item struct {
+	typ itemType
+	pos pos
+	val string
+}
+
+func (i item) String() string {
+	switch {
+	case i.typ == itemEOF:
+		return "EOF"
+	case i.typ == itemError:
+		return i.val
+	case len(i.val) > 10:
+		return fmt.Sprintf("%.10q...", i.val)
+	}
+	return fmt.Sprintf("%q", i.val)
+}
+
+type itemType int
+
+const (
+	itemError itemType = iota
+	itemEOF
+	itemVariable
+	itemValue
+	itemEndSplit
+	// PKGBUILD variables
+	itemPkgname      // pkgname variable
+	itemPkgver       // pkgver variable
+	itemPkgrel       // pkgrel variable
+	itemPkgdir       // pkgdir variable
+	itemEpoch        // epoch variable
+	itemPkgbase      // pkgbase variable
+	itemPkgdesc      // pkgdesc variable
+	itemArch         // arch variable
+	itemURL          // url variable
+	itemLicense      // license variable
+	itemGroups       // groups variable
+	itemDepends      // depends variable
+	itemOptdepends   // optdepends variable
+	itemMakedepends  // makedepends variable
+	itemCheckdepends // checkdepends variable
+	itemProvides     // provides variable
+	itemConflicts    // conflicts variable
+	itemReplaces     // replaces variable
+	itemBackup       // backup variable
+	itemOptions      // options variable
+	itemInstall      // install variable
+	itemChangelog    // changelog variable
+	itemSource       // source variable
+	itemNoextract    // noextract variable
+	itemMd5sums      // md5sums variable
+	itemSha1sums     // sha1sums variable
+	itemSha224sums   // sha224sums variable
+	itemSha256sums   // sha256sums variable
+	itemSha384sums   // sha384sums variable
+	itemSha512sums   // sha512sums variable
+	itemValidpgpkeys // validpgpkeys variable
+)
+
+// PKGBUILD variables
+var variables = map[string]itemType{
+	"pkgname":      itemPkgname,
+	"pkgver":       itemPkgver,
+	"pkgrel":       itemPkgrel,
+	"pkgdir":       itemPkgdir,
+	"epoch":        itemEpoch,
+	"pkgbase":      itemPkgbase,
+	"pkgdesc":      itemPkgdesc,
+	"arch":         itemArch,
+	"url":          itemURL,
+	"license":      itemLicense,
+	"groups":       itemGroups,
+	"depends":      itemDepends,
+	"optdepends":   itemOptdepends,
+	"makedepends":  itemMakedepends,
+	"checkdepends": itemCheckdepends,
+	"provides":     itemProvides,
+	"conflicts":    itemConflicts,
+	"replaces":     itemReplaces,
+	"backup":       itemBackup,
+	"options":      itemOptions,
+	"install":      itemInstall,
+	"changelog":    itemChangelog,
+	"source":       itemSource,
+	"noextract":    itemNoextract,
+	"md5sums":      itemMd5sums,
+	"sha1sums":     itemSha1sums,
+	"sha224sums":   itemSha224sums,
+	"sha256sums":   itemSha256sums,
+	"sha384sums":   itemSha384sums,
+	"sha512sums":   itemSha512sums,
+	"validpgpkeys": itemValidpgpkeys,
+}
+
+const eof = -1
+
+// stateFn represents the state of the scanner as a function that returns the next state
+type stateFn func(*lexer) stateFn
+
+// lexer holds the state of the scanner
+type lexer struct {
+	input   string
+	state   stateFn
+	pos     pos
+	start   pos
+	width   pos
+	lastPos pos
+	items   chan item // channel of scanned items
+}
+
+// next returns the next rune in the input
+func (l *lexer) next() rune {
+	if int(l.pos) >= len(l.input) {
+		l.width = 0
+		return eof
+	}
+	r, w := utf8.DecodeRuneInString(l.input[l.pos:])
+	l.width = pos(w)
+	l.pos += l.width
+	return r
+}
+
+// peek returns but does not consume the next rune in the input
+func (l *lexer) peek() rune {
+	r := l.next()
+	l.backup()
+	return r
+}
+
+// backup steps back one rune. Can only be called once per call of next
+func (l *lexer) backup() {
+	l.pos -= l.width
+}
+
+// emit passes an item back to the client
+func (l *lexer) emit(t itemType) {
+	l.items <- item{t, l.start, l.input[l.start:l.pos]}
+	l.start = l.pos
+}
+
+// ignore skips over the pending input before this point
+func (l *lexer) ignore() {
+	l.start = l.pos
+}
+
+// errorf returns an error token and terminates the scan by passing
+// back a nil pointer that will be the next state, terminating l.nextItem.
+func (l *lexer) errorf(format string, args ...interface{}) stateFn {
+	l.items <- item{itemError, l.start, fmt.Sprintf(format, args...)}
+	return nil
+}
+
+// nextItem returns the next item from the input.
+func (l *lexer) nextItem() item {
+	item := <-l.items
+	l.lastPos = item.pos
+	return item
+}
+
+func lex(input string) *lexer {
+	l := &lexer{
+		input: input,
+		items: make(chan item),
+	}
+	go l.run()
+	return l
+}
+
+func (l *lexer) run() {
+	for l.state = lexEnv; l.state != nil; {
+		l.state = l.state(l)
+	}
+}
+
+func lexEnv(l *lexer) stateFn {
+	var r rune
+	for {
+		switch r = l.next(); {
+		case r == eof:
+			l.emit(itemEOF)
+			return nil
+		case isAlphaNumericUnderscore(r):
+			return lexVariable
+		case r == '\n':
+			if l.input[l.start:l.pos] == "\n\n" {
+				l.ignore()
+				l.emit(itemEndSplit)
+			}
+		case r == '\t':
+			l.ignore()
+		case r == '#':
+			return lexComment
+		default:
+			l.errorf("unable to parse character: %c", r)
+		}
+	}
+}
+
+func lexComment(l *lexer) stateFn {
+	for {
+		switch l.next() {
+		case '\n':
+			l.ignore()
+			return lexEnv
+		case eof:
+			l.emit(itemEOF)
+			return nil
+		}
+	}
+}
+
+func lexVariable(l *lexer) stateFn {
+	for {
+		switch r := l.next(); {
+		case isAlphaNumericUnderscore(r):
+			// absorb
+		case r == ' ' && l.peek() == '=':
+			l.backup()
+			variable := l.input[l.start:l.pos]
+
+			// strip arch from source_arch like constructs
+			witharch := strings.SplitN(variable, "_", 2)
+			if len(witharch) == 2 {
+				if _, ok := archs[witharch[1]]; ok {
+					variable = witharch[0]
+				}
+			}
+
+			if _, ok := variables[variable]; ok {
+				l.emit(variables[variable])
+				// TODO to cut off ' = '
+				l.next()
+				l.next()
+				l.next()
+				l.ignore()
+				return lexValue
+			}
+			return l.errorf("invalid variable: %s", variable)
+		default:
+			pattern := l.input[l.start:l.pos]
+			return l.errorf("invalid pattern: %s", pattern)
+		}
+	}
+}
+
+func lexValue(l *lexer) stateFn {
+	for {
+		switch l.next() {
+		case '\n':
+			l.backup()
+			l.emit(itemValue)
+			return lexEnv
+		}
+	}
+}
+
+// isAlphaNumericUnderscore reports whether r is an alphabetic, digit, or underscore.
+func isAlphaNumericUnderscore(r rune) bool {
+	return r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r)
+}

+ 530 - 0
vendor/github.com/mikkeloscar/gopkgbuild/pkgbuild.go

@@ -0,0 +1,530 @@
+package pkgbuild
+
+import (
+	"bytes"
+	"fmt"
+	"io/ioutil"
+	"strconv"
+	"strings"
+)
+
+// Arch is a system architecture
+type Arch uint8
+
+const (
+	// Any architecture
+	Any Arch = iota
+	// I686 architecture
+	I686
+	// X8664 x86_64 (64bit) architecture
+	X8664
+	// ARMv5 architecture (archlinux-arm)
+	ARMv5
+	// ARMv6h architecture (archlinux-arm)
+	ARMv6h
+	// ARMv7h architecture (archlinux-arm)
+	ARMv7h
+	// ARMv8 architecture (64bit) (archlinux-arm)
+	ARMv8
+	// MIPS64 architecture
+	MIPS64
+)
+
+var archs = map[string]Arch{
+	"any":      Any,
+	"i686":     I686,
+	"x86":      I686,
+	"x86_64":   X8664,
+	"aarch64":  ARMv8,
+	"arm":      ARMv5,
+	"armv5":    ARMv5,
+	"armv6h":   ARMv6h,
+	"armv7h":   ARMv7h,
+	"mips64el": MIPS64,
+}
+
+// Dependency describes a dependency with min and max version, if any.
+type Dependency struct {
+	Name   string           // dependency name
+	MinVer *CompleteVersion // min version
+	sgt    bool             // defines if min version is strictly greater than
+	MaxVer *CompleteVersion // max version
+	slt    bool             // defines if max version is strictly less than
+}
+
+// PKGBUILD is a struct describing a parsed PKGBUILD file.
+// Required fields are:
+//	pkgname
+//	pkgver
+//	pkgrel
+//	arch
+//	(license) - not required but recommended
+//
+// parsing a PKGBUILD file without these fields will fail
+type PKGBUILD struct {
+	Pkgnames     []string
+	Pkgver       Version // required
+	Pkgrel       int     // required
+	Pkgdir       string
+	Epoch        int
+	Pkgbase      string
+	Pkgdesc      string
+	Arch         []Arch // required
+	URL          string
+	License      []string // recommended
+	Groups       []string
+	Depends      []*Dependency
+	Optdepends   []string
+	Makedepends  []*Dependency
+	Checkdepends []*Dependency
+	Provides     []string
+	Conflicts    []string
+	Replaces     []string
+	Backup       []string
+	Options      []string
+	Install      string
+	Changelog    string
+	Source       []string
+	Noextract    []string
+	Md5sums      []string
+	Sha1sums     []string
+	Sha224sums   []string
+	Sha256sums   []string
+	Sha384sums   []string
+	Sha512sums   []string
+	Validpgpkeys []string
+}
+
+// Newer is true if p has a higher version number than p2
+func (p *PKGBUILD) Newer(p2 *PKGBUILD) bool {
+	if p.Epoch < p2.Epoch {
+		return false
+	}
+
+	if p.Pkgver.bigger(p2.Pkgver) {
+		return true
+	}
+
+	if p2.Pkgver.bigger(p.Pkgver) {
+		return false
+	}
+
+	return p.Pkgrel > p2.Pkgrel
+}
+
+// Older is true if p has a smaller version number than p2
+func (p *PKGBUILD) Older(p2 *PKGBUILD) bool {
+	if p.Epoch < p2.Epoch {
+		return true
+	}
+
+	if p2.Pkgver.bigger(p.Pkgver) {
+		return true
+	}
+
+	if p.Pkgver.bigger(p2.Pkgver) {
+		return false
+	}
+
+	return p.Pkgrel < p2.Pkgrel
+}
+
+// Version returns the full version of the PKGBUILD (including epoch and rel)
+func (p *PKGBUILD) Version() string {
+	if p.Epoch > 0 {
+		return fmt.Sprintf("%d:%s-%d", p.Epoch, p.Pkgver, p.Pkgrel)
+	}
+
+	return fmt.Sprintf("%s-%d", p.Pkgver, p.Pkgrel)
+}
+
+// CompleteVersion returns a Complete version struct including version, rel and
+// epoch.
+func (p *PKGBUILD) CompleteVersion() CompleteVersion {
+	return CompleteVersion{
+		Version: p.Pkgver,
+		Epoch:   uint8(p.Epoch),
+		Pkgrel:  uint8(p.Pkgrel),
+	}
+}
+
+// BuildDepends is Depends, MakeDepends and CheckDepends combined.
+func (p *PKGBUILD) BuildDepends() []*Dependency {
+	// TODO real merge
+	deps := make([]*Dependency, len(p.Depends)+len(p.Makedepends)+len(p.Checkdepends))
+
+	deps = append(p.Depends, p.Makedepends...)
+	deps = append(deps, p.Checkdepends...)
+
+	return deps
+}
+
+// IsDevel returns true if package contains devel packages (-{bzr,git,svn,hg})
+// TODO: more robust check.
+func (p *PKGBUILD) IsDevel() bool {
+	for _, name := range p.Pkgnames {
+		if strings.HasSuffix(name, "-git") {
+			return true
+		}
+
+		if strings.HasSuffix(name, "-svn") {
+			return true
+		}
+
+		if strings.HasSuffix(name, "-hg") {
+			return true
+		}
+
+		if strings.HasSuffix(name, "-bzr") {
+			return true
+		}
+	}
+
+	return false
+}
+
+// MustParseSRCINFO must parse the .SRCINFO given by path or it will panic
+func MustParseSRCINFO(path string) *PKGBUILD {
+	pkgbuild, err := ParseSRCINFO(path)
+	if err != nil {
+		panic(err)
+	}
+	return pkgbuild
+}
+
+// ParseSRCINFO parses .SRCINFO file given by path.
+// This is a safe alternative to ParsePKGBUILD given that a .SRCINFO file is
+// available
+func ParseSRCINFO(path string) (*PKGBUILD, error) {
+	f, err := ioutil.ReadFile(path)
+	if err != nil {
+		return nil, fmt.Errorf("unable to read file: %s, %s", path, err.Error())
+	}
+
+	return parsePKGBUILD(string(f))
+}
+
+// parse a PKGBUILD and check that the required fields has a non-empty value
+func parsePKGBUILD(input string) (*PKGBUILD, error) {
+	pkgb, err := parse(input)
+	if err != nil {
+		return nil, err
+	}
+
+	if !validPkgver(string(pkgb.Pkgver)) {
+		return nil, fmt.Errorf("invalid pkgver: %s", pkgb.Pkgver)
+	}
+
+	if len(pkgb.Arch) == 0 {
+		return nil, fmt.Errorf("Arch missing")
+	}
+
+	if len(pkgb.Pkgnames) == 0 {
+		return nil, fmt.Errorf("missing pkgname")
+	}
+
+	for _, name := range pkgb.Pkgnames {
+		if !validPkgname(name) {
+			return nil, fmt.Errorf("invalid pkgname: %s", name)
+		}
+	}
+
+	return pkgb, nil
+}
+
+// parses a SRCINFO formatted PKGBUILD
+func parse(input string) (*PKGBUILD, error) {
+	var pkgbuild *PKGBUILD
+	var next item
+
+	lexer := lex(input)
+Loop:
+	for {
+		token := lexer.nextItem()
+		switch token.typ {
+		case itemPkgbase:
+			next = lexer.nextItem()
+			pkgbuild = &PKGBUILD{Epoch: 0, Pkgbase: next.val}
+		case itemPkgname:
+			next = lexer.nextItem()
+			pkgbuild.Pkgnames = append(pkgbuild.Pkgnames, next.val)
+		case itemPkgver:
+			next = lexer.nextItem()
+			version, err := parseVersion(next.val)
+			if err != nil {
+				return nil, err
+			}
+			pkgbuild.Pkgver = version
+		case itemPkgrel:
+			next = lexer.nextItem()
+			rel, err := strconv.ParseInt(next.val, 10, 0)
+			if err != nil {
+				return nil, err
+			}
+			pkgbuild.Pkgrel = int(rel)
+		case itemPkgdir:
+			next = lexer.nextItem()
+			pkgbuild.Pkgdir = next.val
+		case itemEpoch:
+			next = lexer.nextItem()
+			epoch, err := strconv.ParseInt(next.val, 10, 0)
+			if err != nil {
+				return nil, err
+			}
+
+			if epoch < 0 {
+				return nil, fmt.Errorf("invalid epoch: %d", epoch)
+			}
+			pkgbuild.Epoch = int(epoch)
+		case itemPkgdesc:
+			next = lexer.nextItem()
+			pkgbuild.Pkgdesc = next.val
+		case itemArch:
+			next = lexer.nextItem()
+			if arch, ok := archs[next.val]; ok {
+				pkgbuild.Arch = append(pkgbuild.Arch, arch)
+			} else {
+				return nil, fmt.Errorf("invalid Arch: %s", next.val)
+			}
+		case itemURL:
+			next = lexer.nextItem()
+			pkgbuild.URL = next.val
+		case itemLicense:
+			next = lexer.nextItem()
+			pkgbuild.License = append(pkgbuild.License, next.val)
+		case itemGroups:
+			next = lexer.nextItem()
+			pkgbuild.Groups = append(pkgbuild.Groups, next.val)
+		case itemDepends:
+			next = lexer.nextItem()
+			deps, err := parseDependency(next.val, pkgbuild.Depends)
+			if err != nil {
+				return nil, err
+			}
+			pkgbuild.Depends = deps
+		case itemOptdepends:
+			next = lexer.nextItem()
+			pkgbuild.Optdepends = append(pkgbuild.Optdepends, next.val)
+		case itemMakedepends:
+			next = lexer.nextItem()
+			deps, err := parseDependency(next.val, pkgbuild.Makedepends)
+			if err != nil {
+				return nil, err
+			}
+			pkgbuild.Makedepends = deps
+		case itemCheckdepends:
+			next = lexer.nextItem()
+			deps, err := parseDependency(next.val, pkgbuild.Checkdepends)
+			if err != nil {
+				return nil, err
+			}
+			pkgbuild.Checkdepends = deps
+		case itemProvides:
+			next = lexer.nextItem()
+			pkgbuild.Provides = append(pkgbuild.Provides, next.val)
+		case itemConflicts:
+			next = lexer.nextItem()
+			pkgbuild.Conflicts = append(pkgbuild.Conflicts, next.val)
+		case itemReplaces:
+			next = lexer.nextItem()
+			pkgbuild.Replaces = append(pkgbuild.Replaces, next.val)
+		case itemBackup:
+			next = lexer.nextItem()
+			pkgbuild.Backup = append(pkgbuild.Backup, next.val)
+		case itemOptions:
+			next = lexer.nextItem()
+			pkgbuild.Options = append(pkgbuild.Options, next.val)
+		case itemInstall:
+			next = lexer.nextItem()
+			pkgbuild.Install = next.val
+		case itemChangelog:
+			next = lexer.nextItem()
+			pkgbuild.Changelog = next.val
+		case itemSource:
+			next = lexer.nextItem()
+			pkgbuild.Source = append(pkgbuild.Source, next.val)
+		case itemNoextract:
+			next = lexer.nextItem()
+			pkgbuild.Noextract = append(pkgbuild.Noextract, next.val)
+		case itemMd5sums:
+			next = lexer.nextItem()
+			pkgbuild.Md5sums = append(pkgbuild.Md5sums, next.val)
+		case itemSha1sums:
+			next = lexer.nextItem()
+			pkgbuild.Sha1sums = append(pkgbuild.Sha1sums, next.val)
+		case itemSha224sums:
+			next = lexer.nextItem()
+			pkgbuild.Sha224sums = append(pkgbuild.Sha224sums, next.val)
+		case itemSha256sums:
+			next = lexer.nextItem()
+			pkgbuild.Sha256sums = append(pkgbuild.Sha256sums, next.val)
+		case itemSha384sums:
+			next = lexer.nextItem()
+			pkgbuild.Sha384sums = append(pkgbuild.Sha384sums, next.val)
+		case itemSha512sums:
+			next = lexer.nextItem()
+			pkgbuild.Sha512sums = append(pkgbuild.Sha512sums, next.val)
+		case itemValidpgpkeys:
+			next = lexer.nextItem()
+			pkgbuild.Validpgpkeys = append(pkgbuild.Validpgpkeys, next.val)
+		case itemEndSplit:
+		case itemError:
+			return nil, fmt.Errorf(token.val)
+		case itemEOF:
+			break Loop
+		default:
+			return nil, fmt.Errorf(token.val)
+		}
+	}
+	return pkgbuild, nil
+}
+
+// parse and validate a version string
+func parseVersion(s string) (Version, error) {
+	if validPkgver(s) {
+		return Version(s), nil
+	}
+
+	return "", fmt.Errorf("invalid version string: %s", s)
+}
+
+// check if name is a valid pkgname format
+func validPkgname(name string) bool {
+	if len(name) < 1 {
+		return false
+	}
+
+	if name[0] == '-' {
+		return false
+	}
+
+	for _, r := range name {
+		if !isValidPkgnameChar(uint8(r)) {
+			return false
+		}
+	}
+
+	return true
+}
+
+// check if version is a valid pkgver format
+func validPkgver(version string) bool {
+	if len(version) < 1 {
+		return false
+	}
+
+	if !isAlphaNumeric(version[0]) {
+		return false
+	}
+
+	for _, r := range version[1:] {
+		if !isValidPkgverChar(uint8(r)) {
+			return false
+		}
+	}
+
+	return true
+}
+
+// ParseDeps parses a string slice of dependencies into a slice of Dependency
+// objects.
+func ParseDeps(deps []string) ([]*Dependency, error) {
+	var err error
+	dependencies := make([]*Dependency, 0)
+
+	for _, dep := range deps {
+		dependencies, err = parseDependency(dep, dependencies)
+		if err != nil {
+			return nil, err
+		}
+	}
+
+	return dependencies, nil
+}
+
+// parse dependency with possible version restriction
+func parseDependency(dep string, deps []*Dependency) ([]*Dependency, error) {
+	var name string
+	var dependency *Dependency
+
+	if dep[0] == '-' {
+		return nil, fmt.Errorf("invalid dependency name")
+	}
+
+	i := 0
+	for _, c := range dep {
+		if !isValidPkgnameChar(uint8(c)) {
+			break
+		}
+		i++
+	}
+
+	// check if the dependency has been set before
+	name = dep[0:i]
+	for _, d := range deps {
+		if d.Name == name {
+			dependency = d
+		}
+	}
+
+	if dependency == nil {
+		dependency = &Dependency{
+			Name: name,
+			sgt:  false,
+			slt:  false,
+		}
+		deps = append(deps, dependency)
+	}
+
+	if len(dep) == len(name) {
+		return deps, nil
+	}
+
+	var eq bytes.Buffer
+	for _, c := range dep[i:] {
+		if c == '<' || c == '>' || c == '=' {
+			i++
+			eq.WriteRune(c)
+			continue
+		}
+		break
+	}
+
+	version, err := NewCompleteVersion(dep[i:])
+	if err != nil {
+		return nil, err
+	}
+
+	switch eq.String() {
+	case "==":
+		dependency.MinVer = version
+		dependency.MaxVer = version
+	case "<=":
+		dependency.MaxVer = version
+	case ">=":
+		dependency.MinVer = version
+	case "<":
+		dependency.MaxVer = version
+		dependency.slt = true
+	case ">":
+		dependency.MinVer = version
+		dependency.sgt = true
+	}
+
+	return deps, nil
+}
+
+// isLowerAlpha reports whether c is a lowercase alpha character
+func isLowerAlpha(c uint8) bool {
+	return 'a' <= c && c <= 'z'
+}
+
+// check if c is a valid pkgname char
+func isValidPkgnameChar(c uint8) bool {
+	return isLowerAlpha(c) || isDigit(c) || c == '@' || c == '.' || c == '_' || c == '+' || c == '-'
+}
+
+// check if c is a valid pkgver char
+func isValidPkgverChar(c uint8) bool {
+	return isAlphaNumeric(c) || c == '_' || c == '+' || c == '.'
+}

+ 289 - 0
vendor/github.com/mikkeloscar/gopkgbuild/version.go

@@ -0,0 +1,289 @@
+package pkgbuild
+
+import (
+	"fmt"
+	"strconv"
+	"strings"
+)
+
+// Version string
+type Version string
+
+type CompleteVersion struct {
+	Version Version
+	Epoch   uint8
+	Pkgrel  uint8
+}
+
+func (c *CompleteVersion) String() string {
+	return fmt.Sprintf("%d-%s-%d", c.Epoch, c.Version, c.Pkgrel)
+}
+
+// NewCompleteVersion creates a CompleteVersion including basic version, epoch
+// and rel from string
+func NewCompleteVersion(s string) (*CompleteVersion, error) {
+	var err error
+	epoch := 0
+	rel := 0
+
+	// handle possible epoch
+	versions := strings.Split(s, ":")
+	if len(versions) > 2 {
+		return nil, fmt.Errorf("invalid version format: %s", s)
+	}
+
+	if len(versions) > 1 {
+		epoch, err = strconv.Atoi(versions[0])
+		if err != nil {
+			return nil, err
+		}
+	}
+
+	// handle possible rel
+	versions = strings.Split(versions[len(versions)-1], "-")
+	if len(versions) > 2 {
+		return nil, fmt.Errorf("invalid version format: %s", s)
+	}
+
+	if len(versions) > 1 {
+		rel, err = strconv.Atoi(versions[1])
+		if err != nil {
+			return nil, err
+		}
+	}
+
+	// finally check that the actual version is valid
+	if validPkgver(versions[0]) {
+		return &CompleteVersion{
+			Version: Version(versions[0]),
+			Epoch:   uint8(epoch),
+			Pkgrel:  uint8(rel),
+		}, nil
+	}
+
+	return nil, fmt.Errorf("invalid version format: %s", s)
+}
+
+// Older returns true if a is older than the argument version string
+func (a *CompleteVersion) Older(v string) bool {
+	b, err := NewCompleteVersion(v)
+	if err != nil {
+		return false
+	}
+
+	return a.cmp(b) == -1
+}
+
+// Newer returns true if a is newer than the argument version string
+func (a *CompleteVersion) Newer(v string) bool {
+	b, err := NewCompleteVersion(v)
+	if err != nil {
+		return false
+	}
+
+	return a.cmp(b) == 1
+}
+
+// Equal returns true if a is equal to the argument version string
+func (a *CompleteVersion) Equal(v string) bool {
+	b, err := NewCompleteVersion(v)
+	if err != nil {
+		return false
+	}
+
+	return a.cmp(b) == 0
+}
+
+// Compare a to b:
+// return 1: a is newer than b
+//        0: a and b are the same version
+//       -1: b is newer than a
+func (a *CompleteVersion) cmp(b *CompleteVersion) int8 {
+	if a.Epoch > b.Epoch {
+		return 1
+	}
+
+	if a.Epoch < b.Epoch {
+		return -1
+	}
+
+	if a.Version.bigger(b.Version) {
+		return 1
+	}
+
+	if b.Version.bigger(a.Version) {
+		return -1
+	}
+
+	if a.Pkgrel > b.Pkgrel {
+		return 1
+	}
+
+	if a.Pkgrel < b.Pkgrel {
+		return -1
+	}
+
+	return 0
+}
+
+// Compare alpha and numeric segments of two versions.
+// return 1: a is newer than b
+//        0: a and b are the same version
+//       -1: b is newer than a
+//
+// This is based on the rpmvercmp function used in libalpm
+// https://projects.archlinux.org/pacman.git/tree/lib/libalpm/version.c
+func rpmvercmp(a, b Version) int {
+	if a == b {
+		return 0
+	}
+
+	var one, two, ptr1, ptr2 int
+	var isNum bool
+	one, two, ptr1, ptr2 = 0, 0, 0, 0
+
+	// loop through each version segment of a and b and compare them
+	for len(a) > one && len(b) > two {
+		for len(a) > one && !isAlphaNumeric(a[one]) {
+			one++
+		}
+		for len(b) > two && !isAlphaNumeric(b[two]) {
+			two++
+		}
+
+		// if we ran to the end of either, we are finished with the loop
+		if !(len(a) > one && len(b) > two) {
+			break
+		}
+
+		// if the seperator lengths were different, we are also finished
+		if one-ptr1 != two-ptr2 {
+			if one-ptr1 < two-ptr2 {
+				return -1
+			}
+			return 1
+		}
+
+		ptr1 = one
+		ptr2 = two
+
+		// grab first completely alpha or completely numeric segment
+		// leave one and two pointing to the start of the alpha or numeric
+		// segment and walk ptr1 and ptr2 to end of segment
+		if isDigit(a[ptr1]) {
+			for len(a) > ptr1 && isDigit(a[ptr1]) {
+				ptr1++
+			}
+			for len(b) > ptr2 && isDigit(b[ptr2]) {
+				ptr2++
+			}
+			isNum = true
+		} else {
+			for len(a) > ptr1 && isAlpha(a[ptr1]) {
+				ptr1++
+			}
+			for len(b) > ptr2 && isAlpha(b[ptr2]) {
+				ptr2++
+			}
+			isNum = false
+		}
+
+		// take care of the case where the two version segments are
+		// different types: one numeric, the other alpha (i.e. empty)
+		// numeric segments are always newer than alpha segments
+		if two == ptr2 {
+			if isNum {
+				return 1
+			}
+			return -1
+		}
+
+		if isNum {
+			// we know this part of the strings only contains digits
+			// so we can ignore the error value since it should
+			// always be nil
+			as, _ := strconv.ParseInt(string(a[one:ptr1]), 10, 0)
+			bs, _ := strconv.ParseInt(string(b[two:ptr2]), 10, 0)
+
+			// whichever number has more digits wins
+			if as > bs {
+				return 1
+			}
+			if as < bs {
+				return -1
+			}
+		} else {
+			cmp := alphaCompare(a[one:ptr1], b[two:ptr2])
+			if cmp < 0 {
+				return -1
+			}
+			if cmp > 0 {
+				return 1
+			}
+		}
+
+		// advance one and two to next segment
+		one = ptr1
+		two = ptr2
+	}
+
+	// this catches the case where all numeric and alpha segments have
+	// compared identically but the segment separating characters were
+	// different
+	if len(a) <= one && len(b) <= two {
+		return 0
+	}
+
+	// the final showdown. we never want a remaining alpha string to
+	// beat an empty string. the logic is a bit weird, but:
+	// - if one is empty and two is not an alpha, two is newer.
+	// - if one is an alpha, two is newer.
+	// - otherwise one is newer.
+	if (len(a) <= one && !isAlpha(b[two])) || len(a) > one && isAlpha(a[one]) {
+		return -1
+	}
+	return 1
+}
+
+// alphaCompare compares two alpha version segments and will return a positive
+// value if a is bigger than b and a negative if b is bigger than a else 0
+func alphaCompare(a, b Version) int8 {
+	if a == b {
+		return 0
+	}
+
+	i := 0
+	for len(a) > i && len(b) > i && a[i] == b[i] {
+		i++
+	}
+
+	if len(a) == i && len(b) > i {
+		return -1
+	}
+
+	if len(b) == i {
+		return 1
+	}
+
+	return int8(a[i]) - int8(b[i])
+}
+
+// check if version number v is bigger than v2
+func (v Version) bigger(v2 Version) bool {
+	return rpmvercmp(v, v2) == 1
+}
+
+// isAlphaNumeric reports whether c is an alpha character or digit
+func isAlphaNumeric(c uint8) bool {
+	return isDigit(c) || isAlpha(c)
+}
+
+// isAlpha reports whether c is an alpha character
+func isAlpha(c uint8) bool {
+	return 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z'
+}
+
+// isDigit reports whether d is an ASCII digit
+func isDigit(d uint8) bool {
+	return '0' <= d && d <= '9'
+}

+ 25 - 0
vendor/vendor.json

@@ -0,0 +1,25 @@
+{
+	"comment": "",
+	"ignore": "test",
+	"package": [
+		{
+			"checksumSHA1": "sT9KemwEQt8FOjq/C5no9gpdFgU=",
+			"path": "github.com/jguer/go-alpm",
+			"revision": "f82ad11b38f675991ef2425dbeff03ef346bc113",
+			"revisionTime": "2017-05-07T12:31:44Z"
+		},
+		{
+			"checksumSHA1": "FNyfHWps1OdA3izWdVkxmPtMf1A=",
+			"path": "github.com/mikkeloscar/aur",
+			"revision": "dc2f99767ec5d809269bd3bac3878f6e949f8e64",
+			"revisionTime": "2017-05-02T13:48:13Z"
+		},
+		{
+			"checksumSHA1": "2MqUneYW520vQevWV6MITvYjdf4=",
+			"path": "github.com/mikkeloscar/gopkgbuild",
+			"revision": "46d010163d87513b0f05fb67400475348bd50cc9",
+			"revisionTime": "2017-05-09T09:30:41Z"
+		}
+	],
+	"rootPath": "github.com/jguer/yay"
+}

+ 1 - 1
yay.go

@@ -143,7 +143,7 @@ func main() {
 	case "-S":
 		err = install(pkgs, options)
 	case "-Syu", "-Suy":
-		err = upgrade(options)
+		err = upgradePkgs(options)
 	case "-Si":
 		err = syncInfo(pkgs, options)
 	case "yogurt":