resources: Fix golint issues
Including a trick to get the golinter to allow our compact code!
This commit is contained in:
@@ -85,7 +85,7 @@ type cuid struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewConverger builds a new converger struct.
|
// NewConverger builds a new converger struct.
|
||||||
func NewConverger(timeout int, stateFn func(bool) error) *converger {
|
func NewConverger(timeout int, stateFn func(bool) error) Converger {
|
||||||
return &converger{
|
return &converger{
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
stateFn: stateFn,
|
stateFn: stateFn,
|
||||||
|
|||||||
@@ -529,8 +529,9 @@ func (obj *EmbdEtcd) CtxError(ctx context.Context, err error) (context.Context,
|
|||||||
if obj.ctxErr != nil { // stop on permanent error
|
if obj.ctxErr != nil { // stop on permanent error
|
||||||
return ctx, obj.ctxErr
|
return ctx, obj.ctxErr
|
||||||
}
|
}
|
||||||
const ctxErr = "ctxErr"
|
type ctxKey string // use a non-basic type as ctx key (str can conflict)
|
||||||
const ctxIter = "ctxIter"
|
const ctxErr ctxKey = "ctxErr"
|
||||||
|
const ctxIter ctxKey = "ctxIter"
|
||||||
expBackoff := func(tmin, texp, iter, tmax int) time.Duration {
|
expBackoff := func(tmin, texp, iter, tmax int) time.Duration {
|
||||||
// https://en.wikipedia.org/wiki/Exponential_backoff
|
// https://en.wikipedia.org/wiki/Exponential_backoff
|
||||||
// tmin <= texp^iter - 1 <= tmax // TODO: check my math
|
// tmin <= texp^iter - 1 <= tmax // TODO: check my math
|
||||||
|
|||||||
@@ -692,7 +692,7 @@ type Remotes struct {
|
|||||||
fileWatch chan string
|
fileWatch chan string
|
||||||
cConns uint16 // number of concurrent ssh connections, zero means unlimited
|
cConns uint16 // number of concurrent ssh connections, zero means unlimited
|
||||||
interactive bool // allow interactive prompting
|
interactive bool // allow interactive prompting
|
||||||
sshPrivIdRsa string // path to ~/.ssh/id_rsa
|
sshPrivIDRsa string // path to ~/.ssh/id_rsa
|
||||||
caching bool // whether to try and cache the copy of the binary
|
caching bool // whether to try and cache the copy of the binary
|
||||||
depth uint16 // depth of this node in the remote execution hierarchy
|
depth uint16 // depth of this node in the remote execution hierarchy
|
||||||
prefix string // folder prefix to use for misc storage
|
prefix string // folder prefix to use for misc storage
|
||||||
@@ -715,7 +715,7 @@ type Remotes struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewRemotes builds a Remotes struct.
|
// NewRemotes builds a Remotes struct.
|
||||||
func NewRemotes(clientURLs, remoteURLs []string, noop bool, remotes []string, fileWatch chan string, cConns uint16, interactive bool, sshPrivIdRsa string, caching bool, depth uint16, prefix string, converger cv.Converger, convergerCb func(func(map[string]bool) error) (func(), error), flags Flags) *Remotes {
|
func NewRemotes(clientURLs, remoteURLs []string, noop bool, remotes []string, fileWatch chan string, cConns uint16, interactive bool, sshPrivIDRsa string, caching bool, depth uint16, prefix string, converger cv.Converger, convergerCb func(func(map[string]bool) error) (func(), error), flags Flags) *Remotes {
|
||||||
return &Remotes{
|
return &Remotes{
|
||||||
clientURLs: clientURLs,
|
clientURLs: clientURLs,
|
||||||
remoteURLs: remoteURLs,
|
remoteURLs: remoteURLs,
|
||||||
@@ -724,7 +724,7 @@ func NewRemotes(clientURLs, remoteURLs []string, noop bool, remotes []string, fi
|
|||||||
fileWatch: fileWatch,
|
fileWatch: fileWatch,
|
||||||
cConns: cConns,
|
cConns: cConns,
|
||||||
interactive: interactive,
|
interactive: interactive,
|
||||||
sshPrivIdRsa: sshPrivIdRsa,
|
sshPrivIDRsa: sshPrivIDRsa,
|
||||||
caching: caching,
|
caching: caching,
|
||||||
depth: depth,
|
depth: depth,
|
||||||
prefix: prefix,
|
prefix: prefix,
|
||||||
@@ -832,18 +832,18 @@ func (obj *Remotes) NewSSH(file string) (*SSH, error) {
|
|||||||
|
|
||||||
// sshKeyAuth is a helper function to get the ssh key auth struct needed
|
// sshKeyAuth is a helper function to get the ssh key auth struct needed
|
||||||
func (obj *Remotes) sshKeyAuth() (ssh.AuthMethod, error) {
|
func (obj *Remotes) sshKeyAuth() (ssh.AuthMethod, error) {
|
||||||
if obj.sshPrivIdRsa == "" {
|
if obj.sshPrivIDRsa == "" {
|
||||||
return nil, fmt.Errorf("empty path specified")
|
return nil, fmt.Errorf("empty path specified")
|
||||||
}
|
}
|
||||||
p := ""
|
p := ""
|
||||||
// TODO: this doesn't match strings of the form: ~james/.ssh/id_rsa
|
// TODO: this doesn't match strings of the form: ~james/.ssh/id_rsa
|
||||||
if strings.HasPrefix(obj.sshPrivIdRsa, "~/") {
|
if strings.HasPrefix(obj.sshPrivIDRsa, "~/") {
|
||||||
usr, err := user.Current()
|
usr, err := user.Current()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Remote: Can't find home directory automatically.")
|
log.Printf("Remote: Can't find home directory automatically.")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
p = path.Join(usr.HomeDir, obj.sshPrivIdRsa[len("~/"):])
|
p = path.Join(usr.HomeDir, obj.sshPrivIDRsa[len("~/"):])
|
||||||
}
|
}
|
||||||
if p == "" {
|
if p == "" {
|
||||||
return nil, fmt.Errorf("empty path specified")
|
return nil, fmt.Errorf("empty path specified")
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ import (
|
|||||||
|
|
||||||
// global tweaks of verbosity and code path
|
// global tweaks of verbosity and code path
|
||||||
const (
|
const (
|
||||||
PK_DEBUG = false
|
Debug = false
|
||||||
PARANOID = false // enable if you see any ghosts
|
Paranoid = false // enable if you see any ghosts
|
||||||
)
|
)
|
||||||
|
|
||||||
// constants which might need to be tweaked or which contain special dbus strings.
|
// constants which might need to be tweaked or which contain special dbus strings.
|
||||||
@@ -74,76 +74,76 @@ var (
|
|||||||
//type enum_filter uint64
|
//type enum_filter uint64
|
||||||
// https://github.com/hughsie/PackageKit/blob/master/lib/packagekit-glib2/pk-enum.c
|
// https://github.com/hughsie/PackageKit/blob/master/lib/packagekit-glib2/pk-enum.c
|
||||||
const ( //static const PkEnumMatch enum_filter[]
|
const ( //static const PkEnumMatch enum_filter[]
|
||||||
PK_FILTER_ENUM_UNKNOWN uint64 = 1 << iota // "unknown"
|
PkFilterEnumUnknown uint64 = 1 << iota // "unknown"
|
||||||
PK_FILTER_ENUM_NONE // "none"
|
PkFilterEnumNone // "none"
|
||||||
PK_FILTER_ENUM_INSTALLED // "installed"
|
PkFilterEnumInstalled // "installed"
|
||||||
PK_FILTER_ENUM_NOT_INSTALLED // "~installed"
|
PkFilterEnumNotInstalled // "~installed"
|
||||||
PK_FILTER_ENUM_DEVELOPMENT // "devel"
|
PkFilterEnumDevelopment // "devel"
|
||||||
PK_FILTER_ENUM_NOT_DEVELOPMENT // "~devel"
|
PkFilterEnumNotDevelopment // "~devel"
|
||||||
PK_FILTER_ENUM_GUI // "gui"
|
PkFilterEnumGui // "gui"
|
||||||
PK_FILTER_ENUM_NOT_GUI // "~gui"
|
PkFilterEnumNotGui // "~gui"
|
||||||
PK_FILTER_ENUM_FREE // "free"
|
PkFilterEnumFree // "free"
|
||||||
PK_FILTER_ENUM_NOT_FREE // "~free"
|
PkFilterEnumNotFree // "~free"
|
||||||
PK_FILTER_ENUM_VISIBLE // "visible"
|
PkFilterEnumVisible // "visible"
|
||||||
PK_FILTER_ENUM_NOT_VISIBLE // "~visible"
|
PkFilterEnumNotVisible // "~visible"
|
||||||
PK_FILTER_ENUM_SUPPORTED // "supported"
|
PkFilterEnumSupported // "supported"
|
||||||
PK_FILTER_ENUM_NOT_SUPPORTED // "~supported"
|
PkFilterEnumNotSupported // "~supported"
|
||||||
PK_FILTER_ENUM_BASENAME // "basename"
|
PkFilterEnumBasename // "basename"
|
||||||
PK_FILTER_ENUM_NOT_BASENAME // "~basename"
|
PkFilterEnumNotBasename // "~basename"
|
||||||
PK_FILTER_ENUM_NEWEST // "newest"
|
PkFilterEnumNewest // "newest"
|
||||||
PK_FILTER_ENUM_NOT_NEWEST // "~newest"
|
PkFilterEnumNotNewest // "~newest"
|
||||||
PK_FILTER_ENUM_ARCH // "arch"
|
PkFilterEnumArch // "arch"
|
||||||
PK_FILTER_ENUM_NOT_ARCH // "~arch"
|
PkFilterEnumNotArch // "~arch"
|
||||||
PK_FILTER_ENUM_SOURCE // "source"
|
PkFilterEnumSource // "source"
|
||||||
PK_FILTER_ENUM_NOT_SOURCE // "~source"
|
PkFilterEnumNotSource // "~source"
|
||||||
PK_FILTER_ENUM_COLLECTIONS // "collections"
|
PkFilterEnumCollections // "collections"
|
||||||
PK_FILTER_ENUM_NOT_COLLECTIONS // "~collections"
|
PkFilterEnumNotCollections // "~collections"
|
||||||
PK_FILTER_ENUM_APPLICATION // "application"
|
PkFilterEnumApplication // "application"
|
||||||
PK_FILTER_ENUM_NOT_APPLICATION // "~application"
|
PkFilterEnumNotApplication // "~application"
|
||||||
PK_FILTER_ENUM_DOWNLOADED // "downloaded"
|
PkFilterEnumDownloaded // "downloaded"
|
||||||
PK_FILTER_ENUM_NOT_DOWNLOADED // "~downloaded"
|
PkFilterEnumNotDownloaded // "~downloaded"
|
||||||
)
|
)
|
||||||
|
|
||||||
// constants from packagekit c library.
|
// constants from packagekit c library.
|
||||||
const ( //static const PkEnumMatch enum_transaction_flag[]
|
const ( //static const PkEnumMatch enum_transaction_flag[]
|
||||||
PK_TRANSACTION_FLAG_ENUM_NONE uint64 = 1 << iota // "none"
|
PkTransactionFlagEnumNone uint64 = 1 << iota // "none"
|
||||||
PK_TRANSACTION_FLAG_ENUM_ONLY_TRUSTED // "only-trusted"
|
PkTransactionFlagEnumOnlyTrusted // "only-trusted"
|
||||||
PK_TRANSACTION_FLAG_ENUM_SIMULATE // "simulate"
|
PkTransactionFlagEnumSimulate // "simulate"
|
||||||
PK_TRANSACTION_FLAG_ENUM_ONLY_DOWNLOAD // "only-download"
|
PkTransactionFlagEnumOnlyDownload // "only-download"
|
||||||
PK_TRANSACTION_FLAG_ENUM_ALLOW_REINSTALL // "allow-reinstall"
|
PkTransactionFlagEnumAllowReinstall // "allow-reinstall"
|
||||||
PK_TRANSACTION_FLAG_ENUM_JUST_REINSTALL // "just-reinstall"
|
PkTransactionFlagEnumJustReinstall // "just-reinstall"
|
||||||
PK_TRANSACTION_FLAG_ENUM_ALLOW_DOWNGRADE // "allow-downgrade"
|
PkTransactionFlagEnumAllowDowngrade // "allow-downgrade"
|
||||||
)
|
)
|
||||||
|
|
||||||
// constants from packagekit c library.
|
// constants from packagekit c library.
|
||||||
const ( //typedef enum
|
const ( //typedef enum
|
||||||
PK_INFO_ENUM_UNKNOWN uint64 = 1 << iota
|
PkInfoEnumUnknown uint64 = 1 << iota
|
||||||
PK_INFO_ENUM_INSTALLED
|
PkInfoEnumInstalled
|
||||||
PK_INFO_ENUM_AVAILABLE
|
PkInfoEnumAvailable
|
||||||
PK_INFO_ENUM_LOW
|
PkInfoEnumLow
|
||||||
PK_INFO_ENUM_ENHANCEMENT
|
PkInfoEnumEnhancement
|
||||||
PK_INFO_ENUM_NORMAL
|
PkInfoEnumNormal
|
||||||
PK_INFO_ENUM_BUGFIX
|
PkInfoEnumBugfix
|
||||||
PK_INFO_ENUM_IMPORTANT
|
PkInfoEnumImportant
|
||||||
PK_INFO_ENUM_SECURITY
|
PkInfoEnumSecurity
|
||||||
PK_INFO_ENUM_BLOCKED
|
PkInfoEnumBlocked
|
||||||
PK_INFO_ENUM_DOWNLOADING
|
PkInfoEnumDownloading
|
||||||
PK_INFO_ENUM_UPDATING
|
PkInfoEnumUpdating
|
||||||
PK_INFO_ENUM_INSTALLING
|
PkInfoEnumInstalling
|
||||||
PK_INFO_ENUM_REMOVING
|
PkInfoEnumRemoving
|
||||||
PK_INFO_ENUM_CLEANUP
|
PkInfoEnumCleanup
|
||||||
PK_INFO_ENUM_OBSOLETING
|
PkInfoEnumObsoleting
|
||||||
PK_INFO_ENUM_COLLECTION_INSTALLED
|
PkInfoEnumCollectionInstalled
|
||||||
PK_INFO_ENUM_COLLECTION_AVAILABLE
|
PkInfoEnumCollectionAvailable
|
||||||
PK_INFO_ENUM_FINISHED
|
PkInfoEnumFinished
|
||||||
PK_INFO_ENUM_REINSTALLING
|
PkInfoEnumReinstalling
|
||||||
PK_INFO_ENUM_DOWNGRADING
|
PkInfoEnumDowngrading
|
||||||
PK_INFO_ENUM_PREPARING
|
PkInfoEnumPreparing
|
||||||
PK_INFO_ENUM_DECOMPRESSING
|
PkInfoEnumDecompressing
|
||||||
PK_INFO_ENUM_UNTRUSTED
|
PkInfoEnumUntrusted
|
||||||
PK_INFO_ENUM_TRUSTED
|
PkInfoEnumTrusted
|
||||||
PK_INFO_ENUM_UNAVAILABLE
|
PkInfoEnumUnavailable
|
||||||
PK_INFO_ENUM_LAST
|
PkInfoEnumLast
|
||||||
)
|
)
|
||||||
|
|
||||||
// Conn is a wrapper struct so we can pass bus connection around in the struct.
|
// Conn is a wrapper struct so we can pass bus connection around in the struct.
|
||||||
@@ -184,7 +184,7 @@ func (bus *Conn) Close() error {
|
|||||||
|
|
||||||
// internal helper to add signal matches to the bus, should only be called once
|
// internal helper to add signal matches to the bus, should only be called once
|
||||||
func (bus *Conn) matchSignal(ch chan *dbus.Signal, path dbus.ObjectPath, iface string, signals []string) error {
|
func (bus *Conn) matchSignal(ch chan *dbus.Signal, path dbus.ObjectPath, iface string, signals []string) error {
|
||||||
if PK_DEBUG {
|
if Debug {
|
||||||
log.Printf("PackageKit: matchSignal(%v, %v, %v, %v)", ch, path, iface, signals)
|
log.Printf("PackageKit: matchSignal(%v, %v, %v, %v)", ch, path, iface, signals)
|
||||||
}
|
}
|
||||||
// eg: gdbus monitor --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit | grep <signal>
|
// eg: gdbus monitor --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit | grep <signal>
|
||||||
@@ -224,7 +224,7 @@ func (bus *Conn) WatchChanges() (chan *dbus.Signal, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if PARANOID { // TODO: this filtering might not be necessary anymore...
|
if Paranoid { // TODO: this filtering might not be necessary anymore...
|
||||||
// try to handle the filtering inside this function!
|
// try to handle the filtering inside this function!
|
||||||
rch := make(chan *dbus.Signal)
|
rch := make(chan *dbus.Signal)
|
||||||
go func() {
|
go func() {
|
||||||
@@ -257,7 +257,7 @@ func (bus *Conn) WatchChanges() (chan *dbus.Signal, error) {
|
|||||||
|
|
||||||
// CreateTransaction creates and returns a transaction path.
|
// CreateTransaction creates and returns a transaction path.
|
||||||
func (bus *Conn) CreateTransaction() (dbus.ObjectPath, error) {
|
func (bus *Conn) CreateTransaction() (dbus.ObjectPath, error) {
|
||||||
if PK_DEBUG {
|
if Debug {
|
||||||
log.Println("PackageKit: CreateTransaction()")
|
log.Println("PackageKit: CreateTransaction()")
|
||||||
}
|
}
|
||||||
var interfacePath dbus.ObjectPath
|
var interfacePath dbus.ObjectPath
|
||||||
@@ -266,7 +266,7 @@ func (bus *Conn) CreateTransaction() (dbus.ObjectPath, error) {
|
|||||||
if call != nil {
|
if call != nil {
|
||||||
return "", call
|
return "", call
|
||||||
}
|
}
|
||||||
if PK_DEBUG {
|
if Debug {
|
||||||
log.Printf("PackageKit: CreateTransaction(): %v", interfacePath)
|
log.Printf("PackageKit: CreateTransaction(): %v", interfacePath)
|
||||||
}
|
}
|
||||||
return interfacePath, nil
|
return interfacePath, nil
|
||||||
@@ -284,12 +284,12 @@ func (bus *Conn) ResolvePackages(packages []string, filter uint64) ([]string, er
|
|||||||
// add signal matches for Package and Finished which will always be last
|
// add signal matches for Package and Finished which will always be last
|
||||||
var signals = []string{"Package", "Finished", "Error", "Destroy"}
|
var signals = []string{"Package", "Finished", "Error", "Destroy"}
|
||||||
bus.matchSignal(ch, interfacePath, PkIfaceTransaction, signals)
|
bus.matchSignal(ch, interfacePath, PkIfaceTransaction, signals)
|
||||||
if PK_DEBUG {
|
if Debug {
|
||||||
log.Printf("PackageKit: ResolvePackages(): Object(%v, %v)", PkIface, interfacePath)
|
log.Printf("PackageKit: ResolvePackages(): Object(%v, %v)", PkIface, interfacePath)
|
||||||
}
|
}
|
||||||
obj := bus.GetBus().Object(PkIface, interfacePath) // pass in found transaction path
|
obj := bus.GetBus().Object(PkIface, interfacePath) // pass in found transaction path
|
||||||
call := obj.Call(FmtTransactionMethod("Resolve"), 0, filter, packages)
|
call := obj.Call(FmtTransactionMethod("Resolve"), 0, filter, packages)
|
||||||
if PK_DEBUG {
|
if Debug {
|
||||||
log.Println("PackageKit: ResolvePackages(): Call: Success!")
|
log.Println("PackageKit: ResolvePackages(): Call: Success!")
|
||||||
}
|
}
|
||||||
if call.Err != nil {
|
if call.Err != nil {
|
||||||
@@ -300,7 +300,7 @@ loop:
|
|||||||
// FIXME: add a timeout option to error in case signals are dropped!
|
// FIXME: add a timeout option to error in case signals are dropped!
|
||||||
select {
|
select {
|
||||||
case signal := <-ch:
|
case signal := <-ch:
|
||||||
if PK_DEBUG {
|
if Debug {
|
||||||
log.Printf("PackageKit: ResolvePackages(): Signal: %+v", signal)
|
log.Printf("PackageKit: ResolvePackages(): Signal: %+v", signal)
|
||||||
}
|
}
|
||||||
if signal.Path != interfacePath {
|
if signal.Path != interfacePath {
|
||||||
@@ -338,8 +338,8 @@ loop:
|
|||||||
|
|
||||||
// IsInstalledList queries a list of packages to see if they are installed.
|
// IsInstalledList queries a list of packages to see if they are installed.
|
||||||
func (bus *Conn) IsInstalledList(packages []string) ([]bool, error) {
|
func (bus *Conn) IsInstalledList(packages []string) ([]bool, error) {
|
||||||
var filter uint64 // initializes at the "zero" value of 0
|
var filter uint64 // initializes at the "zero" value of 0
|
||||||
filter += PK_FILTER_ENUM_ARCH // always search in our arch
|
filter += PkFilterEnumArch // always search in our arch
|
||||||
packageIDs, e := bus.ResolvePackages(packages, filter)
|
packageIDs, e := bus.ResolvePackages(packages, filter)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, fmt.Errorf("ResolvePackages error: %v", e)
|
return nil, fmt.Errorf("ResolvePackages error: %v", e)
|
||||||
@@ -593,7 +593,7 @@ loop:
|
|||||||
|
|
||||||
// GetUpdates gets a list of packages that are installed and which can be updated, mod filter.
|
// GetUpdates gets a list of packages that are installed and which can be updated, mod filter.
|
||||||
func (bus *Conn) GetUpdates(filter uint64) ([]string, error) {
|
func (bus *Conn) GetUpdates(filter uint64) ([]string, error) {
|
||||||
if PK_DEBUG {
|
if Debug {
|
||||||
log.Println("PackageKit: GetUpdates()")
|
log.Println("PackageKit: GetUpdates()")
|
||||||
}
|
}
|
||||||
packageIDs := []string{}
|
packageIDs := []string{}
|
||||||
@@ -664,11 +664,11 @@ func (bus *Conn) PackagesToPackageIDs(packageMap map[string]string, filter uint6
|
|||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(filter&PK_FILTER_ENUM_ARCH == PK_FILTER_ENUM_ARCH) {
|
if !(filter&PkFilterEnumArch == PkFilterEnumArch) {
|
||||||
filter += PK_FILTER_ENUM_ARCH // always search in our arch
|
filter += PkFilterEnumArch // always search in our arch
|
||||||
}
|
}
|
||||||
|
|
||||||
if PK_DEBUG {
|
if Debug {
|
||||||
log.Printf("PackageKit: PackagesToPackageIDs(): %v", strings.Join(packages, ", "))
|
log.Printf("PackageKit: PackagesToPackageIDs(): %v", strings.Join(packages, ", "))
|
||||||
}
|
}
|
||||||
resolved, e := bus.ResolvePackages(packages, filter)
|
resolved, e := bus.ResolvePackages(packages, filter)
|
||||||
@@ -771,7 +771,7 @@ func (bus *Conn) PackagesToPackageIDs(packageMap map[string]string, filter uint6
|
|||||||
// this check is for packages that need to verify their "newest" status
|
// this check is for packages that need to verify their "newest" status
|
||||||
// we need to know this so we can install the correct newest packageID!
|
// we need to know this so we can install the correct newest packageID!
|
||||||
recursion := make(map[string]*PkPackageIDActionData)
|
recursion := make(map[string]*PkPackageIDActionData)
|
||||||
if !(filter&PK_FILTER_ENUM_NEWEST == PK_FILTER_ENUM_NEWEST) {
|
if !(filter&PkFilterEnumNewest == PkFilterEnumNewest) {
|
||||||
checkPackages := []string{}
|
checkPackages := []string{}
|
||||||
filteredPackageMap := make(map[string]string)
|
filteredPackageMap := make(map[string]string)
|
||||||
for index, pkg := range packages {
|
for index, pkg := range packages {
|
||||||
@@ -788,13 +788,13 @@ func (bus *Conn) PackagesToPackageIDs(packageMap map[string]string, filter uint6
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we _could_ do a second resolve and then parse like this...
|
// we _could_ do a second resolve and then parse like this...
|
||||||
//resolved, e := bus.ResolvePackages(..., filter+PK_FILTER_ENUM_NEWEST)
|
//resolved, e := bus.ResolvePackages(..., filter+PkFilterEnumNewest)
|
||||||
// but that's basically what recursion here could do too!
|
// but that's basically what recursion here could do too!
|
||||||
if len(checkPackages) > 0 {
|
if len(checkPackages) > 0 {
|
||||||
if PK_DEBUG {
|
if Debug {
|
||||||
log.Printf("PackageKit: PackagesToPackageIDs(): Recurse: %v", strings.Join(checkPackages, ", "))
|
log.Printf("PackageKit: PackagesToPackageIDs(): Recurse: %v", strings.Join(checkPackages, ", "))
|
||||||
}
|
}
|
||||||
recursion, e = bus.PackagesToPackageIDs(filteredPackageMap, filter+PK_FILTER_ENUM_NEWEST)
|
recursion, e = bus.PackagesToPackageIDs(filteredPackageMap, filter+PkFilterEnumNewest)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, fmt.Errorf("Recursion error: %v", e)
|
return nil, fmt.Errorf("Recursion error: %v", e)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,22 +177,22 @@ func (obj *PkgRes) groupMappingHelper() map[string]string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (obj *PkgRes) pkgMappingHelper(bus *packagekit.Conn) (map[string]*packagekit.PkPackageIDActionData, error) {
|
func (obj *PkgRes) pkgMappingHelper(bus *packagekit.Conn) (map[string]*packagekit.PkPackageIDActionData, error) {
|
||||||
packageMap := obj.groupMappingHelper() // get the grouped values
|
packageMap := obj.groupMappingHelper() // get the grouped values
|
||||||
packageMap[obj.Name] = obj.State // key is pkg name, value is pkg state
|
packageMap[obj.Name] = obj.State // key is pkg name, value is pkg state
|
||||||
var filter uint64 // initializes at the "zero" value of 0
|
var filter uint64 // initializes at the "zero" value of 0
|
||||||
filter += packagekit.PK_FILTER_ENUM_ARCH // always search in our arch (optional!)
|
filter += packagekit.PkFilterEnumArch // always search in our arch (optional!)
|
||||||
// we're requesting latest version, or to narrow down install choices!
|
// we're requesting latest version, or to narrow down install choices!
|
||||||
if obj.State == "newest" || obj.State == "installed" {
|
if obj.State == "newest" || obj.State == "installed" {
|
||||||
// if we add this, we'll still see older packages if installed
|
// if we add this, we'll still see older packages if installed
|
||||||
// this is an optimization, and is *optional*, this logic is
|
// this is an optimization, and is *optional*, this logic is
|
||||||
// handled inside of PackagesToPackageIDs now automatically!
|
// handled inside of PackagesToPackageIDs now automatically!
|
||||||
filter += packagekit.PK_FILTER_ENUM_NEWEST // only search for newest packages
|
filter += packagekit.PkFilterEnumNewest // only search for newest packages
|
||||||
}
|
}
|
||||||
if !obj.AllowNonFree {
|
if !obj.AllowNonFree {
|
||||||
filter += packagekit.PK_FILTER_ENUM_FREE
|
filter += packagekit.PkFilterEnumFree
|
||||||
}
|
}
|
||||||
if !obj.AllowUnsupported {
|
if !obj.AllowUnsupported {
|
||||||
filter += packagekit.PK_FILTER_ENUM_SUPPORTED
|
filter += packagekit.PkFilterEnumSupported
|
||||||
}
|
}
|
||||||
result, err := bus.PackagesToPackageIDs(packageMap, filter)
|
result, err := bus.PackagesToPackageIDs(packageMap, filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -298,7 +298,7 @@ func (obj *PkgRes) CheckApply(apply bool) (checkOK bool, err error) {
|
|||||||
|
|
||||||
var transactionFlags uint64 // initializes at the "zero" value of 0
|
var transactionFlags uint64 // initializes at the "zero" value of 0
|
||||||
if !obj.AllowUntrusted { // allow
|
if !obj.AllowUntrusted { // allow
|
||||||
transactionFlags += packagekit.PK_TRANSACTION_FLAG_ENUM_ONLY_TRUSTED
|
transactionFlags += packagekit.PkTransactionFlagEnumOnlyTrusted
|
||||||
}
|
}
|
||||||
// apply correct state!
|
// apply correct state!
|
||||||
log.Printf("%s: Set: %v...", obj.fmtNames(util.StrListIntersection(applyPackages, obj.getNames())), obj.State)
|
log.Printf("%s: Set: %v...", obj.fmtNames(util.StrListIntersection(applyPackages, obj.getNames())), obj.State)
|
||||||
|
|||||||
@@ -533,7 +533,7 @@ func (obj *BaseRes) Compare(res Res) bool {
|
|||||||
// if resources are grouped, are the groups the same?
|
// if resources are grouped, are the groups the same?
|
||||||
if i, j := obj.GetGroup(), res.GetGroup(); len(i) != len(j) {
|
if i, j := obj.GetGroup(), res.GetGroup(); len(i) != len(j) {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else if len(i) > 0 { // trick the golinter
|
||||||
ix, jx := Sort(i), Sort(j)
|
ix, jx := Sort(i), Sort(j)
|
||||||
for k := range ix {
|
for k := range ix {
|
||||||
if !ix[k].Compare(jx[k]) { // compare sub resources
|
if !ix[k].Compare(jx[k]) { // compare sub resources
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ echo running test-golint.sh
|
|||||||
# FIXME: test a range of commits, since only the last patch is checked here
|
# FIXME: test a range of commits, since only the last patch is checked here
|
||||||
PREVIOUS='HEAD^'
|
PREVIOUS='HEAD^'
|
||||||
CURRENT='HEAD'
|
CURRENT='HEAD'
|
||||||
THRESHOLD=5 # percent problems per new LOC
|
THRESHOLD=1 # percent problems per new LOC
|
||||||
XPWD=`pwd`
|
XPWD=`pwd`
|
||||||
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" # dir!
|
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" # dir!
|
||||||
cd "${ROOT}" >/dev/null
|
cd "${ROOT}" >/dev/null
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ gml='gometalinter --disable-all'
|
|||||||
#gml="$gml --enable=goconst"
|
#gml="$gml --enable=goconst"
|
||||||
#gml="$gml --enable=gocyclo"
|
#gml="$gml --enable=gocyclo"
|
||||||
gml="$gml --enable=goimports"
|
gml="$gml --enable=goimports"
|
||||||
#gml="$gml --enable=golint" # TODO: only a few fixes needed
|
gml="$gml --enable=golint"
|
||||||
#gml="$gml --enable=gosimple" # TODO: only a few fixes needed
|
#gml="$gml --enable=gosimple" # TODO: only a few fixes needed
|
||||||
gml="$gml --enable=gotype"
|
gml="$gml --enable=gotype"
|
||||||
#gml="$gml --enable=ineffassign" # TODO: only a few fixes needed
|
#gml="$gml --enable=ineffassign" # TODO: only a few fixes needed
|
||||||
|
|||||||
Reference in New Issue
Block a user